English 中文(简体)
UsingOS 3d Chemer
原标题:Using iOS 3d Mixer

我只有一支与I/O单位连接的多渠道混合体,才有一个“AUGraph”组织。 反馈通过反馈功能和一切都非常可行。

我正试图转而把3D混合物,而不是多渠道混合器。 因此,我把参数从K.AudioUnit SubType_MultiChannelMixer移至KAudiot SubType_AU3DMixerEmbeded,并留下所有其他装置。

其结果是一种高调的幻觉,似乎开始像一些东西一样松.,然后才变得 whi。 我走过了3个D混合物单位的每个单位,并将之置于其违约状态,但没有变化。 绕过K3DMixerParam-Enable paraile,确实在 mu起和冲走 play。

What setup I might have missed? or know where to find an example of a working 3d Mixer?

最佳回答

As already pointed out the 3d mixer needs mono inputs. But you also have to use UInt16 as the input sample data type. This is a working AudioStreamBasicDescription:

AudioStreamBasicDescription streamFormat = {0};
size_t bytesPerSample = sizeof (UInt16);

streamFormat.mFormatID          = kAudioFormatLinearPCM;
streamFormat.mFormatFlags       = kAudioFormatFlagsCanonical;
streamFormat.mBytesPerPacket    = bytesPerSample;
streamFormat.mFramesPerPacket   = 1;
streamFormat.mBytesPerFrame     = bytesPerSample;
streamFormat.mChannelsPerFrame  = 1;
streamFormat.mBitsPerChannel    = 8 * bytesPerSample;
streamFormat.mSampleRate        = graphSampleRate;

// Set the input stream format of the desired 3D mixer unit audio bus
AudioUnitSetProperty (
                      mixerUnit,
                      kAudioUnitProperty_StreamFormat,
                      kAudioUnitScope_Input,
                      audioBus,
                      &streamFormat,
                      sizeof (streamFormat)
                      );
问题回答

As all answers already mention: the 3D Mixer on iOS needs mono inputs.

On iOS 8 / Xcode 6, the concept of canonical formats is deprecated and I found this (and only this) mono stream format description working as 3D Mixer input bus stream format description:

AudioStreamBasicDescription monoStreamFormat = {0};
monoStreamFormat.mSampleRate        = sampleRate;
monoStreamFormat.mFormatID          = kAudioFormatLinearPCM;
monoStreamFormat.mFormatFlags       = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
monoStreamFormat.mBitsPerChannel    = 16;
monoStreamFormat.mChannelsPerFrame  = 1;
monoStreamFormat.mFramesPerPacket   = 1;
monoStreamFormat.mBytesPerPacket    = 2;
monoStreamFormat.mBytesPerFrame     = 2;

The sample rate should be set and then obtained from the AVAudioSession.

Set this format on the output of the Audio Unit connected to the 3D Mixer input. Which is probably a AUConverter Unit...

但请注意,该吨数已经过测试;SOS8。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签