pitchmarker.m

来自「matlab code for discrete time signal pro」· M 代码 · 共 70 行

M
70
字号
function [ pitch ] = PitchMarker(section)% Pitch Marker% Finds all the pitch marks in the input file and returns the % markings in a matrix %clear all%close all%[x,fs,bit]=wavread('brass_jazz.wav');%section=x;% initial settingsblocksize=400;mark=[1:length(section)]*0;last_pos=1;place=1;blocksize=300;i=1;while last_pos+floor(blocksize*1.7) < length(section)        % grabs the next block to examine    temp=section(last_pos+50:last_pos+floor(blocksize*1.7));    % finds the high point in the block    [mag,place]=max(temp);        % checks to see if there is really a signal in this block    if mag < 0.01        place=length(temp);        mode = 0;        mark(place+last_pos+50)=1;        pitch(i)=place+last_pos+50;    else        mode = 1;    end    % checks to see if there is a pitch mark before the current pitch mark    while mode == 1        % finds largest point in block from beginning to current pitch mark        [mag2,place2]=max(temp(1:place-50));        % checks to see if high mark is suffincent size to be a pitch mark        if mag2 > 0.90*mag            mag=mag2;            place=place2;        else            mode = 0;            mark(place+last_pos+50)=1;            pitch(i)=place+last_pos+50;        end    end         % starts the next block to be examind 50 samples after this block    blocksize=place+50;        % makes sure next blocksize is of sufficent size    if blocksize < 150		blocksize=150;    end        last_pos=place+last_pos+50;    i=i+1;end% plot(mark)% hold on% plot(section,'r')% hold off 

⌨️ 快捷键说明

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