I have simple code that uses AudioUnit to render sine wave to the output. My question is: what is the range of values that I should put in frames ? I mean, in AudioUnitRender function I am supposed to supply buffer array with some audio data … So what values should I put in ? Currently I’m inserting values from -1 to 1, but I see that I can also use larger values …
So what’s maximum value that I should use (that represents 100% volume) ?
Thanks 🙂
That totally depends on what the stream format is that you’re using. You should create a
AudioStreamBasicDescriptionand set that as the input format to your audio unit. There’s lots of different stream formats and each have a different way of representing what “100% volume” is. If you choose floating point then it will be -1.0 to 1.0 for example but if you choose unsigned 16-bit then it’ll be from 0 to 65535.I’m not sure what code you already have for setting up your audio unit but a good example seems to be shown here:
http://atastypixel.com/blog/using-remoteio-audio-unit/
In that example you’ll notice it’s creating an
AudioStreamBasicDescriptionand choosing linear PCM with thekAudioFormatFlagIsSignedIntegerflag, at 16 bits per channel and 1 channel. So that means that the values will go from -32768 to 32767.