function [melody, elapsedTime]=stDsRead(dsDir, opt, showPlot) % Read the dataset (DS) for singing transcription (ST) % % Usage: % dataset=stDatasetRead(datasetDir); % % Example: % dsDir='d:/dataSet/public/MIR-ST500'; % [ds, time]=stDsRead(dsDir, [], 1); % fprintf('Time for reading "%s" = %g sec\n', dsDir, time); % Roger Jang, 20200618 if nargin<1, selfdemo; return; end if ischar(dsDir) && strcmpi(dsDir, 'defaultOpt') % Set the default options melody.junk=0; return end if nargin<2||isempty(opt), opt=feval(mfilename, 'defaultOpt'); end if nargin<3, showPlot=0; end myTic=tic; %% melody=dir(dsDir); melody=melody([melody.isdir]); melody(1:2)=[]; % Get rid of "." and ".." melodyCount=length(melody); %% for i=1:melodyCount melody(i).songId=eval(melody(i).name); end [~, id]=sort([melody.songId]); melody=melody(id); %% for i=1:melodyCount % Read the groundtruth melody(i).gtFile=fullfile(melody(i).folder, melody(i).name, sprintf('%d_groundtruth.txt', melody(i).songId)); melody(i).noteGt=noteFileRead(melody(i).gtFile); % Read the groundtruth file % Read the feature file melody(i).feaFile=fullfile(melody(i).folder, melody(i).name, sprintf('%d_feature.json', melody(i).songId)); melody(i).fea=jsondecode(fileread(melody(i).feaFile)); % Read the feature file if showPlot, fprintf('%d/%d: gtFile=%s, feaFile=%s\n', i, melodyCount, melody(i).gtFile, melody(i).feaFile); end end %% melody=rmfield(melody, 'isdir'); melody=rmfield(melody, 'date'); melody=rmfield(melody, 'datenum'); elapsedTime=toc(myTic); % Elapsed time % ====== Self demo function selfdemo mObj=mFileParse(which(mfilename)); strEval(mObj.example);