iPhone AudioConverter and Audio File - Does anyone know how to use this on Audio Unit stuff
iPhone AudioConverter and Audio File - Does anyone know how to use this on Audio Unit stuff
- Subject: iPhone AudioConverter and Audio File - Does anyone know how to use this on Audio Unit stuff
- From: wm schauweker <email@hidden>
- Date: Fri, 15 Jan 2010 11:27:00 -0800 (PST)
I wrote an earlier email about trying to use the Audio Converter/AudioFile combination, and encountering failures. A kind person pointed me to yet another Apple mechanism imbedded in someone else's code.
Well, I'd really like to finish what I have started, so I will ask my question(s) a different way, and provide some additional test data.
1. Has anyone in the history of the world figured out with what magic incantation one can induce Audio Converter to accept Audio Unit samples as input?
o I managed to find an ASBD combination that allowed me to create an AudioConverter. This is NOT the combination I want, but it at least gets gives me a starting point. In particular, if I feed the following ASBD as both input format and output format, then AudioConverterNew returns
without error. Note in passing that the function seems to hate AudioFormatFlagIsNonInterleaved.
inputFormat.mSampleRate = 44100.0;
inputFormat.mFormatID = kAudioFormatLinearPCM;
inputFormat.mFramesPerPacket = 1;
inputFormat.mChannelsPerFrame = 2;
inputFormat.mBytesPerFrame = 4;
inputFormat.mBytesPerPacket = 4;
inputFormat.mBitsPerChannel = 16;
inputFormat.mReserved = 0;
inputFormat.mFormatFlags =
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked |
// kAudioFormatFlagIsNonInterleaved |
0;
o An interesting failure: I tried using the following, which is just fine for telling an Audio Unit how to emit output or accept input:
CAStreamBasicDescription inputFormat;
inputFormat.SetAUCanonical(2,
false);
(Fails when trying to create the converter.)
(Also, checking the .h file: A CASBD is an ASBD.)
o Another interesting failure: I tried brute force, applying all of the flags that seemed to make sense, including the few things I could glean by searching the internet. (I also tried leaving out the non-interleaved flag.)
inputFormat.mSampleRate = 44100.0;
inputFormat.mFormatID = kAudioFormatLinearPCM;
inputFormat.mFramesPerPacket = 1;
inputFormat.mChannelsPerFrame = 2;
inputFormat.mBytesPerFrame = 4;
inputFormat.mBytesPerPacket = 4;
inputFormat.mBitsPerChannel = 16;
inputFormat.mReserved =
0;
inputFormat.mFormatFlags =
kAudioFormatFlagIsSignedInteger |
kAudioFormatFlagsNativeEndian |
kLinearPCMFormatFlagIsNonInterleaved |
kLinearPCMFormatFlagsSampleFractionShift |
kLinearPCMFormatFlagsSampleFractionMask |
0
;
(Failed when trying to create the converter.)
2. Has anyone figured out why ASBDs that pass AudioConverterNew would fail when passed to AudioFileCreateWithURL?
o Admittedly nonsensically, I fed the following ASBD as input and output format to to AudioConverterNew:
// Specify converted recording
format.
convertedFormat.mSampleRate = 44100.0;
convertedFormat.mFormatID = kAudioFormatLinearPCM;
convertedFormat.mFramesPerPacket = 1;
convertedFormat.mChannelsPerFrame = 2;
convertedFormat.mBytesPerFrame = 4;
convertedFormat.mBytesPerPacket = 4;
convertedFormat.mBitsPerChannel = 16;
convertedFormat.mReserved = 0;
convertedFormat.mFormatFlags =
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked |
// kAudioFormatFlagIsNonInterleaved |
0;
I then fed it to AudioFileCreate..., Along with a URL to create a WAV file.
It threw a format exception.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden