* fixed jitter problems for midi clock and removed superfluous UI elements

git-svn-id: svn://localhost/ardour2/branches/3.0@4008 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-10-25 08:28:10 +00:00
parent 33d02c7902
commit fd824717a7
14 changed files with 58 additions and 59 deletions

View file

@ -701,7 +701,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void toggle_use_mmc ();
void toggle_send_mmc ();
void toggle_send_mtc ();
void toggle_use_midi_clock ();
void toggle_use_osc ();

View file

@ -436,8 +436,6 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (option_actions, X_("UseMMC"), _("Use MMC"), mem_fun (*this, &ARDOUR_UI::toggle_use_mmc));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (option_actions, X_("UseMIDIClock"), _("Use MIDI Clock"), mem_fun (*this, &ARDOUR_UI::toggle_use_midi_clock));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (option_actions, X_("SendMIDIfeedback"), _("Send MIDI feedback"), mem_fun (*this, &ARDOUR_UI::toggle_send_midi_feedback));
ActionManager::session_sensitive_actions.push_back (act);

View file

@ -67,12 +67,6 @@ ARDOUR_UI::toggle_use_mmc ()
ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
}
void
ARDOUR_UI::toggle_use_midi_clock ()
{
ActionManager::toggle_config_state ("options", "UseMIDIClock", &Configuration::set_midi_clock_control, &Configuration::get_midi_clock_control);
}
void
ARDOUR_UI::toggle_use_osc ()
{
@ -1108,8 +1102,6 @@ ARDOUR_UI::parameter_changed (const char* parameter_name)
} else if (PARAM_IS ("mmc-control")) {
ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
} else if (PARAM_IS ("midi-clock-control")) {
ActionManager::map_some_state ("options", "UseMIDIClock", &Configuration::get_midi_clock_control);
} else if (PARAM_IS ("midi-feedback")) {
ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
} else if (PARAM_IS ("do-not-record-plugins")) {

View file

@ -36,7 +36,6 @@ CONFIG_VARIABLE (bool, trace_midi_output, "trace-midi-output", false)
CONFIG_VARIABLE (bool, send_mtc, "send-mtc", false)
CONFIG_VARIABLE (bool, send_mmc, "send-mmc", true)
CONFIG_VARIABLE (bool, mmc_control, "mmc-control", true)
CONFIG_VARIABLE (bool, midi_clock_control, "midi-clock-control", false)
CONFIG_VARIABLE (bool, midi_feedback, "midi-feedback", false)
CONFIG_VARIABLE (uint8_t, mmc_receive_device_id, "mmc-receive-device-id", 0)
CONFIG_VARIABLE (uint8_t, mmc_send_device_id, "mmc-send-device-id", 0)

View file

@ -1306,13 +1306,9 @@ class Session : public PBD::StatefulDestructible
void deliver_mmc (MIDI::MachineControl::Command, nframes_t);
void spp_start (MIDI::Parser&);
void spp_continue (MIDI::Parser&);
void spp_stop (MIDI::Parser&);
void midi_clock_start (MIDI::Parser&);
void midi_clock_continue (MIDI::Parser&);
void midi_clock_stop (MIDI::Parser&);
void spp_start (MIDI::Parser&, nframes_t timestamp);
void spp_continue (MIDI::Parser&, nframes_t timestamp);
void spp_stop (MIDI::Parser&, nframes_t timestamp);
void mmc_deferred_play (MIDI::MachineControl &);
void mmc_stop (MIDI::MachineControl &);

View file

@ -143,9 +143,9 @@ class MIDIClock_Slave : public Slave, public sigc::trackable {
float average;
void reset ();
void start (MIDI::Parser& parser);
void stop (MIDI::Parser& parser);
void update_midi_clock (MIDI::Parser& parser);
void start (MIDI::Parser& parser, nframes_t timestamp);
void stop (MIDI::Parser& parser, nframes_t timestamp);
void update_midi_clock (MIDI::Parser& parser, nframes_t timestamp);
void read_current (SafeTime *) const;
bool _started;

View file

@ -26,12 +26,14 @@
#include <pbd/pthread_utils.h>
#include <midi++/port.h>
#include <midi++/jack.h>
#include <ardour/slave.h>
#include <ardour/session.h>
#include <ardour/audioengine.h>
#include <ardour/cycles.h>
#include <ardour/tempo.h>
#include "i18n.h"
using namespace ARDOUR;
@ -73,9 +75,9 @@ MIDIClock_Slave::rebind (MIDI::Port& p)
}
void
MIDIClock_Slave::update_midi_clock (Parser& parser)
MIDIClock_Slave::update_midi_clock (Parser& parser, nframes_t timestamp)
{
nframes_t now = session.engine().frame_time();
nframes_t now = timestamp;
SafeTime last;
read_current (&last);
@ -109,8 +111,14 @@ MIDIClock_Slave::update_midi_clock (Parser& parser)
average += accumulator[i];
average /= accumulator_size;
JACK_MidiPort *jack_port = dynamic_cast<JACK_MidiPort *>(port);
pthread_t process_thread_id = 0;
if(jack_port) {
process_thread_id = jack_port->get_process_thread();
}
std::cerr << "got MIDI Clock message at time " << now
std::cerr << "Thread " << pthread_name() << " with id " << pthread_self() << " process Thread ID: " << process_thread_id
<< " got MIDI Clock message at time " << now
<< " real delta: " << midi_clock_frame
<< " reference: " << one_ppqn_in_frames
<< " accu index: " << accumulator_index
@ -127,7 +135,7 @@ MIDIClock_Slave::update_midi_clock (Parser& parser)
}
void
MIDIClock_Slave::start (Parser& parser)
MIDIClock_Slave::start (Parser& parser, nframes_t timestamp)
{
nframes_t now = session.engine().frame_time();
@ -154,7 +162,7 @@ MIDIClock_Slave::start (Parser& parser)
}
void
MIDIClock_Slave::stop (Parser& parser)
MIDIClock_Slave::stop (Parser& parser, nframes_t timestamp)
{
std::cerr << "MIDIClock_Slave got stop message" << endl;
@ -225,7 +233,7 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
pos = last.position;
session.request_locate (pos, false);
session.request_transport_speed (0);
this->stop(*port->input());
this->stop(*port->input(), now);
reset();
return false;
}
@ -238,7 +246,8 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
speed = midi_clock_speed;
cerr << " final speed: " << speed << " elapsed: " << elapsed << " elapsed (scaled) " << elapsed * speed << " position: " << pos << endl;
cerr << " final speed: " << speed << " elapsed: " << elapsed << " elapsed (scaled) " << elapsed * speed << " position: " << pos
<< " Thread ID: " << pthread_self() << endl;
return true;
}

