Improve step-editor chord mode: step on note-off

This commit is contained in:
Robin Gareus 2025-03-04 16:16:03 +01:00
parent 814fbfcb73
commit 826ad62d91
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 14 additions and 0 deletions

View file

@ -68,6 +68,7 @@ StepEditor::start_step_editing ()
step_edit_region_view = 0; step_edit_region_view = 0;
last_added_pitch = -1; last_added_pitch = -1;
last_added_end = Temporal::Beats(); last_added_end = Temporal::Beats();
_tracker.reset ();
resync_step_edit_position (); resync_step_edit_position ();
prepare_step_edit_region (); prepare_step_edit_region ();
@ -203,9 +204,19 @@ StepEditor::check_step_edit ()
break; break;
} }
_tracker.track (buf);
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON && size == 3) { if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON && size == 3) {
step_add_note (buf[0] & 0xf, buf[1], buf[2], Temporal::Beats()); step_add_note (buf[0] & 0xf, buf[1], buf[2], Temporal::Beats());
} }
/* note-off w/chord .. move to next beat */
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_OFF && size == 3 && _tracker.empty ()) {
if (step_edit_region_view && _step_edit_within_chord) {
step_edit_beat_pos += _step_edit_chord_duration;
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
}
}
} }
delete [] buf; delete [] buf;
} }

View file

@ -30,6 +30,8 @@
#include "temporal/beats.h" #include "temporal/beats.h"
#include "temporal/timeline.h" #include "temporal/timeline.h"
#include "ardour/midi_state_tracker.h"
namespace ARDOUR { namespace ARDOUR {
class MidiTrack; class MidiTrack;
class MidiRegion; class MidiRegion;
@ -97,6 +99,7 @@ private:
MidiTimeAxisView& _mtv; MidiTimeAxisView& _mtv;
int8_t last_added_pitch; int8_t last_added_pitch;
Temporal::Beats last_added_end; Temporal::Beats last_added_end;
ARDOUR::MidiNoteTracker _tracker;
sigc::connection delete_connection; sigc::connection delete_connection;
sigc::connection hide_connection; sigc::connection hide_connection;