📄 note2mid0.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -