diff options
author | Hans Baier <hansfbaier@googlemail.com> | 2008-11-22 15:40:19 +0000 |
---|---|---|
committer | Hans Baier <hansfbaier@googlemail.com> | 2008-11-22 15:40:19 +0000 |
commit | 2f07b77503f01e75970241e3aa4c9b6fc723a83f (patch) | |
tree | 6689c54d7d37509e92cb52ef514f466280096b79 /libs | |
parent | 5de817c2509b3f8ab35e1aea7292e84ca51037ab (diff) |
* 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
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/midi_ring_buffer.h | 8 | ||||
-rw-r--r-- | libs/evoral/evoral/MIDIEvent.hpp | 2 | ||||
-rw-r--r-- | libs/evoral/src/MIDIEvent.cpp | 14 | ||||
-rw-r--r-- | libs/midi++2/jack_midiport.cc | 38 |
4 files changed, 39 insertions, 23 deletions
diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index 8bd4260283..ba271df615 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -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 diff --git a/libs/evoral/evoral/MIDIEvent.hpp b/libs/evoral/evoral/MIDIEvent.hpp index 863103aa74..bbf1e580f1 100644 --- a/libs/evoral/evoral/MIDIEvent.hpp +++ b/libs/evoral/evoral/MIDIEvent.hpp @@ -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) diff --git a/libs/evoral/src/MIDIEvent.cpp b/libs/evoral/src/MIDIEvent.cpp index 35161515d6..7617d2ae9a 100644 --- a/libs/evoral/src/MIDIEvent.cpp +++ b/libs/evoral/src/MIDIEvent.cpp @@ -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())); } } diff --git a/libs/midi++2/jack_midiport.cc b/libs/midi++2/jack_midiport.cc index 6f3661d937..0464649989 100644 --- a/libs/midi++2/jack_midiport.cc +++ b/libs/midi++2/jack_midiport.cc @@ -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]); + } + } + } } } |