Mercurial > hg > emotion-detection-top-level
view Code/Descriptors/Matlab/Common/detect_pitch.m @ 1:a3d62264030c
tested and working
author | Dawn Black <dawn.black@eecs.qmul.ac.uk> |
---|---|
date | Mon, 10 Sep 2012 09:13:53 +0100 |
parents | ea0c737c6323 |
children | 92ca03a8fa99 |
line wrap: on
line source
function [ pitch ] = pitch_Detection( sampleWavFileName, OVERWRITE ) % open original pitch calculation sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); fileName = [ sampleFileName '_YIN_pitch.txt']; % read pitch metrics from file fileID = fopen( fileName ); if( (fileID <= 0) || (OVERWRITE) ) %does the file exist? % no disp('WARNING: MISSING PITCH FILE'); %calculate it [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); % perform pitch detection framePrd = calculate_pitchYIN( sampleFileName, x, fs, frameLength ); fileID = fopen( fileName, 'w'); for( i=1:length( framePrd )) fprintf(fileID, '%d %f \n', framePrd(i,1), framePrd(i,2) ); end fclose( fileID ); fileID = fopen( fileName ); end pitch = fscanf( fileID, '%f', inf ); pitch = pitch(2:2:end); fclose( fileID ); end