/*
Copyright (C) 2009 Paul Davis
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cmath>
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/actions.h"
+#include "ardour_ui.h"
#include "midi_list_editor.h"
#include "note_player.h"
MidiModel::NoteDiffCommand::Property prop (MidiModel::NoteDiffCommand::NoteNumber);
bool apply = false;
bool was_selected = false;
- char* opname;
+ char const * opname;
if (!view.get_path_at_pos (ev->x, ev->y, path, col, cellx, celly)) {
return false;
previous_selection.push_back (*i);
- if (iter = model->get_iter (*i)) {
+ if ((iter = model->get_iter (*i))) {
note = (*iter)[columns._note];
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:
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:
TreeModel::Path path;
TreeViewColumn* col;
TreeModel::iterator iter;
- TreeModel::Row row;
MidiModel::NoteDiffCommand* cmd;
boost::shared_ptr<MidiModel> m (region->midi_source(0)->model());
boost::shared_ptr<NoteType> note;
bool apply = false;
int idelta = 0;
double fdelta = 0;
- char* opname;
+ char const * opname;
switch (edit_column) {
case 0: // start
break;
* 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()) {
}
if (fval > 0.0) {
- fdelta = fval - note->length();
+ fdelta = fval - note->length().to_double();
prop = MidiModel::NoteDiffCommand::Length;
opname = _("change note length");
apply = true;
TreeView::Selection::ListHandle_Path rows = view.get_selection()->get_selected_rows ();
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
- if (iter = model->get_iter (*i)) {
+ if ((iter = model->get_iter (*i))) {
note = (*iter)[columns._note];
row[columns.velocity] = (*i)->velocity();
Timecode::BBT_Time bbt;
- double dur;
_session->tempo_map().bbt_time (conv.to ((*i)->time()), bbt);
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()) {
void
MidiListEditor::selection_changed ()
{
- if (!Config->get_sound_midi_notes()) {
+ if (!ARDOUR_UI::config()->get_sound_midi_notes()) {
return;
}
NotePlayer* player = new NotePlayer (track);
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
- if (iter = model->get_iter (*i)) {
+ if ((iter = model->get_iter (*i))) {
note = (*iter)[columns._note];
player->add (note);
}