Re: ExtAudioFile and 8-bit samples
Re: ExtAudioFile and 8-bit samples
- Subject: Re: ExtAudioFile and 8-bit samples
- From: Brian Willoughby <email@hidden>
- Date: Tue, 01 Mar 2011 15:49:22 -0800
On Mar 1, 2011, at 01:10, Kevin Wojniak wrote:
I've got some raw audio data that is in 8-bit samples. Without
knowing any more details about the format (other than sample rate
and channel), I threw it into an ExtAudioFile as an AIFF. The
output sounded ok right but was very noisy. After googling around I
figured out the data was encoded as offset-binary and AIFF expects
two's compliment. Applying this conversion before writing the
buffer resolved the issue.
I was under the impression ExtAudioFile would do this for me.
However, all the various options I tried for mFormatFlags didn't
change anything (and none of them seemed to apply, based on their
descriptions). Here is what I'm using:
AudioStreamBasicDescription stream = {0};
stream.mSampleRate = 22000;
stream.mFormatID = kAudioFormatLinearPCM;
stream.mFormatFlags = 0;
stream.mBytesPerPacket = 1;
stream.mFramesPerPacket = 1;
stream.mBytesPerFrame = 1;
stream.mChannelsPerFrame = 1;
stream.mBitsPerChannel = 8;
Am I just missing the wrong configuration, or is this encoding not
supported?
You have left mFormatFlags blank, so I don't see how CoreAudio can
correctly guess. Then again, "0" might be the correct flags. The
key is kAudioFormatIsSignedInteger, which must be false for offset-
binary. kAudioFormatFlagIsFloat is false . The following should be
don't care settings for an 8-bit format, but there's always the
chance that CoreAudio expects one or more of them to be set:
kAudioFormatFlagIsBigEndian, IsPacked, IsAlignedHigh,
IsNonInterleaved. There is also a kAudioFormatFlagsAreAllClear bit
which you might try setting to indicate that all flags should truly
be off, as opposed to simply not initialized.
Another issue is that you probably need two
AudioStreamBasicDescription settings. Your first, client format,
should describe the data exactly as you have it in your raw data.
The second, the file format, should be compatible with AIFF. They
might turn out to be exactly the same if AIFF supports your format as-
is, but it might still be necessary to set both formats in
ExtAudioFile to avoid a conversion to/from some default format if you
leave one unspecified.
Brian Willoughby
Sound Consulting
_______________________________________________
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