Mercurial > hg > emotion-detection-top-level
view Code/Descriptors/Matlab/Common/detect_pitch.m @ 0:ea0c737c6323
first commit
author | Dawn Black <dawn.black@eecs.qmul.ac.uk> |
---|---|
date | Thu, 26 Jul 2012 14:46:25 +0100 |
parents | |
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