crossFilt causing Matlab audio plugin pops

1 次查看(过去 30 天)
Audio plugin splits incoming audio into three bands and applies gain to center band and sums all back together. Debugging by only writing out one band, continuous pop noise still occurs. Is this because the crossover filter should be done with a different method in the App?
When I do this process offline in a normal m file there is no distortion.
classdef test_process < audioPlugin
properties
LowBand = 500;
HighBand = 5000;
fs = 48000;
gain = 0;
end
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter('LowBand','Label','Hz','Mapping',{'lin',70,1000}),...
audioPluginParameter('HighBand','Label','Hz','Mapping',{'lin',2000,10000}),...
audioPluginParameter('gain','Label','dB','Mapping',{'lin',0,20}));
end
methods
function out = process(plugin,in)
%set up crossover filter
crossFilt = crossoverFilter( ...
NumCrossovers=2, ...
CrossoverFrequencies=[plugin.LowBand,plugin.HighBand], ...
CrossoverSlopes=12, ...
SampleRate=plugin.fs);
[m1,m2,m3] = crossFilt(in); % split into three bands
%normal operation commented out for debug
% midGain = m2*(db2mag(plugin.gain)); % apply gain to mid band
% out = m1+midGain+m3; % sum three bands
%Test without any sum
out = m2; % test just mid band
end
end
end

采纳的回答

jibrahim
jibrahim 2024-10-4
编辑:Rena Berman 2024-10-22
Hi Matthew,
the main problem here is that you are recreating the corssover filter for every incoming frame of audio. Instead, you should create it once, in the contructor, in order to preserve the internal filter state.
You should also use getSampleRate to get the value of the plugin's sample rate instead of maintaning it as a property.
Here is a new version.
classdef test_process < audioPlugin
properties
LowBand = 500;
HighBand = 5000;
gain = 0;
end
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter('LowBand','Label','Hz','Mapping',{'lin',70,1000}),...
audioPluginParameter('HighBand','Label','Hz','Mapping',{'lin',2000,10000}),...
audioPluginParameter('gain','Label','dB','Mapping',{'lin',0,20}));
end
properties (Access=protected)
crossFilt
end
methods
function plugin = test_process
%set up crossover filter
plugin.crossFilt = crossoverFilter( ...
NumCrossovers=2, ...
CrossoverFrequencies=[plugin.LowBand,plugin.HighBand], ...
CrossoverSlopes=12, ...
SampleRate=getSampleRate(plugin));
end
function out = process(plugin,in)
%set up crossover filter
[m1,m2,m3] = plugin.crossFilt(in); % split into three bands
%normal operation commented out for debug
% midGain = m2*(db2mag(plugin.gain)); % apply gain to mid band
% out = m1+midGain+m3; % sum three bands
%Test without any sum
out = m1+m2+m3; % test just mid band
end
function set.LowBand(plugin,val)
plugin.crossFilt.CrossoverFrequencies(1) = val;%#ok
plugin.LowBand = val;
end
function set.HighBand(plugin,val)
plugin.crossFilt.CrossoverFrequencies(2) = val;%#ok
plugin.HighBand = val;
end
end
end
  1 个评论
Matthew Worker
Matthew Worker 2024-10-4
This solution works. Originally initializing the filter every frame is the root cause of the issue.
Thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

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