How to use Audio Plugin Example System Objects in a custom Plugin

1 view (last 30 days)
Hello,
I realy like the Audio Plugin Examples . I want to use some of them as parts of my Plugin. However i find it realy hard to implement those that are System Objects.
for example i would like to have this filter and this eq in the plugin.
audiopluginexample.VarSlopeBandpassFilter
audiopluginexample.ParametricEqualizerWithUDP
i tried using the code available through "edit" ,but as they are system objects i cannot just do that. Object Names are fixed etc.
the Question is how do i implement them in a custom audio Plugin?
for example how can i make a plugin that passes audio from the audiopluginexample.VarSlopeBandpassFilter through the audiopluginexample.ParametricEqualizerWithUDP.
thanks in advance im stuck on that one for a while now.

Accepted Answer

jibrahim
jibrahim on 2 Feb 2021
Hi Adrian,
Take a look at the plugin below and see if this answers your needs. What this plugin does is essentially internally use a var-slope BP filter and a param EQ.
classdef ExampleEQ < audioPlugin
%#codegen
properties
% Cutoff frequency in Hz
LowCutoff = 20
HighCutoff = 18e3;
% Slope in dB/octave
LowSlope = '12'
HighSlope = '30'
CenterFrequency1 = 100
CenterFrequency2 = 1000
CenterFrequency3 = 10000
% Q factors for each band
QualityFactor1 = 2
QualityFactor2 = 2
QualityFactor3 = 2
% dB gain for each band
PeakGain1 = 0
PeakGain2 = 0
PeakGain3 = 0
end
properties (Access = private)
pVarSlopeBP
pParamEQ
end
properties (Constant)
% Define the plugin interface
PluginInterface = audioPluginInterface( ...
'InputChannels',2,...
'OutputChannels',2,...
'PluginName','Example EQ',...
audioPluginParameter('LowCutoff', ...
'DisplayName', 'Low Cutoff', ...
'Label', 'Hz', ...
'Mapping', { 'log', 20, 20000},...
'Style', 'rotaryknob', 'Layout', [1 1]),...
audioPluginParameter('HighCutoff', ...
'DisplayName', 'High Cutoff', ...
'Label', 'Hz', ...
'Mapping', { 'log', 20, 20000},...
'Style', 'rotaryknob', 'Layout', [1 2]),...
audioPluginParameter('LowSlope', ...
'DisplayName', 'Low Slope', ...
'Label', 'dB/octave', ...
'Mapping', { 'enum', '0','6','12','18','24','30','36','42','48'},...
'Layout', [3 1]),...
audioPluginParameter('HighSlope', ...
'DisplayName', 'High Slope', ...
'Label', 'dB/octave', ...
'Mapping', { 'enum', '0','6','12','18','24','30','36','42','48'},...
'Layout', [3 2]), ...
audioPluginParameter('PeakGain1','DisplayName','Low Gain','Label','dB',...
'Mapping',{'lin',-20,20},'Style','vslider','Layout',[5 1]),...
audioPluginParameter('CenterFrequency1','DisplayName','Low Frequency','Label','Hz',...
'Mapping',{'log',20,20e3},'Style','rotaryknob','Layout',[7 1]),...
audioPluginParameter('QualityFactor1','DisplayName','Low Q',...
'Mapping',{'log',0.2,700},'Style','rotaryknob','Layout',[9 1]),...
audioPluginParameter('PeakGain2','DisplayName','Mid Gain','Label','dB',...
'Mapping',{'lin',-20,20},'Style','vslider','Layout',[5 2]),...
audioPluginParameter('CenterFrequency2','DisplayName','Mid Frequency','Label','Hz',...
'Mapping',{'log',20,20e3},'Style','rotaryknob','Layout',[7 2]),...
audioPluginParameter('QualityFactor2','DisplayName','Mid Q',...
'Mapping',{'log',0.2,700},'Style','rotaryknob','Layout',[9 2]),...
audioPluginParameter('PeakGain3','DisplayName','High Gain','Label','dB',...
'Mapping',{'lin',-20,20},'Style','vslider','Layout',[5 3]),...
audioPluginParameter('CenterFrequency3','DisplayName','High Frequency','Label','Hz',...
'Mapping',{'log',20,20e3},'Style','rotaryknob','Layout',[7 3]),...
audioPluginParameter('QualityFactor3','DisplayName','High Q',...
'Mapping',{'log',0.2,700},'Style','rotaryknob','Layout',[9 3])...
);
end
%----------------------------------------------------------------------
% Public methods
%----------------------------------------------------------------------
methods
function plugin = ExampleEQ()
% Constructor
% Initialize a multinotch filter
plugin.pVarSlopeBP = audiopluginexample.VarSlopeBandpassFilter;
plugin.pParamEQ = audiopluginexample.ParametricEqualizerWithUDP;
fs = plugin.getSampleRate;
setSampleRate(plugin.pVarSlopeBP, fs);
setSampleRate(plugin.pParamEQ, fs);
end
%------------------------------------------------------------------
function set.LowCutoff(plugin,val)
plugin.pVarSlopeBP.LowCutoff = val;%#ok<MCSUP>
plugin.LowCutoff = val;
end
function set.HighCutoff(plugin,val)
plugin.pVarSlopeBP.HighCutoff = val;%#ok<MCSUP>
plugin.HighCutoff = val;
end
function set.LowSlope(plugin,val)
plugin.pVarSlopeBP.LowSlope = val;%#ok<MCSUP>
plugin.LowSlope = val;
end
function set.HighSlope(plugin,val)
plugin.pVarSlopeBP.HighSlope = val;%#ok<MCSUP>
plugin.HighSlope = val;
end
function set.CenterFrequency1(plugin,val)
plugin.pParamEQ.CenterFrequency1 = val;%#ok<MCSUP>
plugin.CenterFrequency1 = val;
end
function set.CenterFrequency2(plugin,val)
plugin.pParamEQ.CenterFrequency2 = val;%#ok<MCSUP>
plugin.CenterFrequency2 = val;
end
function set.CenterFrequency3(plugin,val)
plugin.pParamEQ.CenterFrequency3 = val;%#ok<MCSUP>
plugin.CenterFrequency3 = val;
end
function set.QualityFactor1(plugin,val)
plugin.pParamEQ.QualityFactor1 = val;%#ok<MCSUP>
plugin.QualityFactor1 = val;
end
function set.QualityFactor2(plugin,val)
plugin.pParamEQ.QualityFactor2 = val;%#ok<MCSUP>
plugin.QualityFactor2 = val;
end
function set.QualityFactor3(plugin,val)
plugin.pParamEQ.QualityFactor3 = val;%#ok<MCSUP>
plugin.QualityFactor3 = val;
end
function set.PeakGain1(plugin,val)
plugin.pParamEQ.PeakGain1 = val;%#ok<MCSUP>
plugin.PeakGain1 = val;
end
function set.PeakGain2(plugin,val)
plugin.pParamEQ.PeakGain2 = val;%#ok<MCSUP>
plugin.PeakGain2 = val;
end
function set.PeakGain3(plugin,val)
plugin.pParamEQ.PeakGain3 = val;%#ok<MCSUP>
plugin.PeakGain3 = val;
end
%------------------------------------------------------------------
function y = process(plugin,x)
z = plugin.pVarSlopeBP(x);
y = plugin.pParamEQ(z);
end
%------------------------------------------------------------------
function reset(plugin)
fs = plugin.getSampleRate;
setSampleRate(plugin.pVarSlopeBP, fs);
reset(plugin.pVarSlopeBP)
setSampleRate(plugin.pParamEQ, fs);
reset(plugin.pParamEQ)
end
end
end
  1 Comment
Adrian Alexander
Adrian Alexander on 2 Feb 2021
thank you jibrahim !!
in your code i can work in a better way.
i can apply my signalproccessing in this function easily and i can change the name of the script without a problem .
function y = process(plugin,x)
z = plugin.pVarSlopeBP(x);
y = plugin.pParamEQ(z);
end
All i wanted excelent work ;) and very fast reply

Sign in to comment.

More Answers (0)

Categories

Find more on Audio Plugin Creation and Hosting in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!