subset
Create datastore with subset of files
Description
Examples
subset creates an audio datastore containing a subset of the files of the original 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)
ADS =
audioDatastore with properties:
Files: {
' .../matlab/toolbox/audio/samples/Ambiance-16-44p1-mono-12secs.wav';
' .../matlab/toolbox/audio/samples/AudioArray-16-16-4channels-20secs.wav';
' .../toolbox/audio/samples/ChurchImpulseResponse-16-44p1-mono-5secs.wav'
... and 36 more
}
Folders: {
' .../Bdoc25b.2988451/build/runnable/matlab/toolbox/audio/samples'
}
AlternateFileSystemRoots: {}
OutputDataType: 'double'
OutputEnvironment: 'cpu'
Labels: {}
SupportedOutputFormats: ["wav" "flac" "ogg" "opus" "mp3" "mp4" "m4a"]
DefaultOutputFormat: "wav"
Create a logical vector indicating whether the file names in the audio datastore contain 'Guitar'.
fileContainsGuitar = cellfun(@(c)contains(c,'Guitar'),ADS.Files)fileContainsGuitar = 39×1 logical array
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
⋮
Call subset with the audio datastore and the indices corresponding to the files you want create a new audio datastore from.
ADSsubset = subset(ADS,fileContainsGuitar)
ADSsubset =
audioDatastore with properties:
Files: {
' .../matlab/toolbox/audio/samples/RockGuitar-16-44p1-stereo-72secs.wav';
' .../matlab/toolbox/audio/samples/RockGuitar-16-96-stereo-72secs.flac';
' .../runnable/matlab/toolbox/audio/samples/SoftGuitar-44p1_mono-10mins.ogg'
}
Folders: {
' .../Bdoc25b.2988451/build/runnable/matlab/toolbox/audio/samples'
}
AlternateFileSystemRoots: {}
OutputDataType: 'double'
OutputEnvironment: 'cpu'
Labels: {}
SupportedOutputFormats: ["wav" "flac" "ogg" "opus" "mp3" "mp4" "m4a"]
DefaultOutputFormat: "wav"
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)
ADS =
audioDatastore with properties:
Files: {
' .../matlab/toolbox/audio/samples/Ambiance-16-44p1-mono-12secs.wav';
' .../matlab/toolbox/audio/samples/AudioArray-16-16-4channels-20secs.wav';
' .../toolbox/audio/samples/ChurchImpulseResponse-16-44p1-mono-5secs.wav'
... and 36 more
}
Folders: {
' .../Bdoc25b.2988451/build/runnable/matlab/toolbox/audio/samples'
}
AlternateFileSystemRoots: {}
OutputDataType: 'double'
OutputEnvironment: 'cpu'
Labels: {}
SupportedOutputFormats: ["wav" "flac" "ogg" "opus" "mp3" "mp4" "m4a"]
DefaultOutputFormat: "wav"
Create an audio datastore containing every other file of the original datastore.
indices = 1:2:numel(ADS.Files); ADSsubset = subset(ADS,indices)
ADSsubset =
audioDatastore with properties:
Files: {
' .../matlab/toolbox/audio/samples/Ambiance-16-44p1-mono-12secs.wav';
' .../toolbox/audio/samples/ChurchImpulseResponse-16-44p1-mono-5secs.wav';
' .../runnable/matlab/toolbox/audio/samples/Click-16-44p1-mono-0.2secs.wav'
... and 17 more
}
Folders: {
' .../Bdoc25b.2988451/build/runnable/matlab/toolbox/audio/samples'
}
AlternateFileSystemRoots: {}
OutputDataType: 'double'
OutputEnvironment: 'cpu'
Labels: {}
SupportedOutputFormats: ["wav" "flac" "ogg" "opus" "mp3" "mp4" "m4a"]
DefaultOutputFormat: "wav"
Input Arguments
Specify ADS as an audioDatastore object.
Output Arguments
Subset of audio datastore, returned as an audioDatastore
object.
Version History
Introduced in R2018b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)