MusicalTime => Beats.

This commit is contained in:
David Robillard 2015-01-07 00:12:07 -05:00
parent 4d202d9157
commit 2a251b4570
66 changed files with 625 additions and 584 deletions

View file

@ -116,8 +116,8 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set<NoteBase*> n)
int test_channel = (*_events.begin())->note()->channel (); int test_channel = (*_events.begin())->note()->channel ();
int test_pitch = (*_events.begin())->note()->note (); int test_pitch = (*_events.begin())->note()->note ();
int test_velocity = (*_events.begin())->note()->velocity (); int test_velocity = (*_events.begin())->note()->velocity ();
Evoral::MusicalTime test_time = (*_events.begin())->note()->time (); Evoral::Beats test_time = (*_events.begin())->note()->time ();
Evoral::MusicalTime test_length = (*_events.begin())->note()->length (); Evoral::Beats test_length = (*_events.begin())->note()->length ();
for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) { for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) {
if ((*i)->note()->channel() != test_channel) { if ((*i)->note()->channel() != test_channel) {
@ -193,7 +193,7 @@ EditNoteDialog::done (int r)
} }
} }
Evoral::MusicalTime const t = _region_view->source_relative_time_converter().from (_time_clock.current_time ()); Evoral::Beats const t = _region_view->source_relative_time_converter().from (_time_clock.current_time ());
if (!_time_all.get_sensitive() || _time_all.get_active ()) { if (!_time_all.get_sensitive() || _time_all.get_active ()) {
for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) { for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) {
@ -204,7 +204,7 @@ EditNoteDialog::done (int r)
} }
} }
Evoral::MusicalTime const d = _region_view->region_relative_time_converter().from (_length_clock.current_duration ()); Evoral::Beats const d = _region_view->region_relative_time_converter().from (_length_clock.current_duration ());
if (!_length_all.get_sensitive() || _length_all.get_active ()) { if (!_length_all.get_sensitive() || _length_all.get_active ()) {
for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) { for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) {

View file

@ -4001,71 +4001,71 @@ Editor::get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t durat
return offset; return offset;
} }
Evoral::MusicalTime Evoral::Beats
Editor::get_grid_type_as_beats (bool& success, framepos_t position) Editor::get_grid_type_as_beats (bool& success, framepos_t position)
{ {
success = true; success = true;
switch (_snap_type) { switch (_snap_type) {
case SnapToBeat: case SnapToBeat:
return Evoral::MusicalTime(1.0); return Evoral::Beats(1.0);
break; break;
case SnapToBeatDiv128: case SnapToBeatDiv128:
return Evoral::MusicalTime(1.0/128.0); return Evoral::Beats(1.0/128.0);
break; break;
case SnapToBeatDiv64: case SnapToBeatDiv64:
return Evoral::MusicalTime(1.0/64.0); return Evoral::Beats(1.0/64.0);
break; break;
case SnapToBeatDiv32: case SnapToBeatDiv32:
return Evoral::MusicalTime(1.0/32.0); return Evoral::Beats(1.0/32.0);
break; break;
case SnapToBeatDiv28: case SnapToBeatDiv28:
return Evoral::MusicalTime(1.0/28.0); return Evoral::Beats(1.0/28.0);
break; break;
case SnapToBeatDiv24: case SnapToBeatDiv24:
return Evoral::MusicalTime(1.0/24.0); return Evoral::Beats(1.0/24.0);
break; break;
case SnapToBeatDiv20: case SnapToBeatDiv20:
return Evoral::MusicalTime(1.0/20.0); return Evoral::Beats(1.0/20.0);
break; break;
case SnapToBeatDiv16: case SnapToBeatDiv16:
return Evoral::MusicalTime(1.0/16.0); return Evoral::Beats(1.0/16.0);
break; break;
case SnapToBeatDiv14: case SnapToBeatDiv14:
return Evoral::MusicalTime(1.0/14.0); return Evoral::Beats(1.0/14.0);
break; break;
case SnapToBeatDiv12: case SnapToBeatDiv12:
return Evoral::MusicalTime(1.0/12.0); return Evoral::Beats(1.0/12.0);
break; break;
case SnapToBeatDiv10: case SnapToBeatDiv10:
return Evoral::MusicalTime(1.0/10.0); return Evoral::Beats(1.0/10.0);
break; break;
case SnapToBeatDiv8: case SnapToBeatDiv8:
return Evoral::MusicalTime(1.0/8.0); return Evoral::Beats(1.0/8.0);
break; break;
case SnapToBeatDiv7: case SnapToBeatDiv7:
return Evoral::MusicalTime(1.0/7.0); return Evoral::Beats(1.0/7.0);
break; break;
case SnapToBeatDiv6: case SnapToBeatDiv6:
return Evoral::MusicalTime(1.0/6.0); return Evoral::Beats(1.0/6.0);
break; break;
case SnapToBeatDiv5: case SnapToBeatDiv5:
return Evoral::MusicalTime(1.0/5.0); return Evoral::Beats(1.0/5.0);
break; break;
case SnapToBeatDiv4: case SnapToBeatDiv4:
return Evoral::MusicalTime(1.0/4.0); return Evoral::Beats(1.0/4.0);
break; break;
case SnapToBeatDiv3: case SnapToBeatDiv3:
return Evoral::MusicalTime(1.0/3.0); return Evoral::Beats(1.0/3.0);
break; break;
case SnapToBeatDiv2: case SnapToBeatDiv2:
return Evoral::MusicalTime(1.0/2.0); return Evoral::Beats(1.0/2.0);
break; break;
case SnapToBar: case SnapToBar:
if (_session) { if (_session) {
return Evoral::MusicalTime(_session->tempo_map().meter_at (position).divisions_per_bar()); return Evoral::Beats(_session->tempo_map().meter_at (position).divisions_per_bar());
} }
break; break;
@ -4084,7 +4084,7 @@ Editor::get_grid_type_as_beats (bool& success, framepos_t position)
break; break;
} }
return Evoral::MusicalTime(); return Evoral::Beats();
} }
framecnt_t framecnt_t

View file

@ -315,7 +315,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next); framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next);
framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration); framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration);
Evoral::MusicalTime get_grid_type_as_beats (bool& success, framepos_t position); Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position);
void nudge_forward (bool next, bool force_playhead); void nudge_forward (bool next, bool force_playhead);
void nudge_backward (bool next, bool force_playhead); void nudge_backward (bool next, bool force_playhead);
@ -1172,7 +1172,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void cut_copy (Editing::CutCopyOp); void cut_copy (Editing::CutCopyOp);
bool can_cut_copy () const; bool can_cut_copy () const;
void cut_copy_points (Editing::CutCopyOp, Evoral::MusicalTime earliest=Evoral::MusicalTime(), bool midi=false); void cut_copy_points (Editing::CutCopyOp, Evoral::Beats earliest=Evoral::Beats(), bool midi=false);
void cut_copy_regions (Editing::CutCopyOp, RegionSelection&); void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
void cut_copy_ranges (Editing::CutCopyOp); void cut_copy_ranges (Editing::CutCopyOp);
void cut_copy_midi (Editing::CutCopyOp); void cut_copy_midi (Editing::CutCopyOp);

View file

@ -5229,9 +5229,9 @@ framecnt_t
NoteCreateDrag::grid_frames (framepos_t t) const NoteCreateDrag::grid_frames (framepos_t t) const
{ {
bool success; bool success;
Evoral::MusicalTime grid_beats = _editor->get_grid_type_as_beats (success, t); Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t);
if (!success) { if (!success) {
grid_beats = Evoral::MusicalTime(1); grid_beats = Evoral::Beats(1);
} }
return _region_view->region_beats_to_region_frames (grid_beats); return _region_view->region_beats_to_region_frames (grid_beats);
@ -5288,13 +5288,13 @@ NoteCreateDrag::finished (GdkEvent*, bool had_movement)
framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1])); framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
framecnt_t const g = grid_frames (start); framecnt_t const g = grid_frames (start);
Evoral::MusicalTime const one_tick = Evoral::MusicalTime::ticks(1); Evoral::Beats const one_tick = Evoral::Beats::ticks(1);
if (_editor->snap_mode() == SnapNormal && length < g) { if (_editor->snap_mode() == SnapNormal && length < g) {
length = g; length = g;
} }
Evoral::MusicalTime length_beats = max ( Evoral::Beats length_beats = max (
one_tick, _region_view->region_frames_to_region_beats (length) - one_tick); one_tick, _region_view->region_frames_to_region_beats (length) - one_tick);
_region_view->create_note_at (start, _drag_rect->y0(), length_beats, false); _region_view->create_note_at (start, _drag_rect->y0(), length_beats, false);

View file

