diff options
author | Robin Gareus <robin@gareus.org> | 2017-08-05 15:04:05 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-08-05 15:36:36 +0200 |
commit | 2b7c585dbae9c989d35e2884060aad4b0270f90e (patch) | |
tree | 37e0f7fe263ad221ad29f4497383bea6ce0946f2 /libs | |
parent | f9aff37623ba17a80371572fcba38515ea9b78ca (diff) |
Update backend API: read-only MIDI input buffers
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/mididm.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/port_engine.h | 2 | ||||
-rw-r--r-- | libs/ardour/midi_port.cc | 27 | ||||
-rw-r--r-- | libs/ardour/mididm.cc | 6 | ||||
-rw-r--r-- | libs/backends/alsa/alsa_audiobackend.cc | 2 | ||||
-rw-r--r-- | libs/backends/alsa/alsa_audiobackend.h | 2 | ||||
-rw-r--r-- | libs/backends/coreaudio/coreaudio_backend.cc | 2 | ||||
-rw-r--r-- | libs/backends/coreaudio/coreaudio_backend.h | 2 | ||||
-rw-r--r-- | libs/backends/dummy/dummy_audiobackend.cc | 2 | ||||
-rw-r--r-- | libs/backends/dummy/dummy_audiobackend.h | 2 | ||||
-rw-r--r-- | libs/backends/jack/jack_audiobackend.h | 2 | ||||
-rw-r--r-- | libs/backends/jack/jack_portengine.cc | 2 | ||||
-rw-r--r-- | libs/backends/portaudio/portaudio_backend.cc | 2 | ||||
-rw-r--r-- | libs/backends/portaudio/portaudio_backend.h | 2 |
14 files changed, 32 insertions, 27 deletions
diff --git a/libs/ardour/ardour/mididm.h b/libs/ardour/ardour/mididm.h index 65ed15ab72..5ee964c8e0 100644 --- a/libs/ardour/ardour/mididm.h +++ b/libs/ardour/ardour/mididm.h @@ -41,8 +41,8 @@ public: bool have_signal (void) { return (_monotonic_cnt - _last_signal_tme) < (uint64_t) _sample_rate ; } private: - int64_t parse_mclk (uint8_t* buf, pframes_t timestamp) const; - int64_t parse_mtc (uint8_t* buf, pframes_t timestamp) const; + int64_t parse_mclk (uint8_t const * const buf, pframes_t timestamp) const; + int64_t parse_mtc (uint8_t const * const buf, pframes_t timestamp) const; framecnt_t _sample_rate; diff --git a/libs/ardour/ardour/port_engine.h b/libs/ardour/ardour/port_engine.h index a6fa2a5c84..647253baea 100644 --- a/libs/ardour/ardour/port_engine.h +++ b/libs/ardour/ardour/port_engine.h @@ -245,7 +245,7 @@ class LIBARDOUR_API PortEngine { * of the current process cycle, in samples) will be stored in @param * timestamp */ - virtual int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index) = 0; + virtual int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) = 0; /** Place a MIDI event consisting of @param size bytes copied from the data * at @param buf into the port buffer referred to by @param diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 9a52aef3c6..7a87c4c273 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -129,28 +129,33 @@ MidiPort::get_midi_buffer (pframes_t nframes) pframes_t timestamp; size_t size; - uint8_t* buf; + uint8_t const* buf; port_engine.midi_event_get (timestamp, size, &buf, buffer, i); if (buf[0] == 0xfe) { /* throw away active sensing */ continue; - } else if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) { - /* normalize note on with velocity 0 to proper note off */ - buf[0] = 0x80 | (buf[0] & 0x0F); /* note off */ - buf[2] = 0x40; /* default velocity */ } /* check that the event is in the acceptable time range */ + if ((timestamp < (_global_port_buffer_offset + _port_buffer_offset)) || + (timestamp >= (_global_port_buffer_offset + _port_buffer_offset + nframes))) { + cerr << "Dropping incoming MIDI at time " << timestamp << "; offset=" + << _global_port_buffer_offset << " limit=" + << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n"; + continue; + } - if ((timestamp >= (_global_port_buffer_offset + _port_buffer_offset)) && - (timestamp < (_global_port_buffer_offset + _port_buffer_offset + nframes))) { - _buffer->push_back (timestamp, size, buf); + if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) { + /* normalize note on with velocity 0 to proper note off */ + uint8_t ev[3]; + ev[0] = 0x80 | (buf[0] & 0x0F); /* note off */ + ev[1] = buf[1]; + ev[2] = 0x40; /* default velocity */ + _buffer->push_back (timestamp, size, ev); } else { - cerr << "Dropping incoming MIDI at time " << timestamp << "; offset=" - << _global_port_buffer_offset << " limit=" - << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n"; + _buffer->push_back (timestamp, size, buf); } } diff --git a/libs/ardour/mididm.cc b/libs/ardour/mididm.cc index 0888d154e9..0b95fc1bd5 100644 --- a/libs/ardour/mididm.cc +++ b/libs/ardour/mididm.cc @@ -37,7 +37,7 @@ MIDIDM::MIDIDM (framecnt_t sample_rate) } int64_t -MIDIDM::parse_mclk (uint8_t* buf, pframes_t timestamp) const +MIDIDM::parse_mclk (uint8_t const * const buf, pframes_t timestamp) const { /* calculate time difference */ #define MODCLK (16384) // 1<<(2*7) @@ -52,7 +52,7 @@ MIDIDM::parse_mclk (uint8_t* buf, pframes_t timestamp) const } int64_t -MIDIDM::parse_mtc (uint8_t* buf, pframes_t timestamp) const +MIDIDM::parse_mtc (uint8_t const * const buf, pframes_t timestamp) const { #define MODTC (2097152) // 1<<(3*7) const int64_t tc = (_monotonic_cnt + timestamp) & 0x001FFFFF; @@ -101,7 +101,7 @@ int MIDIDM::process (pframes_t nframes, PortEngine &pe, void *midi_in, void *mid for (pframes_t n = 0; n < nevents; ++n) { pframes_t timestamp; size_t size; - uint8_t* buf; + uint8_t const* buf; int64_t tdiff; pe.midi_event_get (timestamp, size, &buf, midi_in, n); diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 95b95112d6..9d3dc96f43 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -1685,7 +1685,7 @@ AlsaAudioBackend::get_connections (PortEngine::PortHandle port, std::vector<std: int AlsaAudioBackend::midi_event_get ( pframes_t& timestamp, - size_t& size, uint8_t** buf, void* port_buffer, + size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) { assert (buf && port_buffer); diff --git a/libs/backends/alsa/alsa_audiobackend.h b/libs/backends/alsa/alsa_audiobackend.h index bc2620ed9e..97cba16ba5 100644 --- a/libs/backends/alsa/alsa_audiobackend.h +++ b/libs/backends/alsa/alsa_audiobackend.h @@ -291,7 +291,7 @@ class AlsaAudioBackend : public AudioBackend { int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe); /* MIDI */ - int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index); int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size); uint32_t get_midi_event_count (void* port_buffer); void midi_clear (void* port_buffer); diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 9e295662f7..060c7b5db3 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -1407,7 +1407,7 @@ CoreAudioBackend::get_connections (PortEngine::PortHandle port, std::vector<std: int CoreAudioBackend::midi_event_get ( pframes_t& timestamp, - size_t& size, uint8_t** buf, void* port_buffer, + size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) { if (!buf || !port_buffer) return -1; diff --git a/libs/backends/coreaudio/coreaudio_backend.h b/libs/backends/coreaudio/coreaudio_backend.h index 03edf4f6ed..1a302bc749 100644 --- a/libs/backends/coreaudio/coreaudio_backend.h +++ b/libs/backends/coreaudio/coreaudio_backend.h @@ -352,7 +352,7 @@ class CoreAudioBackend : public AudioBackend { int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe); /* MIDI */ - int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index); int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size) { return _midi_event_put (port_buffer, timestamp, buffer, size); } diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index 9d33d96636..692cdc3e08 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -1082,7 +1082,7 @@ DummyAudioBackend::get_connections (PortEngine::PortHandle port, std::vector<std int DummyAudioBackend::midi_event_get ( pframes_t& timestamp, - size_t& size, uint8_t** buf, void* port_buffer, + size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) { assert (buf && port_buffer); diff --git a/libs/backends/dummy/dummy_audiobackend.h b/libs/backends/dummy/dummy_audiobackend.h index 4087cedc49..f009fba59c 100644 --- a/libs/backends/dummy/dummy_audiobackend.h +++ b/libs/backends/dummy/dummy_audiobackend.h @@ -360,7 +360,7 @@ class DummyAudioBackend : public AudioBackend { int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe); /* MIDI */ - int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index); int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size); uint32_t get_midi_event_count (void* port_buffer); void midi_clear (void* port_buffer); diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h index 847b21b767..2c67dc72fd 100644 --- a/libs/backends/jack/jack_audiobackend.h +++ b/libs/backends/jack/jack_audiobackend.h @@ -175,7 +175,7 @@ class JACKAudioBackend : public AudioBackend { return true; } - int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index); int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size); uint32_t get_midi_event_count (void* port_buffer); void midi_clear (void* port_buffer); diff --git a/libs/backends/jack/jack_portengine.cc b/libs/backends/jack/jack_portengine.cc index a73f4608aa..dfa2bdad11 100644 --- a/libs/backends/jack/jack_portengine.cc +++ b/libs/backends/jack/jack_portengine.cc @@ -488,7 +488,7 @@ JACKAudioBackend::disconnect_all (PortHandle port) } int -JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index) +JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) { jack_midi_event_t ev; int ret; diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index d6607595f0..3ce0f094ac 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -1610,7 +1610,7 @@ PortAudioBackend::get_connections (PortEngine::PortHandle port, std::vector<std: int PortAudioBackend::midi_event_get ( pframes_t& timestamp, - size_t& size, uint8_t** buf, void* port_buffer, + size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index) { if (!buf || !port_buffer) return -1; diff --git a/libs/backends/portaudio/portaudio_backend.h b/libs/backends/portaudio/portaudio_backend.h index 601c3433cb..34bdabe787 100644 --- a/libs/backends/portaudio/portaudio_backend.h +++ b/libs/backends/portaudio/portaudio_backend.h @@ -288,7 +288,7 @@ class PortAudioBackend : public AudioBackend { int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe); /* MIDI */ - int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index); int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size); uint32_t get_midi_event_count (void* port_buffer); void midi_clear (void* port_buffer); |