View file

@ -317,10 +317,6 @@ Session::set_midi_clock_port (string port_tag)
Config->set_midi_clock_port_name (port_tag);
_midi_clock_port->input()->start.connect (mem_fun (*this, &Session::midi_clock_start));
_midi_clock_port->input()->contineu.connect (mem_fun (*this, &Session::midi_clock_continue));
_midi_clock_port->input()->stop.connect (mem_fun (*this, &Session::midi_clock_stop));
out:
MIDIClock_PortChanged(); /* EMIT SIGNAL */
change_midi_ports ();
@ -496,7 +492,7 @@ Session::setup_midi_control ()
}
void
Session::spp_start (Parser& ignored)
Session::spp_start (Parser& ignored, nframes_t timestamp)
{
if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
request_transport_speed (1.0);
@ -504,40 +500,41 @@ Session::spp_start (Parser& ignored)
}
void
Session::spp_continue (Parser& ignored)
Session::spp_continue (Parser& ignored, nframes_t timestamp)
{
spp_start (ignored);
spp_start (ignored, timestamp);
}
void
Session::spp_stop (Parser& ignored)
Session::spp_stop (Parser& ignored, nframes_t timestamp)
{
if (Config->get_mmc_control()) {
request_stop ();
}
}
/*
void
Session::midi_clock_start (Parser& ignored)
Session::midi_clock_start (Parser& ignored, nframes_t timestamp)
{
if (Config->get_midi_clock_control() && (Config->get_slave_source() == MIDIClock)) {
if (Config->get_slave_source() == MIDIClock) {
request_transport_speed (1.0);
}
}
void
Session::midi_clock_continue (Parser& ignored)
Session::midi_clock_continue (Parser& parser, nframes_t timestamp)
{
midi_clock_start (ignored);
midi_clock_start (parser, 0);
}
void
Session::midi_clock_stop (Parser& ignored)
Session::midi_clock_stop (Parser& ignored, nframes_t timestamp)
{
if (Config->get_midi_clock_control()) {
if (Config->get_slave_source() == MIDIClock) {
request_stop ();
}
}
*/
void
Session::mmc_deferred_play (MIDI::MachineControl &mmc)

