Browse Source

Continue working on playback.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
946b8f8e93
5 changed files with 50 additions and 4 deletions
  1. +33
    -0
      Timeline/Audio_Track.C
  2. +2
    -0
      Timeline/Audio_Track.H
  3. +9
    -1
      Timeline/Disk_Stream.C
  4. +5
    -2
      Timeline/Disk_Stream.H
  5. +1
    -1
      Timeline/Port.H

+ 33
- 0
Timeline/Audio_Track.C View File

@@ -108,3 +108,36 @@ Audio_Track::handle ( int m )
return Track::handle( m );
}
}


/**********/
/* Engine */
/**********/

/* THREAD: IO */
/** determine region coverage and fill /buf/ with interleaved samples
* from /frame/ to /nframes/ for exactly /channels/ channels. */
void
Audio_Track::play ( sample_t *buf, nframes_t frame, nframes_t nframes, int channels )
{
sample_t *cbuf = new sample_t[ nframes ];

/* quick and dirty--let the regions figure out coverage for themselves */
for ( list <Track_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ )
{
const Region *r = (Region*)i;

for ( int i = channels; i-- )
{
memset( cbuf, 0, nframes * sizeof( sample_t ) );

if ( ! r->read( cbuf, frame, nframes, i ) )
/* error ? */;

/* interleave */
int k = 0;
for ( int j = 0; j < nframes; j += channels )
buf[ j ] = cbuf[ k++ ];
}
}
}

+ 2
- 0
Timeline/Audio_Track.H View File

@@ -53,4 +53,6 @@ public:
void dump ( void );
void remove_selected ( void );

void play ( sample_t *buf, nframes_t frame, nframes_t nframes, int channels );

};

+ 9
- 1
Timeline/Disk_Stream.C View File

@@ -17,6 +17,8 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/

#include "Track_Header.H"

static float seconds_to_buffer = 5.0f;

/* A Disk_Stream uses a separate I/O thread to stream a track's
@@ -57,6 +59,12 @@ virtual ~Disk_Stream::Disk_Stream ( )
jack_ringbuffer_free( _rb[ i ] );
}

Audio_Track *
Disk_Stream::track ( void ) const
{
return (Audio_Track*)_th->track();
}

/** start Disk_Stream thread */
void
Disk_Stream::run ( void )
@@ -77,7 +85,7 @@ Disk_Stream::io_thread ( void *arg )
void
Disk_Stream::read_block ( sample_t *buf )
{
if ( _th->track()->play( buf, _frame, _nframes, channels() ) )
if ( track()->play( buf, _frame, _nframes, channels() ) )
_frame += _nframes;
else
/* error */;


+ 5
- 2
Timeline/Disk_Stream.H View File

@@ -22,7 +22,10 @@
#include <jack/ringbuffer.h>
#include <semaphore.h>

#include "Track_Header.H"
#include <vector>
using std::vector;

class Track_Header;

class Disk_Stream
{
@@ -39,7 +42,7 @@ class Disk_Stream

int channels ( void ) const { return _rb.size(); }

Track * track ( void ) const { return _th->track(); }
Audio_Track * track ( void ) const;

protected:



+ 1
- 1
Timeline/Port.H View File

@@ -30,6 +30,6 @@ public:
bool connected ( void ) const { return jack_port_connected( _port ); }
const char * name ( void ) const { return _name; }

nframes_t write ( sample_t *buf, nframes_t nframes );
void write ( sample_t *buf, nframes_t nframes );

};

Loading…
Cancel
Save