some fuzzy logic to avoid note "overlaps" during step editing
git-svn-id: svn://localhost/ardour2/branches/3.0@7634 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
faca3e5f5d
commit
0b2f156c58
@ -44,6 +44,8 @@ StepEditor::start_step_editing ()
|
|||||||
_step_edit_chord_duration = 0.0;
|
_step_edit_chord_duration = 0.0;
|
||||||
step_edit_region.reset ();
|
step_edit_region.reset ();
|
||||||
step_edit_region_view = 0;
|
step_edit_region_view = 0;
|
||||||
|
last_added_pitch = -1;
|
||||||
|
last_added_end = 0;
|
||||||
|
|
||||||
resync_step_edit_position ();
|
resync_step_edit_position ();
|
||||||
prepare_step_edit_region ();
|
prepare_step_edit_region ();
|
||||||
@ -250,14 +252,30 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
|
|||||||
|
|
||||||
/* make sure its visible on the horizontal axis */
|
/* make sure its visible on the horizontal axis */
|
||||||
|
|
||||||
nframes64_t fpos = step_edit_region->position() +
|
framepos_t fpos = step_edit_region->position() +
|
||||||
step_edit_region_view->beats_to_frames (step_edit_beat_pos + beat_duration);
|
step_edit_region_view->beats_to_frames (step_edit_beat_pos + beat_duration);
|
||||||
|
|
||||||
if (fpos >= (_editor.leftmost_position() + _editor.current_page_frames())) {
|
if (fpos >= (_editor.leftmost_position() + _editor.current_page_frames())) {
|
||||||
_editor.reset_x_origin (fpos - (_editor.current_page_frames()/4));
|
_editor.reset_x_origin (fpos - (_editor.current_page_frames()/4));
|
||||||
}
|
}
|
||||||
|
|
||||||
step_edit_region_view->step_add_note (channel, pitch, velocity, step_edit_beat_pos, beat_duration);
|
Evoral::MusicalTime at = step_edit_beat_pos;
|
||||||
|
Evoral::MusicalTime len = beat_duration;
|
||||||
|
|
||||||
|
if ((last_added_pitch >= 0) && (pitch == last_added_pitch) && (last_added_end == step_edit_beat_pos)) {
|
||||||
|
|
||||||
|
/* avoid any apparent note overlap - move the start of this note
|
||||||
|
up by 1 tick from where the last note ended
|
||||||
|
*/
|
||||||
|
|
||||||
|
at += 1.0/Meter::ticks_per_beat;
|
||||||
|
len -= 1.0/Meter::ticks_per_beat;
|
||||||
|
}
|
||||||
|
|
||||||
|
step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
|
||||||
|
|
||||||
|
last_added_pitch = pitch;
|
||||||
|
last_added_end = at+len;
|
||||||
|
|
||||||
if (_step_edit_triplet_countdown > 0) {
|
if (_step_edit_triplet_countdown > 0) {
|
||||||
_step_edit_triplet_countdown--;
|
_step_edit_triplet_countdown--;
|
||||||
|
@ -61,6 +61,8 @@ class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable
|
|||||||
boost::shared_ptr<ARDOUR::MidiTrack> _track;
|
boost::shared_ptr<ARDOUR::MidiTrack> _track;
|
||||||
StepEntry* step_editor;
|
StepEntry* step_editor;
|
||||||
MidiTimeAxisView& _mtv;
|
MidiTimeAxisView& _mtv;
|
||||||
|
int8_t last_added_pitch;
|
||||||
|
Evoral::MusicalTime last_added_end;
|
||||||
|
|
||||||
void region_removed (boost::weak_ptr<ARDOUR::Region>);
|
void region_removed (boost::weak_ptr<ARDOUR::Region>);
|
||||||
void playlist_changed ();
|
void playlist_changed ();
|
||||||
|
Loading…
Reference in New Issue
Block a user