简体   繁体   中英

What stream format should iOS5 Effect Units use

I'm trying to use a Low Pass Filter AU. I keep getting a kAudioUnitErr_FormatNotSupported (-10868) error when setting the stream format to the filter unit, but if I just use the Remote IO unit there's no error.

The stream format I'm using is (Updated):

myASBD.mSampleRate = hardwareSampleRate;
myASBD.mFormatID = kAudioFormatLinearPCM;      
myASBD.mFormatFlags = kAudioFormatFlagIsSignedInteger;
myASBD.mBitsPerChannel = 8 * sizeof(float);
myASBD.mFramesPerPacket = 1;                                          
myASBD.mChannelsPerFrame = 1;           
myASBD.mBytesPerPacket = sizeof(float) * myASBD.mFramesPerPacket;                                                                            
myASBD.mBytesPerFrame = sizeof(float) * myASBD.mChannelsPerFrame;  

And I'm setting the filter stream like this:

 // Sets input stream type to ASBD
 setupErr = AudioUnitSetProperty(filterUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &myASBD, sizeof(myASBD));
 NSLog(@"Filter in: %i", setupErr);

 //NSAssert(setupErr == noErr, @"No ASBD on Finput");


//Sets output stream type to ASBD
setupErr = AudioUnitSetProperty(filterUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &myASBD, sizeof(myASBD));
NSLog(@"Filter out: %i", setupErr);
NSAssert(setupErr == noErr, @"No ASBD on Foutput");

iOS过滤器音频单元的规范格式为8.24定点(线性PCM),每个通道32位,而不是16位。

what format is working wit the reverb unit??? I'm getting weird errors tryn to record a buffer....any news on this topic?

Try this for the canonical format.

 size_t bytesPerSample = sizeof (AudioUnitSampleType); //Default is 4 bytes myASBD.mSampleRate = hardwareSampleRate; myASBD.mFormatID = kAudioFormatLinearPCM; myASBD.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical; //Canonical AU format myASBD.mBytesPerPacket = bytesPerSample; myASBD.mFramesPerPacket = 1; myASBD.mBytesPerFrame = bytesPerSample; myASBD.mChannelsPerFrame = 2; //Stereo myASBD.mBitsPerChannel = 8 * bytesPerSample; //32bit integer 

You will need to make sure all your AudioUnits ASBDs are configured uniformly.

If you are doing heavy audio processing, floats (supported in iOS5) is not a bad idea too.

 size_t bytesPerSample = sizeof (float); //float is 4 bytes myASBD.mSampleRate = hardwareSampleRate; myASBD.mFormatID = kAudioFormatLinearPCM; myASBD.mFormatFlags = kAudioFormatFlagIsFloat; myASBD.mBytesPerPacket = bytesPerSample; myASBD.mFramesPerPacket = 1; myASBD.mBytesPerFrame = bytesPerSample; myASBD.mChannelsPerFrame = 2; myASBD.mBitsPerChannel = 8 * bytesPerSample; //32bit float 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM