%% Keep Reading While Datastore Has Data
% hasdata returns a logical scalar indicating whether or not there is unread data in the datastore. You can use audioDatastore to read files sequentially until all data is read.
% Specify the file path to the audio samples included with Audio Toolbox™.

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

%
% Create an audio datastore that points to the specified folder.

ADS = audioDatastore(folder);

%
% While the datastore has unread data, read from the datastore.

while hasdata(ADS)
    data = read(ADS);
end

%
% Copyright 2018 The MathWorks, Inc.