diff --git a/src/canvas.C b/src/canvas.C index c87484c..7928f3b 100644 --- a/src/canvas.C +++ b/src/canvas.C @@ -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; } diff --git a/src/grid.C b/src/grid.C index ad00874..e4bcb95 100644 --- a/src/grid.C +++ b/src/grid.C @@ -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(); } } diff --git a/src/grid.H b/src/grid.H index 8978527..cf9bf2f 100644 --- a/src/grid.H +++ b/src/grid.H @@ -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: diff --git a/src/jack.C b/src/jack.C index 195580a..2a7454d 100644 --- a/src/jack.C +++ b/src/jack.C @@ -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; } /** diff --git a/src/jack.H b/src/jack.H index 10cc692..97ce95e 100644 --- a/src/jack.H +++ b/src/jack.H @@ -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 ); diff --git a/src/main.C b/src/main.C index f72afda..cf97e9f 100644 --- a/src/main.C +++ b/src/main.C @@ -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 ); } } diff --git a/src/pattern.C b/src/pattern.C index ad68abb..a17026e 100644 --- a/src/pattern.C +++ b/src/pattern.C @@ -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; } }