void no_outs_cuz_we_no_monitor(bool);
void cycle_start (pframes_t);
void transport_stopped (framepos_t frame);
+ void realtime_locate ();
BufferSet& output_buffers() { return *_output_buffers; }
void flush_buffers (pframes_t nframes, framepos_t time);
void transport_stopped ();
+ void realtime_locate ();
void reset ();
Buffer& get_buffer (pframes_t nframes) {
private:
MidiBuffer* _buffer;
bool _has_been_mixed_down;
- bool _resolve_in_process;
+ bool _resolve_required;
- MidiStateTracker _midi_state_tracker;
+ void resolve_notes (void* jack_buffer, MidiBuffer::TimeType when);
};
} // namespace ARDOUR
int declick, bool can_record, bool rec_monitors_input, bool& need_butler);
void realtime_handle_transport_stopped ();
+ void realtime_locate ();
void use_new_diskstream ();
void set_diskstream (boost::shared_ptr<Diskstream>);
virtual Buffer& get_buffer (pframes_t nframes) = 0;
virtual void flush_buffers (pframes_t /*nframes*/, framepos_t /*time*/) {}
virtual void transport_stopped () {}
+ virtual void realtime_locate () {}
bool physically_connected () const;
virtual ChanCount output_streams() const { return _configured_output; }
virtual void realtime_handle_transport_stopped () {}
+ virtual void realtime_locate () {}
/* note: derived classes should implement state(), NOT get_state(), to allow
us to merge C++ inheritance and XML lack-of-inheritance reasonably
virtual bool record_enabled() const { return false; }
virtual void nonrealtime_handle_transport_stopped (bool abort, bool did_locate, bool flush_processors);
virtual void realtime_handle_transport_stopped () {}
+ virtual void realtime_locate () {}
virtual void set_pending_declick (int);
/* end of vfunc-based API */
void stop_transport (bool abort = false, bool clear_state = false);
void start_transport ();
void realtime_stop (bool abort, bool clear_state);
+ void realtime_locate ();
void non_realtime_start_scrub ();
void non_realtime_set_speed ();
void non_realtime_locate ();
}
}
+void
+Delivery::realtime_locate ()
+{
+ if (_output) {
+ PortSet& ports (_output->ports());
+
+ for (PortSet::iterator i = ports.begin(); i != ports.end(); ++i) {
+ (*i).realtime_locate ();
+ }
+ }
+}
+
gain_t
Delivery::target_gain ()
{
if (_write_source) {
_write_source->set_timeline_position (position);
}
- seek(position, false);
+ seek (position, false);
}
MidiPort::MidiPort (const std::string& name, Flags flags)
: Port (name, DataType::MIDI, flags)
, _has_been_mixed_down (false)
- , _resolve_in_process (false)
+ , _resolve_required (false)
{
_buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI));
}
_has_been_mixed_down = false;
}
+void
+MidiPort::resolve_notes (void* jack_buffer, MidiBuffer::TimeType when)
+{
+ uint8_t ev[3];
+
+ ev[2] = 0;
+
+ for (uint8_t channel = 0; channel <= 0xF; channel++) {
+ ev[0] = (MIDI_CMD_CONTROL | channel);
+
+ /* we need to send all notes off AND turn the
+ * sustain/damper pedal off to handle synths
+ * that prioritize sustain over AllNotesOff
+ */
+
+ ev[1] = MIDI_CTL_SUSTAIN;
+
+ if (jack_midi_event_write (jack_buffer, when, ev, 3) != 0) {
+ cerr << "failed to deliver sustain-zero on channel " << channel << " on port " << name() << endl;
+ }
+
+ ev[1] = MIDI_CTL_ALL_NOTES_OFF;
+
+ if (jack_midi_event_write (jack_buffer, 0, ev, 3) != 0) {
+ cerr << "failed to deliver ALL NOTES OFF on channel " << channel << " on port " << name() << endl;
+ }
+ }
+}
+
void
MidiPort::flush_buffers (pframes_t nframes, framepos_t time)
{
void* jack_buffer = jack_port_get_buffer (_jack_port, nframes);
- // Feed the data through the MidiStateTracker
- bool did_loop;
-
- _midi_state_tracker.track (_buffer->begin(), _buffer->end(), did_loop);
-
- if (did_loop || _resolve_in_process) {
- /* add necessary note offs */
- _midi_state_tracker.resolve_notes (*_buffer, time);
+ if (_resolve_required) {
+ /* resolve all notes at the start of the buffer */
+ resolve_notes (jack_buffer, 0);
+ _resolve_required= false;
}
- _resolve_in_process = false;
-
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
- const Evoral::Event<framepos_t>& ev = *i;
+
+ const Evoral::MIDIEvent<MidiBuffer::TimeType> ev (*i, false);
// event times are in frames, relative to cycle start
assert (ev.time() < (nframes + _global_port_buffer_offset + _port_buffer_offset));
+ if (ev.event_type() == LoopEventType) {
+ resolve_notes (jack_buffer, ev.time());
+ continue;
+ }
+
if (ev.time() >= _global_port_buffer_offset + _port_buffer_offset) {
if (jack_midi_event_write (jack_buffer, (jack_nframes_t) ev.time(), ev.buffer(), ev.size()) != 0) {
cerr << "write failed, drop flushed note off on the floor, time "
void
MidiPort::transport_stopped ()
{
- _resolve_in_process = true;
+ _resolve_required = true;
+}
+
+void
+MidiPort::realtime_locate ()
+{
+ _resolve_required = true;
}
void
BeatsFramesConverter converter(_session.tempo_map(), source_start);
+ DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("MidiSource::midi-read() sstart %1 start %2 cnt %3 tracker %4\n",
+ source_start, start, cnt, tracker));
+
if (_model) {
Evoral::Sequence<double>::const_iterator& i = _model_iter;
return ret;
}
+void
+MidiTrack::realtime_locate ()
+{
+ Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
+ if (!lm.locked ()) {
+ return;
+ }
+
+ for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ (*i)->realtime_locate ();
+ }
+}
+
void
MidiTrack::realtime_handle_transport_stopped ()
{
transport_sub_state = 0;
}
+void
+Session::realtime_locate ()
+{
+ boost::shared_ptr<RouteList> r = routes.reader ();
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ (*i)->realtime_locate ();
+ }
+}
+
void
Session::butler_transport_work ()
{
outbound_mtc_timecode_frame = _transport_frame;
next_quarter_frame_to_send = 0;
+ /* do "stopped" stuff if:
+ *
+ * we are rolling AND
+ * no autoplay in effect AND
+ * we're not going to keep rolling after the locate AND
+ * !(playing a loop with JACK sync)
+ *
+ */
+
if (transport_rolling() && (!auto_play_legal || !config.get_auto_play()) && !with_roll && !(synced_to_jack() && play_loop)) {
realtime_stop (false, true); // XXX paul - check if the 2nd arg is really correct
+ } else {
+ /* otherwise tell the world that we located */
+ realtime_locate ();
}
if (force || !with_loop || loop_changing) {