@ -3968,7 +3968,7 @@ struct AutomationRecord {
* @param op Operation (Cut, Copy or Clear) * @param op Operation (Cut, Copy or Clear)
*/ */
void void
Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bool midi) Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::Beats earliest, bool midi)
{ {
if (selection->points.empty ()) { if (selection->points.empty ()) {
return; return;
@ -4010,7 +4010,7 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo
lists[al].copy->fast_simple_add ((*j)->when, (*j)->value); lists[al].copy->fast_simple_add ((*j)->when, (*j)->value);
if (midi) { if (midi) {
/* Update earliest MIDI start time in beats */ /* Update earliest MIDI start time in beats */
earliest = std::min(earliest, Evoral::MusicalTime((*j)->when)); earliest = std::min(earliest, Evoral::Beats((*j)->when));
} else { } else {
/* Update earliest session start time in frames */ /* Update earliest session start time in frames */
start = std::min(start, (*i)->line().session_position(j)); start = std::min(start, (*i)->line().session_position(j));
@ -4019,8 +4019,8 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo
/* Snap start time backwards, so copy/paste is snap aligned. */ /* Snap start time backwards, so copy/paste is snap aligned. */
if (midi) { if (midi) {
if (earliest == Evoral::MusicalTime::max()) { if (earliest == Evoral::Beats::max()) {
earliest = Evoral::MusicalTime(); // Weird... don't offset earliest = Evoral::Beats(); // Weird... don't offset
} }
earliest.round_down_to_beat(); earliest.round_down_to_beat();
} else { } else {
@ -4073,7 +4073,7 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo
void void
Editor::cut_copy_midi (CutCopyOp op) Editor::cut_copy_midi (CutCopyOp op)
{ {
Evoral::MusicalTime earliest = Evoral::MusicalTime::max(); Evoral::Beats earliest = Evoral::Beats::max();
for (MidiRegionSelection::iterator i = selection->midi_regions.begin(); i != selection->midi_regions.end(); ++i) { for (MidiRegionSelection::iterator i = selection->midi_regions.begin(); i != selection->midi_regions.end(); ++i) {
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i); MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
if (mrv) { if (mrv) {
@ -4919,14 +4919,14 @@ Editor::strip_region_silence ()
Command* Command*
Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv) Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv)
{ {
Evoral::Sequence<Evoral::MusicalTime>::Notes selected; Evoral::Sequence<Evoral::Beats>::Notes selected;
mrv.selection_as_notelist (selected, true); mrv.selection_as_notelist (selected, true);
vector<Evoral::Sequence<Evoral::MusicalTime>::Notes> v; vector<Evoral::Sequence<Evoral::Beats>::Notes> v;
v.push_back (selected); v.push_back (selected);
framepos_t pos_frames = mrv.midi_region()->position() - mrv.midi_region()->start(); framepos_t pos_frames = mrv.midi_region()->position() - mrv.midi_region()->start();
Evoral::MusicalTime pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames); Evoral::Beats pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames);
return op (mrv.midi_region()->model(), pos_beats, v); return op (mrv.midi_region()->model(), pos_beats, v);
} }
@ -5093,7 +5093,7 @@ Editor::insert_patch_change (bool from_context)
*/ */
MidiRegionView* first = dynamic_cast<MidiRegionView*> (rs.front ()); MidiRegionView* first = dynamic_cast<MidiRegionView*> (rs.front ());
Evoral::PatchChange<Evoral::MusicalTime> empty (Evoral::MusicalTime(), 0, 0, 0); Evoral::PatchChange<Evoral::Beats> empty (Evoral::Beats(), 0, 0, 0);
PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD); PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD);
if (d.run() == RESPONSE_CANCEL) { if (d.run() == RESPONSE_CANCEL) {

View file

@ -30,7 +30,7 @@ namespace ArdourCanvas {
class Hit : public NoteBase class Hit : public NoteBase
{ {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
Hit (MidiRegionView& region, Hit (MidiRegionView& region,
ArdourCanvas::Item* parent, ArdourCanvas::Item* parent,

View file

@ -21,7 +21,7 @@
using namespace ARDOUR; using namespace ARDOUR;
MidiCutBuffer::MidiCutBuffer (Session* s) MidiCutBuffer::MidiCutBuffer (Session* s)
: AutomatableSequence<Evoral::MusicalTime> (*s) : AutomatableSequence<Evoral::Beats> (*s)
, _origin (0) , _origin (0)
{ {

View file

@ -27,10 +27,10 @@ namespace ARDOUR {
class Session; class Session;
} }
class MidiCutBuffer : public ARDOUR::AutomatableSequence<Evoral::MusicalTime> class MidiCutBuffer : public ARDOUR::AutomatableSequence<Evoral::Beats>
{ {
public: public:
typedef Evoral::MusicalTime TimeType; typedef Evoral::Beats TimeType;
MidiCutBuffer (ARDOUR::Session*); MidiCutBuffer (ARDOUR::Session*);
~MidiCutBuffer(); ~MidiCutBuffer();

View file

@ -292,7 +292,7 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
if (note->time() + fdelta >= 0) { if (note->time() + fdelta >= 0) {
cmd->change (note, prop, note->time() + fdelta); cmd->change (note, prop, note->time() + fdelta);
} else { } else {
cmd->change (note, prop, Evoral::MusicalTime()); cmd->change (note, prop, Evoral::Beats());
} }
break; break;
case MidiModel::NoteDiffCommand::Velocity: case MidiModel::NoteDiffCommand::Velocity:
@ -300,10 +300,10 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
break; break;
case MidiModel::NoteDiffCommand::Length: case MidiModel::NoteDiffCommand::Length:
if (note->length().to_double() + fdelta >= if (note->length().to_double() + fdelta >=
Evoral::MusicalTime::tick().to_double()) { Evoral::Beats::tick().to_double()) {
cmd->change (note, prop, note->length() + fdelta); cmd->change (note, prop, note->length() + fdelta);
} else { } else {
cmd->change (note, prop, Evoral::MusicalTime::tick()); cmd->change (note, prop, Evoral::Beats::tick());
} }
break; break;
case MidiModel::NoteDiffCommand::Channel: case MidiModel::NoteDiffCommand::Channel:
@ -335,7 +335,7 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
if (note->time() + fdelta >= 0) { if (note->time() + fdelta >= 0) {
cmd->change (note, prop, note->time() + fdelta); cmd->change (note, prop, note->time() + fdelta);
} else { } else {
cmd->change (note, prop, Evoral::MusicalTime()); cmd->change (note, prop, Evoral::Beats());
} }
break; break;
case MidiModel::NoteDiffCommand::Velocity: case MidiModel::NoteDiffCommand::Velocity:
@ -343,10 +343,10 @@ MidiListEditor::scroll_event (GdkEventScroll* ev)
break; break;
case MidiModel::NoteDiffCommand::Length: case MidiModel::NoteDiffCommand::Length:
if (note->length() + fdelta >= if (note->length() + fdelta >=
Evoral::MusicalTime::tick().to_double()) { Evoral::Beats::tick().to_double()) {
cmd->change (note, prop, note->length() + fdelta); cmd->change (note, prop, note->length() + fdelta);
} else { } else {
cmd->change (note, prop, Evoral::MusicalTime::tick()); cmd->change (note, prop, Evoral::Beats::tick());
} }
break; break;
case MidiModel::NoteDiffCommand::Channel: case MidiModel::NoteDiffCommand::Channel:
@ -773,7 +773,7 @@ MidiListEditor::redisplay_model ()
row[columns.start] = ss.str(); row[columns.start] = ss.str();
bbt.bars = 0; bbt.bars = 0;
const Evoral::MusicalTime dur = (*i)->end_time() - (*i)->time(); const Evoral::Beats dur = (*i)->end_time() - (*i)->time();
bbt.beats = dur.get_beats (); bbt.beats = dur.get_beats ();
bbt.ticks = dur.get_ticks (); bbt.ticks = dur.get_ticks ();

View file

@ -45,7 +45,7 @@ namespace ARDOUR {
class MidiListEditor : public ArdourWindow class MidiListEditor : public ArdourWindow
{ {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
MidiListEditor(ARDOUR::Session*, boost::shared_ptr<ARDOUR::MidiRegion>, MidiListEditor(ARDOUR::Session*, boost::shared_ptr<ARDOUR::MidiRegion>,
boost::shared_ptr<ARDOUR::MidiTrack>); boost::shared_ptr<ARDOUR::MidiTrack>);

View file

@ -547,12 +547,12 @@ MidiRegionView::button_release (GdkEventButton* ev)
event_y = ev->y; event_y = ev->y;
group->canvas_to_item (event_x, event_y); group->canvas_to_item (event_x, event_y);
Evoral::MusicalTime beats = get_grid_beats(editor.pixel_to_sample(event_x)); Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x));
/* Shorten the length by 1 tick so that we can add a new note at the next /* Shorten the length by 1 tick so that we can add a new note at the next
grid snap without it overlapping this one. grid snap without it overlapping this one.
*/ */
beats -= Evoral::MusicalTime::tick(); beats -= Evoral::Beats::tick();
create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true); create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
} }
@ -561,12 +561,12 @@ MidiRegionView::button_release (GdkEventButton* ev)
} }
case MouseDraw: case MouseDraw:
{ {
Evoral::MusicalTime beats = get_grid_beats(editor.pixel_to_sample(event_x)); Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x));
/* Shorten the length by 1 tick so that we can add a new note at the next /* Shorten the length by 1 tick so that we can add a new note at the next
grid snap without it overlapping this one. grid snap without it overlapping this one.
*/ */
beats -= Evoral::MusicalTime::tick(); beats -= Evoral::Beats::tick();
create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true); create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
@ -732,7 +732,7 @@ MidiRegionView::key_press (GdkEventKey* ev)
bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier); bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier);
bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier); bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
change_note_lengths (fine, shorter, Evoral::MusicalTime(), start, end); change_note_lengths (fine, shorter, Evoral::Beats(), start, end);
return true; return true;
@ -915,7 +915,7 @@ MidiRegionView::show_list_editor ()
* \param snap_t true to snap t to the grid, otherwise false. * \param snap_t true to snap t to the grid, otherwise false.
*/ */
void void
MidiRegionView::create_note_at (framepos_t t, double y, Evoral::MusicalTime length, bool snap_t) MidiRegionView::create_note_at (framepos_t t, double y, Evoral::Beats length, bool snap_t)
{ {
if (length < 2 * DBL_EPSILON) { if (length < 2 * DBL_EPSILON) {
return; return;
@ -1033,7 +1033,7 @@ MidiRegionView::note_diff_add_change (NoteBase* ev,
void void
MidiRegionView::note_diff_add_change (NoteBase* ev, MidiRegionView::note_diff_add_change (NoteBase* ev,
MidiModel::NoteDiffCommand::Property property, MidiModel::NoteDiffCommand::Property property,
Evoral::MusicalTime val) Evoral::Beats val)
{ {
if (_note_diff_command) { if (_note_diff_command) {
_note_diff_command->change (ev->note(), property, val); _note_diff_command->change (ev->note(), property, val);
@ -1101,7 +1101,7 @@ MidiRegionView::find_canvas_note (boost::shared_ptr<NoteType> note)
} }
void void
MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::MusicalTime>::NoteOperator op, uint8_t val, int chan_mask) MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask)
{ {
MidiModel::Notes notes; MidiModel::Notes notes;
_model->get_notes (notes, op, val, chan_mask); _model->get_notes (notes, op, val, chan_mask);
@ -1259,8 +1259,8 @@ MidiRegionView::display_sysexes()
if (!ARDOUR_UI::config()->get_never_display_periodic_midi()) { if (!ARDOUR_UI::config()->get_never_display_periodic_midi()) {
for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) {
const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::MusicalTime> > mev = const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::Beats> > mev =
boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::MusicalTime> > (*i); boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::Beats> > (*i);
if (mev) { if (mev) {
if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) {
@ -1292,10 +1292,10 @@ MidiRegionView::display_sysexes()
for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) {
const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::MusicalTime> > mev = const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::Beats> > mev =
boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::MusicalTime> > (*i); boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::Beats> > (*i);
Evoral::MusicalTime time = (*i)->time(); Evoral::Beats time = (*i)->time();
if (mev) { if (mev) {
if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) {
@ -1529,7 +1529,7 @@ MidiRegionView::end_write()
/** Resolve an active MIDI note (while recording). /** Resolve an active MIDI note (while recording).
*/ */
void void
MidiRegionView::resolve_note(uint8_t note, Evoral::MusicalTime end_time) MidiRegionView::resolve_note(uint8_t note, Evoral::Beats end_time)
{ {
if (midi_view()->note_mode() != Sustained) { if (midi_view()->note_mode() != Sustained) {
return; return;
@ -1797,7 +1797,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible)
void void
MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity,
Evoral::MusicalTime pos, Evoral::MusicalTime len) Evoral::Beats pos, Evoral::Beats len)
{ {
boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity)); boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity));
@ -1826,7 +1826,7 @@ MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity
} }
void void
MidiRegionView::step_sustain (Evoral::MusicalTime beats) MidiRegionView::step_sustain (Evoral::Beats beats)
{ {
change_note_lengths (false, false, beats, false, true); change_note_lengths (false, false, beats, false, true);
} }
@ -1879,13 +1879,13 @@ MidiRegionView::patch_change_to_patch_key (MidiModel::PatchChangePtr p)
/// Return true iff @p pc applies to the given time on the given channel. /// Return true iff @p pc applies to the given time on the given channel.
static bool static bool
patch_applies (const ARDOUR::MidiModel::constPatchChangePtr pc, Evoral::MusicalTime time, uint8_t channel) patch_applies (const ARDOUR::MidiModel::constPatchChangePtr pc, Evoral::Beats time, uint8_t channel)
{ {
return pc->time() <= time && pc->channel() == channel; return pc->time() <= time && pc->channel() == channel;
} }
void void
MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const MidiRegionView::get_patch_key_at (Evoral::Beats time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const
{ {
// The earliest event not before time // The earliest event not before time
MidiModel::PatchChanges::iterator i = _model->patch_change_lower_bound (time); MidiModel::PatchChanges::iterator i = _model->patch_change_lower_bound (time);
@ -1927,7 +1927,7 @@ MidiRegionView::change_patch_change (PatchChange& pc, const MIDI::Name::PatchPri
} }
void void
MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const Evoral::PatchChange<Evoral::MusicalTime> & new_change) MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const Evoral::PatchChange<Evoral::Beats> & new_change)
{ {
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("alter patch change")); MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("alter patch change"));
@ -1959,13 +1959,13 @@ MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const
* MidiTimeAxisView::get_channel_for_add()) * MidiTimeAxisView::get_channel_for_add())
*/ */
void void
MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::MusicalTime> const & patch) MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::Beats> const & patch)
{ {
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview); MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("add patch change")); MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("add patch change"));
c->add (MidiModel::PatchChangePtr ( c->add (MidiModel::PatchChangePtr (
new Evoral::PatchChange<Evoral::MusicalTime> ( new Evoral::PatchChange<Evoral::Beats> (
absolute_frames_to_source_beats (_region->position() + t), absolute_frames_to_source_beats (_region->position() + t),
mtv->get_channel_for_add(), patch.program(), patch.bank() mtv->get_channel_for_add(), patch.program(), patch.bank()
) )
@ -1979,7 +1979,7 @@ MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::Musi
} }
void void
MidiRegionView::move_patch_change (PatchChange& pc, Evoral::MusicalTime t) MidiRegionView::move_patch_change (PatchChange& pc, Evoral::Beats t)
{ {
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("move patch change")); MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("move patch change"));
c->change_time (pc.patch (), t); c->change_time (pc.patch (), t);
@ -2259,8 +2259,8 @@ MidiRegionView::note_selected (NoteBase* ev, bool add, bool extend)
} else { } else {
/* find end of latest note selected, select all between that and the start of "ev" */ /* find end of latest note selected, select all between that and the start of "ev" */
Evoral::MusicalTime earliest = Evoral::MaxMusicalTime; Evoral::Beats earliest = Evoral::MaxBeats;
Evoral::MusicalTime latest = Evoral::MusicalTime(); Evoral::Beats latest = Evoral::Beats();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i)->note()->end_time() > latest) { if ((*i)->note()->end_time() > latest) {
@ -2418,7 +2418,7 @@ MidiRegionView::move_selection(double dx, double dy, double cumulative_dy)
{ {
typedef vector<boost::shared_ptr<NoteType> > PossibleChord; typedef vector<boost::shared_ptr<NoteType> > PossibleChord;
PossibleChord to_play; PossibleChord to_play;
Evoral::MusicalTime earliest = Evoral::MaxMusicalTime; Evoral::Beats earliest = Evoral::MaxBeats;
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i)->note()->time() < earliest) { if ((*i)->note()->time() < earliest) {
@ -2491,7 +2491,7 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote)
for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) { for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) {
framepos_t new_frames = source_beats_to_absolute_frames ((*i)->note()->time()) + dt; framepos_t new_frames = source_beats_to_absolute_frames ((*i)->note()->time()) + dt;
Evoral::MusicalTime new_time = absolute_frames_to_source_beats (new_frames); Evoral::Beats new_time = absolute_frames_to_source_beats (new_frames);
if (new_time < 0) { if (new_time < 0) {
continue; continue;
@ -2554,7 +2554,7 @@ MidiRegionView::get_end_position_pixels()
} }
framepos_t framepos_t
MidiRegionView::source_beats_to_absolute_frames(Evoral::MusicalTime beats) const MidiRegionView::source_beats_to_absolute_frames(Evoral::Beats beats) const
{ {
/* the time converter will return the frame corresponding to `beats' /* the time converter will return the frame corresponding to `beats'
relative to the start of the source. The start of the source relative to the start of the source. The start of the source
@ -2564,7 +2564,7 @@ MidiRegionView::source_beats_to_absolute_frames(Evoral::MusicalTime beats) const
return source_start + _source_relative_time_converter.to (beats); return source_start + _source_relative_time_converter.to (beats);
} }
Evoral::MusicalTime Evoral::Beats
MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const
{ {
/* the `frames' argument needs to be converted into a frame count /* the `frames' argument needs to be converted into a frame count
@ -2576,12 +2576,12 @@ MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const
} }
framepos_t framepos_t
MidiRegionView::region_beats_to_region_frames(Evoral::MusicalTime beats) const MidiRegionView::region_beats_to_region_frames(Evoral::Beats beats) const
{ {
return _region_relative_time_converter.to(beats); return _region_relative_time_converter.to(beats);
} }
Evoral::MusicalTime Evoral::Beats
MidiRegionView::region_frames_to_region_beats(framepos_t frames) const MidiRegionView::region_frames_to_region_beats(framepos_t frames) const
{ {
return _region_relative_time_converter.from(frames); return _region_relative_time_converter.from(frames);
@ -2678,9 +2678,9 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
} }
if (!cursor_set) { if (!cursor_set) {
const double snapped_x = snap_pixel_to_sample (current_x); const double snapped_x = snap_pixel_to_sample (current_x);
Evoral::MusicalTime beats = region_frames_to_region_beats (snapped_x); Evoral::Beats beats = region_frames_to_region_beats (snapped_x);
Evoral::MusicalTime len = Evoral::MusicalTime(); Evoral::Beats len = Evoral::Beats();
if (at_front) { if (at_front) {
if (beats < canvas_note->note()->end_time()) { if (beats < canvas_note->note()->end_time()) {
@ -2747,12 +2747,12 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
current_x = snap_pixel_to_sample (current_x) + _region->start (); current_x = snap_pixel_to_sample (current_x) + _region->start ();
/* and then to beats */ /* and then to beats */
const Evoral::MusicalTime x_beats = region_frames_to_region_beats (current_x); const Evoral::Beats x_beats = region_frames_to_region_beats (current_x);
if (at_front && x_beats < canvas_note->note()->end_time()) { if (at_front && x_beats < canvas_note->note()->end_time()) {
note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats); note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats);
Evoral::MusicalTime len = canvas_note->note()->time() - x_beats; Evoral::Beats len = canvas_note->note()->time() - x_beats;
len += canvas_note->note()->length(); len += canvas_note->note()->length();
if (!!len) { if (!!len) {
@ -2761,7 +2761,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
} }
if (!at_front) { if (!at_front) {
const Evoral::MusicalTime len = x_beats - canvas_note->note()->time(); const Evoral::Beats len = x_beats - canvas_note->note()->time();
if (!!len) { if (!!len) {
/* XXX convert to beats */ /* XXX convert to beats */
@ -2821,12 +2821,12 @@ MidiRegionView::change_note_note (NoteBase* event, int8_t note, bool relative)
} }
void void
MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evoral::MusicalTime end_delta) MidiRegionView::trim_note (NoteBase* event, Evoral::Beats front_delta, Evoral::Beats end_delta)
{ {
bool change_start = false; bool change_start = false;
bool change_length = false; bool change_length = false;
Evoral::MusicalTime new_start; Evoral::Beats new_start;
Evoral::MusicalTime new_length; Evoral::Beats new_length;
/* NOTE: the semantics of the two delta arguments are slightly subtle: /* NOTE: the semantics of the two delta arguments are slightly subtle:
@ -2841,7 +2841,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo
if (front_delta < 0) { if (front_delta < 0) {
if (event->note()->time() < -front_delta) { if (event->note()->time() < -front_delta) {
new_start = Evoral::MusicalTime(); new_start = Evoral::Beats();
} else { } else {
new_start = event->note()->time() + front_delta; // moves earlier new_start = event->note()->time() + front_delta; // moves earlier
} }
@ -2856,7 +2856,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo
} else { } else {
Evoral::MusicalTime new_pos = event->note()->time() + front_delta; Evoral::Beats new_pos = event->note()->time() + front_delta;
if (new_pos < event->note()->end_time()) { if (new_pos < event->note()->end_time()) {
new_start = event->note()->time() + front_delta; new_start = event->note()->time() + front_delta;
@ -2915,14 +2915,14 @@ MidiRegionView::change_note_channel (NoteBase* event, int8_t chn, bool relative)
} }
void void
MidiRegionView::change_note_time (NoteBase* event, Evoral::MusicalTime delta, bool relative) MidiRegionView::change_note_time (NoteBase* event, Evoral::Beats delta, bool relative)
{ {
Evoral::MusicalTime new_time; Evoral::Beats new_time;
if (relative) { if (relative) {
if (delta < 0.0) { if (delta < 0.0) {
if (event->note()->time() < -delta) { if (event->note()->time() < -delta) {
new_time = Evoral::MusicalTime(); new_time = Evoral::Beats();
} else { } else {
new_time = event->note()->time() + delta; new_time = event->note()->time() + delta;
} }
@ -2937,7 +2937,7 @@ MidiRegionView::change_note_time (NoteBase* event, Evoral::MusicalTime delta, bo
} }
void void
MidiRegionView::change_note_length (NoteBase* event, Evoral::MusicalTime t) MidiRegionView::change_note_length (NoteBase* event, Evoral::Beats t)
{ {
note_diff_add_change (event, MidiModel::NoteDiffCommand::Length, t); note_diff_add_change (event, MidiModel::NoteDiffCommand::Length, t);
} }
@ -3049,11 +3049,11 @@ MidiRegionView::transpose (bool up, bool fine, bool allow_smush)
} }
void void
MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTime delta, bool start, bool end) MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::Beats delta, bool start, bool end)
{ {
if (!delta) { if (!delta) {
if (fine) { if (fine) {
delta = Evoral::MusicalTime(1.0/128.0); delta = Evoral::Beats(1.0/128.0);
} else { } else {
/* grab the current grid distance */ /* grab the current grid distance */
delta = get_grid_beats(_region->position()); delta = get_grid_beats(_region->position());
@ -3073,8 +3073,8 @@ MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTim
/* note the negation of the delta for start */ /* note the negation of the delta for start */
trim_note (*i, trim_note (*i,
(start ? -delta : Evoral::MusicalTime()), (start ? -delta : Evoral::Beats()),
(end ? delta : Evoral::MusicalTime())); (end ? delta : Evoral::Beats()));
i = next; i = next;
} }
@ -3094,13 +3094,13 @@ MidiRegionView::nudge_notes (bool forward, bool fine)
into a vector and sort before using the first one. into a vector and sort before using the first one.
*/ */
const framepos_t ref_point = source_beats_to_absolute_frames ((*(_selection.begin()))->note()->time()); const framepos_t ref_point = source_beats_to_absolute_frames ((*(_selection.begin()))->note()->time());
Evoral::MusicalTime delta; Evoral::Beats delta;
if (!fine) { if (!fine) {
/* non-fine, move by 1 bar regardless of snap */ /* non-fine, move by 1 bar regardless of snap */
delta = Evoral::MusicalTime(trackview.session()->tempo_map().meter_at(ref_point).divisions_per_bar()); delta = Evoral::Beats(trackview.session()->tempo_map().meter_at(ref_point).divisions_per_bar());
} else if (trackview.editor().snap_mode() == Editing::SnapOff) { } else if (trackview.editor().snap_mode() == Editing::SnapOff) {
@ -3378,14 +3378,14 @@ MidiRegionView::paste_internal (framepos_t pos, unsigned paste_count, float time
start_note_diff_command (_("paste")); start_note_diff_command (_("paste"));
const Evoral::MusicalTime snap_beats = get_grid_beats(pos); const Evoral::Beats snap_beats = get_grid_beats(pos);
const Evoral::MusicalTime first_time = (*mcb.notes().begin())->time(); const Evoral::Beats first_time = (*mcb.notes().begin())->time();
const Evoral::MusicalTime last_time = (*mcb.notes().rbegin())->end_time(); const Evoral::Beats last_time = (*mcb.notes().rbegin())->end_time();
const Evoral::MusicalTime duration = last_time - first_time; const Evoral::Beats duration = last_time - first_time;
const Evoral::MusicalTime snap_duration = duration.snap_to(snap_beats); const Evoral::Beats snap_duration = duration.snap_to(snap_beats);
const Evoral::MusicalTime paste_offset = snap_duration * paste_count; const Evoral::Beats paste_offset = snap_duration * paste_count;
const Evoral::MusicalTime pos_beats = absolute_frames_to_source_beats(pos) + paste_offset; const Evoral::Beats pos_beats = absolute_frames_to_source_beats(pos) + paste_offset;
Evoral::MusicalTime end_point = Evoral::MusicalTime(); Evoral::Beats end_point = Evoral::Beats();
DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("Paste data spans from %1 to %2 (%3) ; paste pos beats = %4 (based on %5 - %6)\n", DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("Paste data spans from %1 to %2 (%3) ; paste pos beats = %4 (based on %5 - %6)\n",
first_time, first_time,
@ -3559,9 +3559,9 @@ MidiRegionView::update_ghost_note (double x, double y)
framepos_t const f = snap_frame_to_grid_underneath (unsnapped_frame, grid_frames); framepos_t const f = snap_frame_to_grid_underneath (unsnapped_frame, grid_frames);
/* calculate time in beats relative to start of source */ /* calculate time in beats relative to start of source */
const Evoral::MusicalTime length = get_grid_beats(unsnapped_frame); const Evoral::Beats length = get_grid_beats(unsnapped_frame);
const Evoral::MusicalTime time = std::max( const Evoral::Beats time = std::max(
Evoral::MusicalTime(), Evoral::Beats(),
absolute_frames_to_source_beats (f + _region->position ())); absolute_frames_to_source_beats (f + _region->position ()));
_ghost_note->note()->set_time (time); _ghost_note->note()->set_time (time);
@ -3630,9 +3630,9 @@ MidiRegionView::maybe_select_by_position (GdkEventButton* ev, double /*x*/, doub
uint16_t chn_mask = mtv->midi_track()->get_playback_channel_mask(); uint16_t chn_mask = mtv->midi_track()->get_playback_channel_mask();
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchGreaterThanOrEqual, (uint8_t) floor (note), chn_mask); get_events (e, Evoral::Sequence<Evoral::Beats>::PitchGreaterThanOrEqual, (uint8_t) floor (note), chn_mask);
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchLessThanOrEqual, (uint8_t) floor (note), chn_mask); get_events (e, Evoral::Sequence<Evoral::Beats>::PitchLessThanOrEqual, (uint8_t) floor (note), chn_mask);
} else { } else {
return; return;
} }
@ -3677,7 +3677,7 @@ MidiRegionView::enable_display (bool yn)
} }
void void
MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos) MidiRegionView::show_step_edit_cursor (Evoral::Beats pos)
{ {
if (_step_edit_cursor == 0) { if (_step_edit_cursor == 0) {
ArdourCanvas::Item* const group = get_canvas_group(); ArdourCanvas::Item* const group = get_canvas_group();
@ -3694,7 +3694,7 @@ MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos)
} }
void void
MidiRegionView::move_step_edit_cursor (Evoral::MusicalTime pos) MidiRegionView::move_step_edit_cursor (Evoral::Beats pos)
{ {
_step_edit_cursor_position = pos; _step_edit_cursor_position = pos;
@ -3714,7 +3714,7 @@ MidiRegionView::hide_step_edit_cursor ()
} }
void void
MidiRegionView::set_step_edit_cursor_width (Evoral::MusicalTime beats) MidiRegionView::set_step_edit_cursor_width (Evoral::Beats beats)
{ {
_step_edit_cursor_width = beats; _step_edit_cursor_width = beats;
@ -3758,12 +3758,12 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w)
} }
/* convert from session frames to source beats */ /* convert from session frames to source beats */
Evoral::MusicalTime const time_beats = _source_relative_time_converter.from( Evoral::Beats const time_beats = _source_relative_time_converter.from(
ev.time() - src->timeline_position() + _region->start()); ev.time() - src->timeline_position() + _region->start());
if (ev.type() == MIDI_CMD_NOTE_ON) { if (ev.type() == MIDI_CMD_NOTE_ON) {
boost::shared_ptr<NoteType> note ( boost::shared_ptr<NoteType> note (
new NoteType (ev.channel(), time_beats, Evoral::MusicalTime(), ev.note(), ev.velocity())); new NoteType (ev.channel(), time_beats, Evoral::Beats(), ev.note(), ev.velocity()));
add_note (note, true); add_note (note, true);
@ -3916,7 +3916,7 @@ MidiRegionView::snap_frame_to_grid_underneath (framepos_t p, framecnt_t& grid_fr
{ {
PublicEditor& editor = trackview.editor (); PublicEditor& editor = trackview.editor ();
const Evoral::MusicalTime grid_beats = get_grid_beats(p); const Evoral::Beats grid_beats = get_grid_beats(p);
grid_frames = region_beats_to_region_frames (grid_beats); grid_frames = region_beats_to_region_frames (grid_beats);
@ -3965,14 +3965,14 @@ MidiRegionView::get_selected_channels () const
} }
Evoral::MusicalTime Evoral::Beats
MidiRegionView::get_grid_beats(framepos_t pos) const MidiRegionView::get_grid_beats(framepos_t pos) const
{ {
PublicEditor& editor = trackview.editor(); PublicEditor& editor = trackview.editor();
bool success = false; bool success = false;
Evoral::MusicalTime beats = editor.get_grid_type_as_beats(success, pos); Evoral::Beats beats = editor.get_grid_type_as_beats(success, pos);
if (!success) { if (!success) {
beats = Evoral::MusicalTime(1); beats = Evoral::Beats(1);
} }
return beats; return beats;
} }

View file

@ -66,8 +66,8 @@ class CursorContext;
class MidiRegionView : public RegionView class MidiRegionView : public RegionView
{ {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; typedef Evoral::Sequence<Evoral::Beats>::Notes Notes;
MidiRegionView (ArdourCanvas::Container* parent, MidiRegionView (ArdourCanvas::Container* parent,
RouteTimeAxisView& tv, RouteTimeAxisView& tv,
@ -100,8 +100,8 @@ public:
{ return midi_view()->midi_view(); } { return midi_view()->midi_view(); }
void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity,
Evoral::MusicalTime pos, Evoral::MusicalTime len); Evoral::Beats pos, Evoral::Beats len);
void step_sustain (Evoral::MusicalTime beats); void step_sustain (Evoral::Beats beats);
void set_height (double); void set_height (double);
void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false); void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false);
@ -110,17 +110,17 @@ public:
uint32_t get_fill_color() const; uint32_t get_fill_color() const;
void color_handler (); void color_handler ();
void show_step_edit_cursor (Evoral::MusicalTime pos); void show_step_edit_cursor (Evoral::Beats pos);
void move_step_edit_cursor (Evoral::MusicalTime pos); void move_step_edit_cursor (Evoral::Beats pos);
void hide_step_edit_cursor (); void hide_step_edit_cursor ();
void set_step_edit_cursor_width (Evoral::MusicalTime beats); void set_step_edit_cursor_width (Evoral::Beats beats);
void redisplay_model(); void redisplay_model();
GhostRegion* add_ghost (TimeAxisView&); GhostRegion* add_ghost (TimeAxisView&);
void add_note(const boost::shared_ptr<NoteType> note, bool visible); void add_note(const boost::shared_ptr<NoteType> note, bool visible);
void resolve_note(uint8_t note_num, Evoral::MusicalTime end_time); void resolve_note(uint8_t note_num, Evoral::Beats end_time);
void cut_copy_clear (Editing::CutCopyOp); void cut_copy_clear (Editing::CutCopyOp);
bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx); bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx);
@ -134,7 +134,7 @@ public:
* @key a reference to an instance of MIDI::Name::PatchPrimaryKey whose fields will * @key a reference to an instance of MIDI::Name::PatchPrimaryKey whose fields will
* will be set according to the result of the lookup * will be set according to the result of the lookup
*/ */
void get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const; void get_patch_key_at (Evoral::Beats time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const;
/** Convert a given PatchChange into a PatchPrimaryKey /** Convert a given PatchChange into a PatchPrimaryKey
*/ */
@ -145,10 +145,10 @@ public:
* @param new_patch new patch * @param new_patch new patch
*/ */
void change_patch_change (PatchChange& old_patch, const MIDI::Name::PatchPrimaryKey& new_patch); void change_patch_change (PatchChange& old_patch, const MIDI::Name::PatchPrimaryKey& new_patch);
void change_patch_change (ARDOUR::MidiModel::PatchChangePtr, Evoral::PatchChange<Evoral::MusicalTime> const &); void change_patch_change (ARDOUR::MidiModel::PatchChangePtr, Evoral::PatchChange<Evoral::Beats> const &);
void add_patch_change (framecnt_t, Evoral::PatchChange<Evoral::MusicalTime> const &); void add_patch_change (framecnt_t, Evoral::PatchChange<Evoral::Beats> const &);
void move_patch_change (PatchChange &, Evoral::MusicalTime); void move_patch_change (PatchChange &, Evoral::Beats);
void delete_patch_change (PatchChange *); void delete_patch_change (PatchChange *);
void edit_patch_change (PatchChange *); void edit_patch_change (PatchChange *);
@ -176,7 +176,7 @@ public:
void start_note_diff_command (std::string name = "midi edit"); void start_note_diff_command (std::string name = "midi edit");
void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, uint8_t val); void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, uint8_t val);
void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, Evoral::MusicalTime val); void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, Evoral::Beats val);
void note_diff_add_note (const boost::shared_ptr<NoteType> note, bool selected, bool show_velocity = false); void note_diff_add_note (const boost::shared_ptr<NoteType> note, bool selected, bool show_velocity = false);
void note_diff_remove_note (NoteBase* ev); void note_diff_remove_note (NoteBase* ev);
@ -263,22 +263,22 @@ public:
framepos_t snap_pixel_to_sample(double x); framepos_t snap_pixel_to_sample(double x);
/** Convert a timestamp in beats into frames (both relative to region position) */ /** Convert a timestamp in beats into frames (both relative to region position) */
framepos_t region_beats_to_region_frames(Evoral::MusicalTime beats) const; framepos_t region_beats_to_region_frames(Evoral::Beats beats) const;
/** Convert a timestamp in beats into absolute frames */ /** Convert a timestamp in beats into absolute frames */
framepos_t region_beats_to_absolute_frames(Evoral::MusicalTime beats) const { framepos_t region_beats_to_absolute_frames(Evoral::Beats beats) const {
return _region->position() + region_beats_to_region_frames (beats); return _region->position() + region_beats_to_region_frames (beats);
} }
/** Convert a timestamp in frames to beats (both relative to region position) */ /** Convert a timestamp in frames to beats (both relative to region position) */
Evoral::MusicalTime region_frames_to_region_beats(framepos_t) const; Evoral::Beats region_frames_to_region_beats(framepos_t) const;
/** Convert a timestamp in beats measured from source start into absolute frames */ /** Convert a timestamp in beats measured from source start into absolute frames */
framepos_t source_beats_to_absolute_frames(Evoral::MusicalTime beats) const; framepos_t source_beats_to_absolute_frames(Evoral::Beats beats) const;
/** Convert a timestamp in beats measured from source start into region-relative frames */ /** Convert a timestamp in beats measured from source start into region-relative frames */
framepos_t source_beats_to_region_frames(Evoral::MusicalTime beats) const { framepos_t source_beats_to_region_frames(Evoral::Beats beats) const {
return source_beats_to_absolute_frames (beats) - _region->position(); return source_beats_to_absolute_frames (beats) - _region->position();
} }
/** Convert a timestamp in absolute frames to beats measured from source start*/ /** Convert a timestamp in absolute frames to beats measured from source start*/
Evoral::MusicalTime absolute_frames_to_source_beats(framepos_t) const; Evoral::Beats absolute_frames_to_source_beats(framepos_t) const;
ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const { ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter; return _region_relative_time_converter;
@ -290,7 +290,7 @@ public:
void goto_previous_note (bool add_to_selection); void goto_previous_note (bool add_to_selection);
void goto_next_note (bool add_to_selection); void goto_next_note (bool add_to_selection);
void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); void change_note_lengths (bool, bool, Evoral::Beats beats, bool start, bool end);
void change_velocities (bool up, bool fine, bool allow_smush, bool all_together); void change_velocities (bool up, bool fine, bool allow_smush, bool all_together);
void transpose (bool up, bool fine, bool allow_smush); void transpose (bool up, bool fine, bool allow_smush);
void nudge_notes (bool forward, bool fine); void nudge_notes (bool forward, bool fine);
@ -320,7 +320,7 @@ public:
* \param length duration of the note in beats * \param length duration of the note in beats
* \param snap_t true to snap t to the grid, otherwise false. * \param snap_t true to snap t to the grid, otherwise false.
*/ */
void create_note_at (framepos_t t, double y, Evoral::MusicalTime length, bool snap_t); void create_note_at (framepos_t t, double y, Evoral::Beats length, bool snap_t);
void clear_selection (bool signal = true) { clear_selection_except (0, signal); } void clear_selection (bool signal = true) { clear_selection_except (0, signal); }
@ -414,8 +414,8 @@ private:
double _last_ghost_x; double _last_ghost_x;
double _last_ghost_y; double _last_ghost_y;
ArdourCanvas::Rectangle* _step_edit_cursor; ArdourCanvas::Rectangle* _step_edit_cursor;
Evoral::MusicalTime _step_edit_cursor_width; Evoral::Beats _step_edit_cursor_width;
Evoral::MusicalTime _step_edit_cursor_position; Evoral::Beats _step_edit_cursor_position;
NoteBase* _channel_selection_scoped_note; NoteBase* _channel_selection_scoped_note;
/** A group used to temporarily reparent _note_group to during start trims, so /** A group used to temporarily reparent _note_group to during start trims, so
@ -477,7 +477,7 @@ private:
void drop_down_keys (); void drop_down_keys ();
void maybe_select_by_position (GdkEventButton* ev, double x, double y); void maybe_select_by_position (GdkEventButton* ev, double x, double y);
void get_events (Events& e, Evoral::Sequence<Evoral::MusicalTime>::NoteOperator op, uint8_t val, int chan_mask = 0); void get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask = 0);
void display_patch_changes_on_channel (uint8_t, bool); void display_patch_changes_on_channel (uint8_t, bool);
@ -485,7 +485,7 @@ private:
void data_recorded (boost::weak_ptr<ARDOUR::MidiSource>); void data_recorded (boost::weak_ptr<ARDOUR::MidiSource>);
/** Get grid type as beats, or default to 1 if not snapped to beats. */ /** Get grid type as beats, or default to 1 if not snapped to beats. */
Evoral::MusicalTime get_grid_beats(framepos_t pos) const; Evoral::Beats get_grid_beats(framepos_t pos) const;
void remove_ghost_note (); void remove_ghost_note ();
void mouse_mode_changed (); void mouse_mode_changed ();

View file

@ -32,7 +32,7 @@ namespace ArdourCanvas {
class Note : public NoteBase class Note : public NoteBase
{ {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
Note (MidiRegionView& region, Note (MidiRegionView& region,
ArdourCanvas::Item* parent, ArdourCanvas::Item* parent,

View file

@ -54,7 +54,7 @@ namespace ArdourCanvas {
class NoteBase : public sigc::trackable class NoteBase : public sigc::trackable
{ {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
NoteBase (MidiRegionView& region, bool, const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>()); NoteBase (MidiRegionView& region, bool, const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>());
virtual ~NoteBase (); virtual ~NoteBase ();

View file

@ -31,7 +31,7 @@ namespace ARDOUR {
class NotePlayer : public sigc::trackable { class NotePlayer : public sigc::trackable {
public: public:
typedef Evoral::Note<Evoral::MusicalTime> NoteType; typedef Evoral::Note<Evoral::Beats> NoteType;
NotePlayer (boost::shared_ptr<ARDOUR::MidiTrack>); NotePlayer (boost::shared_ptr<ARDOUR::MidiTrack>);
~NotePlayer (); ~NotePlayer ();

View file

@ -41,12 +41,12 @@ using namespace Gtkmm2ext;
/** @param tc If non-0, a time converter for this patch change. If 0, time control will be desensitized */ /** @param tc If non-0, a time converter for this patch change. If 0, time control will be desensitized */
PatchChangeDialog::PatchChangeDialog ( PatchChangeDialog::PatchChangeDialog (
const ARDOUR::BeatsFramesConverter* tc, const ARDOUR::BeatsFramesConverter* tc,
ARDOUR::Session* session, ARDOUR::Session* session,
Evoral::PatchChange<Evoral::MusicalTime> const & patch, Evoral::PatchChange<Evoral::Beats> const & patch,
ARDOUR::InstrumentInfo& info, ARDOUR::InstrumentInfo& info,
const Gtk::BuiltinStockID& ok, const Gtk::BuiltinStockID& ok,
bool allow_delete) bool allow_delete)
: ArdourDialog (_("Patch Change"), true) : ArdourDialog (_("Patch Change"), true)
, _time_converter (tc) , _time_converter (tc)
, _info (info) , _info (info)
@ -139,16 +139,16 @@ PatchChangeDialog::instrument_info_changed ()
fill_patch_combo (); fill_patch_combo ();
} }
Evoral::PatchChange<Evoral::MusicalTime> Evoral::PatchChange<Evoral::Beats>
PatchChangeDialog::patch () const PatchChangeDialog::patch () const
{ {
Evoral::MusicalTime t = Evoral::MusicalTime(); Evoral::Beats t = Evoral::Beats();
if (_time_converter) { if (_time_converter) {
t = _time_converter->from (_time.current_time ()); t = _time_converter->from (_time.current_time ());
} }
return Evoral::PatchChange<Evoral::MusicalTime> ( return Evoral::PatchChange<Evoral::Beats> (
t, t,
_channel.get_value_as_int() - 1, _channel.get_value_as_int() - 1,
_program.get_value_as_int() - 1, _program.get_value_as_int() - 1,

View file

@ -43,13 +43,13 @@ public:
PatchChangeDialog ( PatchChangeDialog (
const ARDOUR::BeatsFramesConverter *, const ARDOUR::BeatsFramesConverter *,
ARDOUR::Session *, ARDOUR::Session *,
Evoral::PatchChange<Evoral::MusicalTime> const &, Evoral::PatchChange<Evoral::Beats> const &,
ARDOUR::InstrumentInfo&, ARDOUR::InstrumentInfo&,
const Gtk::BuiltinStockID &, const Gtk::BuiltinStockID &,
bool allow_delete = false bool allow_delete = false
); );
Evoral::PatchChange<Evoral::MusicalTime> patch () const; Evoral::PatchChange<Evoral::Beats> patch () const;
private: private:
void fill_bank_combo (); void fill_bank_combo ();

View file

@ -289,7 +289,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0; virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0;
virtual framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next) = 0; virtual framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next) = 0;
virtual framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration) = 0; virtual framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration) = 0;
virtual Evoral::MusicalTime get_grid_type_as_beats (bool& success, framepos_t position) = 0; virtual Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position) = 0;
virtual void edit_notes (MidiRegionView*) = 0; virtual void edit_notes (MidiRegionView*) = 0;
virtual void queue_visual_videotimeline_update () = 0; virtual void queue_visual_videotimeline_update () = 0;

View file

@ -131,7 +131,7 @@ QuantizeDialog::grid_size_to_musical_time (const string& txt) const
if (txt == "main grid") { if (txt == "main grid") {
bool success; bool success;
Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0); Evoral::Beats b = editor.get_grid_type_as_beats (success, 0);
if (!success) { if (!success) {
return 1.0; return 1.0;
} }

View file

@ -41,7 +41,7 @@ StepEditor::StepEditor (PublicEditor& e, boost::shared_ptr<MidiTrack> t, MidiTim
step_edit_insert_position = 0; step_edit_insert_position = 0;
_step_edit_triplet_countdown = 0; _step_edit_triplet_countdown = 0;
_step_edit_within_chord = 0; _step_edit_within_chord = 0;
_step_edit_chord_duration = Evoral::MusicalTime(); _step_edit_chord_duration = Evoral::Beats();
step_edit_region_view = 0; step_edit_region_view = 0;
_track->PlaylistChanged.connect (*this, invalidator (*this), _track->PlaylistChanged.connect (*this, invalidator (*this),
@ -60,11 +60,11 @@ StepEditor::start_step_editing ()
{ {
_step_edit_triplet_countdown = 0; _step_edit_triplet_countdown = 0;
_step_edit_within_chord = 0; _step_edit_within_chord = 0;
_step_edit_chord_duration = Evoral::MusicalTime(); _step_edit_chord_duration = Evoral::Beats();
step_edit_region.reset (); step_edit_region.reset ();
step_edit_region_view = 0; step_edit_region_view = 0;
last_added_pitch = -1; last_added_pitch = -1;
last_added_end = Evoral::MusicalTime(); last_added_end = Evoral::Beats();
resync_step_edit_position (); resync_step_edit_position ();
prepare_step_edit_region (); prepare_step_edit_region ();
@ -198,7 +198,7 @@ StepEditor::check_step_edit ()
incoming.read_contents (size, buf); incoming.read_contents (size, buf);
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON) { if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON) {
step_add_note (buf[0] & 0xf, buf[1], buf[2], Evoral::MusicalTime()); step_add_note (buf[0] & 0xf, buf[1], buf[2], Evoral::Beats());
} }
} }
} }
@ -216,7 +216,7 @@ StepEditor::step_add_program_change (uint8_t /*channel*/, uint8_t /*program*/)
} }
void void
StepEditor::step_edit_sustain (Evoral::MusicalTime beats) StepEditor::step_edit_sustain (Evoral::Beats beats)
{ {
if (step_edit_region_view) { if (step_edit_region_view) {
step_edit_region_view->step_sustain (beats); step_edit_region_view->step_sustain (beats);
@ -224,7 +224,7 @@ StepEditor::step_edit_sustain (Evoral::MusicalTime beats)
} }
void void
StepEditor::move_step_edit_beat_pos (Evoral::MusicalTime beats) StepEditor::move_step_edit_beat_pos (Evoral::Beats beats)
{ {
if (beats > 0.0) { if (beats > 0.0) {
step_edit_beat_pos = min (step_edit_beat_pos + beats, step_edit_beat_pos = min (step_edit_beat_pos + beats,
@ -233,14 +233,14 @@ StepEditor::move_step_edit_beat_pos (Evoral::MusicalTime beats)
if (-beats < step_edit_beat_pos) { if (-beats < step_edit_beat_pos) {
step_edit_beat_pos += beats; // its negative, remember step_edit_beat_pos += beats; // its negative, remember
} else { } else {
step_edit_beat_pos = Evoral::MusicalTime(); step_edit_beat_pos = Evoral::Beats();
} }
} }
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos); step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
} }
int int
StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::MusicalTime beat_duration) StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::Beats beat_duration)
{ {
/* do these things in case undo removed the step edit region /* do these things in case undo removed the step edit region
*/ */
@ -283,8 +283,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
_editor.reset_x_origin (fpos - (_editor.current_page_samples()/4)); _editor.reset_x_origin (fpos - (_editor.current_page_samples()/4));
} }
Evoral::MusicalTime at = step_edit_beat_pos; Evoral::Beats at = step_edit_beat_pos;
Evoral::MusicalTime len = beat_duration; Evoral::Beats len = beat_duration;
if ((last_added_pitch >= 0) && (pitch == last_added_pitch) && (last_added_end == step_edit_beat_pos)) { if ((last_added_pitch >= 0) && (pitch == last_added_pitch) && (last_added_end == step_edit_beat_pos)) {
@ -292,8 +292,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
up by 1 tick from where the last note ended up by 1 tick from where the last note ended
*/ */
at += Evoral::MusicalTime::ticks(1); at += Evoral::Beats::ticks(1);
len -= Evoral::MusicalTime::ticks(1); len -= Evoral::Beats::ticks(1);
} }
step_edit_region_view->step_add_note (channel, pitch, velocity, at, len); step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
@ -313,7 +313,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
step_edit_beat_pos += beat_duration; step_edit_beat_pos += beat_duration;
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos); step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
} else { } else {
step_edit_beat_pos += Evoral::MusicalTime::ticks(1); // tiny, but no longer overlapping step_edit_beat_pos += Evoral::Beats::ticks(1); // tiny, but no longer overlapping
_step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration); _step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
} }
@ -321,7 +321,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
} }
void void
StepEditor::set_step_edit_cursor_width (Evoral::MusicalTime beats) StepEditor::set_step_edit_cursor_width (Evoral::Beats beats)
{ {
if (step_edit_region_view) { if (step_edit_region_view) {
step_edit_region_view->set_step_edit_cursor_width (beats); step_edit_region_view->set_step_edit_cursor_width (beats);
@ -365,7 +365,7 @@ StepEditor::step_edit_toggle_chord ()
} }
void void
StepEditor::step_edit_rest (Evoral::MusicalTime beats) StepEditor::step_edit_rest (Evoral::Beats beats)
{ {
bool success; bool success;
@ -425,7 +425,7 @@ StepEditor::region_removed (boost::weak_ptr<Region> wr)
step_edit_region.reset(); step_edit_region.reset();
step_edit_region_view = 0; step_edit_region_view = 0;
// force a recompute of the insert position // force a recompute of the insert position
step_edit_beat_pos = Evoral::MusicalTime(-1); step_edit_beat_pos = Evoral::Beats(-1);
} }
} }

View file

@ -45,22 +45,22 @@ class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable
virtual ~StepEditor (); virtual ~StepEditor ();
void check_step_edit (); void check_step_edit ();
void step_edit_rest (Evoral::MusicalTime beats); void step_edit_rest (Evoral::Beats beats);
void step_edit_beat_sync (); void step_edit_beat_sync ();
void step_edit_bar_sync (); void step_edit_bar_sync ();
int step_add_bank_change (uint8_t channel, uint8_t bank); int step_add_bank_change (uint8_t channel, uint8_t bank);
int step_add_program_change (uint8_t channel, uint8_t program); int step_add_program_change (uint8_t channel, uint8_t program);
int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity,
Evoral::MusicalTime beat_duration); Evoral::Beats beat_duration);
void step_edit_sustain (Evoral::MusicalTime beats); void step_edit_sustain (Evoral::Beats beats);
bool step_edit_within_triplet () const; bool step_edit_within_triplet () const;
void step_edit_toggle_triplet (); void step_edit_toggle_triplet ();
bool step_edit_within_chord () const; bool step_edit_within_chord () const;
void step_edit_toggle_chord (); void step_edit_toggle_chord ();
void reset_step_edit_beat_pos (); void reset_step_edit_beat_pos ();
void resync_step_edit_to_edit_point (); void resync_step_edit_to_edit_point ();
void move_step_edit_beat_pos (Evoral::MusicalTime beats); void move_step_edit_beat_pos (Evoral::Beats beats);
void set_step_edit_cursor_width (Evoral::MusicalTime beats); void set_step_edit_cursor_width (Evoral::Beats beats);
std::string name() const; std::string name() const;
@ -69,19 +69,19 @@ class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable
private: private:
ARDOUR::framepos_t step_edit_insert_position; ARDOUR::framepos_t step_edit_insert_position;
Evoral::MusicalTime step_edit_beat_pos; Evoral::Beats step_edit_beat_pos;
boost::shared_ptr<ARDOUR::MidiRegion> step_edit_region; boost::shared_ptr<ARDOUR::MidiRegion> step_edit_region;
MidiRegionView* step_edit_region_view; MidiRegionView* step_edit_region_view;
uint8_t _step_edit_triplet_countdown; uint8_t _step_edit_triplet_countdown;
bool _step_edit_within_chord; bool _step_edit_within_chord;
Evoral::MusicalTime _step_edit_chord_duration; Evoral::Beats _step_edit_chord_duration;
PBD::ScopedConnection step_edit_region_connection; PBD::ScopedConnection step_edit_region_connection;
PublicEditor& _editor; PublicEditor& _editor;
boost::shared_ptr<ARDOUR::MidiTrack> _track; boost::shared_ptr<ARDOUR::MidiTrack> _track;
StepEntry* step_editor; StepEntry* step_editor;
MidiTimeAxisView& _mtv; MidiTimeAxisView& _mtv;
int8_t last_added_pitch; int8_t last_added_pitch;
Evoral::MusicalTime last_added_end; Evoral::Beats last_added_end;
void region_removed (boost::weak_ptr<ARDOUR::Region>); void region_removed (boost::weak_ptr<ARDOUR::Region>);
void playlist_changed (); void playlist_changed ();

View file

@ -526,10 +526,10 @@ StepEntry::on_key_release_event (GdkEventKey* ev)
void void
StepEntry::rest_event_handler () StepEntry::rest_event_handler ()
{ {
se->step_edit_rest (Evoral::MusicalTime()); se->step_edit_rest (Evoral::Beats());
} }
Evoral::MusicalTime Evoral::Beats
StepEntry::note_length () StepEntry::note_length ()
{ {
double base_time = 4.0 / (double) length_divisor_adjustment.get_value(); double base_time = 4.0 / (double) length_divisor_adjustment.get_value();
@ -549,7 +549,7 @@ StepEntry::note_length ()
base_time *= 1 + ((dots - 1.0)/dots); base_time *= 1 + ((dots - 1.0)/dots);
} }
return Evoral::MusicalTime(base_time); return Evoral::Beats(base_time);
} }
uint8_t uint8_t
@ -795,7 +795,7 @@ StepEntry::insert_rest ()
void void
StepEntry::insert_grid_rest () StepEntry::insert_grid_rest ()
{ {
se->step_edit_rest (Evoral::MusicalTime()); se->step_edit_rest (Evoral::Beats());
} }
void void

View file

@ -41,14 +41,14 @@ class StepEntry : public ArdourWindow
void note_off_event_handler (int note); void note_off_event_handler (int note);
void rest_event_handler (); void rest_event_handler ();
Evoral::MusicalTime note_length(); Evoral::Beats note_length();
uint8_t note_velocity() const; uint8_t note_velocity() const;
uint8_t note_channel() const; uint8_t note_channel() const;
int current_octave () const { return (int) floor (octave_adjustment.get_value()); } int current_octave () const { return (int) floor (octave_adjustment.get_value()); }
private: private:
Evoral::MusicalTime _current_note_length; Evoral::Beats _current_note_length;
uint8_t _current_note_velocity; uint8_t _current_note_velocity;
Gtk::VBox packer; Gtk::VBox packer;

View file

@ -37,15 +37,15 @@ class TempoMap;
* them to the opposite unit, taking tempo changes into account. * them to the opposite unit, taking tempo changes into account.
*/ */
class LIBARDOUR_API BeatsFramesConverter class LIBARDOUR_API BeatsFramesConverter
: public Evoral::TimeConverter<Evoral::MusicalTime,framepos_t> { : public Evoral::TimeConverter<Evoral::Beats,framepos_t> {
public: public:
BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin) BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
: Evoral::TimeConverter<Evoral::MusicalTime, framepos_t> (origin) : Evoral::TimeConverter<Evoral::Beats, framepos_t> (origin)
, _tempo_map(tempo_map) , _tempo_map(tempo_map)
{} {}
framepos_t to (Evoral::MusicalTime beats) const; framepos_t to (Evoral::Beats beats) const;
Evoral::MusicalTime from (framepos_t frames) const; Evoral::Beats from (framepos_t frames) const;
private: private:
TempoMap& _tempo_map; TempoMap& _tempo_map;

View file

@ -39,10 +39,10 @@ public:
Legatize(bool shrink_only); Legatize(bool shrink_only);
~Legatize(); ~Legatize();
typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; typedef Evoral::Sequence<Evoral::Beats>::Notes Notes;
Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model, Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Notes>& seqs); std::vector<Notes>& seqs);
std::string name() const { return std::string ("legatize"); } std::string name() const { return std::string ("legatize"); }

View file

@ -52,9 +52,9 @@ class MidiSource;
* Because of this MIDI controllers and automatable controllers/widgets/etc * Because of this MIDI controllers and automatable controllers/widgets/etc
* are easily interchangeable. * are easily interchangeable.
*/ */
class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::MusicalTime> { class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::Beats> {
public: public:
typedef Evoral::MusicalTime TimeType; typedef Evoral::Beats TimeType;
MidiModel (boost::shared_ptr<MidiSource>); MidiModel (boost::shared_ptr<MidiSource>);
@ -259,8 +259,8 @@ public:
bool write_section_to(boost::shared_ptr<MidiSource> source, bool write_section_to(boost::shared_ptr<MidiSource> source,
const Glib::Threads::Mutex::Lock& source_lock, const Glib::Threads::Mutex::Lock& source_lock,
Evoral::MusicalTime begin = Evoral::MinMusicalTime, Evoral::Beats begin = Evoral::MinBeats,
Evoral::MusicalTime end = Evoral::MaxMusicalTime); Evoral::Beats end = Evoral::MaxBeats);
// MidiModel doesn't use the normal AutomationList serialisation code // MidiModel doesn't use the normal AutomationList serialisation code
// since controller data is stored in the .mid // since controller data is stored in the .mid

View file

@ -38,8 +38,8 @@ class LIBARDOUR_API MidiOperator {
virtual ~MidiOperator() {} virtual ~MidiOperator() {}
virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
Evoral::MusicalTime, Evoral::Beats,
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&) = 0; std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&) = 0;
virtual std::string name() const = 0; virtual std::string name() const = 0;
}; };

View file

@ -45,7 +45,7 @@ public:
XMLNode& get_state (); XMLNode& get_state ();
int set_state (const XMLNode&, int version); int set_state (const XMLNode&, int version);
void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev); void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::Beats>& ev);
void append_event_frames(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start); void append_event_frames(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start);
void load_model(const Glib::Threads::Mutex::Lock& lock, bool force_reload=false); void load_model(const Glib::Threads::Mutex::Lock& lock, bool force_reload=false);
void destroy_model(const Glib::Threads::Mutex::Lock& lock); void destroy_model(const Glib::Threads::Mutex::Lock& lock);

View file

@ -37,8 +37,8 @@ namespace ARDOUR {
MidiModel used by the MidiRegion MidiModel used by the MidiRegion
*/ */
LIBARDOUR_API extern PBD::PropertyDescriptor<void*> midi_data; LIBARDOUR_API extern PBD::PropertyDescriptor<void*> midi_data;
LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats; LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> start_beats;
LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats; LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> length_beats;
} }
} }
@ -114,8 +114,8 @@ class LIBARDOUR_API MidiRegion : public Region
private: private:
friend class RegionFactory; friend class RegionFactory;
PBD::Property<Evoral::MusicalTime> _start_beats; PBD::Property<Evoral::Beats> _start_beats;
PBD::Property<Evoral::MusicalTime> _length_beats; PBD::Property<Evoral::Beats> _length_beats;
MidiRegion (const SourceList&); MidiRegion (const SourceList&);
MidiRegion (boost::shared_ptr<const MidiRegion>); MidiRegion (boost::shared_ptr<const MidiRegion>);

View file

@ -43,7 +43,7 @@ template<typename T> class MidiRingBuffer;
class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_shared_from_this<MidiSource> class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_shared_from_this<MidiSource>
{ {
public: public:
typedef Evoral::MusicalTime TimeType; typedef Evoral::Beats TimeType;
MidiSource (Session& session, std::string name, Source::Flag flags = Source::Flag(0)); MidiSource (Session& session, std::string name, Source::Flag flags = Source::Flag(0));
MidiSource (Session& session, const XMLNode&); MidiSource (Session& session, const XMLNode&);
@ -59,8 +59,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
*/ */
int write_to (const Lock& lock, int write_to (const Lock& lock,
boost::shared_ptr<MidiSource> newsrc, boost::shared_ptr<MidiSource> newsrc,
Evoral::MusicalTime begin = Evoral::MinMusicalTime, Evoral::Beats begin = Evoral::MinBeats,
Evoral::MusicalTime end = Evoral::MaxMusicalTime); Evoral::Beats end = Evoral::MaxBeats);
/** Read the data in a given time range from the MIDI source. /** Read the data in a given time range from the MIDI source.
* All time stamps in parameters are in audio frames (even if the source has tempo time). * All time stamps in parameters are in audio frames (even if the source has tempo time).
@ -93,8 +93,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
* *
* Caller must ensure that the event is later than the last written event. * Caller must ensure that the event is later than the last written event.
*/ */
virtual void append_event_beats(const Lock& lock, virtual void append_event_beats(const Lock& lock,
const Evoral::Event<Evoral::MusicalTime>& ev) = 0; const Evoral::Event<Evoral::Beats>& ev) = 0;
/** Append a single event with a timestamp in frames. /** Append a single event with a timestamp in frames.
* *
@ -132,9 +132,9 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
* etc. * etc.
*/ */
virtual void mark_midi_streaming_write_completed ( virtual void mark_midi_streaming_write_completed (
const Lock& lock, const Lock& lock,
Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_option, Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_option,
Evoral::MusicalTime when = Evoral::MusicalTime()); Evoral::Beats when = Evoral::Beats());
virtual void session_saved(); virtual void session_saved();
@ -205,11 +205,11 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
boost::shared_ptr<MidiModel> _model; boost::shared_ptr<MidiModel> _model;
bool _writing; bool _writing;
mutable Evoral::Sequence<Evoral::MusicalTime>::const_iterator _model_iter; mutable Evoral::Sequence<Evoral::Beats>::const_iterator _model_iter;
mutable bool _model_iter_valid; mutable bool _model_iter_valid;
mutable Evoral::MusicalTime _length_beats; mutable Evoral::Beats _length_beats;
mutable framepos_t _last_read_end; mutable framepos_t _last_read_end;
/** The total duration of the current capture. */ /** The total duration of the current capture. */
framepos_t _capture_length; framepos_t _capture_length;

View file

@ -46,7 +46,7 @@ public:
void remove (uint8_t note, uint8_t chn); void remove (uint8_t note, uint8_t chn);
void resolve_notes (MidiBuffer& buffer, framepos_t time); void resolve_notes (MidiBuffer& buffer, framepos_t time);
void resolve_notes (Evoral::EventSink<framepos_t>& buffer, framepos_t time); void resolve_notes (Evoral::EventSink<framepos_t>& buffer, framepos_t time);
void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::MusicalTime time); void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::Beats time);
void dump (std::ostream&); void dump (std::ostream&);
void reset (); void reset ();
bool empty() const { return _on == 0; } bool empty() const { return _on == 0; }

View file

@ -35,8 +35,8 @@ public:
~Quantize (); ~Quantize ();
Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&); std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&);
std::string name() const { return std::string ("quantize"); } std::string name() const { return std::string ("quantize"); }
private: private:

View file

@ -51,14 +51,14 @@ public:
return safe_midi_file_extension(path); return safe_midi_file_extension(path);
} }
void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev); void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::Beats>& ev);
void append_event_frames (const Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start); void append_event_frames (const Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start);
void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode); void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode);
void mark_streaming_write_completed (const Lock& lock); void mark_streaming_write_completed (const Lock& lock);
void mark_midi_streaming_write_completed (const Lock& lock, void mark_midi_streaming_write_completed (const Lock& lock,
Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption, Evoral::Sequence<Evoral::Beats>::StuckNoteOption,
Evoral::MusicalTime when = Evoral::MusicalTime()); Evoral::Beats when = Evoral::Beats());
XMLNode& get_state (); XMLNode& get_state ();
int set_state (const XMLNode&, int version); int set_state (const XMLNode&, int version);
@ -77,7 +77,7 @@ public:
private: private:
bool _open; bool _open;
Evoral::MusicalTime _last_ev_time_beats; Evoral::Beats _last_ev_time_beats;
framepos_t _last_ev_time_frames; framepos_t _last_ev_time_frames;
/** end time (start + duration) of last call to read_unlocked */ /** end time (start + duration) of last call to read_unlocked */
mutable framepos_t _smf_last_read_end; mutable framepos_t _smf_last_read_end;

