pf <paulfredlein.TakeThisOut@nospamoptusnet.com.au> wrote:
> Hi,
>
> I'm using MTCoreAudio and need to record x seconds (say 5 seconds) of
> audio into one buffer. I've got the sammple rate but how do I calculate
> the buffer size?
>
> One of the examples I found uses:-
>
> // about 25 seconds of recording time
> #define SOUND_BUFFER_SIZE (8 * 1024 * 1024)
>
> But this is much longer than 25 seconds at what seems to be my computers
> nominalSampleRate of 22050.
To get a buffer that is x seconds long, with a sample rate of r, a sample
size of s, and n channels, your buffer size would be:
size = x * r * s * n
So for 5 seconds at 22050Hz, 4-byte samples, and 2 channels, your buffer
size would be 5 * 22050 * 4 * 2 = 882000 bytes.
--
Michael Ash
Rogue Amoeba Software