%% Synthesize and Channelize Audio
% Synthesize a series of four stereo signals into a broadband signal by
% using the <docid:dsp_ref#bvjrmb3-1 Channel Synthesizer> block. At the 
% receiving end of the model, split this broadband signal back into the 
% individual narrowband signals by using the <docid:dsp_ref#bvjrd9b-1 Channelizer> block.
%
%%
% The inputs to the model are four stereo signals.
%
% * |FunkyDrums.mp3|
% * |SoftGuitar.ogg|
% * |RockDrums.mp3|
% * |RockGuitar.wav|
%
% Each signal has a size of 1024-by-2 samples. The two channels represent 
% the left channel and the right channel of the stereo signal.
% To store the stereo channels, each signal is converted into complex, and 
% multiplexed by a Matrix Concatenate block to form a 1024-by-4 matrix. 
% The Channel Synthesizer block synthesizes these four signals into a single
% broadband signal of size 4096-by-1. The Channelizer block that follows
% splits this broadband signal back into narrow subbands. The output of the
% Channelizer block is a 1024-by-4 matrix, with each channel representing a
% narrow band. 
%%
% Open the model.
model = 'channelizer_synthesizer';
open_system(model)

%%
% Select the audio signal you want to listen to and play this signal using 
% the <docid:dsp_ref#bvacuos-1 Audio Device Writer> block.

%% 
% Run the model. View the spectra of the input, muxed, and output signals.
sim(model)

%%
% The Muxed Spectrum window shows the spectrum of the broadband signal. The 
% Channelized Spectrum window shows the spectra of the four narrowband signals. 
% The input and output spectra match for any selected signal.

%%
% Increase the oversampling ratio of the Channelizer block to 2, which means
% the M/D ratio described in <docid:dsp_ref#bvjrd9b-1.bvbngmf Algorithms> is now 2.
set_param('channelizer_synthesizer/Channelizer','OversamplingRatio','2');
sim(model)

%%
% As you can see in the *Output Spectrum* plot, the output sample rate of the
% polyphase filter bank has increased by a factor of 2.
%%
% Save and close the model.
%set_param('channelizer_synthesizer/Channelizer','OversamplingRatio','1')
%save_system(model) 
close_system(model,0)


%% 
% Copyright 2019 The MathWorks, Inc.