View file

@ -276,9 +276,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
*/ */
framepos_t framepos_plus_bbt (framepos_t pos, Timecode::BBT_Time b) const; framepos_t framepos_plus_bbt (framepos_t pos, Timecode::BBT_Time b) const;
framepos_t framepos_plus_beats (framepos_t, Evoral::MusicalTime) const; framepos_t framepos_plus_beats (framepos_t, Evoral::Beats) const;
framepos_t framepos_minus_beats (framepos_t, Evoral::MusicalTime) const; framepos_t framepos_minus_beats (framepos_t, Evoral::Beats) const;
Evoral::MusicalTime framewalk_to_beats (framepos_t pos, framecnt_t distance) const; Evoral::Beats framewalk_to_beats (framepos_t pos, framecnt_t distance) const;
static const Tempo& default_tempo() { return _default_tempo; } static const Tempo& default_tempo() { return _default_tempo; }
static const Meter& default_meter() { return _default_meter; } static const Meter& default_meter() { return _default_meter; }

View file

@ -50,9 +50,9 @@ namespace ARDOUR {
*/ */
class LIBARDOUR_API Transform : public MidiOperator { class LIBARDOUR_API Transform : public MidiOperator {
public: public:
typedef Evoral::Sequence<Evoral::MusicalTime>::NotePtr NotePtr; typedef Evoral::Sequence<Evoral::Beats>::NotePtr NotePtr;
typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; typedef Evoral::Sequence<Evoral::Beats>::Notes Notes;
typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property; typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
/** Context while iterating over notes during transformation. */ /** Context while iterating over notes during transformation. */
struct Context { struct Context {
@ -132,7 +132,7 @@ public:
Transform(const Program& prog); Transform(const Program& prog);
Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model, Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Notes>& seqs); std::vector<Notes>& seqs);
std::string name() const { return std::string ("transform"); } std::string name() const { return std::string ("transform"); }

View file

@ -57,7 +57,7 @@ public:
explicit Variant(int32_t value) : _type(INT) { _int = value; } explicit Variant(int32_t value) : _type(INT) { _int = value; }
explicit Variant(int64_t value) : _type(LONG) { _long = value; } explicit Variant(int64_t value) : _type(LONG) { _long = value; }
explicit Variant(const Evoral::MusicalTime& beats) explicit Variant(const Evoral::Beats& beats)
: _type(BEATS) : _type(BEATS)
, _beats(beats) , _beats(beats)
{} {}
@ -94,7 +94,7 @@ public:
std::min(value, (double)INT64_MAX))); std::min(value, (double)INT64_MAX)));
break; break;
case BEATS: case BEATS:
_beats = Evoral::MusicalTime(value); _beats = Evoral::Beats(value);
break; break;
default: default:
_type = NOTHING; _type = NOTHING;
@ -158,19 +158,19 @@ public:
return false; return false;
} }
bool operator==(const Evoral::MusicalTime& v) const { bool operator==(const Evoral::Beats& v) const {
return _type == BEATS && _beats == v; return _type == BEATS && _beats == v;
} }
bool operator!() const { return _type == NOTHING; } bool operator!() const { return _type == NOTHING; }
Variant& operator=(Evoral::MusicalTime v) { Variant& operator=(Evoral::Beats v) {
_type = BEATS; _type = BEATS;
_beats = v; _beats = v;
return *this; return *this;
} }
const Evoral::MusicalTime& get_beats() const { const Evoral::Beats& get_beats() const {
ensure_type(BEATS); return _beats; ensure_type(BEATS); return _beats;
} }
@ -202,9 +202,9 @@ private:
} }
} }
Type _type; ///< Type tag Type _type; ///< Type tag
std::string _string; ///< PATH, STRING, URI std::string _string; ///< PATH, STRING, URI
Evoral::MusicalTime _beats; ///< BEATS Evoral::Beats _beats; ///< BEATS
// Union of all primitive numeric types // Union of all primitive numeric types
union { union {

View file

@ -31,9 +31,9 @@ namespace ARDOUR {
* taking tempo changes into account. * taking tempo changes into account.
*/ */
framepos_t framepos_t
BeatsFramesConverter::to (Evoral::MusicalTime beats) const BeatsFramesConverter::to (Evoral::Beats beats) const
{ {
if (beats < Evoral::MusicalTime()) { if (beats < Evoral::Beats()) {
std::cerr << "negative beats passed to BFC: " << beats << std::endl; std::cerr << "negative beats passed to BFC: " << beats << std::endl;
PBD::stacktrace (std::cerr, 30); PBD::stacktrace (std::cerr, 30);
return 0; return 0;
@ -45,7 +45,7 @@ BeatsFramesConverter::to (Evoral::MusicalTime beats) const
* supplied to the constructor. Returns the equivalent number of beats, * supplied to the constructor. Returns the equivalent number of beats,
* taking tempo changes into account. * taking tempo changes into account.
*/ */
Evoral::MusicalTime Evoral::Beats
BeatsFramesConverter::from (framepos_t frames) const BeatsFramesConverter::from (framepos_t frames) const
{ {
return _tempo_map.framewalk_to_beats (_origin_b, frames); return _tempo_map.framewalk_to_beats (_origin_b, frames);
@ -60,7 +60,7 @@ DoubleBeatsFramesConverter::to (double beats) const
PBD::stacktrace (std::cerr, 30); PBD::stacktrace (std::cerr, 30);
return 0; return 0;
} }
return _tempo_map.framepos_plus_beats (_origin_b, Evoral::MusicalTime(beats)) - _origin_b; return _tempo_map.framepos_plus_beats (_origin_b, Evoral::Beats(beats)) - _origin_b;
} }
/** As above, but with beats in double instead (for GUI). */ /** As above, but with beats in double instead (for GUI). */

View file

@ -392,9 +392,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
smfs->append_event_beats( smfs->append_event_beats(
source_lock, source_lock,
Evoral::Event<Evoral::MusicalTime>( Evoral::Event<Evoral::Beats>(
0, 0,
Evoral::MusicalTime::ticks_at_rate(t, source->ppqn()), Evoral::Beats::ticks_at_rate(t, source->ppqn()),
size, size,
buf)); buf));
@ -407,9 +407,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
/* we wrote something */ /* we wrote something */
const framepos_t pos = 0; const framepos_t pos = 0;
const Evoral::MusicalTime length_beats = Evoral::MusicalTime::ticks_at_rate(t, source->ppqn()); const Evoral::Beats length_beats = Evoral::Beats::ticks_at_rate(t, source->ppqn());
BeatsFramesConverter converter(smfs->session().tempo_map(), pos); BeatsFramesConverter converter(smfs->session().tempo_map(), pos);
smfs->update_length(pos + converter.to(length_beats.round_up_to_beat())); smfs->update_length(pos + converter.to(length_beats.round_up_to_beat()));
smfs->mark_streaming_write_completed (source_lock); smfs->mark_streaming_write_completed (source_lock);

View file

@ -31,7 +31,7 @@ Legatize::~Legatize ()
Command* Command*
Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model, Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Legatize::Notes>& seqs) std::vector<Legatize::Notes>& seqs)
{ {
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand(model, "legatize"); MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand(model, "legatize");
@ -43,10 +43,10 @@ Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
break; break;
} }
const Evoral::MusicalTime new_end = (*next)->time() - Evoral::MusicalTime::tick(); const Evoral::Beats new_end = (*next)->time() - Evoral::Beats::tick();
if ((*i)->end_time() > new_end || if ((*i)->end_time() > new_end ||
(!_shrink_only && (*i)->end_time() < new_end)) { (!_shrink_only && (*i)->end_time() < new_end)) {
const Evoral::MusicalTime new_length(new_end - (*i)->time()); const Evoral::Beats new_length(new_end - (*i)->time());
cmd->change((*i), MidiModel::NoteDiffCommand::Length, new_length); cmd->change((*i), MidiModel::NoteDiffCommand::Length, new_length);
} }

View file

@ -940,14 +940,14 @@ MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen
/* set length in beats to entire capture length */ /* set length in beats to entire capture length */
BeatsFramesConverter converter (_session.tempo_map(), capture_info.front()->start); BeatsFramesConverter converter (_session.tempo_map(), capture_info.front()->start);
const Evoral::MusicalTime total_capture_beats = converter.from (total_capture); const Evoral::Beats total_capture_beats = converter.from (total_capture);
_write_source->set_length_beats (total_capture_beats); _write_source->set_length_beats (total_capture_beats);
/* flush to disk: this step differs from the audio path, /* flush to disk: this step differs from the audio path,
where all the data is already on disk. where all the data is already on disk.
*/ */
_write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, total_capture_beats); _write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, total_capture_beats);
/* we will want to be able to keep (over)writing the source /* we will want to be able to keep (over)writing the source
but we don't want it to be removable. this also differs but we don't want it to be removable. this also differs

View file

@ -620,7 +620,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change)
if ((prop = xml_change->property ("old")) != 0) { if ((prop = xml_change->property ("old")) != 0) {
istringstream old_str (prop->value()); istringstream old_str (prop->value());
if (change.property == StartTime || change.property == Length) { if (change.property == StartTime || change.property == Length) {
Evoral::MusicalTime old_time; Evoral::Beats old_time;
old_str >> old_time; old_str >> old_time;
change.old_value = old_time; change.old_value = old_time;
} else { } else {
@ -636,7 +636,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change)
if ((prop = xml_change->property ("new")) != 0) { if ((prop = xml_change->property ("new")) != 0) {
istringstream new_str (prop->value()); istringstream new_str (prop->value());
if (change.property == StartTime || change.property == Length) { if (change.property == StartTime || change.property == Length) {
Evoral::MusicalTime new_time; Evoral::Beats new_time;
new_str >> new_time; new_str >> new_time;
change.new_value = Variant(new_time); change.new_value = Variant(new_time);
} else { } else {
@ -1237,7 +1237,7 @@ MidiModel::PatchChangeDiffCommand::unmarshal_patch_change (XMLNode* n)
{ {
XMLProperty* prop; XMLProperty* prop;
Evoral::event_id_t id = 0; Evoral::event_id_t id = 0;
Evoral::MusicalTime time = Evoral::MusicalTime(); Evoral::Beats time = Evoral::Beats();
int channel = 0; int channel = 0;
int program = 0; int program = 0;
int bank = 0; int bank = 0;
@ -1476,8 +1476,8 @@ MidiModel::sync_to_source (const Glib::Threads::Mutex::Lock& source_lock)
bool bool
MidiModel::write_section_to (boost::shared_ptr<MidiSource> source, MidiModel::write_section_to (boost::shared_ptr<MidiSource> source,
const Glib::Threads::Mutex::Lock& source_lock, const Glib::Threads::Mutex::Lock& source_lock,
Evoral::MusicalTime begin_time, Evoral::Beats begin_time,
Evoral::MusicalTime end_time) Evoral::Beats end_time)
{ {
ReadLock lock(read_lock()); ReadLock lock(read_lock());
MidiStateTracker mst; MidiStateTracker mst;
@ -1489,12 +1489,12 @@ MidiModel::write_section_to (boost::shared_ptr<MidiSource> source,
source->mark_streaming_midi_write_started (source_lock, note_mode()); source->mark_streaming_midi_write_started (source_lock, note_mode());
for (Evoral::Sequence<TimeType>::const_iterator i = begin(TimeType(), true); i != end(); ++i) { for (Evoral::Sequence<TimeType>::const_iterator i = begin(TimeType(), true); i != end(); ++i) {
const Evoral::Event<Evoral::MusicalTime>& ev (*i); const Evoral::Event<Evoral::Beats>& ev (*i);
if (ev.time() >= begin_time && ev.time() < end_time) { if (ev.time() >= begin_time && ev.time() < end_time) {
const Evoral::MIDIEvent<Evoral::MusicalTime>* mev = const Evoral::MIDIEvent<Evoral::Beats>* mev =
static_cast<const Evoral::MIDIEvent<Evoral::MusicalTime>* > (&ev); static_cast<const Evoral::MIDIEvent<Evoral::Beats>* > (&ev);
if (!mev) { if (!mev) {
continue; continue;
@ -2026,7 +2026,7 @@ MidiModel::transpose (TimeType from, TimeType to, int semitones)
void void
MidiModel::control_list_marked_dirty () MidiModel::control_list_marked_dirty ()
{ {
AutomatableSequence<Evoral::MusicalTime>::control_list_marked_dirty (); AutomatableSequence<Evoral::Beats>::control_list_marked_dirty ();
ContentsChanged (); /* EMIT SIGNAL */ ContentsChanged (); /* EMIT SIGNAL */
} }

