* fixed some valgrind issues (uninitialized instance vars)
authorHans Baier <hansfbaier@googlemail.com>
Thu, 8 May 2008 09:53:19 +0000 (09:53 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Thu, 8 May 2008 09:53:19 +0000 (09:53 +0000)
* Added preliminary support for program changes flags from automation lists

git-svn-id: svn://localhost/ardour2/branches/3.0@3327 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_clock.cc
gtk2_ardour/midi_region_view.cc
libs/ardour/ardour/midi_model.h
libs/ardour/midi_model.cc
libs/ardour/region.cc
libs/ardour/smf_source.cc

index 3ca5ca38e47591c78fe6b8a8ac54b8b441b1db86..5ce5159e7299bdf914c1344c64b24c6958cb260b 100644 (file)
@@ -74,7 +74,8 @@ AudioClock::AudioClock (std::string clock_name, bool transient, std::string widg
          colon4 (":"),
          colon5 (":"),
          b1 ("|"),
-         b2 ("|")
+         b2 ("|"),
+         last_when(0)
 {
        session = 0;
        last_when = 0;
index aa245ed0e11e6b371178f0b660bb6e0ba6a424fa..5b0f3070d4112f9ee08e6bce2524a1b9ad4a3cd6 100644 (file)
@@ -460,7 +460,7 @@ MidiRegionView::redisplay_model()
 
                _model->read_lock();
 
-               /*
+               
                MidiModel::Notes notes = _model->notes();
                cerr << endl << "Model contains " << notes.size() << " Notes:" << endl;
                for(MidiModel::Notes::iterator i = notes.begin(); i != notes.end(); ++i) {
@@ -471,13 +471,29 @@ MidiRegionView::redisplay_model()
                             //<< " Note-on: " << note.on_event(). 
                             //<< " Note-off: " << note.off_event() 
                             << endl;
-               }*/
+               }
                
                for (size_t i=0; i < _model->n_notes(); ++i) {
                        add_note(_model->note_at(i));
                }
 
-               // TODO: Add program changes here
+               for (Automatable::Controls::iterator 
+                    control = _model->controls().begin();
+                               control != _model->controls().end(); ++control) {
+
+                       if( control->first.type() == MidiPgmChangeAutomation ) {
+                               Glib::Mutex::Lock list_lock (control->second->list()->lock());
+                               
+                               for(AutomationList::const_iterator event = control->second->list()->begin();
+                               event != control->second->list()->end(); ++event) {
+                                       boost::shared_ptr<MIDI::Event> midi_event(new MIDI::Event());
+                                       MidiControlIterator iter(control->second->list(), (*event)->when, (*event)->value);
+                                       _model->control_to_midi_event(*midi_event, iter);
+                                       add_pgm_change(midi_event);
+                               }
+                               break;
+                       }
+               }
 
                end_write();
 
index 39987dfe7ac68f0982051b9474f69bf02408ad11..3d49123b948d678e03a0e6cc86ba9d7413b5c7d4 100644 (file)
@@ -39,7 +39,9 @@ namespace ARDOUR {
 class Session;
 class MidiSource;
        
-
+/**
+ * This class keeps track of the current x and y for a control
+ */
 class MidiControlIterator {
 public:
        boost::shared_ptr<const AutomationList> automation_list;
@@ -197,6 +199,7 @@ public:
        
        const MidiSource* midi_source() const { return _midi_source; }
        void set_midi_source(MidiSource* source) { _midi_source = source; } 
+       bool control_to_midi_event(MIDI::Event& ev, const MidiControlIterator& iter) const;
        
 private:
        friend class DeltaCommand;
@@ -204,7 +207,6 @@ private:
        void remove_note_unlocked(const boost::shared_ptr<const Note> note);
 
        friend class const_iterator;
-       bool control_to_midi_event(MIDI::Event& ev, const MidiControlIterator& iter) const;
 
 #ifndef NDEBUG
        bool is_sorted() const;
index f17324e8c69b9d4cf55cfad2b828fa3b52283907..e544a64afb7cfc8ecdbce1875bb4ed9cd67cb3f7 100644 (file)
@@ -121,10 +121,11 @@ MidiModel::const_iterator::const_iterator(const MidiModel& model, double t)
                ++_note_iter;
        }
 
-       if (earliest_control.automation_list.get() && earliest_control.x < _event.time())
+       if (earliest_control.automation_list.get() && earliest_control.x < _event.time()) {
                model.control_to_midi_event(_event, earliest_control);
-       else
+       } else {
                _control_iter = _control_iters.end();
+       }
 
        if (_event.size() == 0) {
                //cerr << "Created MIDI iterator @ " << t << " is at end." << endl;
@@ -165,7 +166,7 @@ const MidiModel::const_iterator& MidiModel::const_iterator::operator++()
                double x = 0.0, y = 0.0;
                const bool ret = _control_iter->automation_list->rt_safe_earliest_event_unlocked(
                                _control_iter->x, DBL_MAX, x, y, false);
-               cerr << "control_iter x:" << _control_iter->x << " y:" << _control_iter->y << endl;
+               //cerr << "control_iter x:" << _control_iter->x << " y:" << _control_iter->y << endl;
 
                if (ret) {
                        cerr << "Incremented " << _control_iter->automation_list->parameter().id() << " to " << x << endl;
index 456fc152350d66ce21c1e09b7e8adc17ef7d0e96..a6d153f3592040003a97e4301d57632371e2b1a7 100644 (file)
@@ -68,6 +68,7 @@ Region::Region (Session& s, nframes_t start, nframes_t length, const string& nam
        , _layer(layer)
        , _first_edit(EditChangesNothing)
        , _frozen(0)
+       , _stretch(1.0)
        , _read_data_count(0)
        , _pending_changed(Change (0))
        , _last_layer_op(0)
@@ -97,6 +98,7 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length
        , _read_data_count(0)
        , _pending_changed(Change (0))
        , _last_layer_op(0)
+
 {
        _sources.push_back (src);
        _master_sources.push_back (src);
@@ -121,6 +123,7 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
        , _layer(layer)
        , _first_edit(EditChangesNothing)
        , _frozen(0)
+       , _stretch(1.0)
        , _read_data_count(0)
        , _pending_changed(Change (0))
        , _last_layer_op(0)
@@ -254,6 +257,7 @@ Region::Region (const SourceList& srcs, const XMLNode& node)
        , _layer(0)
        , _first_edit(EditChangesNothing)
        , _frozen(0)
+       , _stretch(1.0)
        , _read_data_count(0)
        , _pending_changed(Change(0))
        , _last_layer_op(0)
@@ -294,6 +298,7 @@ Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
        , _layer(0)
        , _first_edit(EditChangesNothing)
        , _frozen(0)
+       , _stretch(1.0)
        , _read_data_count(0)
        , _pending_changed(Change(0))
        , _last_layer_op(0)
index 46c8e4bf6f3e91e46f6ab724dd18f4d67847e48a..8c2ee6031f760647b10f6c2430d06ca8767b50a0 100644 (file)
@@ -195,7 +195,7 @@ SMFSource::seek_to_footer_position()
        // lets check if there is a track end marker at the end of the data
        fseek(_fd, -4, SEEK_END);
        size_t read_bytes = fread(buffer, sizeof(uint8_t), 4, _fd);
-       cerr << "SMFSource::seek_to_footer_position: read size: " << read_bytes << endl;
+       //cerr << "SMFSource::seek_to_footer_position: read size: " << read_bytes << endl;
        if( (read_bytes == 4) && 
            buffer[0] == 0x00 && 
            buffer[1] == 0xFF &&