Audio clicks (Renderer Bug?)
Audio clicks (Renderer Bug?)
- Subject: Audio clicks (Renderer Bug?)
- From: Francois Hamel <email@hidden>
- Date: Sun, 1 Aug 2004 16:41:34 -0400
Hi,
I had the exact same problem while trying to stream music using a
circular buffer.
At the end of the buffer (not the sound) I would always get a CLICK
noise. I found
out that you just cannot clamp the number of frames the renderer ask
for, even if you
don't have anymore frames to throw at it.
for example in the RenderCallback I had:
<code>
//if there isn't enough frames left, clamp
if(framesLeft < inNumberFrames)
inNumberFrames = framesLeft;
</code>
and this was causing a click noise because even if I clamped the number
of
frames (and the output buffers mDataBytesSize), it seems the renderer
was
still using whatever number of frames it wanted and thus overflowed
pass my buffer.
(it would even make an access violation, randomly, after a while)
it's in many samples I've seen, yet it doesn't work. You absolutly need
to allocate
a bigger buffer than necessary for your sound and zero out the end. For
example,
I figured 372 was the number of frames the renderer kept asking me so I
just allocated
372 "padding frames" at the end of my buffer and zero-ed them out.
<code>
//hack! we need a bigger buffer if the render proc ever needs
more frames than what is left
m_pBufferList->mBuffers[i].mData =
(uint8*)malloc(size + (372 * m_outFormat.mBytesPerFrame));
m_pBufferList->mBuffers[i].mDataByteSize = size;
</code>
now, it's all fine and working now, but I hate having a hard-coded 372
constant like this.
Anyone knows out there how we can determine the maximum amount of
frames a Renderer
might want for a given audio format?
Or is it format dependant at all?
thanks,
Francois Hamel
Beenox Studios
email@hidden
On 04-07-28, at 19:09, john wrote:
>
>
> Hi again,
>
>
>
> Every time my app plays back audi data there is small click right at
>
> the begnning and right at the end of the sound.
>
> I've checked everything I could think of. My AudioOutputUnit is
>
> playing correctly except for this. My input callback zeroes every
>
> sample before filling it with audio data, just in case. But the start
>
> and end allways produces a click. I know that the audio being sent to
>
> the output starts and ends with a nice envelope from zero (because I
>
> am plotting it). So that is not the problem.
>
>
>
> Any ideas?
_______________________________________________
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.