using namespace ARDOUR;
using namespace PBD;
+namespace ARDOUR {
+ namespace Properties {
+ PBD::PropertyDescriptor<void*> midi_data;
+ }
+}
+
+void
+MidiRegion::make_property_quarks ()
+{
+ Properties::midi_data.property_id = g_quark_from_static_string (X_("midi-data"));
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for midi-data = %1\n", Properties::midi_data.property_id));
+}
+
+void
+MidiRegion::register_properties ()
+{
+ /* none yet, but its only a matter of time */
+}
+
/* Basic MidiRegion constructor (many channels) */
MidiRegion::MidiRegion (const SourceList& srcs)
: Region (srcs)
{
- // midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
+ register_properties ();
+
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
model_changed ();
assert(_name.val().find("/") == string::npos);
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset, bool offset_relative)
: Region (other, offset, offset_relative)
{
+ register_properties ();
+
assert(_name.val().find("/") == string::npos);
- // midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
model_changed ();
}
NoteMode mode, MidiStateTracker* tracker) const
{
frameoffset_t internal_offset = 0;
- frameoffset_t src_offset = 0;
framecnt_t to_read = 0;
/* precondition: caller has verified that we cover the desired section */
}
if (position < _position) {
+ /* we are starting the read from before the start of the region */
internal_offset = 0;
- src_offset = _position - position;
- dur -= src_offset;
+ dur -= _position - position;
} else {
+ /* we are starting the read from after the start of the region */
internal_offset = position - _position;
- src_offset = 0;
}
if (internal_offset >= _length) {
boost::shared_ptr<MidiSource> src = midi_source(chan_n);
src->set_note_mode(mode);
+
+ /*
+ cerr << "MR read @ " << position << " * " << to_read
+ << " _position = " << _position
+ << " _start = " << _start
+ << " intoffset = " << internal_offset
+ << endl;
+ */
- framepos_t output_buffer_position = 0;
- framepos_t negative_output_buffer_position = 0;
- if (_position >= _start) {
- // handle resizing of beginnings of regions correctly
- output_buffer_position = _position - _start;
- } else {
- // when _start is greater than _position, we have to subtract
- // _start from the note times in the midi source
- negative_output_buffer_position = _start;
- }
-
- /*cerr << "MR read @ " << position << " * " << to_read
- << " _position = " << _position
- << " _start = " << _start
- << " offset = " << output_buffer_position
- << " negoffset = " << negative_output_buffer_position
- << " intoffset = " << internal_offset
- << endl;*/
+ /* This call reads events from a source and writes them to `dst' timed in session frames */
if (src->midi_read (
dst, // destination buffer
- _position - _start, // start position of the source in this read context
+ _position - _start, // start position of the source in session frames
_start + internal_offset, // where to start reading in the source
to_read, // read duration in frames
- output_buffer_position, // the offset in the output buffer
- negative_output_buffer_position, // amount to substract from note times
tracker,
_filtered_parameters
) != to_read) {
return boost::dynamic_pointer_cast<MidiSource>(source(n));
}
-
-void
-MidiRegion::switch_source(boost::shared_ptr<Source> src)
-{
- _source_connection.disconnect ();
-
- boost::shared_ptr<MidiSource> msrc = boost::dynamic_pointer_cast<MidiSource>(src);
- if (!msrc) {
- return;
- }
-
- // MIDI regions have only one source
- SourceList srcs;
- srcs.push_back (msrc);
-
- drop_sources ();
- use_sources (srcs);
-
- set_name (msrc->name());
-
- msrc->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
-}
-
void
MidiRegion::model_changed ()
{
midi_source()->AutomationStateChanged.connect_same_thread (
_model_connection, boost::bind (&MidiRegion::model_automation_state_changed, this, _1)
);
+
+ model()->ContentsChanged.connect_same_thread (
+ _model_contents_connection, boost::bind (&MidiRegion::model_contents_changed, this));
+}
+
+void
+MidiRegion::model_contents_changed ()
+{
+ send_change (PropertyChange (Properties::midi_data));
}
void