mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 02:56:35 +01:00
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
This commit is contained in:
parent
beb3eea62b
commit
3963d2b0b2
13 changed files with 206 additions and 80 deletions
|
|
@ -52,16 +52,20 @@ sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated;
|
|||
MidiSource::MidiSource (Session& s, string name)
|
||||
: Source (s, name, DataType::MIDI)
|
||||
, _timeline_position(0)
|
||||
, _read_data_count(0)
|
||||
, _write_data_count(0)
|
||||
, _converter(s, _timeline_position)
|
||||
, _writing (false)
|
||||
, _last_read_end(0)
|
||||
{
|
||||
_read_data_count = 0;
|
||||
_write_data_count = 0;
|
||||
}
|
||||
|
||||
MidiSource::MidiSource (Session& s, const XMLNode& node)
|
||||
: Source (s, node)
|
||||
, _timeline_position(0)
|
||||
, _read_data_count(0)
|
||||
, _write_data_count(0)
|
||||
, _converter(s, _timeline_position)
|
||||
, _writing (false)
|
||||
, _last_read_end(0)
|
||||
{
|
||||
|
|
@ -110,12 +114,7 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_
|
|||
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
if (_model) {
|
||||
// FIXME: assumes tempo never changes after start
|
||||
const Tempo& tempo = _session.tempo_map().tempo_at(_timeline_position);
|
||||
const double frames_per_beat = tempo.frames_per_beat(
|
||||
_session.engine().frame_rate(),
|
||||
_session.tempo_map().meter_at(_timeline_position));
|
||||
#define BEATS_TO_FRAMES(t) (((t) * frames_per_beat) + stamp_offset - negative_stamp_offset)
|
||||
#define BEATS_TO_FRAMES(t) (_converter.to(t) + stamp_offset - negative_stamp_offset)
|
||||
|
||||
Evoral::Sequence<double>::const_iterator& i = _model_iter;
|
||||
|
||||
|
|
@ -161,6 +160,13 @@ MidiSource::file_changed (string path)
|
|||
return !e1;
|
||||
}
|
||||
|
||||
void
|
||||
MidiSource::set_timeline_position (nframes_t when)
|
||||
{
|
||||
_timeline_position = when;
|
||||
_converter.set_origin(when);
|
||||
}
|
||||
|
||||
void
|
||||
MidiSource::mark_streaming_midi_write_started (NoteMode mode, nframes_t start_frame)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue