make step entry chord & triplet buttons do their thing, or something close to it

git-svn-id: svn://localhost/ardour2/branches/3.0@7530 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-08-03 04:13:05 +00:00
parent e0edca5a2a
commit 64f9fac9a8
4 changed files with 89 additions and 10 deletions

View File

@ -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 ()
{

View File

@ -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;

View File

@ -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 ();
}
}

View File

@ -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__ */