2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
20 #include "../Audio_Sequence.H"
36 /** determine region coverage and fill /buf/ with interleaved samples
37 * from /frame/ to /nframes/ for exactly /channels/ channels. */
39 Audio_Sequence::play ( sample_t *buf, nframes_t frame, nframes_t nframes, int channels )
41 THREAD_ASSERT( Playback );
43 sample_t *cbuf = new sample_t[ nframes ];
45 memset( cbuf, 0, nframes * sizeof( sample_t ) );
47 /* quick and dirty--let the regions figure out coverage for themselves */
48 for ( list <Sequence_Widget *>::const_iterator i = _widgets.begin();
49 i != _widgets.end(); ++i )
51 const Audio_Region *r = (Audio_Region*)(*i);
53 for ( int i = channels; i--; )
57 if ( ! ( nfr = r->read( cbuf, frame, nframes, i ) ) )
62 buffer_mix( buf, cbuf, nframes );
64 buffer_interleave_one_channel_and_mix( buf, cbuf, i, channels, nframes );