* fixed JACK_MidiPort to get the events into the slave
git-svn-id: svn://localhost/ardour2/branches/3.0@3662 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -114,7 +114,6 @@ class MIDIClock_Slave : public Slave, public sigc::trackable {
|
||||
|
||||
bool locked() const;
|
||||
bool ok() const;
|
||||
bool starting() const { return _starting; }
|
||||
|
||||
nframes_t resolution() const;
|
||||
bool requires_seekahead () const { return true; }
|
||||
@@ -145,7 +144,7 @@ class MIDIClock_Slave : public Slave, public sigc::trackable {
|
||||
void stop (MIDI::Parser& parser);
|
||||
void update_midi_clock (MIDI::Parser& parser);
|
||||
void read_current (SafeTime *) const;
|
||||
bool _starting;
|
||||
bool _started;
|
||||
};
|
||||
|
||||
class ADAT_Slave : public Slave
|
||||
|
||||
@@ -61,7 +61,6 @@ MIDIClock_Slave::rebind (MIDI::Port& p)
|
||||
port = &p;
|
||||
|
||||
std::cerr << "MIDIClock_Slave: connecting to port " << port->name() << std::endl;
|
||||
port->input()->trace(true, &std::cout, string(port->name()));
|
||||
|
||||
connections.push_back (port->input()->timing.connect (mem_fun (*this, &MIDIClock_Slave::update_midi_clock)));
|
||||
connections.push_back (port->input()->start.connect (mem_fun (*this, &MIDIClock_Slave::start)));
|
||||
@@ -71,11 +70,11 @@ MIDIClock_Slave::rebind (MIDI::Port& p)
|
||||
void
|
||||
MIDIClock_Slave::update_midi_clock (Parser& parser)
|
||||
{
|
||||
// ignore clock events if no start event received
|
||||
if(!_started)
|
||||
return;
|
||||
|
||||
nframes_t now = session.engine().frame_time();
|
||||
_starting = false;
|
||||
|
||||
std::cerr << "got MIDI Clock message at time " << now << std::endl;
|
||||
|
||||
SafeTime last;
|
||||
read_current (&last);
|
||||
@@ -98,6 +97,12 @@ MIDIClock_Slave::update_midi_clock (Parser& parser)
|
||||
midi_clock_frame += (long) (one_ppqn_in_frames)
|
||||
+ session.worst_output_latency();
|
||||
|
||||
/*
|
||||
std::cerr << "got MIDI Clock message at time " << now
|
||||
<< " result: " << midi_clock_frame
|
||||
<< " open_ppqn_in_frames: " << one_ppqn_in_frames << std::endl;
|
||||
*/
|
||||
|
||||
if (first_midi_clock_frame == 0) {
|
||||
first_midi_clock_frame = midi_clock_frame;
|
||||
first_midi_clock_time = now;
|
||||
@@ -117,7 +122,7 @@ MIDIClock_Slave::start (Parser& parser)
|
||||
std::cerr << "MIDIClock_Slave got start message" << endl;
|
||||
|
||||
midi_clock_speed = 1.0f;
|
||||
_starting = true;
|
||||
_started = true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -126,13 +131,7 @@ MIDIClock_Slave::stop (Parser& parser)
|
||||
std::cerr << "MIDIClock_Slave got stop message" << endl;
|
||||
|
||||
midi_clock_speed = 0.0f;
|
||||
midi_clock_frame = 0;
|
||||
_starting = false;
|
||||
|
||||
current.guard1++;
|
||||
current.position = midi_clock_frame;
|
||||
current.timestamp = 0;
|
||||
current.guard2++;
|
||||
_started = false;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -197,6 +196,8 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
|
||||
|
||||
speed_now = (float) ((last.position - first_midi_clock_frame) / (double) (now - first_midi_clock_time));
|
||||
|
||||
cerr << "speed_and_position: speed_now: " << speed_now ;
|
||||
|
||||
accumulator[accumulator_index++] = speed_now;
|
||||
|
||||
if (accumulator_index >= accumulator_size) {
|
||||
@@ -239,6 +240,8 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
|
||||
pos = elapsed + last.position;
|
||||
|
||||
speed = midi_clock_speed;
|
||||
|
||||
cerr << " final speed: " << speed << " position: " << pos << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -333,6 +333,8 @@ Session::set_trace_midi_input (bool yn, MIDI::Port* port)
|
||||
{
|
||||
MIDI::Parser* input_parser;
|
||||
|
||||
cerr << "enabling tracing: " << yn << " for input port " << port->name() << endl;
|
||||
|
||||
if (port) {
|
||||
if ((input_parser = port->input()) != 0) {
|
||||
input_parser->trace (yn, &cout, "input: ");
|
||||
@@ -356,6 +358,15 @@ Session::set_trace_midi_input (bool yn, MIDI::Port* port)
|
||||
input_parser->trace (yn, &cout, "input: ");
|
||||
}
|
||||
}
|
||||
|
||||
if (_midi_clock_port
|
||||
&& _midi_clock_port != _mmc_port
|
||||
&& _midi_clock_port != _mtc_port
|
||||
&& _midi_clock_port != _midi_port) {
|
||||
if ((input_parser = _midi_clock_port->input()) != 0) {
|
||||
input_parser->trace (yn, &cout, "input: ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Config->set_trace_midi_input (yn);
|
||||
@@ -1152,9 +1163,7 @@ Session::midi_thread_work ()
|
||||
nfds++;
|
||||
}
|
||||
|
||||
cerr << "before handling midi clock port" << endl;
|
||||
if (_midi_clock_port && (_midi_clock_port != _mmc_port || !Config->get_mmc_control()) && _midi_clock_port->selectable() >= 0) {
|
||||
cerr << "inside handling midi clock port" << endl;
|
||||
pfd[nfds].fd = _midi_clock_port->selectable();
|
||||
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
|
||||
ports[nfds] = _midi_clock_port;
|
||||
|
||||
@@ -60,9 +60,29 @@ JACK_MidiPort::cycle_start (nframes_t nframes)
|
||||
_last_read_index = 0;
|
||||
_last_write_timestamp = 0;
|
||||
|
||||
// output
|
||||
void *buffer = jack_port_get_buffer (_jack_output_port, nframes);
|
||||
jack_midi_clear_buffer (buffer);
|
||||
flush (buffer);
|
||||
|
||||
// input
|
||||
void* jack_buffer = jack_port_get_buffer(_jack_input_port, nframes);
|
||||
const nframes_t event_count = jack_midi_get_event_count(jack_buffer);
|
||||
|
||||
jack_midi_event_t ev;
|
||||
|
||||
for (nframes_t i=0; i < event_count; ++i) {
|
||||
|
||||
jack_midi_event_get (&ev, jack_buffer, i);
|
||||
|
||||
if (input_parser) {
|
||||
input_parser->raw_preparse (*input_parser, ev.buffer, ev.size);
|
||||
for (size_t i = 0; i < ev.size; i++) {
|
||||
input_parser->scanner (ev.buffer[i]);
|
||||
}
|
||||
input_parser->raw_postparse (*input_parser, ev.buffer, ev.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@@ -170,7 +190,7 @@ JACK_MidiPort::read(byte * buf, size_t bufsize)
|
||||
{
|
||||
assert(_currently_in_cycle);
|
||||
assert(_jack_input_port);
|
||||
|
||||
|
||||
jack_midi_event_t ev;
|
||||
|
||||
int err = jack_midi_event_get (&ev,
|
||||
|
||||
@@ -314,6 +314,7 @@ Parser::trace (bool onoff, ostream *o, const string &prefix)
|
||||
trace_connection.disconnect ();
|
||||
|
||||
if (onoff) {
|
||||
cerr << "enabling tracing for port " << _port.name() << endl;
|
||||
trace_stream = o;
|
||||
trace_prefix = prefix;
|
||||
trace_connection = any.connect (mem_fun (*this, &Parser::trace_event));
|
||||
|
||||
Reference in New Issue
Block a user