mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-19 05:06:31 +01:00
convert codebase to use Temporal for various time types
This commit is contained in:
parent
9283bee867
commit
7db12f6b12
114 changed files with 567 additions and 598 deletions
|
|
@ -284,7 +284,7 @@ SMFSource::read_unlocked (const Lock& lock,
|
|||
/* Note that we add on the source start time (in session samples) here so that ev_sample_time
|
||||
is in session samples.
|
||||
*/
|
||||
const samplepos_t ev_sample_time = converter.to(Evoral::Beats::ticks_at_rate(time, ppqn())) + source_start;
|
||||
const samplepos_t ev_sample_time = converter.to(Temporal::Beats::ticks_at_rate(time, ppqn())) + source_start;
|
||||
|
||||
if (loop_range) {
|
||||
loop_range->squish (ev_sample_time);
|
||||
|
|
@ -393,7 +393,7 @@ SMFSource::write_unlocked (const Lock& lock,
|
|||
/** Append an event with a timestamp in beats */
|
||||
void
|
||||
SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
|
||||
const Evoral::Event<Evoral::Beats>& ev)
|
||||
const Evoral::Event<Temporal::Beats>& ev)
|
||||
{
|
||||
if (!_writing || ev.size() == 0) {
|
||||
return;
|
||||
|
|
@ -405,9 +405,9 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
|
|||
for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n");
|
||||
#endif
|
||||
|
||||
Evoral::Beats time = ev.time();
|
||||
Temporal::Beats time = ev.time();
|
||||
if (time < _last_ev_time_beats) {
|
||||
const Evoral::Beats difference = _last_ev_time_beats - time;
|
||||
const Temporal::Beats difference = _last_ev_time_beats - time;
|
||||
if (difference.to_double() / (double)ppqn() < 1.0) {
|
||||
/* Close enough. This problem occurs because Sequence is not
|
||||
actually ordered due to fuzzy time comparison. I'm pretty sure
|
||||
|
|
@ -437,7 +437,7 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
|
|||
|
||||
_length_beats = max(_length_beats, time);
|
||||
|
||||
const Evoral::Beats delta_time_beats = time - _last_ev_time_beats;
|
||||
const Temporal::Beats delta_time_beats = time - _last_ev_time_beats;
|
||||
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);
|
||||
|
|
@ -467,7 +467,7 @@ SMFSource::append_event_samples (const Glib::Threads::Mutex::Lock& lock,
|
|||
}
|
||||
|
||||
BeatsSamplesConverter converter(_session.tempo_map(), position);
|
||||
const Evoral::Beats ev_time_beats = converter.from(ev.time());
|
||||
const Temporal::Beats ev_time_beats = converter.from(ev.time());
|
||||
Evoral::event_id_t event_id;
|
||||
|
||||
if (ev.id() < 0) {
|
||||
|
|
@ -477,7 +477,7 @@ SMFSource::append_event_samples (const Glib::Threads::Mutex::Lock& lock,
|
|||
}
|
||||
|
||||
if (_model) {
|
||||
const Evoral::Event<Evoral::Beats> beat_ev (ev.event_type(),
|
||||
const Evoral::Event<Temporal::Beats> beat_ev (ev.event_type(),
|
||||
ev_time_beats,
|
||||
ev.size(),
|
||||
const_cast<uint8_t*>(ev.buffer()));
|
||||
|
|
@ -486,8 +486,8 @@ SMFSource::append_event_samples (const Glib::Threads::Mutex::Lock& lock,
|
|||
|
||||
_length_beats = max(_length_beats, ev_time_beats);
|
||||
|
||||
const Evoral::Beats last_time_beats = converter.from (_last_ev_time_samples);
|
||||
const Evoral::Beats delta_time_beats = ev_time_beats - last_time_beats;
|
||||
const Temporal::Beats last_time_beats = converter.from (_last_ev_time_samples);
|
||||
const Temporal::Beats delta_time_beats = ev_time_beats - last_time_beats;
|
||||
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);
|
||||
|
|
@ -532,18 +532,18 @@ SMFSource::mark_streaming_midi_write_started (const Lock& lock, NoteMode mode)
|
|||
|
||||
MidiSource::mark_streaming_midi_write_started (lock, mode);
|
||||
Evoral::SMF::begin_write ();
|
||||
_last_ev_time_beats = Evoral::Beats();
|
||||
_last_ev_time_beats = Temporal::Beats();
|
||||
_last_ev_time_samples = 0;
|
||||
}
|
||||
|
||||
void
|
||||
SMFSource::mark_streaming_write_completed (const Lock& lock)
|
||||
{
|
||||
mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
|
||||
mark_midi_streaming_write_completed (lock, Evoral::Sequence<Temporal::Beats>::DeleteStuckNotes);
|
||||
}
|
||||
|
||||
void
|
||||
SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_notes_option, Evoral::Beats when)
|
||||
SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Temporal::Beats>::StuckNoteOption stuck_notes_option, Temporal::Beats when)
|
||||
{
|
||||
MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when);
|
||||
|
||||
|
|
@ -601,8 +601,8 @@ SMFSource::safe_midi_file_extension (const string& file)
|
|||
}
|
||||
|
||||
static bool compare_eventlist (
|
||||
const std::pair< const Evoral::Event<Evoral::Beats>*, gint >& a,
|
||||
const std::pair< const Evoral::Event<Evoral::Beats>*, gint >& b) {
|
||||
const std::pair< const Evoral::Event<Temporal::Beats>*, gint >& a,
|
||||
const std::pair< const Evoral::Event<Temporal::Beats>*, gint >& b) {
|
||||
return ( a.first->time() < b.first->time() );
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
Evoral::SMF::seek_to_start();
|
||||
|
||||
uint64_t time = 0; /* in SMF ticks */
|
||||
Evoral::Event<Evoral::Beats> ev;
|
||||
Evoral::Event<Temporal::Beats> ev;
|
||||
|
||||
uint32_t scratch_size = 0; // keep track of scratch and minimize reallocs
|
||||
|
||||
|
|
@ -645,7 +645,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
bool have_event_id;
|
||||
|
||||
// TODO simplify event allocation
|
||||
std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > > eventlist;
|
||||
std::list< std::pair< Evoral::Event<Temporal::Beats>*, gint > > eventlist;
|
||||
|
||||
for (unsigned i = 1; i <= num_tracks(); ++i) {
|
||||
if (seek_to_track(i)) continue;
|
||||
|
|
@ -671,7 +671,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
if (!have_event_id) {
|
||||
event_id = Evoral::next_event_id();
|
||||
}
|
||||
const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn());
|
||||
const Temporal::Beats event_time = Temporal::Beats::ticks_at_rate(time, ppqn());
|
||||
#ifndef NDEBUG
|
||||
std::string ss;
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
#endif
|
||||
|
||||
eventlist.push_back(make_pair (
|
||||
new Evoral::Event<Evoral::Beats> (
|
||||
new Evoral::Event<Temporal::Beats> (
|
||||
Evoral::MIDI_EVENT, event_time,
|
||||
size, buf, true)
|
||||
, event_id));
|
||||
|
|
@ -705,7 +705,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
|
||||
eventlist.sort(compare_eventlist);
|
||||
|
||||
std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > >::iterator it;
|
||||
std::list< std::pair< Evoral::Event<Temporal::Beats>*, gint > >::iterator it;
|
||||
for (it=eventlist.begin(); it!=eventlist.end(); ++it) {
|
||||
_model->append (*it->first, it->second);
|
||||
delete it->first;
|
||||
|
|
@ -715,7 +715,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
|||
// _playback_buf->dump (cerr);
|
||||
// cerr << "----------------\n";
|
||||
|
||||
_model->end_write (Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, _length_beats);
|
||||
_model->end_write (Evoral::Sequence<Temporal::Beats>::ResolveStuckNotes, _length_beats);
|
||||
_model->set_edited (false);
|
||||
invalidate(lock);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue