Re: upsampling example
Re: upsampling example
- Subject: Re: upsampling example
- From: Christof Faller <email@hidden>
- Date: Thu, 08 Aug 2002 11:44:47 -0400
---------------------------------------------------------------------
For letting the AudioOutputUnit do the re-sampling:
---------------------------------------------------------------------
But if you use an AudioOutputUnit, if will re-sample the audio for you
automatically (just set the input stream parameters to your desired
sampling rate).
Example for setting the stream format of the AudioOutputUnit to 8kHz
(stereo):
// set audio stream format for AudioUnit
AudioStreamBasicDescription austream;
OSStatus err = noErr;
UInt32 count;
austream.mSampleRate = 8000;
austream.mFormatID = kAudioFormatLinearPCM;
austream.mFormatFlags = kLinearPCMFormatFlagIsFloat |
kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsPacked;
austream.mBytesPerPacket = 8;
austream.mFramesPerPacket = 1;
austream.mBytesPerFrame = 8;
austream.mChannelsPerFrame = 2;
austream.mBitsPerChannel = 32;
count = sizeof(AudioStreamBasicDescription);
err = AudioUnitSetProperty(
audiounitinstance,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0, (void *) &austream, count);
if (err != noErr) {
fprintf(stderr, "Could not setup audio unit stream format
for surround!!\n");
exit(0);
}
-----------------------------------------------------------
For doing the re-sampling manually:
-----------------------------------------------------------
Use AudioConverter:
/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioConverter.h
An example can be found here:
Developer/Examples/CoreAudio/Services/DefaultOutputUnit/
Albert Russel wrote:
The audio device in my TiPowerbook 'only' supports stereo 44100Hz output. As
I understand it I have to do the upsampling myself if I want to play an
8000Hz signal. Are there any code samples how this can be done in the
appIOProc of CoreAudio. I now do a linear interpolation between samples but
this sounds a little strange. Or maybe I should use a higher level API that
supports upsampling?
Albert.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.