data= read(ADS)returns audio extracted from the datastore. Each subsequent call to thereadfunction continues reading from the endpoint of the previous call.
While the audio datastore has unread files, read consecutive files from the datastore. Useprogressto monitor the fraction of files read.
whilehasdata(ADS) data = read(ADS); fprintf('Fraction of files read: %.2f\n',progress(ADS))end
部分文件读:0.03部分文件的意图d: 0.06 Fraction of files read: 0.09 Fraction of files read: 0.11 Fraction of files read: 0.14 Fraction of files read: 0.17 Fraction of files read: 0.20 Fraction of files read: 0.23 Fraction of files read: 0.26 Fraction of files read: 0.29 Fraction of files read: 0.31 Fraction of files read: 0.34 Fraction of files read: 0.37 Fraction of files read: 0.40 Fraction of files read: 0.43 Fraction of files read: 0.46 Fraction of files read: 0.49 Fraction of files read: 0.51 Fraction of files read: 0.54 Fraction of files read: 0.57 Fraction of files read: 0.60 Fraction of files read: 0.63 Fraction of files read: 0.66 Fraction of files read: 0.69 Fraction of files read: 0.71 Fraction of files read: 0.74 Fraction of files read: 0.77 Fraction of files read: 0.80 Fraction of files read: 0.83 Fraction of files read: 0.86 Fraction of files read: 0.89 Fraction of files read: 0.91 Fraction of files read: 0.94 Fraction of files read: 0.97 Fraction of files read: 1.00
Return Information About Data
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 structure. The information structure 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\audiouser\Desktop\Turbine-16-44p1-mono-22secs.wav' Label: Desktop
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.