summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-10-05 00:27:26 +0000
committerCarl Hetherington <carl@carlh.net>2010-10-05 00:27:26 +0000
commit822234876169480a271ec4a67bd01aee791681f0 (patch)
treee77f6b5787774c9eb810435dcaa69ac68321aa42
parent22ffdfa6ad9dd20132ba653a1c85f11a359d4633 (diff)
Improve GUI display during MIDI record in various ways.
git-svn-id: svn://localhost/ardour2/branches/3.0@7875 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/midi_streamview.cc18
-rw-r--r--gtk2_ardour/midi_streamview.h22
-rw-r--r--libs/ardour/ardour/midi_source.h5
-rw-r--r--libs/ardour/midi_diskstream.cc2
-rw-r--r--libs/ardour/midi_source.cc6
-rw-r--r--libs/ardour/smf_source.cc8
6 files changed, 35 insertions, 26 deletions
diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc
index fe1f778414..1604d4757d 100644
--- a/gtk2_ardour/midi_streamview.cc
+++ b/gtk2_ardour/midi_streamview.cc
@@ -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
diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h
index 2ef4697b37..e4fdd57718 100644
--- a/gtk2_ardour/midi_streamview.h
+++ b/gtk2_ardour/midi_streamview.h
@@ -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);
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index 3bad6d6ddc..221bfd13f0 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -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 ();
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index 932b9bb2c9..0ac67fae82 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -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);
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index b105aa00c5..ebb2d17696 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -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);
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 4ddbba8457..322c4dff97 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -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;
}