%% Trigger Gain Control Based on Loudness Measurement
% This model enables you to apply dynamic range compression to an audio
% signal while staying inside a preset loudness range. In this model, a
% <docid:audio_ref#bu_1477-1 Compressor> block increases the loudness and
% decreases the dynamic range of an audio signal.  A
% <docid:audio_ref#bvbo0y0-1 Loudness Meter> block calculates the momentary
% loudness of the compressed audio signal. If momentary loudness crosses a
% -23 LUFS threshold, an enabled subsystem applies gain to lower the
% corresponding level of the audio signal.

open_system('LoudnessMeterTriggerExample')

%% 
% 1. Open the <docid:dsp_ref#f5-1117037 Time Scope> and Compressor blocks.
%
% 2. Run the model. To switch between listening to the compressed
% signal with and without gain adjustment, double-click the switch.
%
% 3. To observe the effect of compression on loudness, tune the Compressor
% block parameters and view the compressed audio signal on the Time Scope
% block.

open_system('LoudnessMeterTriggerExample/Time Scope')
sim('LoudnessMeterTriggerExample',6)

%%
close_system('LoudnessMeterTriggerExample')

%% 
% Copyright 2012 The MathWorks, Inc.