classdef myBasicSourcePlugin < audioPluginSource
    properties
        GaindB = 1;
    end
    properties (Access = private)
        GainMemory = 1;
        GainLinear = 1;
    end
    properties (Constant)
        PluginInterface = audioPluginInterface(...
            audioPluginParameter('GaindB',...
            'DisplayName','Damped Gain',...
            'Label','dB',...
            'Mapping',{'pow',1/3,-60,20}));
    end
    methods
        function out = process(plugin)
            noise = randn(getSamplesPerFrame(plugin),2);
            gain = 0.5*(plugin.GainLinear + plugin.GainMemory);
            
            out = noise*gain;
            
            plugin.GainMemory = gain;
        end
        function reset(plugin)
            plugin.GainMemory = 1;
        end
        function set.GaindB(plugin, val)
            plugin.GaindB = val;
            plugin.GainLinear = 10^(val/20);%#ok<MCSUP>
        end
    end  
end