[pulseaudio-discuss] volume ramping

Lennart Poettering lennart at poettering.net
Tue Jan 6 14:43:48 PST 2009


On Mon, 15.12.08 17:12, Baek Chang (baeksan at ccrma.stanford.edu) wrote:

Sorry for the late response,

> I were to utilize a ramping function to process a block of audio in a
> sink-input, where should this be called?  I tried using inserting a ramping
> routine on a sink-input within pa_sink_input_peek(), in sink-input.c
> 
> This seems to give me strange results.  Any suggestions on where I could
> process the audio data of individual sink-inputs before it gets mixed down
> into a single sink?

pa_sink_input_peek() is the right place. But please note that you
should advance you state only in pa_sink_input_drop()!

The background for this: the render code first calls _peek() for all
streams. They might return memory blocks of different sizes. We mix
all blocks into a block that has the smallest size of the ones we
got. Then we tell all streams with _drop() how many bytes have
actually been used. That means: 

a. If _peek() is called twice in a row without a
   _drop() in between no samples have been used -- the stream should
   hence return the same data both times.

b. If _peek() returns 200 bytes but _drop() gets only 100 passed,
   then you should advance your state only by 100, not by 200!

Finally, in some situations we might need to rewind the buffers, so
that the data can be read again from the streams. The streams are
informed about that via pa_sink_input_process_rewind().

So, you need to patch _peek(), _drop() and _process_rewind(). In the
first function you apply your ramping. In the second function you
advance your state. In the third function you rewind your state.

I plan to add new hooks at these three new places so that modules can
modify the sound data in arbitrary ways without any further changes in
the main code.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list