• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: upsampling example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Auto Gain Control (AGC)
      • From: Christof Faller <email@hidden>
References: 
 >upsampling example (From: "Albert Russel" <email@hidden>)

  • Prev by Date: upsampling example
  • Next by Date: Help me find it please
  • Previous by thread: upsampling example
  • Next by thread: Auto Gain Control (AGC)
  • Index(es):
    • Date
    • Thread