diff options
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 40 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 6 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 20 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/step_entry.cc | 1 |
5 files changed, 47 insertions, 25 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 3482c62a51..b761941df1 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -563,7 +563,7 @@ MidiRegionView::key_press (GdkEventKey* ev) bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier); bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier); - change_note_lengths (fine, shorter, start, end); + change_note_lengths (fine, shorter, 0.0, start, end); return true; @@ -1478,7 +1478,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) void MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, - Evoral::MusicalTime pos, Evoral::MusicalTime len) + Evoral::MusicalTime pos, Evoral::MusicalTime len) { boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity)); @@ -1502,6 +1502,12 @@ MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity } void +MidiRegionView::step_sustain (Evoral::MusicalTime beats) +{ + change_note_lengths (false, false, beats, false, true); +} + +void MidiRegionView::add_pgm_change(PCEvent& program, const string& displaytext) { assert(program.time >= 0); @@ -2473,22 +2479,22 @@ MidiRegionView::transpose (bool up, bool fine, bool allow_smush) } void -MidiRegionView::change_note_lengths (bool fine, bool shorter, bool start, bool end) +MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTime delta, bool start, bool end) { - Evoral::MusicalTime delta; - - if (fine) { - delta = 1.0/128.0; - } else { - /* grab the current grid distance */ - bool success; - delta = trackview.editor().get_grid_type_as_beats (success, _region->position()); - if (!success) { - /* XXX cannot get grid type as beats ... should always be possible ... FIX ME */ - cerr << "Grid type not available as beats - TO BE FIXED\n"; - return; - } - } + if (delta == 0.0) { + if (fine) { + delta = 1.0/128.0; + } else { + /* grab the current grid distance */ + bool success; + delta = trackview.editor().get_grid_type_as_beats (success, _region->position()); + if (!success) { + /* XXX cannot get grid type as beats ... should always be possible ... FIX ME */ + cerr << "Grid type not available as beats - TO BE FIXED\n"; + return; + } + } + } if (shorter) { delta = -delta; diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 268bcdc0dd..ccab1d06bc 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -94,8 +94,8 @@ class MidiRegionView : public RegionView { return midi_view()->midi_view(); } void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, - Evoral::MusicalTime pos, Evoral::MusicalTime len); - + Evoral::MusicalTime pos, Evoral::MusicalTime len); + void step_sustain (Evoral::MusicalTime beats); void set_height (double); void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false); @@ -276,7 +276,7 @@ class MidiRegionView : public RegionView void goto_previous_note (); void goto_next_note (); - void change_note_lengths (bool, bool, bool start, bool end); + void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); void change_velocities (bool up, bool fine, bool allow_smush); void transpose (bool up, bool fine, bool allow_smush); void nudge_notes (bool forward); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index e62bd6223c..464ed630f5 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -898,8 +898,12 @@ MidiTimeAxisView::start_step_editing () _step_edit_triplet_countdown = 0; _step_edit_within_chord = 0; _step_edit_chord_duration = 0.0; + + boost::shared_ptr<Region> r = playlist()->top_region_at (step_edit_insert_position); - step_edit_region = playlist()->top_region_at (step_edit_insert_position); + if (r) { + step_edit_region = boost::dynamic_pointer_cast<MidiRegion>(r); + } if (step_edit_region) { RegionView* rv = view()->find_view (step_edit_region); @@ -962,6 +966,8 @@ MidiTimeAxisView::stop_step_editing () if (step_edit_region_view) { step_edit_region_view->hide_step_edit_cursor(); } + + step_edit_region.reset (); } void @@ -1006,6 +1012,14 @@ MidiTimeAxisView::step_add_program_change (uint8_t channel, uint8_t program) return 0; } +void +MidiTimeAxisView::step_edit_sustain (Evoral::MusicalTime beats) +{ + if (step_edit_region_view) { + step_edit_region_view->step_sustain (beats); + } +} + int MidiTimeAxisView::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::MusicalTime beat_duration) { @@ -1144,7 +1158,7 @@ MidiTimeAxisView::step_edit_bar_sync () step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos); } -boost::shared_ptr<Region> +boost::shared_ptr<MidiRegion> MidiTimeAxisView::add_region (framepos_t pos) { Editor* real_editor = dynamic_cast<Editor*> (&_editor); @@ -1172,7 +1186,7 @@ MidiTimeAxisView::add_region (framepos_t pos) real_editor->commit_reversible_command(); - return region; + return boost::dynamic_pointer_cast<MidiRegion>(region); } void diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index cbca25bd0e..8012db5cc1 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -68,7 +68,7 @@ class MidiTimeAxisView : public RouteTimeAxisView void set_height (uint32_t); void hide (); - boost::shared_ptr<ARDOUR::Region> add_region (ARDOUR::framepos_t pos); + boost::shared_ptr<ARDOUR::MidiRegion> add_region (ARDOUR::framepos_t pos); void show_all_automation (); void show_existing_automation (); @@ -95,6 +95,7 @@ class MidiTimeAxisView : public RouteTimeAxisView int step_add_program_change (uint8_t channel, uint8_t program); int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::MusicalTime beat_duration); + void step_edit_sustain (Evoral::MusicalTime beats); bool step_edit_within_triplet () const; void step_edit_toggle_triplet (); bool step_edit_within_chord () const; @@ -147,7 +148,7 @@ class MidiTimeAxisView : public RouteTimeAxisView nframes64_t step_edit_insert_position; Evoral::MusicalTime step_edit_beat_pos; - boost::shared_ptr<ARDOUR::Region> step_edit_region; + boost::shared_ptr<ARDOUR::MidiRegion> step_edit_region; MidiRegionView* step_edit_region_view; uint8_t _step_edit_triplet_countdown; bool _step_edit_within_chord; diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index 7481565363..011fadc3c4 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -1030,4 +1030,5 @@ StepEntry::octave_n (int n) void StepEntry::do_sustain () { + _mtv->step_edit_sustain (note_length()); } |