View file

@ -78,6 +78,8 @@ JACK_MidiPort::cycle_start (nframes_t nframes)
if (input_parser) {
input_parser->raw_preparse (*input_parser, ev.buffer, ev.size);
for (size_t i = 0; i < ev.size; i++) {
// the midi events here are used for MIDI clock only
input_parser->set_midi_clock_timestamp(ev.time + jack_last_frame_time(_jack_client));
input_parser->scanner (ev.buffer[i]);
}
input_parser->raw_postparse (*input_parser, ev.buffer, ev.size);

View file

@ -60,7 +60,9 @@ public:
virtual void set_state (const XMLNode&);
static void set_process_thread (pthread_t);
static pthread_t get_process_thread () { return _process_thread; }
static bool is_process_thread();
protected:
std::string get_typestring () const {
return typestring;
@ -78,7 +80,7 @@ private:
void flush (void* jack_port_buffer);
static pthread_t _process_thread;
static bool is_process_thread();
RingBuffer<Evoral::Event> non_process_thread_fifo;
Glib::Mutex non_process_thread_fifo_lock;

View file

@ -74,15 +74,15 @@ class Parser : public sigc::trackable {
Signal position;
Signal song;
Signal mtc;
Signal mtc;
sigc::signal<void,Parser&> mtc_qtr;
sigc::signal<void, Parser &> all_notes_off;
sigc::signal<void, Parser &> tune;
sigc::signal<void, Parser &> timing;
sigc::signal<void, Parser &> start;
sigc::signal<void, Parser &> stop;
sigc::signal<void, Parser &> contineu; /* note spelling */
sigc::signal<void, Parser &> all_notes_off;
sigc::signal<void, Parser &> tune;
sigc::signal<void, Parser &, nframes_t> timing;
sigc::signal<void, Parser &, nframes_t> start;
sigc::signal<void, Parser &, nframes_t> stop;
sigc::signal<void, Parser &, nframes_t> contineu; /* note spelling */
sigc::signal<void, Parser &> active_sense;
sigc::signal<void, Parser &> reset;
sigc::signal<void, Parser &> eox;
@ -121,6 +121,9 @@ class Parser : public sigc::trackable {
MTC_Status mtc_running() const { return _mtc_running; }
const byte *mtc_current() const { return _mtc_time; }
bool mtc_locked() const { return _mtc_locked; }
const nframes_t get_midi_clock_timestamp() const { return _midi_clock_timestamp; }
void set_midi_clock_timestamp(const nframes_t timestamp) { _midi_clock_timestamp = timestamp; }
sigc::signal<void,MTC_Status> mtc_status;
sigc::signal<bool> mtc_skipped;
@ -168,6 +171,8 @@ class Parser : public sigc::trackable {
MTC_Status _mtc_running;
bool _mtc_locked;
byte last_qtr_frame;
nframes_t _midi_clock_timestamp;
ParseState pre_variable_state;
MIDI::eventType pre_variable_msgtype;

View file

@ -87,7 +87,7 @@ class Port : public sigc::trackable {
int three_byte_msg (byte a, byte b, byte c, timestamp_t timestamp) {
byte msg[3];
msg[0] = a;
msg[0] = a;
msg[1] = b;
msg[2] = c;

View file

@ -538,16 +538,16 @@ Parser::realtime_msg(unsigned char inbyte)
switch (inbyte) {
case 0xf8:
timing (*this);
timing (*this, _midi_clock_timestamp);
break;
case 0xfa:
start (*this);
start (*this, _midi_clock_timestamp);
break;
case 0xfb:
contineu (*this);
contineu (*this, _midi_clock_timestamp);
break;
case 0xfc:
stop (*this);
stop (*this, _midi_clock_timestamp);
break;
case 0xfe:
/* !!! active sense message in realtime_msg: should not reach here

View file

@ -56,7 +56,7 @@ class RingBuffer
}
guint read (T *dest, guint cnt);
guint write (T *src, guint cnt);
guint write (T *src, guint cnt);
struct rw_vector {
T *buf[2];