Hello i run into a problem here.
i got inspired for this way of aproatching oversampling by another question.
it is oversampling an Distortion Algorithm.
All i wanted to do is use the Code from the Question and let the user Pick the Amount of Oversampling desired ." oFactor = [1 2 4 8 16]"
Initialy i wanted to use enum mapping but as it didnt work i simplified the code . the int slider pickes one number of the oFator Array. That way i change the oversampling multiplicator.
The code works with a Constant property but not with one that can be changed. I dont know why.
thank u in advance 😉
Thats the Error i get:
Index in position 1 exceeds array bounds (must not exceed 4).
Error in PickOversampling2/stepImpl (line 70)
xin = disto(plugin.oFactor(plugin.oF)*ii-(plugin.oFactor(plugin.oF)-1):plugin.oFactor(plugin.oF)*endIdx,:);
Error in testbench_PickOversampling2 (line 69)
o1 = step(plugin, in(:,1:2));
Error in validateAudioPlugin
classdef (StrictDefaults)PickOversampling2 < matlab.System & audioPlugin properties (Constant) oFactor = [1 2 4 6 16] ; end properties (Constant, Hidden) PluginInterface = audioPluginInterface(... audioPluginParameter('oF',... 'DisplayName','oF',... 'Label','dB',... 'Mapping',{'int',1,5},... 'Style', 'rotaryknob','Layout', [1 2])) end properties oF = 1 end properties (Access = private) Up16; Down16; end methods % Constructor
function plugin = PickOversampling2 plugin.Up16=dsp.SampleRateConverter; plugin.Down16=dsp.SampleRateConverter; calculateSampleRates(plugin); end end methods(Access = protected) function out = stepImpl(plugin, in) x = step(plugin.Up16,in); %Distortion
Drive_lin = 100 x = x * Drive_lin ; x(x>1)=1 ; x(x<(-1))=-1 ; disto=x; out = zeros(size(in)); for ii = 1:4096:size(in,1) endIdx = min(ii+4095,size(in,1)); xin = disto(plugin.oFactor(plugin.oF)*ii-(plugin.oFactor(plugin.oF)-1):plugin.oFactor(plugin.oF)*endIdx,:); assert(size(xin,1)<=plugin.oFactor(plugin.oF)*4096); out(ii:endIdx,:) = step(plugin.Down16,xin); end end function resetImpl(plugin) reset(plugin.Up16); reset(plugin.Down16); end function calculateSampleRates(plugin) sampleRate = 44100; plugin.Up16.InputSampleRate=sampleRate; plugin.Up16.OutputSampleRate=plugin.oFactor(plugin.oF)*sampleRate; plugin.Down16.InputSampleRate=plugin.oFactor(plugin.oF)*sampleRate; plugin.Down16.OutputSampleRate=sampleRate; end end end
Best Answer