View file

@ -149,7 +149,7 @@ MidiPlaylistSource::write_unlocked (const Lock&,
} }
void void
MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::MusicalTime>& /*ev*/) MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::Beats>& /*ev*/)
{ {
fatal << string_compose (_("programming error: %1"), "MidiPlaylistSource::append_event_beats() called - should be impossible") << endmsg; fatal << string_compose (_("programming error: %1"), "MidiPlaylistSource::append_event_beats() called - should be impossible") << endmsg;
abort(); /*NOTREACHED*/ abort(); /*NOTREACHED*/

View file

@ -53,9 +53,9 @@ using namespace PBD;
namespace ARDOUR { namespace ARDOUR {
namespace Properties { namespace Properties {
PBD::PropertyDescriptor<void*> midi_data; PBD::PropertyDescriptor<void*> midi_data;
PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats; PBD::PropertyDescriptor<Evoral::Beats> start_beats;
PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats; PBD::PropertyDescriptor<Evoral::Beats> length_beats;
} }
} }
@ -80,7 +80,7 @@ MidiRegion::register_properties ()
/* Basic MidiRegion constructor (many channels) */ /* Basic MidiRegion constructor (many channels) */
MidiRegion::MidiRegion (const SourceList& srcs) MidiRegion::MidiRegion (const SourceList& srcs)
: Region (srcs) : Region (srcs)
, _start_beats (Properties::start_beats, Evoral::MusicalTime()) , _start_beats (Properties::start_beats, Evoral::Beats())
, _length_beats (Properties::length_beats, midi_source(0)->length_beats()) , _length_beats (Properties::length_beats, midi_source(0)->length_beats())
{ {
register_properties (); register_properties ();
@ -94,7 +94,7 @@ MidiRegion::MidiRegion (const SourceList& srcs)
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
: Region (other) : Region (other)
, _start_beats (Properties::start_beats, other->_start_beats) , _start_beats (Properties::start_beats, other->_start_beats)
, _length_beats (Properties::length_beats, Evoral::MusicalTime()) , _length_beats (Properties::length_beats, Evoral::Beats())
{ {
update_length_beats (); update_length_beats ();
register_properties (); register_properties ();
@ -107,11 +107,11 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
/** Create a new MidiRegion that is part of an existing one */ /** Create a new MidiRegion that is part of an existing one */
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset) MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset)
: Region (other, offset) : Region (other, offset)
, _start_beats (Properties::start_beats, Evoral::MusicalTime()) , _start_beats (Properties::start_beats, Evoral::Beats())
, _length_beats (Properties::length_beats, Evoral::MusicalTime()) , _length_beats (Properties::length_beats, Evoral::Beats())
{ {
BeatsFramesConverter bfc (_session.tempo_map(), _position); BeatsFramesConverter bfc (_session.tempo_map(), _position);
Evoral::MusicalTime const offset_beats = bfc.from (offset); Evoral::Beats const offset_beats = bfc.from (offset);
_start_beats = other->_start_beats.val() + offset_beats; _start_beats = other->_start_beats.val() + offset_beats;
_length_beats = other->_length_beats.val() - offset_beats; _length_beats = other->_length_beats.val() - offset_beats;
@ -147,8 +147,8 @@ boost::shared_ptr<MidiRegion>
MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const
{ {
BeatsFramesConverter bfc (_session.tempo_map(), _position); BeatsFramesConverter bfc (_session.tempo_map(), _position);
Evoral::MusicalTime const bbegin = bfc.from (_start); Evoral::Beats const bbegin = bfc.from (_start);
Evoral::MusicalTime const bend = bfc.from (_start + _length); Evoral::Beats const bend = bfc.from (_start + _length);
{ {
/* Lock our source since we'll be reading from it. write_to() will /* Lock our source since we'll be reading from it. write_to() will
@ -223,7 +223,7 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
/* zero length regions don't exist - so if _length_beats is zero, this object /* zero length regions don't exist - so if _length_beats is zero, this object
is under construction. is under construction.
*/ */
if (_length_beats.val() == Evoral::MusicalTime()) { if (_length_beats.val() == Evoral::Beats()) {
/* leave _length_beats alone, and change _length to reflect the state of things /* leave _length_beats alone, and change _length to reflect the state of things
at the new position (tempo map may dictate a different number of frames at the new position (tempo map may dictate a different number of frames
*/ */
@ -462,7 +462,7 @@ MidiRegion::fix_negative_start ()
model()->insert_silence_at_start (c.from (-_start)); model()->insert_silence_at_start (c.from (-_start));
_start = 0; _start = 0;
_start_beats = Evoral::MusicalTime(); _start_beats = Evoral::Beats();
} }
/** Transpose the notes in this region by a given number of semitones */ /** Transpose the notes in this region by a given number of semitones */

View file

@ -200,7 +200,7 @@ MidiSource::midi_read (const Lock& lm,
if (_model) { if (_model) {
// Find appropriate model iterator // Find appropriate model iterator
Evoral::Sequence<Evoral::MusicalTime>::const_iterator& i = _model_iter; Evoral::Sequence<Evoral::Beats>::const_iterator& i = _model_iter;
if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) { if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) {
// Cached iterator is invalid, search for the first event past start // Cached iterator is invalid, search for the first event past start
i = _model->begin(converter.from(start), false, filtered); i = _model->begin(converter.from(start), false, filtered);
@ -297,9 +297,9 @@ MidiSource::mark_streaming_write_started (const Lock& lock)
} }
void void
MidiSource::mark_midi_streaming_write_completed (const Lock& lock, MidiSource::mark_midi_streaming_write_completed (const Lock& lock,
Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption option, Evoral::Sequence<Evoral::Beats>::StuckNoteOption option,
Evoral::MusicalTime end) Evoral::Beats end)
{ {
if (_model) { if (_model) {
_model->end_write (option, end); _model->end_write (option, end);
@ -320,11 +320,11 @@ MidiSource::mark_midi_streaming_write_completed (const Lock&
void void
MidiSource::mark_streaming_write_completed (const Lock& lock) MidiSource::mark_streaming_write_completed (const Lock& lock)
{ {
mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
} }
int int
MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end) MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::Beats begin, Evoral::Beats end)
{ {
Lock newsrc_lock (newsrc->mutex ()); Lock newsrc_lock (newsrc->mutex ());
@ -333,7 +333,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev
newsrc->copy_automation_state_from (this); newsrc->copy_automation_state_from (this);
if (_model) { if (_model) {
if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) { if (begin == Evoral::MinBeats && end == Evoral::MaxBeats) {
_model->write_to (newsrc, newsrc_lock); _model->write_to (newsrc, newsrc_lock);
} else { } else {
_model->write_section_to (newsrc, newsrc_lock, begin, end); _model->write_section_to (newsrc, newsrc_lock, begin, end);
@ -347,7 +347,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev
/* force a reload of the model if the range is partial */ /* force a reload of the model if the range is partial */
if (begin != Evoral::MinMusicalTime || end != Evoral::MaxMusicalTime) { if (begin != Evoral::MinBeats || end != Evoral::MaxBeats) {
newsrc->load_model (newsrc_lock, true); newsrc->load_model (newsrc_lock, true);
} else { } else {
newsrc->set_model (newsrc_lock, _model); newsrc->set_model (newsrc_lock, _model);

View file

@ -168,7 +168,7 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
} }
void void
MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::MusicalTime time) MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::Beats time)
{ {
DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on)); DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on));
@ -181,7 +181,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
for (int channel = 0; channel < 16; ++channel) { for (int channel = 0; channel < 16; ++channel) {
for (int note = 0; note < 128; ++note) { for (int note = 0; note < 128; ++note) {
while (_active_notes[note + 128 * channel]) { while (_active_notes[note + 128 * channel]) {
Evoral::MIDIEvent<Evoral::MusicalTime> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true); Evoral::MIDIEvent<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
ev.set_type (MIDI_CMD_NOTE_OFF); ev.set_type (MIDI_CMD_NOTE_OFF);
ev.set_channel (channel); ev.set_channel (channel);
ev.set_note (note); ev.set_note (note);
@ -191,7 +191,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
this, (int) note, (int) channel, time)); this, (int) note, (int) channel, time));
_active_notes[note + 128 * channel]--; _active_notes[note + 128 * channel]--;
/* don't stack events up at the same time */ /* don't stack events up at the same time */
time += Evoral::MusicalTime::tick(); time += Evoral::Beats::tick();
} }
} }
} }

View file

@ -108,7 +108,7 @@ MidiStretch::run (boost::shared_ptr<Region> r, Progress*)
new_model->append(ev, Evoral::next_event_id()); new_model->append(ev, Evoral::next_event_id());
} }
new_model->end_write (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); new_model->end_write (Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
new_model->set_edited (true); new_model->set_edited (true);
new_src->copy_interpolation_from (src); new_src->copy_interpolation_from (src);

View file

@ -54,8 +54,8 @@ Quantize::~Quantize ()
Command* Command*
Quantize::operator () (boost::shared_ptr<MidiModel> model, Quantize::operator () (boost::shared_ptr<MidiModel> model,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs) std::vector<Evoral::Sequence<Evoral::Beats>::Notes>& seqs)
{ {
/* TODO: Rewrite this to be precise with fixed point? */ /* TODO: Rewrite this to be precise with fixed point? */
@ -69,7 +69,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
bool even; bool even;
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize"); MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize");
for (std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) { for (std::vector<Evoral::Sequence<Evoral::Beats>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
even = false; even = false;
@ -119,10 +119,10 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
delta = new_end - (*i)->end_time().to_double(); delta = new_end - (*i)->end_time().to_double();
if (fabs (delta) >= _threshold) { if (fabs (delta) >= _threshold) {
Evoral::MusicalTime new_dur(new_end - new_start); Evoral::Beats new_dur(new_end - new_start);
if (!new_dur) { if (!new_dur) {
new_dur = Evoral::MusicalTime(_end_grid); new_dur = Evoral::Beats(_end_grid);
} }
cmd->change ((*i), MidiModel::NoteDiffCommand::Length, new_dur); cmd->change ((*i), MidiModel::NoteDiffCommand::Length, new_dur);

View file

@ -278,7 +278,7 @@ SMFSource::read_unlocked (const Lock& lock,
/* Note that we add on the source start time (in session frames) here so that ev_frame_time /* Note that we add on the source start time (in session frames) here so that ev_frame_time
is in session frames. is in session frames.
*/ */
const framepos_t ev_frame_time = converter.to(Evoral::MusicalTime::ticks_at_rate(time, ppqn())) + source_start; const framepos_t ev_frame_time = converter.to(Evoral::Beats::ticks_at_rate(time, ppqn())) + source_start;
if (ev_frame_time < start + duration) { if (ev_frame_time < start + duration) {
destination.write (ev_frame_time, ev_type, ev_size, ev_buffer); destination.write (ev_frame_time, ev_type, ev_size, ev_buffer);
@ -380,8 +380,8 @@ SMFSource::write_unlocked (const Lock& lock,
/** Append an event with a timestamp in beats */ /** Append an event with a timestamp in beats */
void void
SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
const Evoral::Event<Evoral::MusicalTime>& ev) const Evoral::Event<Evoral::Beats>& ev)
{ {
if (!_writing || ev.size() == 0) { if (!_writing || ev.size() == 0) {
return; return;
@ -391,9 +391,9 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
name().c_str(), ev.id(), ev.time(), ev.size()); name().c_str(), ev.id(), ev.time(), ev.size());
for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n");*/ for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n");*/
Evoral::MusicalTime time = ev.time(); Evoral::Beats time = ev.time();
if (time < _last_ev_time_beats) { if (time < _last_ev_time_beats) {
const Evoral::MusicalTime difference = _last_ev_time_beats - time; const Evoral::Beats difference = _last_ev_time_beats - time;
if (difference.to_double() / (double)ppqn() < 1.0) { if (difference.to_double() / (double)ppqn() < 1.0) {
/* Close enough. This problem occurs because Sequence is not /* Close enough. This problem occurs because Sequence is not
actually ordered due to fuzzy time comparison. I'm pretty sure actually ordered due to fuzzy time comparison. I'm pretty sure
@ -423,8 +423,8 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
_length_beats = max(_length_beats, time); _length_beats = max(_length_beats, time);
const Evoral::MusicalTime delta_time_beats = time - _last_ev_time_beats; const Evoral::Beats delta_time_beats = time - _last_ev_time_beats;
const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id); Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id);
_last_ev_time_beats = time; _last_ev_time_beats = time;
@ -452,9 +452,9 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock,
return; return;
} }
BeatsFramesConverter converter(_session.tempo_map(), position); BeatsFramesConverter converter(_session.tempo_map(), position);
const Evoral::MusicalTime ev_time_beats = converter.from(ev.time()); const Evoral::Beats ev_time_beats = converter.from(ev.time());
Evoral::event_id_t event_id; Evoral::event_id_t event_id;
if (ev.id() < 0) { if (ev.id() < 0) {
event_id = Evoral::next_event_id(); event_id = Evoral::next_event_id();
@ -463,18 +463,18 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock,
} }
if (_model) { if (_model) {
const Evoral::Event<Evoral::MusicalTime> beat_ev (ev.event_type(), const Evoral::Event<Evoral::Beats> beat_ev (ev.event_type(),
ev_time_beats, ev_time_beats,
ev.size(), ev.size(),
const_cast<uint8_t*>(ev.buffer())); const_cast<uint8_t*>(ev.buffer()));
_model->append (beat_ev, event_id); _model->append (beat_ev, event_id);
} }
_length_beats = max(_length_beats, ev_time_beats); _length_beats = max(_length_beats, ev_time_beats);
const Evoral::MusicalTime last_time_beats = converter.from (_last_ev_time_frames); const Evoral::Beats last_time_beats = converter.from (_last_ev_time_frames);
const Evoral::MusicalTime delta_time_beats = ev_time_beats - last_time_beats; const Evoral::Beats delta_time_beats = ev_time_beats - last_time_beats;
const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id); Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id);
_last_ev_time_frames = ev.time(); _last_ev_time_frames = ev.time();
@ -518,18 +518,18 @@ SMFSource::mark_streaming_midi_write_started (const Lock& lock, NoteMode mode)
MidiSource::mark_streaming_midi_write_started (lock, mode); MidiSource::mark_streaming_midi_write_started (lock, mode);
Evoral::SMF::begin_write (); Evoral::SMF::begin_write ();
_last_ev_time_beats = Evoral::MusicalTime(); _last_ev_time_beats = Evoral::Beats();
_last_ev_time_frames = 0; _last_ev_time_frames = 0;
} }
void void
SMFSource::mark_streaming_write_completed (const Lock& lock) SMFSource::mark_streaming_write_completed (const Lock& lock)
{ {
mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
} }
void void
SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_notes_option, Evoral::MusicalTime when) SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_notes_option, Evoral::Beats when)
{ {
MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when); MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when);
@ -587,8 +587,8 @@ SMFSource::safe_midi_file_extension (const string& file)
} }
static bool compare_eventlist ( static bool compare_eventlist (
const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& a, const std::pair< Evoral::Event<Evoral::Beats>*, gint >& a,
const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& b) { const std::pair< Evoral::Event<Evoral::Beats>*, gint >& b) {
return ( a.first->time() < b.first->time() ); return ( a.first->time() < b.first->time() );
} }
@ -619,7 +619,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
Evoral::SMF::seek_to_start(); Evoral::SMF::seek_to_start();
uint64_t time = 0; /* in SMF ticks */ uint64_t time = 0; /* in SMF ticks */
Evoral::Event<Evoral::MusicalTime> ev; Evoral::Event<Evoral::Beats> ev;
uint32_t scratch_size = 0; // keep track of scratch and minimize reallocs uint32_t scratch_size = 0; // keep track of scratch and minimize reallocs
@ -631,7 +631,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
bool have_event_id; bool have_event_id;
// TODO simplify event allocation // TODO simplify event allocation
std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > > eventlist; std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > > eventlist;
for (unsigned i = 1; i <= num_tracks(); ++i) { for (unsigned i = 1; i <= num_tracks(); ++i) {
if (seek_to_track(i)) continue; if (seek_to_track(i)) continue;
@ -658,7 +658,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
event_id = Evoral::next_event_id(); event_id = Evoral::next_event_id();
} }
const uint32_t event_type = midi_parameter_type(buf[0]); const uint32_t event_type = midi_parameter_type(buf[0]);
const Evoral::MusicalTime event_time = Evoral::MusicalTime::ticks_at_rate(time, ppqn()); const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn());
#ifndef NDEBUG #ifndef NDEBUG
std::string ss; std::string ss;
@ -673,7 +673,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
#endif #endif
eventlist.push_back(make_pair ( eventlist.push_back(make_pair (
new Evoral::Event<Evoral::MusicalTime> ( new Evoral::Event<Evoral::Beats> (
event_type, event_time, event_type, event_time,
size, buf, true) size, buf, true)
, event_id)); , event_id));
@ -692,13 +692,13 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
eventlist.sort(compare_eventlist); eventlist.sort(compare_eventlist);
std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > >::iterator it; std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > >::iterator it;
for (it=eventlist.begin(); it!=eventlist.end(); ++it) { for (it=eventlist.begin(); it!=eventlist.end(); ++it) {
_model->append (*it->first, it->second); _model->append (*it->first, it->second);
delete it->first; delete it->first;
} }
_model->end_write (Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, _length_beats); _model->end_write (Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, _length_beats);
_model->set_edited (false); _model->set_edited (false);
invalidate(lock); invalidate(lock);

View file

@ -1841,7 +1841,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount)
* pos can be -ve, if required. * pos can be -ve, if required.
*/ */
framepos_t framepos_t
TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const
{ {
Glib::Threads::RWLock::ReaderLock lm (lock); Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics::const_iterator next_tempo; Metrics::const_iterator next_tempo;
@ -1891,11 +1891,11 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const
framecnt_t distance_frames = (next_tempo == metrics.end() ? max_framepos : ((*next_tempo)->frame() - pos)); framecnt_t distance_frames = (next_tempo == metrics.end() ? max_framepos : ((*next_tempo)->frame() - pos));
/* Distance to the end in beats */ /* Distance to the end in beats */
Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate( Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate(
distance_frames, tempo->frames_per_beat (_frame_rate)); distance_frames, tempo->frames_per_beat (_frame_rate));
/* Amount to subtract this time */ /* Amount to subtract this time */
Evoral::MusicalTime const delta = min (distance_beats, beats); Evoral::Beats const delta = min (distance_beats, beats);
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n", DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n",
(next_tempo == metrics.end() ? max_framepos : (*next_tempo)->frame()), (next_tempo == metrics.end() ? max_framepos : (*next_tempo)->frame()),
@ -1933,7 +1933,7 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const
/** Subtract some (fractional) beats from a frame position, and return the result in frames */ /** Subtract some (fractional) beats from a frame position, and return the result in frames */
framepos_t framepos_t
TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const
{ {
Glib::Threads::RWLock::ReaderLock lm (lock); Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics::const_reverse_iterator prev_tempo; Metrics::const_reverse_iterator prev_tempo;
@ -2000,11 +2000,11 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
framecnt_t distance_frames = (pos - tempo->frame()); framecnt_t distance_frames = (pos - tempo->frame());
/* Distance to the start in beats */ /* Distance to the start in beats */
Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate( Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate(
distance_frames, tempo->frames_per_beat (_frame_rate)); distance_frames, tempo->frames_per_beat (_frame_rate));
/* Amount to subtract this time */ /* Amount to subtract this time */
Evoral::MusicalTime const sub = min (distance_beats, beats); Evoral::Beats const sub = min (distance_beats, beats);
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n", DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n",
tempo->frame(), distance_frames, distance_beats)); tempo->frame(), distance_frames, distance_beats));
@ -2037,7 +2037,7 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
} }
} else { } else {
pos -= llrint (beats.to_double() * tempo->frames_per_beat (_frame_rate)); pos -= llrint (beats.to_double() * tempo->frames_per_beat (_frame_rate));
beats = Evoral::MusicalTime(); beats = Evoral::Beats();
} }
} }
@ -2183,7 +2183,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
/** Count the number of beats that are equivalent to distance when going forward, /** Count the number of beats that are equivalent to distance when going forward,
starting at pos. starting at pos.
*/ */
Evoral::MusicalTime Evoral::Beats
TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
{ {
Glib::Threads::RWLock::ReaderLock lm (lock); Glib::Threads::RWLock::ReaderLock lm (lock);
@ -2218,7 +2218,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
string_compose ("frame %1 walk by %2 frames, start with tempo = %3 @ %4\n", string_compose ("frame %1 walk by %2 frames, start with tempo = %3 @ %4\n",
pos, distance, *((const Tempo*)tempo), tempo->frame())); pos, distance, *((const Tempo*)tempo), tempo->frame()));
Evoral::MusicalTime beats = Evoral::MusicalTime(); Evoral::Beats beats = Evoral::Beats();
while (distance) { while (distance) {
@ -2246,7 +2246,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
pos += sub; pos += sub;
distance -= sub; distance -= sub;
assert (tempo); assert (tempo);
beats += Evoral::MusicalTime::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate)); beats += Evoral::Beats::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate));
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("now at %1, beats = %2 distance left %3\n", DEBUG_TRACE (DEBUG::TempoMath, string_compose ("now at %1, beats = %2 distance left %3\n",
pos, beats, distance)); pos, beats, distance));

View file

@ -26,11 +26,11 @@ FrameposMinusBeatsTest::singleTempoTest ()
map.add_tempo (tempo, BBT_Time (1, 1, 0)); map.add_tempo (tempo, BBT_Time (1, 1, 0));
/* Subtract 1 beat from beat 3 of the first bar */ /* Subtract 1 beat from beat 3 of the first bar */
framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, MusicalTime(1)); framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (frames_per_beat * 1)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (frames_per_beat * 1));
/* Subtract 4 beats from 3 beats in, to go beyond zero */ /* Subtract 4 beats from 3 beats in, to go beyond zero */
r = map.framepos_minus_beats (frames_per_beat * 3, MusicalTime(4)); r = map.framepos_minus_beats (frames_per_beat * 3, Beats(4));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (- frames_per_beat)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (- frames_per_beat));
} }
@ -70,15 +70,15 @@ FrameposMinusBeatsTest::doubleTempoTest ()
/* Now some tests */ /* Now some tests */
/* Subtract 1 beat from 1|2 */ /* Subtract 1 beat from 1|2 */
framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1)); framepos_t r = map.framepos_minus_beats (24e3, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (0)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (0));
/* Subtract 2 beats from 4|2 (over the tempo change) */ /* Subtract 2 beats from 4|2 (over the tempo change) */
r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2)); r = map.framepos_minus_beats (288e3 + 12e3, Beats(2));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3));
/* Subtract 2.5 beats from 4|2 (over the tempo change) */ /* Subtract 2.5 beats from 4|2 (over the tempo change) */
r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5)); r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3));
} }
@ -124,15 +124,15 @@ FrameposMinusBeatsTest::doubleTempoWithMeterTest ()
/* Now some tests */ /* Now some tests */
/* Subtract 1 beat from 1|2 */ /* Subtract 1 beat from 1|2 */
framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1)); framepos_t r = map.framepos_minus_beats (24e3, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (0)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (0));
/* Subtract 2 beats from 4|2 (over the tempo change) */ /* Subtract 2 beats from 4|2 (over the tempo change) */
r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2)); r = map.framepos_minus_beats (288e3 + 12e3, Beats(2));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3));
/* Subtract 2.5 beats from 4|2 (over the tempo change) */ /* Subtract 2.5 beats from 4|2 (over the tempo change) */
r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5)); r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3));
} }

