summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/midi_time_axis.cc57
-rw-r--r--gtk2_ardour/midi_time_axis.h11
-rw-r--r--gtk2_ardour/step_entry.cc29
-rw-r--r--gtk2_ardour/step_entry.h2
4 files changed, 89 insertions, 10 deletions
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc
index 89a138f8b9..0287a1c0ea 100644
--- a/gtk2_ardour/midi_time_axis.cc
+++ b/gtk2_ardour/midi_time_axis.cc
@@ -909,6 +909,10 @@ MidiTimeAxisView::start_step_editing ()
{
step_edit_insert_position = _editor.get_preferred_edit_position ();
step_edit_beat_pos = -1.0;
+ _step_edit_triplet_countdown = 0;
+ _step_edit_within_chord = 0;
+ _step_edit_chord_duration = 0.0;
+
step_edit_region = playlist()->top_region_at (step_edit_insert_position);
if (step_edit_region) {
@@ -989,14 +993,63 @@ MidiTimeAxisView::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocit
return -1;
}
}
-
+
step_edit_region_view->step_add_note (channel, pitch, velocity, step_edit_beat_pos, beat_duration);
- step_edit_beat_pos += beat_duration;
+
+ if (_step_edit_triplet_countdown > 0) {
+ _step_edit_triplet_countdown--;
+
+ if (_step_edit_triplet_countdown == 0) {
+ _step_edit_triplet_countdown = 3;
+ }
+ }
+
+ if (!_step_edit_within_chord) {
+ step_edit_beat_pos += beat_duration;
+ } else {
+ step_edit_beat_pos += 1.0/Meter::ticks_per_beat; // tiny, but no longer overlapping
+ _step_edit_chord_duration = beat_duration;
+ }
}
return 0;
}
+bool
+MidiTimeAxisView::step_edit_within_triplet() const
+{
+ return _step_edit_triplet_countdown > 0;
+}
+
+bool
+MidiTimeAxisView::step_edit_within_chord() const
+{
+ return _step_edit_within_chord;
+}
+
+void
+MidiTimeAxisView::step_edit_toggle_triplet ()
+{
+ if (_step_edit_triplet_countdown == 0) {
+ _step_edit_within_chord = false;
+ _step_edit_triplet_countdown = 3;
+ } else {
+ _step_edit_triplet_countdown = 0;
+ }
+}
+
+void
+MidiTimeAxisView::step_edit_toggle_chord ()
+{
+ if (_step_edit_within_chord) {
+ _step_edit_within_chord = false;
+ step_edit_beat_pos += _step_edit_chord_duration;
+ } else {
+ _step_edit_triplet_countdown = 0;
+ _step_edit_within_chord = true;
+ }
+}
+
void
MidiTimeAxisView::step_edit_rest ()
{
diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h
index 2c0c8b2d44..fe1835266f 100644
--- a/gtk2_ardour/midi_time_axis.h
+++ b/gtk2_ardour/midi_time_axis.h
@@ -91,8 +91,12 @@ class MidiTimeAxisView : public RouteTimeAxisView
void stop_step_editing ();
void check_step_edit ();
void step_edit_rest ();
- int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity,
- Evoral::MusicalTime beat_duration);
+ int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity,
+ Evoral::MusicalTime beat_duration);
+ bool step_edit_within_triplet () const;
+ void step_edit_toggle_triplet ();
+ bool step_edit_within_chord () const;
+ void step_edit_toggle_chord ();
const MidiMultipleChannelSelector& channel_selector() { return _channel_selector; }
@@ -138,6 +142,9 @@ class MidiTimeAxisView : public RouteTimeAxisView
Evoral::MusicalTime step_edit_beat_pos;
boost::shared_ptr<ARDOUR::Region> step_edit_region;
MidiRegionView* step_edit_region_view;
+ uint8_t _step_edit_triplet_countdown;
+ bool _step_edit_within_chord;
+ Evoral::MusicalTime _step_edit_chord_duration;
void region_removed (boost::weak_ptr<ARDOUR::Region>);
void playlist_changed ();
PBD::ScopedConnection step_edit_region_connection;
diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc
index aa81fead3d..666890996b 100644
--- a/gtk2_ardour/step_entry.cc
+++ b/gtk2_ardour/step_entry.cc
@@ -17,6 +17,8 @@
*/
+#include <iostream>
+
#include "midi_time_axis.h"
#include "step_entry.h"
#include "utils.h"
@@ -169,6 +171,8 @@ StepEntry::StepEntry (MidiTimeAxisView& mtv)
g_signal_connect(G_OBJECT(_piano), "note-off", G_CALLBACK(_note_off_event_handler), this);
rest_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::rest_click));
+ chord_button.signal_toggled().connect (sigc::mem_fun (*this, &StepEntry::chord_toggled));
+ triplet_button.signal_toggled().connect (sigc::mem_fun (*this, &StepEntry::triplet_toggled));
packer.set_spacing (6);
packer.pack_start (upper_box, false, false);
@@ -226,14 +230,11 @@ StepEntry::note_off_event_handler (int note)
velocity = 127;
}
- if (!triplet_button.get_active()) {
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- } else {
+ if (_mtv->step_edit_within_triplet()) {
length *= 2.0/3.0;
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
- _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
}
+
+ _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
}
void
@@ -241,3 +242,19 @@ StepEntry::rest_click ()
{
_mtv->step_edit_rest ();
}
+
+void
+StepEntry::triplet_toggled ()
+{
+ if (triplet_button.get_active () != _mtv->step_edit_within_triplet()) {
+ _mtv->step_edit_toggle_triplet ();
+ }
+}
+
+void
+StepEntry::chord_toggled ()
+{
+ if (chord_button.get_active() != _mtv->step_edit_within_chord ()) {
+ _mtv->step_edit_toggle_chord ();
+ }
+}
diff --git a/gtk2_ardour/step_entry.h b/gtk2_ardour/step_entry.h
index cabd9eba47..d57ac3fadf 100644
--- a/gtk2_ardour/step_entry.h
+++ b/gtk2_ardour/step_entry.h
@@ -79,6 +79,8 @@ class StepEntry : public ArdourDialog
void rest_click ();
void sustain_click ();
+ void chord_toggled ();
+ void triplet_toggled ();
};
#endif /* __gtk2_ardour_step_entry_h__ */