function SYS=lah_limiter_example_module(NAME, MAXDELAY)
% SYS=lah_limiter_example_module(NAME, MAXDELAY)
% Creates a complete look ahead limiter compiled subsystem.
% Arguments:
%    NAME - name of the module.
%    MAXDELAY - look ahead time in milliseconds.

% Copyright 2008.  DSP Concepts, Inc.  All Rights Reserved.
% Author:  Paul Beckmann

% AudioWeaverModule [This tag makes it appear under awe_help]

% ----------------------------------------------------------------------
% Set default input arguments
% ----------------------------------------------------------------------

if (nargin < 2)
	MAXDELAY = 5;
end

% ----------------------------------------------------------------------
% Construct the limiter.  Different logic is used depending up 
% MAXDELAY.
% ----------------------------------------------------------------------

SYS=awe_subsystem('LAHLimiterExample', 'Multi-channel soft knee limiter with look ahead');
add_argument(SYS, 'maxDelay', 'int', MAXDELAY, 'const', 'Maximum delay, in msec');

% Version is auto-updated by SVN:
SYS.moduleVersion = generate_version('$Revision: 30333 $');
if (nargin == 0)
    return;
end
SYS.name=NAME;

% Add input and output pins.  The module supports mono signals only.
pinType = new_pin_type(1, [], []);
add_pin(SYS, 'input', 'in', 'Audio Input', pinType);
add_pin(SYS, 'output', 'out', 'Audio output', pinType);

% Add the high-level variable which controls determines the delay time in
% msec
add_variable(SYS, 'maxDelayTime', 'float', MAXDELAY, 'const', 'Maximum delay time');
SYS.maxDelayTime.units='msec';

% Instantiate the individual modules
add_module(SYS, max_abs_module('max_abs', 1));
add_module(SYS, agc_limiter_core_module('core'));
add_module(SYS, agc_multiplier_module('mult'));
add_module(SYS, delaymsec_module('delay', MAXDELAY));
SYS.delay.currentDelayTime=MAXDELAY;   

% Wire together the modules
connect(SYS, '', 'max_abs');
connect(SYS, 'max_abs', 'core');
connect(SYS, 'core', 'mult.g');
connect(SYS, '', 'delay');
connect(SYS, 'delay', 'mult.in');
connect(SYS, 'mult', '');

% ----------------------------------------------------------------------
% Create the UI
% ----------------------------------------------------------------------

add_control(SYS, '.core');
add_control(SYS, '.delay.currentDelayTime', 'topRight');

% ----------------------------------------------------------------------
% Code generation details
% ----------------------------------------------------------------------

SYS.flattenOnBuild=0;
SYS.delay.maxDelayTime.constructorCode='S->maxDelayTime';
SYS.delay.currentDelayTime.constructorCode='S->maxDelayTime';

% ----------------------------------------------------------------------
% Module browser information
% ----------------------------------------------------------------------

SYS.moduleBrowser.path = 'Examples';
SYS.moduleBrowser.image = '../images/ExamplesIcon.bmp';
SYS.moduleBrowser.name = 'Look Ahead Limiter';

SYS.shapeInfo.legend = 'Look Ahead Limiter';
SYS.shapeInfo.size = [10 6];

return;


