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
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!