data = read(ADS) returns
audio extracted from the datastore. Each subsequent call to the read
function continues reading from the endpoint of the previous call.
While the audio datastore has unread files, read consecutive files from the datastore. Use progress to monitor the fraction of files read.
while hasdata(ADS)
data = read(ADS);
fprintf('Fraction of files read: %.2f\n',progress(ADS))
end
Fraction of files read: 0.03
Fraction of files read: 0.07
Fraction of files read: 0.10
Fraction of files read: 0.13
Fraction of files read: 0.17
Fraction of files read: 0.20
Fraction of files read: 0.23
Fraction of files read: 0.27
Fraction of files read: 0.30
Fraction of files read: 0.33
Fraction of files read: 0.37
Fraction of files read: 0.40
Fraction of files read: 0.43
Fraction of files read: 0.47
Fraction of files read: 0.50
Fraction of files read: 0.53
Fraction of files read: 0.57
Fraction of files read: 0.60
Fraction of files read: 0.63
Fraction of files read: 0.67
Fraction of files read: 0.70
Fraction of files read: 0.73
Fraction of files read: 0.77
Fraction of files read: 0.80
Fraction of files read: 0.83
Fraction of files read: 0.87
Fraction of files read: 0.90
Fraction of files read: 0.93
Fraction of files read: 0.97
Fraction of files read: 1.00
Specify the file path to the audio samples you want to include in the audio datastore. In this example, the samples are located on a local desktop. Create an audio datastore that points to the specified folder.
When you read data from the datastore, you can additionally return information about the data as a struct. The information struct contains the file name, any labels associated with the file, and the sample rate of the file.
[data,info] = read(ADS);
info
info =
struct with fields:
SampleRate: 44100
FileName: 'C:\Users\bhemmat\Desktop\Turbine-16-44p1-mono-22secs.wav'
Label: Desktop