- Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
- if (!lm.locked()) {
- boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
- framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
- if (can_internal_playback_seek(llabs(playback_distance))) {
- /* TODO should declick, and/or note-off */
- internal_playback_seek(playback_distance);
- }
- return 0;
- }
-
- boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
-
- if (n_outputs().n_total() == 0 && _processors.empty()) {
- return 0;
- }
-
- if (!_active) {
- silence (nframes);
- if (_meter_point == MeterInput && (_monitoring & MonitorInput || _diskstream->record_enabled())) {
- _meter->reset();
- }
- return 0;
- }
-
- framepos_t transport_frame = _session.transport_frame();
-
- int dret;
- framecnt_t playback_distance;
-
- if ((nframes = check_initial_delay (nframes, transport_frame)) == 0) {
- /* need to do this so that the diskstream sets its
- playback distance to zero, thus causing diskstream::commit
- to do nothing.
- */
- BufferSet bufs; /* empty set - is OK, since nothing will happen */
-
- dret = diskstream->process (bufs, transport_frame, 0, playback_distance, false);
- need_butler = diskstream->commit (playback_distance);
- return dret;
- }
-
- BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
-
- fill_buffers_with_input (bufs, _input, nframes);
-
- /* filter captured data before meter sees it */
- _capture_filter.filter (bufs);
-
- if (_meter_point == MeterInput && (_monitoring & MonitorInput || _diskstream->record_enabled())) {
- _meter->run (bufs, start_frame, end_frame, nframes, true);
- }
-
-
- _silent = false;
-
- if ((dret = diskstream->process (bufs, transport_frame, nframes, playback_distance, (monitoring_state() == MonitoringDisk))) != 0) {
- need_butler = diskstream->commit (playback_distance);
- silence (nframes);
- return dret;
- }
-
- /* note diskstream uses our filter to filter/map playback channels appropriately. */
-
- if (monitoring_state() == MonitoringInput) {
-
- /* not actually recording, but we want to hear the input material anyway,
- at least potentially (depending on monitoring options)
- */
-
- /* because the playback buffer is event based and not a
- * continuous stream, we need to make sure that we empty
- * it of events every cycle to avoid it filling up with events
- * read from disk, while we are actually monitoring input
- */
-
- diskstream->flush_playback (start_frame, end_frame);
-
- }
-
-
- /* append immediate messages to the first MIDI buffer (thus sending it to the first output port) */
-
- write_out_of_band_data (bufs, start_frame, end_frame, nframes);
-
- /* final argument: don't waste time with automation if we're not recording or rolling */
-
- process_output_buffers (bufs, start_frame, end_frame, nframes,
- declick, (!diskstream->record_enabled() && !_session.transport_stopped()));
-
- for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
- boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
- if (d) {
- d->flush_buffers (nframes);
+ const MidiBuffer& buf = bufs.get_midi(0);
+ for (MidiBuffer::const_iterator e = buf.begin(); e != buf.end(); ++e) {
+ const Evoral::Event<samplepos_t>& ev = *e;
+ const Evoral::Parameter param = midi_parameter(ev.buffer(), ev.size());
+ const boost::shared_ptr<AutomationControl> control = automation_control (param);
+ if (control) {
+ double old = control->get_double (false, 0);
+ control->set_double (ev.value(), 0, false);
+ if (old != ev.value()) {
+ control->Changed (false, Controllable::NoGroup);
+ }