[Audio System Toolbox] Changing properties bound to Interface Parameters
    13 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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).
Anyone encountered the same problem or knows how to do this kind of assignments?
0 Commenti
Risposte (1)
  Charlie DeVane
    
 il 13 Dic 2018
        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 Commenti
Vedere anche
Categorie
				Scopri di più su Audio Plugin Creation and Hosting in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

