VST creation: Index in position 1 is invalid

2 次查看(过去 30 天)
Everything works properly in audioTestBench but I get "Index in position 1 is invalid" error when I try to export my audio plugin. Thanks for any help...
classdef reverser2 < audioPlugin
properties
dry = 0.5;
wet = 0.5;
size = 1;
twriteBuffer = 1; % start writing from buffer 1 (and reading on buffer 2)
end
properties (Access = private)
tBuffera = zeros(176400,2);
tBufferb = zeros(176400,2);
BufferIndex = 1;
NSamples = 44100;
end
properties (Constant)
PluginInterface = audioPluginInterface(...
audioPluginParameter('dry',...
'DisplayName','Dry',...
'Mapping',{'lin',0,1}),...
audioPluginParameter('wet',...
'DisplayName','Wet',...
'Mapping',{'lin',0,1}),...
audioPluginParameter('size',...
'DisplayName','Buffer size',...
'Mapping',{'lin',0.1,4},...
'Label','seconds'))
end
methods
function out = process(plugin, in)
out = zeros(size(in));
writeIndex = plugin.BufferIndex; % set writing point (last sample read)
readIndex = plugin.NSamples - writeIndex; % set reading point (mirrored point of the writing)
who = plugin.twriteBuffer;
% plugin.CircularBuffer=flipud(plugin.CircularBuffer);
if readIndex <= 0
readIndex = readIndex + plugin.NSamples;
end
for i = 1:size(in,1)
if who == 1
plugin.tBuffera(writeIndex,:) = in(i,:);
reverse = plugin.tBufferb(readIndex,:);
else
plugin.tBufferb(writeIndex,:) = in(i,:);
reverse = plugin.tBuffera(readIndex,:);
end
out(i,:) = in(i,:)*plugin.dry + reverse*plugin.wet;
writeIndex = writeIndex + 1; % move forward the writing point
if writeIndex > plugin.NSamples
writeIndex = 1;
end
readIndex = readIndex - 1; % move backward the reading point
if readIndex <= 0
readIndex = plugin.NSamples;
if who == 1
who = 2;
else
who = 1;
end
end
end
plugin.BufferIndex = writeIndex;
plugin.twriteBuffer = who;
end
function set.size(plugin, val)
plugin.size = val;
plugin.NSamples = floor(getSampleRate(plugin)*val);
end
end
end
  2 个评论
Tommaso
Tommaso 2023-8-15
is there a way to know it?
Because I get it when I click on export as a generic dialog window.

请先登录,再进行评论。

回答(1 个)

jibrahim
jibrahim 2023-8-16
I assume you get an error when you attempt to generate an audio plugin.
I can reproduce your error if I validate the audio plugin:
validateAudioPlugin reverser2
You will see the error coming from line 41. The index readIndex is negative.
You should be able to debug your code by following the errors from validateAudioPlugin. Use common debugging tools to put breakpoints on the offending line of your code.
  1 个评论
Tommaso
Tommaso 2023-8-16
thanks for the advice in debugging. Still struggling on why a got a negative index value.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio Plugin Creation and Hosting 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by