note2pv0.m

来自「自动语音识别源码对非特定人的孤立词语音识别算法 进行研究。考虑到语音识别技术在」· M 代码 · 共 34 行

M
34
字号
function [mid, noteStartPos] = note2mid(midi, resampleRate, plotOpt)
% note2mid: Note to mid conversion
%	Usage:
%	[mid, noteStartPos] = note2mid(midi, resampleRate, plotOpt)
%		midi: semitone and duration sequence, where the duration is based on 1/64 second
%		resampleRate: usually 4
%		mid: Pitch vector where each point represents a pitch of 1/16 second
%		noteStartPos: A vector of the same size as mid, with 1 denotes the start position of a note

%	Roger Jang, 20030501

if nargin==0, selfdemo; return; end
if nargin<2, resampleRate=4; end
if nargin<3, plotOpt=0; end

[mid, noteStartPos] = note2mid2mex(midi, resampleRate);

if plotOpt
	subplot(2,1,1);
	plotmidi(midi, 1/64);
	subplot(2,1,2);
	time=(1:length(mid))/16;
	line(time, mid, 'marker', '.', 'linestyle', 'none');
	index=find(noteStartPos);
	line(time(index), mid(index), 'marker', 'o', 'color', 'r', 'linestyle', 'none');
	axis tight; box on; grid on;
	xlabel('Time (seconds)');
	ylabel('Semitones');
	title('Output of note2mid()');
end

% ====== Self demo
function selfdemo
smtn = [-1 -4 -4 -3 -6 -6 -8 -6 -4 -3 -1 -1 -1]+69;	% Semitones for 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?