From ed6c5727c044a4c7047394a539210659c1c31d86 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 16 Jul 2011 09:56:31 +0100 Subject: [PATCH] Fixing, almost there --- .../audio/plugin_client/LV2/juce_LV2_Wrapper.cpp | 60 ++++++++++++---------- .../src/audio/plugin_client/LV2/lv2_rdf_gen.cpp | 28 ++++------ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/juce/source/src/audio/plugin_client/LV2/juce_LV2_Wrapper.cpp b/juce/source/src/audio/plugin_client/LV2/juce_LV2_Wrapper.cpp index d75ff8f..140058f 100644 --- a/juce/source/src/audio/plugin_client/LV2/juce_LV2_Wrapper.cpp +++ b/juce/source/src/audio/plugin_client/LV2/juce_LV2_Wrapper.cpp @@ -110,6 +110,7 @@ public: ~JuceLV2Wrapper() { printf("~JuceLV2Wrapper()\n"); + channels.free(); ports_ctrl.clear(); ports_ctrl_last.clear(); deleteAndZero(filter); @@ -162,6 +163,8 @@ public: void do_activate() { if (filter != nullptr) { + channels.calloc(JucePlugin_MaxNumInputChannels + JucePlugin_MaxNumOutputChannels); + filter->setNonRealtime(false); filter->setPlayConfigDetails(JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels, sample_rate, buffer_size); filter->prepareToPlay(sample_rate, buffer_size); @@ -176,46 +179,48 @@ public: #endif } -#if 0 - wrapper->filter->setNonRealtime(false); - wrapper->filter->setPlayConfigDetails(JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels, wrapper->sample_rate, block_size); - wrapper->filter->prepareToPlay(wrapper->sample_rate, block_size); - //updateParameters(); - wrapper->midi_buffer.ensureSize(2048); - wrapper->midi_buffer.clear(); -#endif } void do_run(uint32_t sample_count) { -#if 0 - int padding = get_parameters_padding(); + // Change buffer size if needed + if (buffer_size != sample_count) { + buffer_size = sample_count; + filter->setPlayConfigDetails(JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels, sample_rate, buffer_size); + filter->prepareToPlay(sample_rate, buffer_size); + } /* Check for updated parameters */ - for (int i = 0; i < ports_control.size(); i++) { - if (ports_control[i] != nullptr) { - float cur_value = *(float*)ports_control[i]; - if (ports_control_last[i] != cur_value) { - filter->setParameter(i+padding, cur_value); + int ctrl_pad = get_parameters_padding(); + + for (int i = 0; i < ports_ctrl.size(); i++) { + if (ports_ctrl[i] != nullptr) { + float cur_value = *(float*)ports_ctrl[i]; + if (ports_ctrl_last[i] != cur_value) { + filter->setParameter(i+ctrl_pad, cur_value); } } } - //const ScopedLock sl(wrapper->filter->getCallbackLock()); + int k = 0; + for (; k < JucePlugin_MaxNumInputChannels; k++) { + channels[k] = ports_ain[k]; + } + + for (int j=0; k < JucePlugin_MaxNumOutputChannels; j++, k++) { + channels[k] = ports_ain[j]; + } + + //const ScopedLock sl(filter->getCallbackLock()); - if (wrapper->filter->isSuspended()) { - for (int i=0; iports_output[i], sizeof(float)*sample_count); + if (filter->isSuspended()) { + for (int i = 0; i < JucePlugin_MaxNumOutputChannels; i++) { + zeromem(ports_aout[i], sizeof(float) * sample_count); } } else { - AudioSampleBuffer chans(wrapper->ports_output, JucePlugin_MaxNumOutputChannels, sample_count); - wrapper->filter->processBlock(chans, wrapper->midi_buffer); + AudioSampleBuffer chans(channels, jmax(JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels), sample_count); + filter->processBlock(chans, midi_buffer); } - - if (!wrapper->midi_buffer.isEmpty()) { - wrapper->midi_buffer.clear(); - } -#endif } void do_deactivate() @@ -224,6 +229,7 @@ public: { filter->releaseResources(); //outgoingEvents.freeEvents(); + channels.free(); } } @@ -248,6 +254,8 @@ private: Array ports_ctrl; Array ports_ctrl_last; + HeapBlock channels; + #if JucePlugin_WantsMidiInput || JucePlugin_ProducesMidiOutput uint16_t midi_uri_id; MidiBuffer midi_buffer; diff --git a/juce/source/src/audio/plugin_client/LV2/lv2_rdf_gen.cpp b/juce/source/src/audio/plugin_client/LV2/lv2_rdf_gen.cpp index 45f8346..de3fb0b 100644 --- a/juce/source/src/audio/plugin_client/LV2/lv2_rdf_gen.cpp +++ b/juce/source/src/audio/plugin_client/LV2/lv2_rdf_gen.cpp @@ -6,7 +6,7 @@ #include #include -#include "JuceHeader.h" +#include "juce.h" #include "JucePluginCharacteristics.h" // These are dummy values! @@ -136,12 +136,12 @@ String get_plugin_ttl(String URI, String Binary) plugin += "\n"; if (filter->hasEditor()) { - plugin += "<" + get_juce_ui_uri() + ">\n"; - plugin += " a lv2ui:JUCEUI ;\n"; - plugin += " lv2ui:binary <" + Binary + ".so> .\n"; plugin += "<" + get_external_ui_uri() + ">\n"; plugin += " a lv2ui:external ;\n"; plugin += " lv2ui:binary <" + Binary + ".so> .\n"; + plugin += "<" + get_juce_ui_uri() + ">\n"; + plugin += " a lv2ui:JUCEUI ;\n"; + plugin += " lv2ui:binary <" + Binary + ".so> .\n"; plugin += "\n"; } @@ -158,7 +158,7 @@ String get_plugin_ttl(String URI, String Binary) plugin += " lv2:index " + String(port_index) + ";\n"; plugin += " lv2:symbol \"midi_in\";\n"; plugin += " lv2:name \"MIDI Input\";\n"; - plugin += " ] ;\n"; + plugin += " ] ;\n\n"; port_index++; #endif @@ -169,14 +169,10 @@ String get_plugin_ttl(String URI, String Binary) plugin += " lv2:index " + String(port_index) + ";\n"; plugin += " lv2:symbol \"midi_out\";\n"; plugin += " lv2:name \"MIDI Output\";\n"; - plugin += " ] ;\n"; + plugin += " ] ;\n\n"; port_index++; #endif -#if JucePlugin_WantsMidiInput || JucePlugin_ProducesMidiOutput - plugin += "\n"; -#endif - for (i=0; i 0 || JucePlugin_MaxNumOutputChannels > 0 - plugin += "\n"; -#endif - for (i=0; i < filter->getNumParameters(); i++) { if (i == 0) { plugin += " lv2:port [\n"; @@ -243,8 +235,8 @@ String get_plugin_ttl(String URI, String Binary) plugin += " lv2:maximum 1.0;\n"; // TODO - units - if (i == JucePlugin_MaxNumOutputChannels-1) { - plugin += " ] ;\n"; + if (i == filter->getNumParameters()-1) { + plugin += " ] ;\n\n"; } else { plugin += " ],\n"; } -- 2.11.4.GIT