diff options
author | Hans Baier <hansfbaier@googlemail.com> | 2008-08-06 22:22:35 +0000 |
---|---|---|
committer | Hans Baier <hansfbaier@googlemail.com> | 2008-08-06 22:22:35 +0000 |
commit | 8164a0992d005659fe4cce1dce12f6464438f371 (patch) | |
tree | 5f1a95ee980d5f08f80dd1843275c98ed69b9a39 /libs | |
parent | 6954080ce18e0eee08361c02b1f25bd4512e9d90 (diff) |
* 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
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/slave.h | 3 | ||||
-rw-r--r-- | libs/ardour/midi_clock_slave.cc | 27 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 13 | ||||
-rw-r--r-- | libs/midi++2/jack_midiport.cc | 22 | ||||
-rw-r--r-- | libs/midi++2/midiparser.cc | 1 |
5 files changed, 49 insertions, 17 deletions
diff --git a/libs/ardour/ardour/slave.h b/libs/ardour/ardour/slave.h index 9df8574430..0656ed305d 100644 --- a/libs/ardour/ardour/slave.h +++ b/libs/ardour/ardour/slave.h @@ -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 diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 841dc55d25..569f14eeb5 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -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; } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index a807c5e98b..dd927a3add 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -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; diff --git a/libs/midi++2/jack_midiport.cc b/libs/midi++2/jack_midiport.cc index 0b49517212..5b9fb79a4f 100644 --- a/libs/midi++2/jack_midiport.cc +++ b/libs/midi++2/jack_midiport.cc @@ -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, diff --git a/libs/midi++2/midiparser.cc b/libs/midi++2/midiparser.cc index 4a058e102a..b533195c5f 100644 --- a/libs/midi++2/midiparser.cc +++ b/libs/midi++2/midiparser.cc @@ -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)); |