Signed-off-by: falkTX <falktx@falktx.com>pull/417/head
@@ -21,6 +21,18 @@ | |||
#include "../../extra/RingBuffer.hpp" | |||
#if DISTRHO_PLUGIN_NUM_INPUTS > 2 | |||
# define DISTRHO_PLUGIN_NUM_INPUTS_2 2 | |||
#else | |||
# define DISTRHO_PLUGIN_NUM_INPUTS_2 DISTRHO_PLUGIN_NUM_INPUTS | |||
#endif | |||
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 2 | |||
# define DISTRHO_PLUGIN_NUM_OUTPUTS_2 2 | |||
#else | |||
# define DISTRHO_PLUGIN_NUM_OUTPUTS_2 DISTRHO_PLUGIN_NUM_OUTPUTS | |||
#endif | |||
using DISTRHO_NAMESPACE::HeapRingBuffer; | |||
struct NativeBridge { | |||
@@ -302,7 +302,7 @@ struct RtAudioBridge : NativeBridge { | |||
if (withInput) | |||
{ | |||
inParams.deviceId = rtAudio->getDefaultInputDevice(); | |||
inParams.nChannels = DISTRHO_PLUGIN_NUM_INPUTS; | |||
inParams.nChannels = DISTRHO_PLUGIN_NUM_INPUTS_2; | |||
inParamsPtr = &inParams; | |||
} | |||
#endif | |||
@@ -310,7 +310,7 @@ struct RtAudioBridge : NativeBridge { | |||
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 | |||
RtAudio::StreamParameters outParams; | |||
outParams.deviceId = rtAudio->getDefaultOutputDevice(); | |||
outParams.nChannels = DISTRHO_PLUGIN_NUM_OUTPUTS; | |||
outParams.nChannels = DISTRHO_PLUGIN_NUM_OUTPUTS_2; | |||
RtAudio::StreamParameters* const outParamsPtr = &outParams; | |||
#else | |||
RtAudio::StreamParameters* const outParamsPtr = nullptr; | |||
@@ -359,14 +359,14 @@ struct RtAudioBridge : NativeBridge { | |||
if (self->jackProcessCallback == nullptr) | |||
{ | |||
if (outputBuffer != nullptr) | |||
std::memset((float*)outputBuffer, 0, sizeof(float)*numFrames*DISTRHO_PLUGIN_NUM_OUTPUTS); | |||
std::memset((float*)outputBuffer, 0, sizeof(float)*numFrames*DISTRHO_PLUGIN_NUM_OUTPUTS_2); | |||
return 0; | |||
} | |||
#if DISTRHO_PLUGIN_NUM_INPUTS > 0 | |||
if (float* const insPtr = static_cast<float*>(inputBuffer)) | |||
{ | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_INPUTS; ++i) | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_INPUTS_2; ++i) | |||
self->audioBuffers[i] = insPtr + (i * numFrames); | |||
} | |||
#endif | |||
@@ -374,7 +374,7 @@ struct RtAudioBridge : NativeBridge { | |||
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 | |||
if (float* const outsPtr = static_cast<float*>(outputBuffer)) | |||
{ | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS_2; ++i) | |||
self->audioBuffers[DISTRHO_PLUGIN_NUM_INPUTS + i] = outsPtr + (i * numFrames); | |||
} | |||
#endif | |||
@@ -68,7 +68,7 @@ struct SDL2Bridge : NativeBridge { | |||
#if DISTRHO_PLUGIN_NUM_INPUTS > 0 | |||
SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "Capure"); | |||
requested.channels = DISTRHO_PLUGIN_NUM_INPUTS; | |||
requested.channels = DISTRHO_PLUGIN_NUM_INPUTS_2; | |||
requested.callback = AudioInputCallback; | |||
SDL_AudioSpec receivedCapture; | |||
@@ -81,7 +81,7 @@ struct SDL2Bridge : NativeBridge { | |||
return false; | |||
#endif | |||
} | |||
else if (receivedCapture.channels != DISTRHO_PLUGIN_NUM_INPUTS) | |||
else if (receivedCapture.channels != DISTRHO_PLUGIN_NUM_INPUTS_2) | |||
{ | |||
SDL_CloseAudioDevice(captureDeviceId); | |||
captureDeviceId = 0; | |||
@@ -93,7 +93,7 @@ struct SDL2Bridge : NativeBridge { | |||
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 | |||
SDL_AudioSpec receivedPlayback; | |||
SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "Playback"); | |||
requested.channels = DISTRHO_PLUGIN_NUM_OUTPUTS; | |||
requested.channels = DISTRHO_PLUGIN_NUM_OUTPUTS_2; | |||
requested.callback = AudioOutputCallback; | |||
playbackDeviceId = SDL_OpenAudioDevice(nullptr, 0, &requested, &receivedPlayback, | |||
@@ -104,7 +104,7 @@ struct SDL2Bridge : NativeBridge { | |||
return false; | |||
} | |||
if (receivedPlayback.channels != DISTRHO_PLUGIN_NUM_OUTPUTS) | |||
if (receivedPlayback.channels != DISTRHO_PLUGIN_NUM_OUTPUTS_2) | |||
{ | |||
SDL_CloseAudioDevice(playbackDeviceId); | |||
playbackDeviceId = 0; | |||
@@ -211,15 +211,15 @@ struct SDL2Bridge : NativeBridge { | |||
if (self->jackProcessCallback == nullptr) | |||
return; | |||
const uint numFrames = static_cast<uint>(len / sizeof(float) / DISTRHO_PLUGIN_NUM_INPUTS); | |||
const uint numFrames = static_cast<uint>(len / sizeof(float) / DISTRHO_PLUGIN_NUM_INPUTS_2); | |||
DISTRHO_SAFE_ASSERT_UINT2_RETURN(numFrames == self->bufferSize, numFrames, self->bufferSize,); | |||
const float* const fstream = (const float*)stream; | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_INPUTS; ++i) | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_INPUTS_2; ++i) | |||
{ | |||
for (uint j=0; j<numFrames; ++j) | |||
self->audioBuffers[i][j] = fstream[j * DISTRHO_PLUGIN_NUM_INPUTS + i]; | |||
self->audioBuffers[i][j] = fstream[j * DISTRHO_PLUGIN_NUM_INPUTS_2 + i]; | |||
} | |||
#if DISTRHO_PLUGIN_NUM_OUTPUTS == 0 | |||
@@ -245,7 +245,7 @@ struct SDL2Bridge : NativeBridge { | |||
return; | |||
} | |||
const uint numFrames = static_cast<uint>(len / sizeof(float) / DISTRHO_PLUGIN_NUM_OUTPUTS); | |||
const uint numFrames = static_cast<uint>(len / sizeof(float) / DISTRHO_PLUGIN_NUM_OUTPUTS_2); | |||
DISTRHO_SAFE_ASSERT_UINT2_RETURN(numFrames == self->bufferSize, numFrames, self->bufferSize,); | |||
const ScopedDenormalDisable sdd; | |||
@@ -253,10 +253,10 @@ struct SDL2Bridge : NativeBridge { | |||
float* const fstream = (float*)stream; | |||
for (uint i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) | |||
for (uint i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS_2; ++i) | |||
{ | |||
for (uint j=0; j < numFrames; ++j) | |||
fstream[j * DISTRHO_PLUGIN_NUM_OUTPUTS + i] = self->audioBuffers[DISTRHO_PLUGIN_NUM_INPUTS + i][j]; | |||
fstream[j * DISTRHO_PLUGIN_NUM_OUTPUTS_2 + i] = self->audioBuffers[DISTRHO_PLUGIN_NUM_INPUTS + i][j]; | |||
} | |||
} | |||
#endif | |||
@@ -163,7 +163,7 @@ struct WebBridge : NativeBridge { | |||
if (WAB.audioContext.state === 'suspended') | |||
WAB.audioContext.resume(); | |||
}); | |||
}, DISTRHO_PLUGIN_NUM_INPUTS, DISTRHO_PLUGIN_NUM_OUTPUTS, bufferSize, audioBufferStorage, WebAudioCallback, this); | |||
}, DISTRHO_PLUGIN_NUM_INPUTS_2, DISTRHO_PLUGIN_NUM_OUTPUTS_2, bufferSize, audioBufferStorage, WebAudioCallback, this); | |||
return true; | |||
} | |||
@@ -247,7 +247,7 @@ struct WebBridge : NativeBridge { | |||
} else if (navigator.webkitGetUserMedia !== undefined) { | |||
navigator.webkitGetUserMedia(constraints, success, fail); | |||
} | |||
}, DISTRHO_PLUGIN_NUM_INPUTS); | |||
}, DISTRHO_PLUGIN_NUM_INPUTS_2); | |||
return true; | |||
} | |||
@@ -279,7 +279,7 @@ struct WebBridge : NativeBridge { | |||
WAB.captureStreamNode.disconnect(WAB.processor); | |||
return 1; | |||
}, DISTRHO_PLUGIN_NUM_INPUTS, DISTRHO_PLUGIN_NUM_OUTPUTS, newBufferSize) != 0; | |||
}, DISTRHO_PLUGIN_NUM_INPUTS_2, DISTRHO_PLUGIN_NUM_OUTPUTS_2, newBufferSize) != 0; | |||
if (!success) | |||
return false; | |||
@@ -292,9 +292,10 @@ struct WebBridge : NativeBridge { | |||
bufferSizeCallback(newBufferSize, jackBufferSizeArg); | |||
EM_ASM({ | |||
var numInputs = $0; | |||
var numOutputs = $1; | |||
var bufferSize = $2; | |||
var numInputsR = $0; | |||
var numInputs = $1; | |||
var numOutputs = $2; | |||
var bufferSize = $3; | |||
var WAB = Module['WebAudioBridge']; | |||
// store the new processor | |||
@@ -309,13 +310,13 @@ struct WebBridge : NativeBridge { | |||
var buffer = e['inputBuffer']['getChannelData'](i); | |||
for (var j = 0; j < bufferSize; ++j) { | |||
// setValue($3 + ((bufferSize * i) + j) * 4, buffer[j], 'float'); | |||
HEAPF32[$3 + (((bufferSize * i) + j) << 2) >> 2] = buffer[j]; | |||
HEAPF32[$4 + (((bufferSize * i) + j) << 2) >> 2] = buffer[j]; | |||
} | |||
} | |||
dynCall('vi', $4, [$5]); | |||
dynCall('vi', $5, [$6]); | |||
for (var i = 0; i < numOutputs; ++i) { | |||
var buffer = e['outputBuffer']['getChannelData'](i); | |||
var offset = bufferSize * (numInputs + i); | |||
var offset = bufferSize * (numInputsR + i); | |||
for (var j = 0; j < bufferSize; ++j) { | |||
buffer[j] = HEAPF32[$3 + ((offset + j) << 2) >> 2]; | |||
} | |||
@@ -329,7 +330,7 @@ struct WebBridge : NativeBridge { | |||
if (WAB.captureStreamNode) | |||
WAB.captureStreamNode.connect(WAB.processor); | |||
}, DISTRHO_PLUGIN_NUM_INPUTS, DISTRHO_PLUGIN_NUM_OUTPUTS, bufferSize, audioBufferStorage, WebAudioCallback, this); | |||
}, DISTRHO_PLUGIN_NUM_INPUTS, DISTRHO_PLUGIN_NUM_INPUTS_2, DISTRHO_PLUGIN_NUM_OUTPUTS_2, bufferSize, audioBufferStorage, WebAudioCallback, this); | |||
return true; | |||
} | |||
@@ -452,7 +453,7 @@ struct WebBridge : NativeBridge { | |||
} | |||
else | |||
{ | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) | |||
for (uint i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS_2; ++i) | |||
std::memset(self->audioBuffers[DISTRHO_PLUGIN_NUM_INPUTS + i], 0, sizeof(float)*numFrames); | |||
} | |||
} | |||