Improve GUI display during MIDI record in various ways.
authorCarl Hetherington <carl@carlh.net>
Tue, 5 Oct 2010 00:27:26 +0000 (00:27 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 5 Oct 2010 00:27:26 +0000 (00:27 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7875 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/midi_streamview.cc
gtk2_ardour/midi_streamview.h
libs/ardour/ardour/midi_source.h
libs/ardour/midi_diskstream.cc
libs/ardour/midi_source.cc
libs/ardour/smf_source.cc

index fe1f778414579d60939093c9b1105d9411e8db5b..1604d4757d9df779c740ec13a4d8199f071b3192 100644 (file)
@@ -459,7 +459,6 @@ MidiStreamView::setup_rec_box ()
                                                                      (RegionFactory::create (sources, plist, false)));
 
                                assert(region);
-                               region->suspend_property_changes ();
                                region->set_position (_trackview.session()->transport_frame(), this);
                                rec_regions.push_back (make_pair(region, (RegionView*)0));
 
@@ -553,8 +552,9 @@ MidiStreamView::setup_rec_box ()
        }
 }
 
+/** @param start Start position to update in session frames */
 void
-MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t start, nframes_t dur)
+MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, framepos_t const start, nframes_t dur)
 {
        ENSURE_GUI_THREAD (*this, &MidiStreamView::update_rec_regions, data, start, dur)
 
@@ -602,13 +602,8 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
                                                        ((MidiRegionView*)iter->second)->begin_write();
                                                }
 
-                                               /* also update rect */
-                                               ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle;
-                                               gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
-                                               rect->property_x2() = xend;
-
-                                               ARDOUR::BeatsFramesConverter tconv(_trackview.session()->tempo_map(), region->position());
-                                               const MidiModel::TimeType start_beats = tconv.from(start);
+                                               ARDOUR::BeatsFramesConverter tconv(_trackview.session()->tempo_map(), region->position() - region->start());
+                                               const MidiModel::TimeType start_beats = tconv.from (start - tconv.origin_b ());
 
                                                /* draw events */
                                                MidiRegionView* mrv = (MidiRegionView*)iter->second;
@@ -693,8 +688,11 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
        }
 }
 
+/** @param start Start of the range in session frames.
+ *  @param cnd Number of frames in the range.
+ */
 void
-MidiStreamView::rec_data_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr<Source> weak_src)
+MidiStreamView::rec_data_range_ready (framepos_t start, nframes_t cnt, boost::weak_ptr<Source> weak_src)
 {
        // this is called from the butler thread for now
 
index 2ef4697b372c0f8e8270e870c7705ba32d1d07d6..e4fdd577186edf28f645fc1673acdb740c91c42a 100644 (file)
@@ -102,19 +102,19 @@ class MidiStreamView : public StreamView
        void setup_rec_box ();
 
        void rec_data_range_ready (
-                       nframes_t start,
-                       nframes_t dur,
-                       boost::weak_ptr<ARDOUR::Source> src);
-
+               ARDOUR::framepos_t start,
+               nframes_t dur,
+               boost::weak_ptr<ARDOUR::Source> src);
+       
        void update_rec_regions (
-                       boost::shared_ptr<ARDOUR::MidiModel> data,
-                       nframes_t start,
-                       nframes_t dur);
-
+               boost::shared_ptr<ARDOUR::MidiModel> data,
+               ARDOUR::framepos_t const start,
+               nframes_t dur);
+       
        RegionView* add_region_view_internal (
-                       boost::shared_ptr<ARDOUR::Region>,
-                       bool wait_for_waves,
-                       bool recording = false);
+               boost::shared_ptr<ARDOUR::Region>,
+               bool wait_for_waves,
+               bool recording = false);
 
        void display_region(MidiRegionView* region_view, bool load_model);
        void display_track (boost::shared_ptr<ARDOUR::Track> tr);
index 3bad6d6ddc871f0f7eb27c1d5724ea857b64c9e2..221bfd13f0869185e28310b51dbe94123ae05238 100644 (file)
@@ -91,7 +91,10 @@ class MidiSource : virtual public Source
 
        static PBD::Signal1<void,MidiSource*> MidiSourceCreated;
 
-       // Signal a range of recorded data is available for reading from model()
+       /** Emitted when a range of recorded data is available for reading from model().
+        *  First parameter is the start of the range in session frames.
+        *  Second parameter is the number of frames.
+        */
        mutable PBD::Signal2<void,framepos_t,nframes_t> ViewDataRangeReady;
 
        XMLNode& get_state ();
index 932b9bb2c9332f7c8010d857a6b57e8963445be6..0ac67fae82f764f25ce79d66fc1fa6fef730162b 100644 (file)
@@ -1143,7 +1143,7 @@ MidiDiskstream::set_record_enabled (bool yn)
 void
 MidiDiskstream::engage_record_enable ()
 {
-    bool rolling = _session.transport_speed() != 0.0f;
+       bool const rolling = _session.transport_speed() != 0.0f;
 
        g_atomic_int_set (&_record_enabled, 1);
 
index b105aa00c5b9db3d56986df1b8ab2ceab34bd622..ebb2d17696608f92c2afc803c6c567e125c745d4 100644 (file)
@@ -251,6 +251,10 @@ MidiSource::midi_read (Evoral::EventSink<nframes_t>& dst, framepos_t source_star
        }
 }
 
+/** Write data from a MidiRingBuffer to this source.
+ *  @param source Source to read from.
+ *  @param source_start This source's start position in session frames.
+ */
 nframes_t
 MidiSource::midi_write (MidiRingBuffer<nframes_t>& source, framepos_t source_start, nframes_t duration)
 {
@@ -311,7 +315,7 @@ MidiSource::clone (Evoral::MusicalTime begin, Evoral::MusicalTime end)
         boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
                 SourceFactory::createWritable(DataType::MIDI, _session,
                                               newpath, false, _session.frame_rate()));
-        
+
         newsrc->set_timeline_position(_timeline_position);
        newsrc->copy_interpolation_from (this);
        newsrc->copy_automation_state_from (this);
index 4ddbba8457fd76348aadd76cd0bedbbde906ded7..322c4dff9703396b148756fc0d9fad4fc9c3f778 100644 (file)
@@ -201,7 +201,10 @@ SMFSource::read_unlocked (Evoral::EventSink<nframes_t>& destination, framepos_t
        return duration;
 }
 
-/** All stamps in audio frames */
+/** Write data to this source from a MidiRingBuffer.
+ *  @param source Buffer to read from.
+ *  @param position This source's start position in session frames.
+ */
 nframes_t
 SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& source, framepos_t position, nframes_t duration)
 {
@@ -243,6 +246,7 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& source, framepos_t positio
                        break;
                }
 
+               /* convert from session time to time relative to the source start */
                assert(time >= position);
                time -= position;
 
@@ -262,7 +266,7 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& source, framepos_t positio
        Evoral::SMF::flush();
        free(buf);
 
-       ViewDataRangeReady(position + _last_write_end, duration); /* EMIT SIGNAL */
+       ViewDataRangeReady (_last_write_end, duration); /* EMIT SIGNAL */
 
        return duration;
 }