close all; clear all; load mir-st010.mat %% Process a given song songId=6; note=ds(songId).noteGt; pv.pitch=ds(songId).fea.vocal_pitch; pv.time=ds(songId).fea.time; pv.name='隱形的翅膀'; %timeInterval=[27 33.5]; %pv=pvSubsequence(pv, timeInterval); %pv.name='「隱形的翅膀」的第一句'; %figure; pvPlot(pv); %% Note %note=noteSubsequence(note, timeInterval); %figure; notePlot(note); %% Note to PV myTic0=tic; stdScale=1:100; stdNoteCount=length(stdScale); pv2=note2pv(note, 8000/256); toc(myTic0) %% Compute transition probability myTic0=tic; pitch2=pv2.pitch; pitch2(pitch2==0)=1; % For easy indexing pvCount=length(pitch2); transProb=zeros(stdNoteCount); for i=1:pvCount-1 pos1=pitch2(i); pos2=pitch2(i+1); transProb(pos1, pos2)=transProb(pos1, pos2)+1; end toc(myTic0) temp=transProb; temp(temp==0)=nan; figure; imagesc(temp); axis image; colorbar %% Compute state probablility myTic0=tic; observed=cell(stdNoteCount); for i=1:stdNoteCount observed{i}=[]; end for i=1:stdNoteCount index=find(pitch2==i); observed{i}=[observed{i}, pv.pitch(index)]; end observationCount=zeros(1, stdNoteCount); for i=1:stdNoteCount observationCount(i)=length(observed{i}); end toc(myTic0) figure; bar(observationCount); xlabel('Semitones'); ylabel('Pitch count'); %% figure; plot(observed{61}); %% figure; plot(observed{63});