summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-02-28 04:59:34 +1100
committernick_m <mainsbridge@gmail.com>2016-05-27 23:38:10 +1000
commitbc42dea451a5cfce4d7ede70a4c14f208fcaeb3c (patch)
treec7c07c527e78347d1a15d9204060f4f42771e4f2 /gtk2_ardour
parentd8549c6ff5d882a740ed3509852318f245cad857 (diff)
Tempo ramps - first stab at metric marks locked to frames or beats.
- pretty much untested.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_drag.cc37
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc31
-rw-r--r--gtk2_ardour/tempo_dialog.cc107
-rw-r--r--gtk2_ardour/tempo_dialog.h17
4 files changed, 167 insertions, 25 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 45a6245bc7..b8339cc557 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3210,7 +3210,13 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
if (_copy == true) {
_editor->begin_reversible_command (_("copy meter mark"));
XMLNode &before = map.get_state();
- map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when);
+
+ if (_marker->meter().position_lock_style() == AudioTime) {
+ map.add_meter (_marker->meter(), _marker->position());
+ } else {
+ map.add_meter (_marker->meter(), map.bbt_to_beats (when), when);
+ }
+
XMLNode &after = map.get_state();
_editor->session()->add_command(new MementoCommand<TempoMap>(map, &before, &after));
_editor->commit_reversible_command ();
@@ -3219,8 +3225,12 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
_editor->begin_reversible_command (_("move meter mark"));
/* we removed it before, so add it back now */
+ if (_marker->meter().position_lock_style() == AudioTime) {
+ map.add_meter (_marker->meter(), _marker->position());
+ } else {
+ map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when);
+ }
- map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when);
XMLNode &after = map.get_state();
_editor->session()->add_command(new MementoCommand<TempoMap>(map, before_state, &after));
_editor->commit_reversible_command ();
@@ -3336,21 +3346,32 @@ TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
return;
}
- motion (event, false);
+ //motion (event, false);
TempoMap& map (_editor->session()->tempo_map());
if (_copy == true) {
_editor->begin_reversible_command (_("copy tempo mark"));
XMLNode &before = map.get_state();
- map.add_tempo (_marker->tempo(), _real_section->beat(), _marker->tempo().type());
+
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.add_tempo (_marker->tempo(), _real_section->beat(), _marker->tempo().type());
+ } else {
+ map.add_tempo (_marker->tempo(), _real_section->frame(), _marker->tempo().type());
+ }
+
XMLNode &after = map.get_state();
_editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after));
_editor->commit_reversible_command ();
} else {
/* we removed it before, so add it back now */
- map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , _real_section->beat(), _marker->tempo().type());
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , _real_section->beat(), _marker->tempo().type());
+ } else {
+ map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , _real_section->frame(), _marker->tempo().type());
+ }
+
XMLNode &after = map.get_state();
_editor->session()->add_command (new MementoCommand<TempoMap>(map, before_state, &after));
_editor->commit_reversible_command ();
@@ -3368,7 +3389,11 @@ TempoMarkerDrag::aborted (bool moved)
if (moved) {
TempoMap& map (_editor->session()->tempo_map());
/* we removed it before, so add it back now */
- map.add_tempo (_marker->tempo(), _marker->tempo().beat(), _marker->tempo().type());
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.add_tempo (_marker->tempo(), _marker->tempo().beat(), _marker->tempo().type());
+ } else {
+ map.add_tempo (_marker->tempo(), _marker->tempo().frame(), _marker->tempo().type());
+ }
// delete the dummy marker we used for visual representation while moving.
// a new visual marker will show up automatically.
delete _marker;
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index 8361315495..53cc28cd63 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -238,16 +238,18 @@ Editor::mouse_add_new_tempo_event (framepos_t frame)
double bpm = 0;
Timecode::BBT_Time requested;
-
bpm = tempo_dialog.get_bpm ();
double nt = tempo_dialog.get_note_type();
bpm = max (0.01, bpm);
tempo_dialog.get_bbt_time (requested);
-
begin_reversible_command (_("add tempo mark"));
XMLNode &before = map.get_state();
- map.add_tempo (Tempo (bpm,nt), map.bbt_to_beats (requested), tempo_dialog.get_tempo_type());
+ if (tempo_dialog.get_lock_style() == MusicTime) {
+ map.add_tempo (Tempo (bpm,nt), map.bbt_to_beats (requested), tempo_dialog.get_tempo_type());
+ } else {
+ map.add_tempo (Tempo (bpm,nt), frame, tempo_dialog.get_tempo_type());
+ }
XMLNode &after = map.get_state();
_session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
@@ -286,7 +288,11 @@ Editor::mouse_add_new_meter_event (framepos_t frame)
begin_reversible_command (_("add meter mark"));
XMLNode &before = map.get_state();
- map.add_meter (Meter (bpb, note_type), map.bbt_to_beats (requested), requested);
+ if (meter_dialog.get_lock_style() == MusicTime) {
+ map.add_meter (Meter (bpb, note_type), map.bbt_to_beats (requested), requested);
+ } else {
+ map.add_meter (Meter (bpb, note_type), frame, meter_dialog.get_lock_style());
+ }
_session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
commit_reversible_command ();
@@ -330,13 +336,17 @@ Editor::edit_meter_section (MeterSection* section)
bpb = max (1.0, bpb); // XXX is this a reasonable limit?
double note_type = meter_dialog.get_note_type ();
-
Timecode::BBT_Time when;
meter_dialog.get_bbt_time(when);
+ framepos_t const frame = _session->tempo_map().frame_at_beat (_session->tempo_map().bbt_to_beats (when));
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
- _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when);
+ if (meter_dialog.get_lock_style() == MusicTime) {
+ _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when);
+ } else {
+ _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), frame);
+ }
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
@@ -356,13 +366,20 @@ Editor::edit_tempo_section (TempoSection* section)
double bpm = tempo_dialog.get_bpm ();
double nt = tempo_dialog.get_note_type ();
+ double beat;
Timecode::BBT_Time when;
+
tempo_dialog.get_bbt_time(when);
bpm = max (0.01, bpm);
+ beat = _session->tempo_map().bbt_to_beats (when);
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
- _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), _session->tempo_map().bbt_to_beats (when), tempo_dialog.get_tempo_type());
+ if (tempo_dialog.get_lock_style() == MusicTime) {
+ _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), beat, tempo_dialog.get_tempo_type());
+ } else {
+ _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), _session->tempo_map().frame_at_beat (beat), tempo_dialog.get_tempo_type());
+ }
XMLNode &after = _session->tempo_map().get_state();
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc
index c9609c4a0a..b8f5a0c531 100644
--- a/gtk2_ardour/tempo_dialog.cc
+++ b/gtk2_ardour/tempo_dialog.cc
@@ -47,7 +47,7 @@ TempoDialog::TempoDialog (TempoMap& map, framepos_t frame, const string&)
Tempo tempo (map.tempo_at (frame));
map.bbt_time (frame, when);
- init (when, tempo.beats_per_minute(), tempo.note_type(), TempoSection::Constant, true);
+ init (when, tempo.beats_per_minute(), tempo.note_type(), TempoSection::Constant, true, PositionLockStyle::MusicTime);
}
TempoDialog::TempoDialog (TempoMap& map, TempoSection& section, const string&)
@@ -61,11 +61,11 @@ TempoDialog::TempoDialog (TempoMap& map, TempoSection& section, const string&)
{
Timecode::BBT_Time when;
map.bbt_time (map.frame_at_beat (section.beat()), when);
- init (when, section.beats_per_minute(), section.note_type(), section.type(), section.movable());
+ init (when, section.beats_per_minute(), section.note_type(), section.type(), section.movable(), section.position_lock_style());
}
void
-TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type, TempoSection::Type type, bool movable)
+TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type, TempoSection::Type type, bool movable, PositionLockStyle style)
{
vector<string> strings;
NoteTypes::iterator x;
@@ -123,15 +123,33 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type,
}
}
if (tt == tempo_types.end()) {
- tempo_type.set_active_text (strings[0]); // "ramped"
+ tempo_type.set_active_text (strings[1]); // "constant"
+ }
+
+ strings.clear();
+
+ lock_styles.insert (make_pair (_("music"), PositionLockStyle::MusicTime));
+ strings.push_back (_("music"));
+ lock_styles.insert (make_pair (_("audio"), PositionLockStyle::AudioTime));
+ strings.push_back (_("audio"));
+ set_popdown_strings (lock_style, strings);
+ LockStyles::iterator ls;
+ for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) {
+ if (ls->second == style) {
+ lock_style.set_active_text (ls->first);
+ break;
+ }
+ }
+ if (ls == lock_styles.end()) {
+ lock_style.set_active_text (strings[0]); // "music"
}
Table* table;
if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
- table = manage (new Table (5, 6));
+ table = manage (new Table (5, 7));
} else {
- table = manage (new Table (5, 5));
+ table = manage (new Table (5, 6));
}
table->set_spacings (6);
@@ -182,6 +200,12 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type,
get_vbox()->set_border_width (12);
get_vbox()->pack_end (*table);
+ Label* lock_style_label = manage (new Label(_("Lock Style:"), ALIGN_LEFT, ALIGN_CENTER));
+ table->attach (*lock_style_label, 0, 1, row+2, row+3);
+ table->attach (lock_style, 1, 2, row+2, row + 3);
+ get_vbox()->set_border_width (12);
+ get_vbox()->pack_end (*table);
+
table->show_all ();
add_button (Stock::CANCEL, RESPONSE_CANCEL);
@@ -206,6 +230,7 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type,
when_beat_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false);
pulse_selector.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::pulse_change));
tempo_type.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::tempo_type_change));
+ lock_style.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::lock_style_change));
tap_tempo_button.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_button_press), false);
tap_tempo_button.signal_focus_out_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_focus_out));
@@ -296,6 +321,19 @@ TempoDialog::get_tempo_type ()
return x->second;
}
+PositionLockStyle
+TempoDialog::get_lock_style ()
+{
+ LockStyles::iterator x = lock_styles.find (lock_style.get_active_text());
+
+ if (x == lock_styles.end()) {
+ error << string_compose(_("incomprehensible lock style (%1)"), lock_style.get_active_text()) << endmsg;
+ return PositionLockStyle::MusicTime;
+ }
+
+ return x->second;
+}
+
void
TempoDialog::pulse_change ()
{
@@ -308,6 +346,12 @@ TempoDialog::tempo_type_change ()
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
}
+void
+TempoDialog::lock_style_change ()
+{
+ set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
+}
+
bool
TempoDialog::tap_tempo_button_press (GdkEventButton *ev)
{
@@ -362,7 +406,7 @@ MeterDialog::MeterDialog (TempoMap& map, framepos_t frame, const string&)
Meter meter (map.meter_at(frame));
map.bbt_time (frame, when);
- init (when, meter.divisions_per_bar(), meter.note_divisor(), true);
+ init (when, meter.divisions_per_bar(), meter.note_divisor(), true, PositionLockStyle::MusicTime);
}
MeterDialog::MeterDialog (TempoMap& map, MeterSection& section, const string&)
@@ -370,11 +414,11 @@ MeterDialog::MeterDialog (TempoMap& map, MeterSection& section, const string&)
{
Timecode::BBT_Time when;
map.bbt_time (map.frame_at_beat (section.beat()), when);
- init (when, section.divisions_per_bar(), section.note_divisor(), section.movable());
+ init (when, section.divisions_per_bar(), section.note_divisor(), section.movable(), section.position_lock_style());
}
void
-MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, bool movable)
+MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, bool movable, PositionLockStyle style)
{
char buf[64];
vector<string> strings;
@@ -417,9 +461,28 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b
note_type.set_active_text (strings[3]); // "quarter"
}
+ strings.clear();
+
+ lock_styles.insert (make_pair (_("music"), PositionLockStyle::MusicTime));
+ strings.push_back (_("music"));
+ lock_styles.insert (make_pair (_("audio ur brane wul xplod"), PositionLockStyle::AudioTime));
+ strings.push_back (_("audio"));
+ set_popdown_strings (lock_style, strings);
+ LockStyles::iterator ls;
+ for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) {
+ if (ls->second == style) {
+ lock_style.set_active_text (ls->first);
+ break;
+ }
+ }
+ if (ls == lock_styles.end()) {
+ lock_style.set_active_text (strings[0]); // "music"
+ }
+
Label* note_label = manage (new Label (_("Note value:"), ALIGN_LEFT, ALIGN_CENTER));
+ Label* lock_label = manage (new Label (_("Lock style:"), ALIGN_LEFT, ALIGN_CENTER));
Label* bpb_label = manage (new Label (_("Beats per bar:"), ALIGN_LEFT, ALIGN_CENTER));
- Table* table = manage (new Table (3, 2));
+ Table* table = manage (new Table (3, 3));
table->set_spacings (6);
table->attach (*bpb_label, 0, 1, 0, 1, FILL|EXPAND, FILL|EXPAND);
@@ -438,6 +501,9 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b
table->attach (when_bar_entry, 1, 2, 2, 3, FILL | EXPAND, FILL | EXPAND);
}
+ table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND);
+ table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK);
+
get_vbox()->set_border_width (12);
get_vbox()->pack_start (*table, false, false);
@@ -456,6 +522,8 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b
when_bar_entry.signal_key_press_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_press), false);
when_bar_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_release));
note_type.signal_changed().connect (sigc::mem_fun (*this, &MeterDialog::note_type_change));
+ lock_style.signal_changed().connect (sigc::mem_fun (*this, &MeterDialog::lock_style_change));
+
}
bool
@@ -527,6 +595,12 @@ MeterDialog::note_type_change ()
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
}
+void
+MeterDialog::lock_style_change ()
+{
+ set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
+}
+
double
MeterDialog::get_bpb ()
{
@@ -552,6 +626,19 @@ MeterDialog::get_note_type ()
return x->second;
}
+PositionLockStyle
+MeterDialog::get_lock_style ()
+{
+ LockStyles::iterator x = lock_styles.find (lock_style.get_active_text());
+
+ if (x == lock_styles.end()) {
+ error << string_compose(_("incomprehensible meter lock style (%1)"), lock_style.get_active_text()) << endmsg;
+ return PositionLockStyle::MusicTime;
+ }
+
+ return x->second;
+}
+
bool
MeterDialog::get_bbt_time (Timecode::BBT_Time& requested)
{
diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h
index c6828e3ad2..706085c688 100644
--- a/gtk2_ardour/tempo_dialog.h
+++ b/gtk2_ardour/tempo_dialog.h
@@ -45,9 +45,10 @@ public:
double get_note_type ();
bool get_bbt_time (Timecode::BBT_Time&);
ARDOUR::TempoSection::Type get_tempo_type ();
+ ARDOUR::PositionLockStyle get_lock_style ();
private:
- void init (const Timecode::BBT_Time& start, double bpm , double note_type, ARDOUR::TempoSection::Type type, bool movable);
+ void init (const Timecode::BBT_Time& start, double bpm , double note_type, ARDOUR::TempoSection::Type type, bool movable, ARDOUR::PositionLockStyle style);
bool is_user_input_valid() const;
void bpm_changed ();
bool bpm_button_press (GdkEventButton* );
@@ -55,6 +56,7 @@ private:
bool entry_key_release (GdkEventKey* );
void pulse_change ();
void tempo_type_change ();
+ void lock_style_change ();
bool tap_tempo_button_press (GdkEventButton* );
bool tap_tempo_focus_out (GdkEventFocus* );
@@ -64,6 +66,9 @@ private:
typedef std::map<std::string, ARDOUR::TempoSection::Type> TempoTypes;
TempoTypes tempo_types;
+ typedef std::map<std::string, ARDOUR::PositionLockStyle> LockStyles;
+ LockStyles lock_styles;
+
bool tapped; // whether the tap-tempo button has been clicked
double sum_x, sum_xx, sum_xy, sum_y;
double tap_count;
@@ -80,6 +85,8 @@ private:
Gtk::Label pulse_selector_label;
Gtk::Button tap_tempo_button;
Gtk::ComboBoxText tempo_type;
+ Gtk::ComboBoxText lock_style;
+
};
@@ -92,20 +99,26 @@ public:
double get_bpb ();
double get_note_type ();
+ ARDOUR::PositionLockStyle get_lock_style ();
bool get_bbt_time (Timecode::BBT_Time&);
private:
- void init (const Timecode::BBT_Time&, double, double, bool);
+ void init (const Timecode::BBT_Time&, double, double, bool, ARDOUR::PositionLockStyle style);
bool is_user_input_valid() const;
bool entry_key_press (GdkEventKey* );
bool entry_key_release (GdkEventKey* );
void note_type_change ();
+ void lock_style_change ();
typedef std::map<std::string,float> NoteTypes;
NoteTypes note_types;
+ typedef std::map<std::string, ARDOUR::PositionLockStyle> LockStyles;
+ LockStyles lock_styles;
+
Gtk::Entry bpb_entry;
Gtk::ComboBoxText note_type;
+ Gtk::ComboBoxText lock_style;
std::vector<std::string> strings;
Gtk::Button ok_button;
Gtk::Button cancel_button;