diff options
author | David Robillard <d@drobilla.net> | 2009-02-16 02:51:16 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-16 02:51:16 +0000 |
commit | 3963d2b0b224e79fdf8e852e39fc3a765fa1431b (patch) | |
tree | 0c6c8a9d519d46437ffe9cb96f09ca337f33faff /gtk2_ardour/midi_region_view.cc | |
parent | beb3eea62bf217d0a7b2a86a96d5c375329df10a (diff) |
Move all beats <-> frames time conversion into a single object that can be passed around.
This has 3 main benefits:
- All conversion code is in one place (less duplication, potential bugs)
- The conversion method can be passed to things that are ignorant
of the actual time units involved, information required, etc.
(In the future it would be nice to have user selectable tempo/frame time)
- It should be relatively simple now to support tempo changes part-way
through a MIDI region (at least architecturally speaking)
git-svn-id: svn://localhost/ardour2/branches/3.0@4594 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 5339131c8e..7a4acb560d 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -641,9 +641,6 @@ MidiRegionView::display_program_change_flags() } } break; - } else if (control->first.type() == MidiCCAutomation) { - //cerr << " found CC Automation of channel " << int(control->first.channel()) - // << " and id " << control->first.id() << endl; } } } @@ -1391,17 +1388,13 @@ MidiRegionView::get_position_pixels() nframes64_t MidiRegionView::beats_to_frames(double beats) const { - const Meter& m = trackview.session().tempo_map().meter_at(_region->position()); - const Tempo& t = trackview.session().tempo_map().tempo_at(_region->position()); - return lrint(beats * m.frames_per_bar(t, trackview.session().frame_rate()) / m.beats_per_bar()); + return midi_region()->midi_source()->converter().to(beats); } double MidiRegionView::frames_to_beats(nframes64_t frames) const { - const Meter& m = trackview.session().tempo_map().meter_at(_region->position()); - const Tempo& t = trackview.session().tempo_map().tempo_at(_region->position()); - return frames / m.frames_per_bar(t, trackview.session().frame_rate()) * m.beats_per_bar(); + return midi_region()->midi_source()->converter().from(frames); } void |