* set right interpolation on MidiModel controls after recording too
authorHans Baier <hansfbaier@googlemail.com>
Thu, 29 Jan 2009 00:18:26 +0000 (00:18 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Thu, 29 Jan 2009 00:18:26 +0000 (00:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4459 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/smf_source.h
libs/ardour/smf_source.cc

index 7d114d49edda20d6e7dece2080062770c7e6718d..0c0dba3d96f26da36a7dfd13069939193870b16f 100644 (file)
@@ -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;
index cf01cb808ba7d79aa59e137aea1a215e19a9c107..dadd7a8e0a5e2b2a630adacd18661ab6d3e93c11 100644 (file)
@@ -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,22 +664,30 @@ SMFSource::load_model(bool lock, bool force_reload)
                }
        }
 
+       make_sure_controls_have_the_right_interpolation();
+       
+       _model->end_write(false);
+       _model->set_edited(false);
+
+       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 0
+                       #if LINEAR_INTERPOLATION_MODE_WORKS_PROPERLY
                        EventTypeMap::instance().interpolation_of((*c).first));
                        #else
                        Evoral::ControlList::Discrete);
                        #endif
        }
-       
-       _model->end_write(false);
-       _model->set_edited(false);
-
-       free(buf);
 }