Browse Source

Be more efficient when recording.

tags/non-sequencer-v1.9.4
Jonathan Moore Liles 13 years ago
parent
commit
9974e9bb47
7 changed files with 28 additions and 16 deletions
  1. +8
    -0
      src/canvas.C
  2. +3
    -1
      src/grid.C
  3. +3
    -1
      src/grid.H
  4. +4
    -8
      src/jack.C
  5. +1
    -1
      src/jack.H
  6. +3
    -4
      src/main.C
  7. +6
    -1
      src/pattern.C

+ 8
- 0
src/canvas.C View File

@@ -504,6 +504,7 @@ Canvas::draw_playhead ( void )
} }
} }



copy(); copy();


for ( uint x = m.vp->w; x-- ; ) for ( uint x = m.vp->w; x-- ; )
@@ -512,6 +513,13 @@ Canvas::draw_playhead ( void )


flip(); flip();


/* actually if we're recording, we should draw the grid once per
* playhead movement also */
if ( pattern::recording() == m.grid )
{
draw();
}

return 1; return 1;
} }




+ 3
- 1
src/grid.C View File

@@ -52,6 +52,7 @@ Grid::Grid ( void )
viewport.y = 0; viewport.y = 0;


_playing = false; _playing = false;
_suspend_update = false;
_start = _end = _index = 0; _start = _end = _index = 0;
} }


@@ -124,7 +125,8 @@ Grid::unlock ( void )


_rw = NULL; _rw = NULL;


signal_events_change();
if ( ! _suspend_update )
signal_events_change();
} }
} }




+ 3
- 1
src/grid.H View File

@@ -111,6 +111,8 @@ protected:


int _draw_shape; int _draw_shape;


bool _suspend_update;

unsigned int _bpb; /* beats per bar */ unsigned int _bpb; /* beats per bar */
unsigned int _ppqn; /* pulses per quarter note (beat) */ unsigned int _ppqn; /* pulses per quarter note (beat) */


@@ -142,7 +144,7 @@ protected:


private: private:


int _locked;
volatile int _locked;


public: public:




+ 4
- 8
src/jack.C View File

@@ -89,19 +89,15 @@ static port_t input[2]; /* contro
jack_nframes_t nframes; /* for compatibility with older jack */ jack_nframes_t nframes; /* for compatibility with older jack */


/** get next recorded event, if any--runs in UI thread */ /** get next recorded event, if any--runs in UI thread */
midievent *
midi_input_event ( int port )
bool
midi_input_event ( int port, midievent *me )
{ {
if ( jack_ringbuffer_read_space( input[ port ].ring_buf ) >= sizeof( midievent ) ) if ( jack_ringbuffer_read_space( input[ port ].ring_buf ) >= sizeof( midievent ) )
{ {
midievent *me = new midievent;

// MESSAGE( "passing midi input to non-RT thread" );

if ( jack_ringbuffer_read( input[ port ].ring_buf, (char *)me, sizeof( midievent ) ) ) if ( jack_ringbuffer_read( input[ port ].ring_buf, (char *)me, sizeof( midievent ) ) )
return me;
return true;
} }
return NULL;
return false;
} }


/** /**


+ 1
- 1
src/jack.H View File

@@ -7,7 +7,7 @@ enum { CONTROL, PERFORMANCE };


class midievent; class midievent;


midievent * midi_input_event ( int port );
bool midi_input_event ( int port, midievent *e );
void midi_output_event ( int port, const midievent *e ); void midi_output_event ( int port, const midievent *e );
void midi_output_event ( int port, const midievent *e, tick_t duration ); void midi_output_event ( int port, const midievent *e, tick_t duration );
void midi_all_sound_off ( void ); void midi_all_sound_off ( void );


+ 3
- 4
src/main.C View File

@@ -96,11 +96,10 @@ init_song ( void )
void void
handle_midi_input ( void ) handle_midi_input ( void )
{ {
midievent *e;
while ( ( e = midi_input_event( PERFORMANCE ) ) )
midievent e;
while ( ( midi_input_event( PERFORMANCE, &e ) ) )
{ {
pattern::record_event( e );
delete e;
pattern::record_event( &e );
} }
} }




+ 6
- 1
src/pattern.C View File

@@ -136,6 +136,9 @@ pattern::reset ( void )
} }
} }


/* records a MIDI event into a temporary buffer. It'll only be
* permanently added to pattern after recording stops or the pattern
* loops. */
void void
pattern::record_event ( const midievent *me ) pattern::record_event ( const midievent *me )
{ {
@@ -232,8 +235,10 @@ pattern::record_event ( const midievent *me )
el->unlink( e ); el->unlink( e );
p->_rw->events.insert( e ); p->_rw->events.insert( e );
} }

p->_suspend_update = true;
p->unlock(); p->unlock();
p->_suspend_update = false;
} }
} }




Loading…
Cancel
Save