midi: allow clearing clip from GenericMIDI binding

This commit allows the user to clear clips from the Luppp grid
with a MIDI message. The binding method is very similar to the
existing "grid:event" style, with added to "action" representing
1 for press, and 0 for release, -1 now represents a "clear" event.

As such, the following binding would clear clip track 1, scene 1,
when midi note number 60 had a note on event. Note that the value
for "send" is also set to -1, indicating it is not a send binding.

Active set to -1 indicates that the clip should be cleared:

{
  "action": "grid:event",
  "status": 144,
  "data":    60,
  "track":    1,
  "scene":    1,
  "send":    -1,
  "active":  -1
}

See Github issue #134
This commit is contained in:
Harry van Haaren 2017-09-29 18:14:25 +01:00
parent 94261743cb
commit be14f4005a
4 changed files with 19 additions and 8 deletions

View file

@ -495,10 +495,16 @@ void GenericMIDI::midi(unsigned char* midi)
jack->getLogic()->trackJackSendActivate(b->track,b->active);
break;
case Event::GRID_EVENT:
if ( b->active )
if ( b->active == 1 ) {
/* press */
jack->getGridLogic()->pressed( b->track, b->scene );
else
} else if ( b->active == -1 ) {
/* clear */
jack->getGridLogic()->clear( b->track, b->scene );
} else {
/* release */
jack->getGridLogic()->released( b->track, b->scene );
}
break;
case Event::GRID_SELECT_CLIP_EVENT:

View file

@ -176,12 +176,8 @@ void handleDspEvents()
if ( availableRead >= sizeof(EventGridState) ) {
EventGridState ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridState) );
// clear clips in Controllers
if ( ev.state == GridLogic::STATE_EMPTY ) {
jack->getLooper( ev.track )->getClip( ev.scene )->init();
jack->getControllerUpdater()->setTrackSceneProgress(ev.track, ev.scene, 0 );
jack->getControllerUpdater()->setSceneState( ev.track, ev.scene, GridLogic::STATE_EMPTY );
}
if ( ev.state == GridLogic::STATE_EMPTY )
jack->getGridLogic()->clear( ev.track, ev.scene );
}
break;
}

View file

@ -211,6 +211,12 @@ void GridLogic::pressed( int track, int scene )
jack->getControllerUpdater()->setSceneState(track, scene, s );
}
void GridLogic::clear( int track, int scene )
{
jack->getLooper( track )->getClip( scene )->init();
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 );
jack->getControllerUpdater()->setSceneState( track, scene, GridLogic::STATE_EMPTY );
}
void GridLogic::released( int track, int scene )
{

View file

@ -61,6 +61,9 @@ public:
/// button press / click event
void pressed( int track, int scene );
/// clears the clip at this location
void clear( int track, int scene );
/// button release / click-release event
void released( int track, int scene );