Be more efficient when recording.

pull/3/head
Jonathan Moore Liles 2012-02-29 19:57:23 -08:00
parent 71e0583696
commit 9974e9bb47
7 changed files with 28 additions and 16 deletions

View File

@ -504,6 +504,7 @@ Canvas::draw_playhead ( void )
}
}
copy();
for ( uint x = m.vp->w; x-- ; )
@ -512,6 +513,13 @@ Canvas::draw_playhead ( void )
flip();
/* actually if we're recording, we should draw the grid once per
* playhead movement also */
if ( pattern::recording() == m.grid )
{
draw();
}
return 1;
}

View File

@ -52,6 +52,7 @@ Grid::Grid ( void )
viewport.y = 0;
_playing = false;
_suspend_update = false;
_start = _end = _index = 0;
}
@ -124,7 +125,8 @@ Grid::unlock ( void )
_rw = NULL;
signal_events_change();
if ( ! _suspend_update )
signal_events_change();
}
}

View File

@ -111,6 +111,8 @@ protected:
int _draw_shape;
bool _suspend_update;
unsigned int _bpb; /* beats per bar */
unsigned int _ppqn; /* pulses per quarter note (beat) */
@ -142,7 +144,7 @@ protected:
private:
int _locked;
volatile int _locked;
public:

View File

@ -89,19 +89,15 @@ static port_t input[2]; /* contro
jack_nframes_t nframes; /* for compatibility with older jack */
/** 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 ) )
{
midievent *me = new midievent;
// MESSAGE( "passing midi input to non-RT thread" );
if ( jack_ringbuffer_read( input[ port ].ring_buf, (char *)me, sizeof( midievent ) ) )
return me;
return true;
}
return NULL;
return false;
}
/**

View File

@ -7,7 +7,7 @@ enum { CONTROL, PERFORMANCE };
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, tick_t duration );
void midi_all_sound_off ( void );

View File

@ -96,11 +96,10 @@ init_song ( void )
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 );
}
}

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
pattern::record_event ( const midievent *me )
{
@ -232,8 +235,10 @@ pattern::record_event ( const midievent *me )
el->unlink( e );
p->_rw->events.insert( e );
}
p->_suspend_update = true;
p->unlock();
p->_suspend_update = false;
}
}