summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_port.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-06-28 16:55:41 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-06-28 16:55:41 +0000
commit84be4eafc5228eacfed02f78489fa82d401c2947 (patch)
tree4dab87b4691919375ab3a867a011b5caf9ce2e59 /libs/ardour/midi_port.cc
parent4388556923da8b174fdbea445ea20a8eb72189c6 (diff)
basic infrastructure for enabling/disabling MIDI input to a given track
git-svn-id: svn://localhost/ardour2/branches/3.0@9772 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_port.cc')
-rw-r--r--libs/ardour/midi_port.cc71
1 files changed, 42 insertions, 29 deletions
diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc
index a8bff5bfa7..c27332fce1 100644
--- a/libs/ardour/midi_port.cc
+++ b/libs/ardour/midi_port.cc
@@ -30,6 +30,7 @@ MidiPort::MidiPort (const std::string& name, Flags flags)
: Port (name, DataType::MIDI, flags)
, _has_been_mixed_down (false)
, _resolve_required (false)
+ , _input_active (true)
{
_buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI));
}
@@ -62,36 +63,42 @@ MidiPort::get_midi_buffer (pframes_t nframes)
if (receives_input ()) {
- void* jack_buffer = jack_port_get_buffer (_jack_port, nframes);
- const pframes_t event_count = jack_midi_get_event_count (jack_buffer);
-
- assert (event_count < _buffer->capacity());
-
- /* suck all relevant MIDI events from the JACK MIDI port buffer
- into our MidiBuffer
- */
-
- for (pframes_t i = 0; i < event_count; ++i) {
-
- jack_midi_event_t ev;
-
- jack_midi_event_get (&ev, jack_buffer, i);
-
- if (ev.buffer[0] == 0xfe) {
- /* throw away active sensing */
- continue;
- }
-
- /* check that the event is in the acceptable time range */
+ if (_input_active) {
+
+ void* jack_buffer = jack_port_get_buffer (_jack_port, nframes);
+ const pframes_t event_count = jack_midi_get_event_count (jack_buffer);
+
+ assert (event_count < _buffer->capacity());
+
+ /* suck all relevant MIDI events from the JACK MIDI port buffer
+ into our MidiBuffer
+ */
+
+ for (pframes_t i = 0; i < event_count; ++i) {
+
+ jack_midi_event_t ev;
+
+ jack_midi_event_get (&ev, jack_buffer, i);
+
+ if (ev.buffer[0] == 0xfe) {
+ /* throw away active sensing */
+ continue;
+ }
+
+ /* check that the event is in the acceptable time range */
+
+ if ((ev.time >= (_global_port_buffer_offset + _port_buffer_offset)) &&
+ (ev.time < (_global_port_buffer_offset + _port_buffer_offset + nframes))) {
+ _buffer->push_back (ev);
+ } else {
+ cerr << "Dropping incoming MIDI at time " << ev.time << "; offset="
+ << _global_port_buffer_offset << " limit="
+ << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n";
+ }
+ }
- if ((ev.time >= (_global_port_buffer_offset + _port_buffer_offset)) &&
- (ev.time < (_global_port_buffer_offset + _port_buffer_offset + nframes))) {
- _buffer->push_back (ev);
- } else {
- cerr << "Dropping incoming MIDI at time " << ev.time << "; offset="
- << _global_port_buffer_offset << " limit="
- << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n";
- }
+ } else {
+ _buffer->silence (nframes);
}
} else {
@@ -205,3 +212,9 @@ MidiPort::reset ()
delete _buffer;
_buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI));
}
+
+void
+MidiPort::set_input_active (bool yn)
+{
+ _input_active = yn;
+}