Matlab, Audio Toolbox, Live Audio Tuning Problem with Plugin: How do I handle more than one property?

2 visualizaciones (últimos 30 días)
I want to implement an plugin with multiple properties. I want to controll every property on its own via a slider. I create my UI with parameterTuner(). I have no problem implementing one property, for example gain (see my code below). I understand, that the functionality is implemented in the process funtion. I also understand, that the sliders are specified in audioPluginInterface(). I can create the sliders i want, but i dont get how i can add functionality to more than one slider. Using the (i think requiered) process function which hosts the slider functionaliy, i can only add functionality to one slider. I need to know how i can add functionality to additional sliders (or knobs, etc).
This is my Plugin Code. I am currently able to adjust my gain property and now i want to have a seperate, additional slider to adjust my stereo width.
classdef VoicePlugin < audioPlugin
properties
Gain = 1;
Width = 1;
end
properties (Constant)
PluginInterface = audioPluginInterface(audioPluginParameter('Gain',... %gain slider AllREADY IMPLEMTED
'DisplayName','Gain', ...
'Mapping',{'lin',-48,12}, ...
'Layout',[1,1], ...
'Style','vslider'), ...
audioPluginParameter('Width', ... %stereo width slider I WANT TO IMPLEMENT FUNCTIONALITY FOR THIS SLIDER
'DisplayName','Width', ...
'Mapping',{'pow',2,0,4},...
'Layout', [1,2],...
'Style','vslider'),...
audioPluginGridLayout('RowHeight',[300,20],'ColumnWidth', [100,100]));
end
methods
%functionality for gain slider
function out = process(plugin, in)
linAmp = 10 ^ (plugin.Gain/20);
out = in * linAmp;
end
%HOW DO I IMPLEMENT THIS FUNCTIONALITY FOR MY WIDTH SLIDER??
% x = [in(:,1) + in(:,2), in(:,1) - in(:,2)];
% y = [x(:,1), x(:,2)*plugin.Width];
% out = [(y(:,1) + y(:,2))/2, (y(:,1) - y(:,2))/2];
function reset(plugin)
plugin.Gain = 1;
% plugin.Width = 1;
end
function set.Gain(plugin, val)
plugin.Gain = val;
end
% function set.Width(plugin, val)
% plugin.Width = val;
% end
end
end
This is the code of my main programm which uses the plugin, to tune input audio live.
%main script
deviceReader = audioDeviceReader(16000,1000); %sample rate (frames per sec), samples per frame
%deviceReader.ChannelMappingSource = 'Property' %use two channels
setup(deviceReader);
deviceWriter = audioDeviceWriter('SampleRate',deviceReader.SampleRate);
plugin = VoicePlugin();
controllGain = parameterTuner(plugin);
drawnow
%pause(1)
% scope = timescope()
disp('Begin Signal Input...')
%tic
while ishandle(controllGain)
mySignal = deviceReader(); %mySignal is a matrix, rows = samples per frame, columns = audio channels
myProcessedSignal = process(plugin, mySignal);
deviceWriter(myProcessedSignal);
% scope(myProcessedSignal);
% break;
drawnow limitrate
end
disp('End Signal Input')
release(deviceReader)
release(deviceWriter)
Thank you in advance!

Respuestas (1)

jibrahim
jibrahim el 5 de Abr. de 2021
Hi Laurids,
The process function defines how the output is computed based on the input and plugin property values. Maybe I am miunderstanding your issue, but something like this should wrok (it is up to you to change the process code to do what you want):
classdef VoicePlugin < audioPlugin
properties
Gain = 1;
Width = 1;
end
properties (Constant)
PluginInterface = audioPluginInterface(audioPluginParameter('Gain',...
'DisplayName','Gain', ...
'Mapping',{'lin',-48,12}, ...
'Layout',[1,1], ...
'Style','vslider'), ...
audioPluginParameter('Width', ...
'DisplayName','Width', ...
'Mapping',{'pow',2,0,4},...
'Layout', [1,2],...
'Style','vslider'),...
audioPluginGridLayout('RowHeight',[300,20],'ColumnWidth', [100,100]));
end
methods
function out = process(plugin, in)
linAmp = 10 ^ (plugin.Gain/20);
x = [in(:,1) + in(:,2), in(:,1) - in(:,2)];
y = [x(:,1), x(:,2)*plugin.Width];
out = linAmp * [(y(:,1) + y(:,2))/2, (y(:,1) - y(:,2))/2];
end
function set.Gain(plugin, val)
plugin.Gain = val;
end
function set.Width(plugin, val)
plugin.Width = val;
end
end
end

Categorías

Más información sobre Audio Plugin Creation and Hosting en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by