summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-19 14:59:47 +0000
committerDavid Robillard <d@drobilla.net>2007-04-19 14:59:47 +0000
commit71d83ce627f8d8ddfc381312155d1a05082618b2 (patch)
tree4a72651c9e91714e7359eff3f710ab1bd9fe8735 /src
parent7743f1b787692e6c6cc4a84f08d9ca1b39974917 (diff)
downloadingen-71d83ce627f8d8ddfc381312155d1a05082618b2.tar.gz
ingen-71d83ce627f8d8ddfc381312155d1a05082618b2.tar.bz2
ingen-71d83ce627f8d8ddfc381312155d1a05082618b2.zip
Applied patch from larsl to fix DSSI MIDI.
git-svn-id: http://svn.drobilla.net/lad/ingen@456 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/engine/DSSINode.cpp59
-rw-r--r--src/libs/engine/DSSINode.h7
-rw-r--r--src/libs/engine/LADSPANode.cpp1
3 files changed, 49 insertions, 18 deletions
diff --git a/src/libs/engine/DSSINode.cpp b/src/libs/engine/DSSINode.cpp
index ff9fd11a..53af15ef 100644
--- a/src/libs/engine/DSSINode.cpp
+++ b/src/libs/engine/DSSINode.cpp
@@ -36,6 +36,7 @@ DSSINode::DSSINode(const Plugin* plugin, const string& name, size_t poly, Patch*
_bank(-1),
_program(-1),
_midi_in_port(NULL),
+ _midi_in_buffer(NULL),
_alsa_events(new snd_seq_event_t[_buffer_size]),
_alsa_encoder(NULL)
{
@@ -135,23 +136,30 @@ DSSINode::program(int bank, int program)
void
-DSSINode::convert_events()
+DSSINode::convert_events(SampleCount nframes)
{
assert(has_midi_input());
- assert(_midi_in_port != NULL);
-#if 0
- Buffer<MidiMessage>& buffer = *_midi_in_port->buffer(0);
+
_encoded_events = 0;
-
- for (size_t i = 0; i < buffer.filled_size(); ++i) {
- snd_midi_event_encode(_alsa_encoder, buffer.value_at(i).buffer,
- buffer.value_at(i).size,
- &_alsa_events[_encoded_events]);
- _alsa_events[_encoded_events].time.tick = buffer.value_at(i).time;
- if (_alsa_events[_encoded_events].type != SND_SEQ_EVENT_NONE)
- ++_encoded_events;
+ MidiBuffer& buffer = *_midi_in_buffer;
+
+ if (_midi_in_buffer == 0)
+ return;
+
+ buffer.prepare_read(nframes);
+ double timestamp;
+ uint32_t size;
+ unsigned char* data;
+ while (buffer.get_event(&timestamp, &size, &data) < nframes &&
+ _encoded_events < _buffer_size) {
+ snd_midi_event_encode(_alsa_encoder, data, size,
+ &_alsa_events[_encoded_events]);
+ _alsa_events[_encoded_events].time.tick =
+ (snd_seq_tick_time_t)timestamp;
+ if (_alsa_events[_encoded_events].type != SND_SEQ_EVENT_NONE)
+ ++_encoded_events;
+ buffer.increment();
}
-#endif
}
@@ -168,11 +176,11 @@ DSSINode::process(SampleCount nframes, FrameTime start, FrameTime end)
NodeBase::pre_process(nframes, start, end);
if (_dssi_descriptor->run_synth) {
- convert_events();
+ convert_events(nframes);
_dssi_descriptor->run_synth(_instances[0], nframes,
_alsa_events, _encoded_events);
} else if (_dssi_descriptor->run_multiple_synths) {
- convert_events();
+ convert_events(nframes);
// I hate this stupid function
snd_seq_event_t* events[1] = { _alsa_events };
long unsigned events_sizes[1] = { _encoded_events };
@@ -187,6 +195,27 @@ DSSINode::process(SampleCount nframes, FrameTime start, FrameTime end)
void
+DSSINode::set_port_buffer(size_t voice, size_t port_num, Buffer* buf)
+{
+ assert(voice < _poly);
+
+ // Could be a MIDI port after this
+ if (port_num < _descriptor->PortCount) {
+ AudioBuffer* audio_buffer = dynamic_cast<AudioBuffer*>(buf);
+ assert(audio_buffer);
+ _descriptor->connect_port(_instances[voice], port_num,
+ audio_buffer->data());
+ }
+
+ else if (port_num == _descriptor->PortCount && has_midi_input()) {
+ MidiBuffer* midi_buffer = dynamic_cast<MidiBuffer*>(buf);
+ assert(midi_buffer);
+ _midi_in_buffer = midi_buffer;
+ }
+}
+
+
+void
DSSINode::send_control(int port_num, float value)
{
string path = _ui_base_path + "/control";
diff --git a/src/libs/engine/DSSINode.h b/src/libs/engine/DSSINode.h
index 9be7b761..ffe1a641 100644
--- a/src/libs/engine/DSSINode.h
+++ b/src/libs/engine/DSSINode.h
@@ -55,7 +55,9 @@ public:
void program(int bank, int program);
void process(SampleCount nframes, FrameTime start, FrameTime end);
-
+
+ void set_port_buffer(size_t voice, size_t port_num, Buffer* buf);
+
bool update_programs(bool send_events);
void set_default_program();
const std::map<int, Bank>& get_programs() const;
@@ -75,7 +77,7 @@ private:
void send_quit();
// Conversion to ALSA MIDI events
- void convert_events();
+ void convert_events(SampleCount nframes);
DSSI_Descriptor* _dssi_descriptor;
@@ -91,6 +93,7 @@ private:
std::map<int, Bank> _banks;
InputPort* _midi_in_port;
+ MidiBuffer* _midi_in_buffer;
snd_seq_event_t* _alsa_events;
unsigned long _encoded_events;
snd_midi_event_t* _alsa_encoder;
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index b347afa6..ff32fc04 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -193,7 +193,6 @@ LADSPANode::set_port_buffer(size_t voice, size_t port_num, Buffer* buf)
AudioBuffer* audio_buffer = dynamic_cast<AudioBuffer*>(buf);
assert(audio_buffer);
- // Could be a MIDI port after this
if (port_num < _descriptor->PortCount)
_descriptor->connect_port(_instances[voice], port_num,
audio_buffer->data());