View file

@ -25,11 +25,11 @@ FrameposPlusBeatsTest::singleTempoTest ()
map.add_tempo (tempo, BBT_Time (1, 1, 0)); map.add_tempo (tempo, BBT_Time (1, 1, 0));
/* Add 1 beat to beat 3 of the first bar */ /* Add 1 beat to beat 3 of the first bar */
framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::MusicalTime(1)); framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r);
/* Add 4 beats to a -ve frame of 1 beat before zero */ /* Add 4 beats to a -ve frame of 1 beat before zero */
r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::MusicalTime(4)); r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::Beats(4));
CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r);
} }
@ -69,15 +69,15 @@ FrameposPlusBeatsTest::doubleTempoTest ()
/* Now some tests */ /* Now some tests */
/* Add 1 beat to 1|2 */ /* Add 1 beat to 1|2 */
framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1)); framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r);
/* Add 2 beats to 3|4 (over the tempo change) */ /* Add 2 beats to 3|4 (over the tempo change) */
r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2)); r = map.framepos_plus_beats (264e3, Evoral::Beats(2));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
/* Add 2.5 beats to 3|3|960 (over the tempo change) */ /* Add 2.5 beats to 3|3|960 (over the tempo change) */
r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5)); r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
} }
@ -123,15 +123,15 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest ()
/* Now some tests */ /* Now some tests */
/* Add 1 beat to 1|2 */ /* Add 1 beat to 1|2 */
framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1)); framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r);
/* Add 2 beats to 3|4 (over the tempo change) */ /* Add 2 beats to 3|4 (over the tempo change) */
r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2)); r = map.framepos_plus_beats (264e3, Evoral::Beats(2));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
/* Add 2.5 beats to 3|3|960 (over the tempo change) */ /* Add 2.5 beats to 3|3|960 (over the tempo change) */
r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5)); r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
} }

