diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index 7d114d49ed..0c0dba3d96 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -113,6 +113,8 @@ class SMFSource : public MidiSource, public Evoral::SMF { bool find (std::string path, bool must_exist, bool& is_new); bool removable() const; bool writable() const { return _flags & Writable; } + + void make_sure_controls_have_the_right_interpolation(); Glib::ustring _path; Flag _flags; diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index cf01cb808b..dadd7a8e0a 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -235,7 +235,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt) ev.set(buf, size, time); ev.set_event_type(EventTypeMap::instance().midi_event_type(ev.buffer()[0])); if (! (ev.is_channel_event() || ev.is_smf_meta_event() || ev.is_sysex()) ) { - //cerr << "SMFSource: WARNING: caller tried to write non SMF-Event of type " << std::hex << int(ev.buffer()[0]) << endl; + cerr << "SMFSource: WARNING: caller tried to write non SMF-Event of type " << std::hex << int(ev.buffer()[0]) << endl; continue; } @@ -246,6 +246,10 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt) } } + if (_model) { + make_sure_controls_have_the_right_interpolation(); + } + SMF::flush(); free(buf); @@ -660,17 +664,7 @@ SMFSource::load_model(bool lock, bool force_reload) } } - // set interpolation style to defaults, can be changed by the GUI later - Evoral::ControlSet::Controls controls = _model->controls(); - for (Evoral::ControlSet::Controls::iterator c = controls.begin(); c != controls.end(); ++c) { - (*c).second->list()->set_interpolation( - // to be enabled when ControlList::rt_safe_earliest_event_linear_unlocked works properly - #if 0 - EventTypeMap::instance().interpolation_of((*c).first)); - #else - Evoral::ControlList::Discrete); - #endif - } + make_sure_controls_have_the_right_interpolation(); _model->end_write(false); _model->set_edited(false); @@ -678,6 +672,24 @@ SMFSource::load_model(bool lock, bool force_reload) free(buf); } +#define LINEAR_INTERPOLATION_MODE_WORKS_PROPERLY 0 + +void +SMFSource::make_sure_controls_have_the_right_interpolation() +{ + // set interpolation style to defaults, can be changed by the GUI later + Evoral::ControlSet::Controls controls = _model->controls(); + for (Evoral::ControlSet::Controls::iterator c = controls.begin(); c != controls.end(); ++c) { + (*c).second->list()->set_interpolation( + // to be enabled when ControlList::rt_safe_earliest_event_linear_unlocked works properly + #if LINEAR_INTERPOLATION_MODE_WORKS_PROPERLY + EventTypeMap::instance().interpolation_of((*c).first)); + #else + Evoral::ControlList::Discrete); + #endif + } +} + void SMFSource::destroy_model()