{
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) {
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 ()
{
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; }
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;
*/
+#include <iostream>
+
#include "midi_time_axis.h"
#include "step_entry.h"
#include "utils.h"
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);
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
{
_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 ();
+ }
+}
void rest_click ();
void sustain_click ();
+ void chord_toggled ();
+ void triplet_toggled ();
};
#endif /* __gtk2_ardour_step_entry_h__ */