* added XML deserialisation for control and program changes

* added pointer checks
* fixed typos in comments


git-svn-id: svn://localhost/ardour2/branches/3.0@4234 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier
2008-11-22 15:40:19 +00:00
parent 5de817c250
commit 2f07b77503
4 changed files with 39 additions and 23 deletions

View File

@@ -85,7 +85,7 @@ private:
/** Read the time and size of an event. This call MUST be immediately proceeded
* by a call to read_contents (or the read pointer will be garabage).
* by a call to read_contents (or the read pointer will be garbage).
*/
inline bool
MidiRingBuffer::read_prefix(Evoral::EventTime* time, Evoral::EventType* type, uint32_t* size)
@@ -100,8 +100,8 @@ MidiRingBuffer::read_prefix(Evoral::EventTime* time, Evoral::EventType* type, ui
}
/** Read the contenst of an event. This call MUST be immediately preceeded
* by a call to read_prefix (or the returned even will be garabage).
/** Read the content of an event. This call MUST be immediately preceded
* by a call to read_prefix (or the returned even will be garbage).
*/
inline bool
MidiRingBuffer::read_contents(uint32_t size, uint8_t* buf)
@@ -112,7 +112,7 @@ MidiRingBuffer::read_contents(uint32_t size, uint8_t* buf)
/** Read a block of MIDI events from buffer.
*
* Timestamps of events returned are relative to start (ie event with stamp 0
* Timestamps of events returned are relative to start (i.e. event with stamp 0
* occurred at start), with offset added.
*/
inline size_t

View File

@@ -69,7 +69,9 @@ struct MIDIEvent : public Event {
inline uint8_t note() const { return (_buffer[1]); }
inline uint8_t velocity() const { return (_buffer[2]); }
inline uint8_t cc_number() const { return (_buffer[1]); }
inline void set_cc_number(uint8_t number) { _buffer[1] = number; }
inline uint8_t cc_value() const { return (_buffer[2]); }
inline void set_cc_value(uint8_t value) { _buffer[2] = value; }
inline uint8_t pitch_bender_lsb() const { return (_buffer[1]); }
inline uint8_t pitch_bender_msb() const { return (_buffer[2]); }
inline uint16_t pitch_bender_value() const { return ( ((0x7F & _buffer[2]) << 7)

View File

@@ -22,14 +22,24 @@ namespace Evoral {
#ifdef EVORAL_MIDI_XML
MIDIEvent::MIDIEvent(const XMLNode& event)
MIDIEvent::MIDIEvent(const XMLNode& event)
: Event()
{
string name = event.name();
if (name == "ControlChange") {
_buffer = (uint8_t*) ::malloc(3);
_owns_buffer = true;
set_type(MIDI_CMD_CONTROL);
set_cc_number(atoi(event.property("Control")->value().c_str()));
set_cc_value (atoi(event.property("Value")->value().c_str()));
} else if (name == "ProgramChange") {
_buffer = (uint8_t*) ::malloc(2);
_owns_buffer = true;
set_type(MIDI_CMD_PGM_CHANGE);
set_pgm_number(atoi(event.property("Number")->value().c_str()));
}
}

View File

@@ -60,28 +60,32 @@ 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);
if (_jack_output_port != 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);
if (_jack_input_port != 0) {
// 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;
jack_midi_event_t ev;
for (nframes_t i=0; i < event_count; ++i) {
for (nframes_t i=0; i < event_count; ++i) {
jack_midi_event_get (&ev, jack_buffer, i);
jack_midi_event_get (&ev, jack_buffer, i);
if (input_parser) {
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]);
}
}
if (input_parser) {
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]);
}
}
}
}
}