View file

@ -121,7 +121,7 @@ Transform::Operation::eval(Context& ctx) const
Command* Command*
Transform::operator()(boost::shared_ptr<MidiModel> model, Transform::operator()(boost::shared_ptr<MidiModel> model,
Evoral::MusicalTime position, Evoral::Beats position,
std::vector<Notes>& seqs) std::vector<Notes>& seqs)
{ {
typedef MidiModel::NoteDiffCommand Command; typedef MidiModel::NoteDiffCommand Command;

View file

@ -0,0 +1,247 @@
/* This file is part of Evoral.
* Copyright (C) 2008-2015 David Robillard <http://drobilla.net>
* Copyright (C) 2000-2008 Paul Davis
*
* Evoral 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.
*
* Evoral 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 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.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef EVORAL_BEATS_HPP
#define EVORAL_BEATS_HPP
#include <float.h>
#include <math.h>
#include <stdint.h>
#include <iostream>
#include <limits>
#include "evoral/visibility.h"
namespace Evoral {
/** Musical time in beats. */
class /*LIBEVORAL_API*/ Beats {
public:
LIBEVORAL_API static const double PPQN;
Beats() : _time(0.0) {}
/** Create from a real number of beats. */
explicit Beats(double time) : _time(time) {}
/** Create from an integer number of beats. */
static Beats beats(int32_t beats) {
return Beats((double)beats);
}
/** Create from ticks at the standard PPQN. */
static Beats ticks(uint32_t ticks) {
return Beats(ticks / PPQN);
}
/** Create from ticks at a given rate.
*
* Note this can also be used to create from frames by setting ppqn to the
* number of samples per beat.
*/
static Beats ticks_at_rate(uint64_t ticks, uint32_t ppqn) {
return Beats((double)ticks / (double)ppqn);
}
Beats& operator=(const Beats& other) {
_time = other._time;
return *this;
}
Beats round_up_to_beat() const {
return Evoral::Beats(ceil(_time));
}
Beats round_down_to_beat() const {
return Evoral::Beats(floor(_time));
}
Beats snap_to(const Evoral::Beats& snap) const {
return Beats(ceil(_time / snap._time) * snap._time);
}
inline bool operator==(const Beats& b) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - b._time) <= (1.0 / PPQN);
}
inline bool operator==(double t) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - t) <= (1.0 / PPQN);
}
inline bool operator==(int beats) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - beats) <= (1.0 / PPQN);
}
inline bool operator!=(const Beats& b) const {
return !operator==(b);
}
inline bool operator<(const Beats& b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b._time) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time < b._time;
}
}
inline bool operator<=(const Beats& b) const {
return operator==(b) || operator<(b);
}
inline bool operator>(const Beats& b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b._time) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time > b._time;
}
}
inline bool operator>=(const Beats& b) const {
return operator==(b) || operator>(b);
}
inline bool operator<(double b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time < b;
}
}
inline bool operator<=(double b) const {
return operator==(b) || operator<(b);
}
inline bool operator>(double b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time > b;
}
}
inline bool operator>=(double b) const {
return operator==(b) || operator>(b);
}
Beats operator+(const Beats& b) const {
return Beats(_time + b._time);
}
Beats operator-(const Beats& b) const {
return Beats(_time - b._time);
}
Beats operator+(double d) const {
return Beats(_time + d);
}
Beats operator-(double d) const {
return Beats(_time - d);
}
Beats operator-() const {
return Beats(-_time);
}
template<typename Number>
Beats operator*(Number factor) const {
return Beats(_time * factor);
}
Beats& operator+=(const Beats& b) {
_time += b._time;
return *this;
}
Beats& operator-=(const Beats& b) {
_time -= b._time;
return *this;
}
double to_double() const { return _time; }
uint64_t to_ticks() const { return lrint(_time * PPQN); }
uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); }
uint32_t get_beats() const { return floor(_time); }
uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); }
bool operator!() const { return _time == 0; }
static Beats min() { return Beats(DBL_MIN); }
static Beats max() { return Beats(DBL_MAX); }
static Beats tick() { return Beats(1.0 / PPQN); }
private:
double _time;
};
extern LIBEVORAL_API const Beats MaxBeats;
extern LIBEVORAL_API const Beats MinBeats;
/*
TIL, several horrible hours later, that sometimes the compiler looks in the
namespace of a type (Evoral::Beats in this case) for an operator, and
does *NOT* look in the global namespace.
C++ is proof that hell exists and we are living in it. In any case, move
these to the global namespace and PBD::Property's loopy
virtual-method-in-a-template will bite you.
*/
inline std::ostream&
operator<<(std::ostream& os, const Beats& t)
{
os << t.to_double();
return os;
}
inline std::istream&
operator>>(std::istream& is, Beats& t)
{
double beats;
is >> beats;
t = Beats(beats);
return is;
}
} // namespace Evoral
namespace PBD {
namespace DEBUG {
LIBEVORAL_API extern uint64_t Beats;
}
}
namespace std {
template<>
struct numeric_limits<Evoral::Beats> {
static Evoral::Beats min() { return Evoral::Beats::min(); }
static Evoral::Beats max() { return Evoral::Beats::max(); }
};
}
#endif // EVORAL_BEATS_HPP

