/*
- Copyright (C) 1999-2002 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2005-2009 Taybin Rutkin <taybin@taybin.com>
+ * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
+ * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
+ * Copyright (C) 2013 Michael Fisher <mfisher31@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include <string>
#include <cmath>
outbound_mtc_timecode_frame = 0;
next_quarter_frame_to_send = 0;
- /* Set up the qtr sample message */
+ /* Set up the qtr frame message */
mtc_msg[0] = 0xf1;
mtc_msg[2] = 0xf1;
void
Session::mmc_record_strobe (MIDI::MachineControl &/*mmc*/)
{
- if (Profile->get_trx()) {
-
- /* In Tracks Live, there is no concept of punch, so we just
- treat RecordStrobe like RecordPause. This violates the MMC
- specification.
- */
-
- if (Config->get_mmc_control()) {
- maybe_enable_record();
- }
- return;
- }
-
if (!Config->get_mmc_control() || (_step_editors > 0)) {
return;
}
target_sample = max_samplepos;
}
- /* Some (all?) MTC/MMC devices do not send a full MTC sample
+ /* Some (all?) MTC/MMC devices do not send a full MTC frame
at the end of a locate, instead sending only an MMC
locate command. This causes the current position
of an MTC slave to become out of date. Catch this.
if (_engine.freewheeling() || !Config->get_send_mtc()) {
return 0;
}
- if (!transport_master()->locked()) {
+
+ if (transport_master_is_external() && !transport_master()->locked()) {
return 0;
}
DEBUG_TRACE (DEBUG::MTC, string_compose ("Full MTC TC %1 (off %2)\n", outbound_mtc_timecode_frame, mtc_offset));
- // I don't understand this bit yet.. [DR]
- // I do [rg]:
- // according to MTC spec 24, 30 drop and 30 non-drop TC, the sample-number represented by 8 quarter frames must be even.
+ /* according to MTC spec 24, 30 drop and 30 non-drop TC, the frame-number represented by 8 quarter frames must be even. */
if (((mtc_timecode_bits >> 5) != MIDI::MTC_25_FPS) && (transmitting_timecode_time.frames % 2)) {
- // start MTC quarter frame transmission on an even sample
+ /* start MTC quarter frame transmission on an even frame */
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
outbound_mtc_timecode_frame += _samples_per_timecode_frame;
}
// Send message at offset 0, sent time is for the start of this cycle
MidiBuffer& mb (_midi_ports->mtc_output_port()->get_midi_buffer (nframes));
- mb.push_back (Port::port_offset(), sizeof (msg), msg);
+ mb.push_back (0, sizeof (msg), msg);
_pframes_since_last_mtc = 0;
return 0;
/** Send MTC (quarter-frame) messages for this cycle.
* Must be called exactly once per cycle from the process thread. Realtime safe.
* This function assumes the state of full Timecode is sane, eg. the slave is
- * expecting quarter frame messages and has the right sample of reference (any
+ * expecting quarter frame messages and has the right frame of reference (any
* full MTC Timecode time messages that needed to be sent should have been sent
* earlier already this cycle by send_full_time_code)
*/
// cerr << "(MTC) Not sending MTC\n";
return 0;
}
- if (!transport_master()->locked()) {
+ if (transport_master_is_external() && !transport_master()->locked()) {
return 0;
}
double const quarter_frame_duration = _samples_per_timecode_frame / 4.0;
DEBUG_TRACE (DEBUG::MTC, string_compose ("TF %1 SF %2 MT %3 QF %4 QD %5\n",
- _transport_sample, start_sample, outbound_mtc_timecode_frame,
- next_quarter_frame_to_send, quarter_frame_duration));
+ _transport_sample, start_sample, outbound_mtc_timecode_frame,
+ next_quarter_frame_to_send, quarter_frame_duration));
if (rint(outbound_mtc_timecode_frame + (next_quarter_frame_to_send * quarter_frame_duration)) < _transport_sample) {
// send full timecode and set outbound_mtc_timecode_frame, next_quarter_frame_to_send
DEBUG_TRACE (DEBUG::MTC, string_compose ("next sample to send: %1\n", next_quarter_frame_to_send));
switch (next_quarter_frame_to_send) {
- case 0:
- mtc_msg[1] = 0x00 | (transmitting_timecode_time.frames & 0xf);
- break;
- case 1:
- mtc_msg[1] = 0x10 | ((transmitting_timecode_time.frames & 0xf0) >> 4);
- break;
- case 2:
- mtc_msg[1] = 0x20 | (transmitting_timecode_time.seconds & 0xf);
- break;
- case 3:
- mtc_msg[1] = 0x30 | ((transmitting_timecode_time.seconds & 0xf0) >> 4);
- break;
- case 4:
- mtc_msg[1] = 0x40 | (transmitting_timecode_time.minutes & 0xf);
- break;
- case 5:
- mtc_msg[1] = 0x50 | ((transmitting_timecode_time.minutes & 0xf0) >> 4);
- break;
- case 6:
- mtc_msg[1] = 0x60 | ((mtc_timecode_bits | transmitting_timecode_time.hours) & 0xf);
- break;
- case 7:
- mtc_msg[1] = 0x70 | (((mtc_timecode_bits | transmitting_timecode_time.hours) & 0xf0) >> 4);
- break;
+ case 0:
+ mtc_msg[1] = 0x00 | (transmitting_timecode_time.frames & 0xf);
+ break;
+ case 1:
+ mtc_msg[1] = 0x10 | ((transmitting_timecode_time.frames & 0xf0) >> 4);
+ break;
+ case 2:
+ mtc_msg[1] = 0x20 | (transmitting_timecode_time.seconds & 0xf);
+ break;
+ case 3:
+ mtc_msg[1] = 0x30 | ((transmitting_timecode_time.seconds & 0xf0) >> 4);
+ break;
+ case 4:
+ mtc_msg[1] = 0x40 | (transmitting_timecode_time.minutes & 0xf);
+ break;
+ case 5:
+ mtc_msg[1] = 0x50 | ((transmitting_timecode_time.minutes & 0xf0) >> 4);
+ break;
+ case 6:
+ mtc_msg[1] = 0x60 | ((mtc_timecode_bits | transmitting_timecode_time.hours) & 0xf);
+ break;
+ case 7:
+ mtc_msg[1] = 0x70 | (((mtc_timecode_bits | transmitting_timecode_time.hours) & 0xf0) >> 4);
+ break;
}
- const samplepos_t msg_time = rint(outbound_mtc_timecode_frame + (quarter_frame_duration * next_quarter_frame_to_send));
+ const samplepos_t msg_time = rint (outbound_mtc_timecode_frame + (quarter_frame_duration * next_quarter_frame_to_send));
// This message must fall within this block or something is broken
assert (msg_time >= start_sample);
#ifndef NDEBUG
if (DEBUG_ENABLED(DEBUG::MTC)) {
- DEBUG_STR_DECL(foo)
+ DEBUG_STR_DECL(foo);
DEBUG_STR_APPEND(foo,"sending ");
DEBUG_STR_APPEND(foo, transmitting_timecode_time);
DEBUG_TRACE (DEBUG::MTC, string_compose ("%1 qfm = %2, stamp = %3\n", DEBUG_STR(foo).str(), next_quarter_frame_to_send,
- out_stamp));
+ out_stamp));
}
#endif
void
Session::send_immediate_mmc (MachineControlCommand c)
{
- if (AudioEngine::instance()->in_process_thread()) {
- _mmc->send (c, Port::port_offset());
- } else {
- _mmc->send (c, 0);
- }
-
+ _mmc->send (c, 0);
}
bool
return true;
}
-/***********************************************************************
- OUTBOUND SYSTEM COMMON STUFF
-**********************************************************************/
-
+/* *********************************************************************
+ * OUTBOUND SYSTEM COMMON STUFF
+ **********************************************************************/
void
Session::send_song_position_pointer (samplepos_t)
return _midi_ports->scene_input_port ();
}
+boost::shared_ptr<AsyncMIDIPort>
+Session::vkbd_output_port () const
+{
+ return _midi_ports->vkbd_output_port ();
+}
+
boost::shared_ptr<MidiPort>
Session::midi_clock_output_port () const
{
return _midi_ports->midi_clock_output_port ();
}
-
boost::shared_ptr<MidiPort>
Session::mtc_output_port () const
{
if (!msp.empty()) {
- if (old_midi_target) {
- old_midi_target->input()->disconnect (this);
- }
-
for (vector<string>::const_iterator p = msp.begin(); p != msp.end(); ++p) {
- /* disconnect the port from everything */
- AudioEngine::instance()->disconnect (*p);
+ PortManager::MidiPortInformation mpi (AudioEngine::instance()->midi_port_information (*p));
+
+ /* if a port is marked for control data, do not
+ * disconnect it from everything since it may also be
+ * used via a control surface or some other
+ * functionality.
+ */
+
+ if (!(mpi.properties & MidiPortControl)) {
+ /* disconnect the port from everything */
+ AudioEngine::instance()->disconnect (*p);
+ }
/* connect it to the new target */
new_midi_target->input()->connect (new_midi_target->input()->nth(0), (*p), this);
}