summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_list_editor.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-22 21:49:42 -0500
committerDavid Robillard <d@drobilla.net>2014-11-22 21:49:42 -0500
commit57c1b6e261076cae9b61e74aa0aff47a9f296c0f (patch)
tree0ed8e37d0fe4bdc7c49437062d16045d1d9b3881 /gtk2_ardour/midi_list_editor.cc
parent231e0009b40464ed0c74efcb4585c6ace1336b59 (diff)
Fix quantization and other time-related ops.
Diffstat (limited to 'gtk2_ardour/midi_list_editor.cc')
-rw-r--r--gtk2_ardour/midi_list_editor.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/gtk2_ardour/midi_list_editor.cc b/gtk2_ardour/midi_list_editor.cc
index 32c87bae86..0a87823f8e 100644
--- a/gtk2_ardour/midi_list_editor.cc
+++ b/gtk2_ardour/midi_list_editor.cc
@@ -291,17 +291,18 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
if (note->time() + fdelta >= 0) {
cmd->change (note, prop, note->time() + fdelta);
} else {
- cmd->change (note, prop, 0.0);
+ cmd->change (note, prop, Evoral::MusicalTime());
}
break;
case MidiModel::NoteDiffCommand::Velocity:
cmd->change (note, prop, (uint8_t) (note->velocity() + idelta));
break;
case MidiModel::NoteDiffCommand::Length:
- if (note->length() + fdelta >= 1.0/BBT_Time::ticks_per_beat) {
+ if (note->length().to_double() + fdelta >=
+ Evoral::MusicalTime::tick().to_double()) {
cmd->change (note, prop, note->length() + fdelta);
} else {
- cmd->change (note, prop, 1.0/BBT_Time::ticks_per_beat);
+ cmd->change (note, prop, Evoral::MusicalTime::tick());
}
break;
case MidiModel::NoteDiffCommand::Channel:
@@ -333,17 +334,18 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
if (note->time() + fdelta >= 0) {
cmd->change (note, prop, note->time() + fdelta);
} else {
- cmd->change (note, prop, 0.0);
+ cmd->change (note, prop, Evoral::MusicalTime());
}
break;
case MidiModel::NoteDiffCommand::Velocity:
cmd->change (note, prop, (uint8_t) (note->velocity() + idelta));
break;
case MidiModel::NoteDiffCommand::Length:
- if (note->length() + fdelta >= 1.0/BBT_Time::ticks_per_beat) {
+ if (note->length() + fdelta >=
+ Evoral::MusicalTime::tick().to_double()) {
cmd->change (note, prop, note->length() + fdelta);
} else {
- cmd->change (note, prop, 1.0/BBT_Time::ticks_per_beat);
+ cmd->change (note, prop, Evoral::MusicalTime::tick());
}
break;
case MidiModel::NoteDiffCommand::Channel:
@@ -637,7 +639,7 @@ MidiListEditor::edited (const std::string& path, const std::string& text)
* entry for the actual note ticks
*/
- int len_ticks = lrint (note->length() * Timecode::BBT_Time::ticks_per_beat);
+ uint64_t len_ticks = note->length().to_ticks();
std::map<int,string>::iterator x = note_length_map.find (len_ticks);
if (x == note_length_map.end()) {
@@ -682,7 +684,7 @@ MidiListEditor::edited (const std::string& path, const std::string& text)
}
if (fval > 0.0) {
- fdelta = fval - note->length();
+ fdelta = fval - note->length().to_double();
prop = MidiModel::NoteDiffCommand::Length;
opname = _("change note length");
apply = true;
@@ -762,7 +764,6 @@ MidiListEditor::redisplay_model ()
row[columns.velocity] = (*i)->velocity();
Timecode::BBT_Time bbt;
- double dur;
_session->tempo_map().bbt_time (conv.to ((*i)->time()), bbt);
@@ -771,11 +772,11 @@ MidiListEditor::redisplay_model ()
row[columns.start] = ss.str();
bbt.bars = 0;
- dur = (*i)->end_time() - (*i)->time();
- bbt.beats = floor (dur);
- bbt.ticks = (uint32_t) lrint (fmod (dur, 1.0) * Timecode::BBT_Time::ticks_per_beat);
+ const Evoral::MusicalTime dur = (*i)->end_time() - (*i)->time();
+ bbt.beats = dur.get_beats ();
+ bbt.ticks = dur.get_ticks ();
- int len_ticks = lrint ((*i)->length() * Timecode::BBT_Time::ticks_per_beat);
+ int len_ticks = (*i)->length().to_ticks();
std::map<int,string>::iterator x = note_length_map.find (len_ticks);
if (x != note_length_map.end()) {