View file

@ -27,6 +27,7 @@
#include <limits> #include <limits>
#include <list> #include <list>
#include "evoral/Beats.hpp"
#include "evoral/visibility.h" #include "evoral/visibility.h"
#include "pbd/debug.h" #include "pbd/debug.h"
@ -38,207 +39,9 @@ namespace Evoral {
*/ */
typedef int32_t event_id_t; typedef int32_t event_id_t;
/** Musical time: beats relative to some defined origin */
class /*LIBEVORAL_API*/ MusicalTime {
public:
LIBEVORAL_API static const double PPQN;
MusicalTime() : _time(0.0) {}
/** Create from a real number of beats. */
explicit MusicalTime(double time) : _time(time) {}
/** Create from an integer number of beats. */
static MusicalTime beats(int32_t beats) {
return MusicalTime((double)beats);
}
/** Create from ticks at the standard PPQN. */
static MusicalTime ticks(uint32_t ticks) {
return MusicalTime(ticks / PPQN);
}
/** Create from ticks at a given rate.
*
* Note this can also be used to create from frames by setting ppqn to the
* number of samples per beat.
*/
static MusicalTime ticks_at_rate(uint64_t ticks, uint32_t ppqn) {
return MusicalTime((double)ticks / (double)ppqn);
}
MusicalTime& operator=(const MusicalTime& other) {
_time = other._time;
return *this;
}
MusicalTime round_up_to_beat() const {
return Evoral::MusicalTime(ceil(_time));
}
MusicalTime round_down_to_beat() const {
return Evoral::MusicalTime(floor(_time));
}
MusicalTime snap_to(const Evoral::MusicalTime& snap) const {
return MusicalTime(ceil(_time / snap._time) * snap._time);
}
inline bool operator==(const MusicalTime& b) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - b._time) <= (1.0 / PPQN);
}
inline bool operator==(double t) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - t) <= (1.0 / PPQN);
}
inline bool operator==(int beats) const {
/* Acceptable tolerance is 1 tick. */
return fabs(_time - beats) <= (1.0 / PPQN);
}
inline bool operator!=(const MusicalTime& b) const {
return !operator==(b);
}
inline bool operator<(const MusicalTime& b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b._time) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time < b._time;
}
}
inline bool operator<=(const MusicalTime& b) const {
return operator==(b) || operator<(b);
}
inline bool operator>(const MusicalTime& b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b._time) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time > b._time;
}
}
inline bool operator>=(const MusicalTime& b) const {
return operator==(b) || operator>(b);
}
inline bool operator<(double b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time < b;
}
}
inline bool operator<=(double b) const {
return operator==(b) || operator<(b);
}
inline bool operator>(double b) const {
/* Acceptable tolerance is 1 tick. */
if (fabs(_time - b) <= (1.0 / PPQN)) {
return false; /* Effectively identical. */
} else {
return _time > b;
}
}
inline bool operator>=(double b) const {
return operator==(b) || operator>(b);
}
MusicalTime operator+(const MusicalTime& b) const {
return MusicalTime(_time + b._time);
}
MusicalTime operator-(const MusicalTime& b) const {
return MusicalTime(_time - b._time);
}
MusicalTime operator+(double d) const {
return MusicalTime(_time + d);
}
MusicalTime operator-(double d) const {
return MusicalTime(_time - d);
}
MusicalTime operator-() const {
return MusicalTime(-_time);
}
template<typename Number>
MusicalTime operator*(Number factor) const {
return MusicalTime(_time * factor);
}
MusicalTime& operator+=(const MusicalTime& b) {
_time += b._time;
return *this;
}
MusicalTime& operator-=(const MusicalTime& b) {
_time -= b._time;
return *this;
}
double to_double() const { return _time; }
uint64_t to_ticks() const { return lrint(_time * PPQN); }
uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); }
uint32_t get_beats() const { return floor(_time); }
uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); }
bool operator!() const { return _time == 0; }
static MusicalTime min() { return MusicalTime(DBL_MIN); }
static MusicalTime max() { return MusicalTime(DBL_MAX); }
static MusicalTime tick() { return MusicalTime(1.0 / PPQN); }
private:
double _time;
};
extern LIBEVORAL_API const MusicalTime MaxMusicalTime;
extern LIBEVORAL_API const MusicalTime MinMusicalTime;
/** Type of an event (opaque, mapped by application) */ /** Type of an event (opaque, mapped by application) */
typedef uint32_t EventType; typedef uint32_t EventType;
/*
TIL, several horrible hours later, that sometimes the compiler looks in the
namespace of a type (Evoral::MusicalTime in this case) for an operator, and
does *NOT* look in the global namespace.
C++ is proof that hell exists and we are living in it. In any case, move
these to the global namespace and PBD::Property's loopy
virtual-method-in-a-template will bite you.
*/
inline std::ostream&
operator<<(std::ostream& os, const MusicalTime& t)
{
os << t.to_double();
return os;
}
inline std::istream&
operator>>(std::istream& is, MusicalTime& t)
{
double beats;
is >> beats;
t = MusicalTime(beats);
return is;
}
} // namespace Evoral } // namespace Evoral
namespace PBD { namespace PBD {
@ -246,16 +49,7 @@ namespace PBD {
LIBEVORAL_API extern uint64_t Sequence; LIBEVORAL_API extern uint64_t Sequence;
LIBEVORAL_API extern uint64_t Note; LIBEVORAL_API extern uint64_t Note;
LIBEVORAL_API extern uint64_t ControlList; LIBEVORAL_API extern uint64_t ControlList;
LIBEVORAL_API extern uint64_t MusicalTime;
} }
} }
namespace std {
template<>
struct numeric_limits<Evoral::MusicalTime> {
static Evoral::MusicalTime min() { return Evoral::MusicalTime::min(); }
static Evoral::MusicalTime max() { return Evoral::MusicalTime::max(); }
};
}
#endif // EVORAL_TYPES_HPP #endif // EVORAL_TYPES_HPP

