%% Output Mono Audio from Datastore
% Specify the file path to the audio samples included with Audio Toolbox™. Create an audio datastore that points to the specified folder.

folder = fullfile(matlabroot,'toolbox','audio','samples');
ADS = audioDatastore(folder);

%
% Call transform to create a new datastore that mixes multichannel signals to mono.

ADSnew = transform(ADS,@(x)mean(x,2));

%
% Read from the new datastore and confirm that it only outputs mono signals.

while hasdata(ADSnew)
    audio = read(ADSnew);
    fprintf('Number of channels = %d\n',size(audio,2))
end

%
% Copyright 2018 The MathWorks, Inc.