%% Audio Effects for iOS Devices
% This example shows how to use System objects(TM) from Audio Toolbox(TM)
% to implement echo and reverberation effects in a Simulink(R) model. You
% can run the model on your host computer or deploy it to an Apple iOS
% device.

% Copyright 2016-2019 The MathWorks, Inc.

%% Introduction
% Echo and reverberation are two commonly-used audio effects in recording,
% movie making, and sound design. Echo is a reflection of sound that 
% arrives at the listener with a delay after the direct sound.
% Echo can be produced by the bottom of a well or by the walls of
% a building. Reverberation is a large number of sound reflections building
% up and then decaying. A common use of reverberation is to simulate music
% played in a closed room. Most digital audio workstations (DAWs) have 
% options to add echo and reverberation effects to sound tracks.
%
% In this example, you design and implement echo and reverberation audio
% effects in a Simulink model. You can run your model on the host computer
% or an Apple iOS device.
 
%% Required Hardware
% To run this example on iOS devices you will need the following hardware:
%
% * iPhone, iPod or an iPad
% * Host computer with Mac OS X system
% * USB cable to connect the device to host computer
% 
%% Model Setup
% 
% <<../audioeffectsiOS_model.png>>
%
%%
% The |audioeffectsiOS| model provides a choice of audio effect (echo or
% reverberation), device (host computer or iOS device), and audio source
% (MATLAB workspace or microphone). You can choose the configuration by
% clicking the |Configuration UI| button.
%
% Configuration UI: 
% 
% <<../audioeffectsiOS_configuration.png>>
%
%% Audio Effect: Echo
% The echo effect has four tunable parameters that can be modified while 
% the model is running:
%
% * Delay - Delay applied to audio signal, in seconds
% * Gain - Linear gain of the delayed audio
% * FeedbackLevel - Feedback gain applied to delay line
% * Wet/Dry Mix - Ratio of wet signal added to dry signal
% 
% *Run Echo Effect on the Host Computer*
%
% If you choose to run the echo effect on your host computer, a UI designed
% to interact with the simulation is provided and can be opened by clicking
% |Host Tuning UI|. The UI allows you to tune echo parameters and hear the
% echo sound effect in real time.
%
% Host tuning UI for echo effect:
% 
% <<../audioeffectsiOS_echohosttuning.png>>
%
% *Run Echo Effect on an Apple iOS Device*
% 
% When you choose to run the echo effect on your Apple iOS device, you need
% to first ensure that you have installed |Simulink Support Package for
% Apple iOS Devices| and that your iOS device is provisioned.
% 
% Once your iOS device is properly configured, use a USB cable to connect
% the device to your host computer.
%
% You can choose to make an iOS standalone echo effect app by clicking the
% |Deploy to hardware| button on the Simulink Editor toolbar. After
% deployment, the app can run on your iOS device even when it is
% disconnected from the host computer. You can also run the model in
% |External| mode by clicking the |Run| button on the Simulink Editor
% toolbar. To run in |External| mode, the iOS device must stay connected to
% the host computer.
% 
% The UI for the echo effect displays on your iOS device screen, as shown
% below:
%
% <<../audioeffectsiOS_echoslider.jpg>>
% 
%% Audio Effect: Reverberation 
% The reverberation effect has six tunable parameters that can be modified
% while the model is running:
%
% * Pre-delay - Time between hearing direct sound and the first early reflection
% * Highcut frequency - Cutoff frequency for the lowpass filter at the front of the reverberator structure
% * Diffusion - Density of reverb tail
% * Decay factor - Decay factor of reverb tail
% * High Frequency Damping - Attenuation of high frequencies in the reverberation output
% * Wet/Dry Mix - Ratio of wet signal added to dry signal
%
% *Run Reverberation Effect on the Host Computer*
%
% If you choose to run the reverberation effect on your host computer, a UI designed to 
% interact with the simulation is provided and
% can be opened by clicking |Host Tuning UI|. The UI 
% allows you to tune reverberation parameters and hear the reverberation sound effect in real
% time.
%
% Host tuning UI for reverberation effect:
%
% <<../audioeffectsiOS_reverbhosttuning.png>>
%
% *Run Reverberation Effect on an Apple iOS Device*
%
% When you choose to run the reverberation effect on your Apple iOS device,
% you need to first ensure that you have installed |Simulink Support
% Package for Apple iOS Devices| and that your iOS device is provisioned.
% 
% Once your iOS device is properly configured, use a USB cable to connect
% the device to your host computer.
%
% You can choose to make an iOS standalone reverberation effect app by
% clicking the |Deploy to hardware| button on the Simulink Editor toolbar. 
% After deployment, the
% app can run on your iOS device even when it is disconnected from the host
% computer. You can also run the model in |External| mode by clicking the |Run|
% button on the Simulink Editor toolbar. To run in |External| mode, the iOS
% device must stay connected to the host computer.
% 
% The UI for the reverberation effect displays on your iOS device screen, as shown below:
%
% <<../audioeffectsiOS_reverbslider.jpg>>
%
