1

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 :)

xx77aBs
  • 4,678
  • 9
  • 53
  • 77

1 Answers1

3

That totally depends on what the stream format is that you're using. You should create a AudioStreamBasicDescription and 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 AudioStreamBasicDescription and choosing linear PCM with the kAudioFormatFlagIsSignedInteger flag, at 16 bits per channel and 1 channel. So that means that the values will go from -32768 to 32767.

mattjgalloway
  • 34,792
  • 12
  • 100
  • 110