[ardour-dev] playback model
jesse at essej.net
Tue Nov 8 06:46:51 PST 2005
On 11/7/05, Gregorio Canelos <gtc at email.arizona.edu> wrote:
> Appreciate the direction to the URL.
> I was hoping for a more implementation-oriented explanation. I
> understand what playlists do, I'm wondering how they communicate with
> the timer, and what mechanism actually queues the sounds at the correct
> time... ie: say I have a playlist and it is assigned to a single track.
> When playback happens, how does the playlist feed each sound to the
> line at the correct time? Is there a general algorithm that you could
> outline? I am using the java sound api, and want to experiment a little
> with my own wav player.
OK, you asked for it.
Basically, the realtime audio thread (the one that is used by the jack
process callback) simply pulls data from ringbuffers for each
track/bus and applies gain/effects etc and readies the data for
output. Simply by pulling the samples from these buffers in order,
the proper transport position is maintained. At (or before) playback
start, the buffers are reset and refilled before the audio thread can
start pulling data from them and advancing the transport position.
Another thread we call the disk butler is responsible for filling
these ringbuffers for all tracks.
Each track has an associated Diskstream which (at the request of the
butler) fills the next N samples into the buffer by calling a read
method on its associated Playlist object. The playlist in turn calls
read methods on the appropriate Region(s) that it manages. These
Regions have a reference to a file Source which encapsulates the data
on disk, and ultimately the read methods are called on them.
See the following files in the libs/ardour directory in the source
tree to see what i described above:
Many of those classes have parent classes that are relevant as well,
but tracing the disk butler through those files should be useful.
Also see session_process.cc for the main control path through the
More information about the Ardour-Dev