MATLAB Answers

[Audio System Toolbox] Changing properties bound to Interface Parameters

5 ビュー (過去 30 日間)
Marco Tiraboschi
Marco Tiraboschi 2017 年 8 月 15 日
回答済み: Charlie DeVane 2018 年 12 月 13 日
While programming an audioPlugin with Audio System Toolbox, I stumbled across this problem: it doesn't seem possible to change from code the value of a property that has been bound to an interface (audioPluginInterface) parameter.
I'll show a simple example of what I mean. Let's say I want to have a boost that decreases its gain of 3dB when clipping happens. I'd have
classdef safeBoost < audioPlugin
properties
gain = 1;
end
properties (Access = private)
update = 10^(-3/20);
end
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter( 'gain' , ...
'DisplayName' , 'Boost' , ...
'Mapping' , { 'log' , 10^(-120/20) , 10^(120/20) } ) );
end
methods
function out = process(plugin, in)
out = in*plugin.gain;
if max(out(:)) > 1
plugin.gain = plugin.gain*plugin.update; % <-- Running plugin changed parameter 'gain' from 1e+06 to 707946.
end
end
end
end
As you can read in the comment, the validation is unsuccessful due to the error " Running plugin changed parameter 'gain' ". I guess there is a way of assigning a value to a property when it's bound to a parameter (assignment to a property not bound to a parameter doesn't seem to cause any trouble).
I went through the documentation ( here and here ), but didn't find anything about it.
Anyone encountered the same problem or knows how to do this kind of assignments?

  0 件のコメント

サインインしてコメントする。

回答 (1 件)

Charlie DeVane
Charlie DeVane 2018 年 12 月 13 日
Assignments to parameter properties are not permitted because the plugin host cannot detect the parameter change, leaving the host and the plugin out of sync.
A possible workaround for this limitation is shown in the code below. Audio gain is applied using a private property safeGain. Whenever the parameter property gain is changed, safeGain is set to that value, and gain reduction is applied to safeGain similar to before. This gives you the desired gain reduction behavior, although the actual gain being used is not visibile in the plugin interface.
hope this helps,
Charlie
classdef safeBoost < audioPlugin
properties
gain = 1;
end
properties (Access = private)
update = 10^(-3/20);
safeGain = 1
end
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter( 'gain' , ...
'DisplayName' , 'Boost' , ...
'Mapping' , { 'log' , 10^(-120/20) , 10^(120/20) } ) );
end
methods
function out = process(plugin, in)
out = in*plugin.safeGain;
if max(out(:)) > 1
plugin.safeGain = plugin.safeGain*plugin.update;
end
end
function set.gain(plugin, value)
plugin.gain = value;
plugin.safeGain = value; %#ok<MCSUP>
end
end
end

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by