VST Code generation issues with element-wise multiplication

3 visualizaciones (últimos 30 días)
Robert
Robert el 11 de Nov. de 2022
Comentada: Jimmy Lapierre el 11 de Nov. de 2022
The following code produces audible discontinuities when compiled to a VST:
gains = [0.5, 0.725];
out = in .* gains;
But this works fine
gains = [0.5, 0.725];
out = [in(:,1) * gains(1), in(:,2) * gains(2)];
Is this a known issue with code generation?

Respuestas (1)

VBBV
VBBV el 11 de Nov. de 2022
gains = [0.5, 0.725];
in = rand(8)
in = 8×8
0.8849 0.9486 0.2943 0.5330 0.5551 0.2483 0.9058 0.8506 0.6508 0.8914 0.3171 0.4493 0.6775 0.0840 0.3678 0.6322 0.2078 0.4190 0.9428 0.2469 0.3487 0.5543 0.0761 0.7525 0.8023 0.4535 0.7250 0.9433 0.3312 0.5522 0.5628 0.8056 0.2804 0.6671 0.6911 0.2097 0.8895 0.6512 0.3580 0.4607 0.2275 0.3705 0.9019 0.3368 0.4651 0.0667 0.7093 0.3143 0.8744 0.2188 0.9651 0.2883 0.7966 0.2366 0.2595 0.6238 0.6302 0.3316 0.5598 0.3719 0.0362 0.0559 0.2016 0.5517
out = [in(:,1) * gains(1), in(:,2) * gains(2)]
out = 8×2
0.4425 0.6877 0.3254 0.6463 0.1039 0.3038 0.4011 0.3288 0.1402 0.4837 0.1137 0.2686 0.4372 0.1587 0.3151 0.2404
out = in .* gains % check the matrix multiplication rule
Arrays have incompatible sizes for this operation.
  3 comentarios
Robert
Robert el 11 de Nov. de 2022
Thanks for the quick response. I agree with this, but the default VST is 2 in, 2 out. This code should work if that were true:
gains = [0.5, 0.75];
in = [ones(5,1), ones(5,1)*2];
out = in .* gains
out = 5×2
0.5000 1.5000 0.5000 1.5000 0.5000 1.5000 0.5000 1.5000 0.5000 1.5000
Is it possible that the VST doesn't always default to stereo like the documentation says?
"By default, both the input to and output from the process method have two channels (columns). The number of input rows (frame size) passed to process is determined by the environment in which it is run. The output must have the same number of rows as the input.", found here:
https://www.mathworks.com/help/audio/gs/audio-plugins-in-matlab.html
Jimmy Lapierre
Jimmy Lapierre el 11 de Nov. de 2022
I was able to reproduce the issue. I will investigate further.
>> p=loadAudioPlugin('GainTest.dll')
p =
VST plugin 'GainTest' 2 in, 2 out
>> process(p,ones(4,2))
ans =
0.5000 0.7250
1.0000 1.0000
1.0000 1.0000
1.0000 1.0000
Please use the workaround in the meantime.
p.s. modifying the input in-place is allowed, so it could look like this:
function x = process(~,x)
gains = [0.5, 0.725];
x(:,1) = gains(1)*x(:,1);
x(:,2) = gains(2)*x(:,2);
end

Iniciar sesión para comentar.

Categorías

Más información sobre Audio Plugin Creation and Hosting en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by