View file

@ -155,7 +155,7 @@ Event<Timestamp>::set_original_time (Timestamp t)
#endif // EVORAL_EVENT_ALLOC #endif // EVORAL_EVENT_ALLOC
template class Event<Evoral::MusicalTime>; template class Event<Evoral::Beats>;
template class Event<double>; template class Event<double>;
template class Event<int64_t>; template class Event<int64_t>;

View file

@ -102,7 +102,7 @@ MIDIEvent<Time>::to_xml() const
#endif // EVORAL_MIDI_XML #endif // EVORAL_MIDI_XML
template class MIDIEvent<Evoral::MusicalTime>; template class MIDIEvent<Evoral::Beats>;
} // namespace Evoral } // namespace Evoral

View file

@ -108,7 +108,7 @@ Note<Time>::operator=(const Note<Time>& other)
return *this; return *this;
} }
template class Note<Evoral::MusicalTime>; template class Note<Evoral::Beats>;
} // namespace Evoral } // namespace Evoral

View file

@ -364,6 +364,6 @@ SMF<Time>::write_var_len(uint32_t value)
return ret; return ret;
} }
template class SMF<Evoral::MusicalTime>; template class SMF<Evoral::Beats>;
} // namespace Evoral } // namespace Evoral

View file

@ -1404,6 +1404,6 @@ Sequence<Time>::dump (ostream& str) const
str << "--- dump\n"; str << "--- dump\n";
} }
template class Sequence<Evoral::MusicalTime>; template class Sequence<Evoral::Beats>;
} // namespace Evoral } // namespace Evoral

View file

@ -45,6 +45,6 @@ IdentityConverter<A,B>::from(B b) const
template class IdentityConverter<double, framepos_t>; template class IdentityConverter<double, framepos_t>;
template class TimeConverter<double, framepos_t>; template class TimeConverter<double, framepos_t>;
template class TimeConverter<Evoral::MusicalTime, framepos_t>; template class TimeConverter<Evoral::Beats, framepos_t>;
} // namespace Evoral } // namespace Evoral

View file

@ -22,8 +22,8 @@
namespace Evoral { namespace Evoral {
const double MusicalTime::PPQN = 1920.0; const double Beats::PPQN = 1920.0;
const MusicalTime MaxMusicalTime = Evoral::MusicalTime(DBL_MAX); const Beats MaxBeats = Evoral::Beats(DBL_MAX);
const MusicalTime MinMusicalTime = Evoral::MusicalTime(DBL_MIN); const Beats MinBeats = Evoral::Beats(DBL_MIN);
} }

View file

@ -45,25 +45,25 @@ SMFTest::takeFiveTest ()
smf.seek_to_start(); smf.seek_to_start();
uint64_t time = 0; /* in SMF ticks */ uint64_t time = 0; /* in SMF ticks */
Evoral::Event<Evoral::MusicalTime> ev; Evoral::Event<Evoral::Beats> ev;
uint32_t delta_t = 0; uint32_t delta_t = 0;
uint32_t size = 0; uint32_t size = 0;
uint8_t* buf = NULL; uint8_t* buf = NULL;
int ret; int ret;
while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) { while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) {
ev.set(buf, size, Evoral::MusicalTime()); ev.set(buf, size, Evoral::Beats());
time += delta_t; time += delta_t;
if (ret > 0) { // didn't skip (meta) event if (ret > 0) { // didn't skip (meta) event
//cerr << "read smf event type " << hex << int(buf[0]) << endl; //cerr << "read smf event type " << hex << int(buf[0]) << endl;
ev.set_time(Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn())); ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
ev.set_event_type(type_map->midi_event_type(buf[0])); ev.set_event_type(type_map->midi_event_type(buf[0]));
seq->append(ev, next_event_id ()); seq->append(ev, next_event_id ());
} }
} }
seq->end_write (Sequence<Time>::Relax, seq->end_write (Sequence<Time>::Relax,
Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn())); Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
CPPUNIT_ASSERT(!seq->empty()); CPPUNIT_ASSERT(!seq->empty());
} }

View file

@ -57,7 +57,7 @@ class SMFTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
typedef Evoral::MusicalTime Time; typedef Evoral::Beats Time;
void setUp() { void setUp() {
type_map = new DummyTypeMap(); type_map = new DummyTypeMap();

View file

@ -75,7 +75,7 @@ SequenceTest::iteratorSeekTest ()
} }
bool on = true; bool on = true;
for (Sequence<Time>::const_iterator i = seq->begin(Evoral::MusicalTime(600)); i != seq->end(); ++i) { for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) {
if (on) { if (on) {
CPPUNIT_ASSERT(((const MIDIEvent<Time>&)*i).is_note_on()); CPPUNIT_ASSERT(((const MIDIEvent<Time>&)*i).is_note_on());
CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100)); CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100));

View file

@ -113,7 +113,7 @@ class SequenceTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END (); CPPUNIT_TEST_SUITE_END ();
public: public:
typedef MusicalTime Time; typedef Beats Time;
typedef std::vector< boost::shared_ptr< Note<Time> > > Notes; typedef std::vector< boost::shared_ptr< Note<Time> > > Notes;
void setUp () { void setUp () {
@ -125,7 +125,7 @@ public:
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
test_notes.push_back( test_notes.push_back(
boost::shared_ptr<Note<Time> >( boost::shared_ptr<Note<Time> >(
new Note<Time>(0, MusicalTime(i * 100), MusicalTime(100), 64 + i, 64))); new Note<Time>(0, Beats(i * 100), Beats(100), 64 + i, 64)));
} }
} }

View file

@ -97,7 +97,7 @@ Patch::get_state (void)
node->add_property("Name", _name); node->add_property("Name", _name);
/* /*
typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::MusicalTime> > > PatchMidiCommands; typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::Beats> > > PatchMidiCommands;
XMLNode* commands = node->add_child("PatchMIDICommands"); XMLNode* commands = node->add_child("PatchMIDICommands");
for (PatchMidiCommands::const_iterator event = _patch_midi_commands.begin(); for (PatchMidiCommands::const_iterator event = _patch_midi_commands.begin();
event != _patch_midi_commands.end(); event != _patch_midi_commands.end();