Audio Toolbox : Illegal use of reserved keyword "classdef"
    조회 수: 16 (최근 30일)
  
       이전 댓글 표시
    
% Ping Ping Delay Audio Plugin Class
% 
% Author: Nathanael Channings
% 
% Date: 14/11/20
classdef PingPongDelayPlugin < audioPlugin
    % Declare user Controlled Parameters
    properties
        % Output User Variables
        Wet = 0.7;
        Dry = 0.5;
        GainL = 0.8;
        GainR = 0.8;
        % Delay User Variables
        delayType = 2;      % 1(Straight)
                            % 2(pingPong)
        leftDelay = 0.3;    % Delay Value of the Right Channel
        rightDelay = 0.5;   % Delay Value of the Right Channel
        feedback = 0.7;     % Feedback Value for Both Channels
        % Distortion User Variable
        % Modulation User Variables
        % Reverb User Variables
    end
    % Declare Private Plugin Parameters
    properties (Access = private)
        % Delay Variables
        sDelayL = round(leftDelay*getSampleRate(plugin));
        sDelayR = round(rightDelay*getSampleRate(plugin));
        delayLineLeft = zeros(sDelayL,1);
        delayLineRight = zeros(sDelayR,1);
        dIdxL = 1;
        dIdxR = 1;
        % Filter Variables
        % Distortion Variables
        % Modulation Variables
    end
    % Design Plugin GUI
    properties (Constant)
        PluginInterface = audioPluginInterface(...
            audioPluginParameter('delayType','DisplayName','Delay Type','Style','rotaryknob','Mapping',{'int',1,3}),...
            audioPluginParameter('leftDelay','DisplayName','Left Delay','Style','rotaryKnob','Mapping',{'lin',0,2}),...
            audioPluginParameter('rightDelay','DisplayName','Right Delay','Style','rotaryKnob','Mapping',{'lin',0,2})...
            );
    end
    % This is Where Your DSP Lives
    methods
        function out = process(plugin,in)
            % Define the I/O Buffer Length
            L = max(size(in));
            out = zeros(L,2);   % Output Array
            d = zeros(N,2);     % Distortion Array
            m = zeros(N,2);     % Modulated Array
            % Create a Main Time Loop with the length of the buffer
            for n = 1:L
                % Define the Output
                out(n,1) = plugin.Dry*in(n,1) + plugin.Wet*plugin.delayLineLeft(plugin.dIdxL);
                out(n,2) = plugin.Dry*in(n,2) + plugin.Wet*plugin.delayLineRight(plugin.dIdxR);
                % Write Samples to the Delay Lines
                if plugin.delayType == 1
                    tempL = plugin.feedback*plugin.delayLineLeft(plugin.dIdxL);
                    tempR = plugin.feedback*plugin.delayLineRight(plugin.dIdxR);
                    plugin.delayLineLeft(plugin.dIdxL) = tempL;
                    plugin.delayLineRight(plugin.dIdxR) = tempR;
                else if plugin.delayType == 2
                        tempL = plugin.feedback*plugin.delayLineLeft(plugin.dIdxL);
                        tempR = plugin.feedback*plugin.delayLineRight(plugin.dIdxR);
                        plugin.delayLineLeft(plugin.dIdxL) = tempR;
                        plugin.delayLineRight(plugin.dIdxR) = tempL;
                    end
                end
                % Iterate Through Each Delay Line Index
                plugin.dIdxL = plugin.dIdxL + 1;
                if plugin.dIdxL > plugin.sDelayL
                    plugin.dIdxL = 1;
                end
                plugin.dIdxR = plugin.dIdxR + 1;
                if plugin.dIdxR > plugin.sDelayR
                    plugin.dIdxR = 1;
                end
            end % End of for Loop
        end % End of Function
    end % End of Methods
end % End of Class
댓글 수: 4
답변 (2개)
  Steven Lord
    
      
 2020년 11월 15일
        To use a class file you don't run the classdef file directly. You construct the object by calling the constructor (the function with the same name as the file) with the appropriate inputs. Because this classdef file does not contain an explicit constructor function, you'd call the default constructor that accepts no inputs.
myobj = PingPongDelayPlugin
Now you can call various functions on myobj.
  Walter Roberson
      
      
 2020년 11월 15일
        
      편집: Walter Roberson
      
      
 2020년 11월 15일
  
      If you define a constant property then when you use the property to initialize other properties you must qualify with the class name.
https://www.mathworks.com/help/matlab/matlab_oop/expressions-in-class-definitions.html
Properties not declared as Constant or enumeration are considered variables and cannot be referenced directly in constructing default values. Instead you need to define a method that will be executed when the object is constructed. constants and enumerations are assigned when the class is constructed.
Remember that when you do not declare leftDelay constant then you are declaring that the user can change the value, and when you do that then which of the values should be used to construct new objects?
It is valid to construct a constant property to initialize with, and also to declare a variable property as the current value for any given object.
https://www.mathworks.com/help/matlab/matlab_oop/specifying-properties.html#brqy3km-10
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


