Mercurial > hg > emotion-detection-top-level
changeset 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,6 @@ +syntax: glob +*conflicted copy* +re:^Code/Descriptors/yin/junk/ +re:^Code/Descriptors/yin/yin/junk/ +*~ +*.wav
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/SVM_Formants_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,540 @@ +function [] = SVM_Formants_Singing( varargin ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 0; +% output results file name +masterFileOutputID = fopen( 'SVM_paper_SingingFormantsStats.txt', 'a' ); +% input results file name +inputFileName = 'paper_singingFormantsStats.txt'; + +% This function allows the user to stipulate which Singing voice LLD's they +% wish to forward to a k-means classifier and produces a file of +% performance characteristics. Input arguments stipulate the LLD's and +% there is a choice of:- +% +% ---- PRAAT FORMANT MEASUREMENTS ---- +% '_Formant_Burg' +% '_Formant_all' +% '_Formant_robust' +% +% A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt +% is produced that contains the results of the k-mean classification for +% the LLD's specified and named in the result document title. + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +% get the column numbers of the results that we want to classify + +% COLUMN NUMBER : METRIC +% +% ------------- BURG FORMANTS --------------- +% 11 : Number of BURG formants listed = nBF +% +% THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT +nMetrics = 24; +% +% 12 : mean frequency of the first BURG formant +% 13 : variance of the first BURG formant +% 14 : minimum frequency of the first BURG formant +% 15 : maximum frequency of the first BURG formant +% 16 : mean Frequency Derivative of the first BURG formant +% 17 : varience of the Frequency Derivative of the first BURG formant +% 18 : min of the Frequency Derivative of the first BURG formant +% 19 : max of the Frequency Derivative of the first BURG formant +% 20 : mean of the Frequency 2nd Derivative of the first BURG formant +% 21 : varience of the Frequency 2nd Derivative of the first BURG formant +% 22 : min of the Frequency 2nd Derivative of the first BURG formant +% 23 : max of the Frequency 2nd Derivative of the first BURG formant +% 24 : mean of the Bandwidth of the first BURG formant +% 25 : varience of the Bandwidth of the first BURG formant +% 26 : min of the Bandwidth of the first BURG formant +% 27 : max of the Bandwidth of the first BURG formant +% 28 : mean of the Bandwidth Derivative of the first BURG formant +% 29 : varience of the Bandwidth Derivative of the first BURG formant +% 30 : min of the Bandwidth Derivative of the first BURG formant +% 31 : max of the Bandwidth Derivative of the first BURG formant +% 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant +% 33 : var of the Bandwidth 2nd Derivative of the first BURG formant +% 34 : min of the Bandwidth 2nd Derivative of the first BURG formant +% 35 : max of the Bandwidth 2nd Derivative of the first BURG formant +% +% ....... there are nMetrics for each formant in nBF formants, so cycle +% through until the last is reached ...... +% +% 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant +% +% FOR THE MEAN OF ALL BURG FORMANTS +% 36 + (nBF*nMetrics) : mean of all formants Frequency +% 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% +% ------------- ALL FORMANTS --------------- +% +% 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF +% +% startOfALLMeasurements = 36 + (nBF*nMetrics) + 13; +% +% startOfALLMeasurements : mean frequency of the first ALL formant +% startOfALLMeasurements + 1 : variance of the first ALL formant +% startOfALLMeasurements + 2 : minimum frequency of the first ALL formant +% startOfALLMeasurements + 3 : maximum frequency of the first ALL formant +% startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant +% +% ....... there are nMetrics for each formant in nAF formants, so cycle +% through until the last is reached ...... +% +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant +% +% FOR THE MEAN OF ALL ALL FORMANTS +% startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% +% ------------- ROBUST FORMANTS --------------- +% +% startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF +% +% startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13; +% +% startOfROBUSTMeasurements : mean frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant +% startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant +% +% ....... there are nMetrics for each formant in nRF formants, so cycle +% through until the last is reached ...... +% +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% +% FOR THE MEAN OF ALL ROBUST FORMANTS +% startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% + +noOfArguments = length(varargin); +columnIndices = []; + +getBURGFormants = 0; +getAllFormants=0; +getRobustFormants=0; + +for i=1 : noOfArguments + if( strcmp( varargin{i}, 'formant_Burg' )) + getBURGFormants = 1; + elseif( strcmp( varargin{i}, 'formant_all' )) + getAllFormants=1; + elseif( strcmp( varargin{i}, 'formant_robust' )) + getRobustFormants=1; + end +end + +titleName = ''; +for i=1 : noOfArguments + titleName = [ titleName varargin{i} '_']; + fprintf( masterFileOutputID, '%s_', varargin{i} ); +end + +fprintf( masterFileOutputID, '\t' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +groups = []; + +while( ~(feof(inputFileID)) ) + + outputValues = []; + + thestr = fgetl(inputFileID); + if( lineCount > 10 ) % skip the file header + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + groups( fileCount ) = 1; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + groups( fileCount ) = 0; + else + disp('EEEK!'); + pause; + end + +% % determine whether we have a male, female or trans sample +% gender( fileCount ) = '?'; +% if( ~(isempty(strfind(thestr,'fem')))) +% % gender is female +% gender( fileCount ) = 'F'; +% elseif( ~(isempty(strfind(thestr,'male')))) +% % gender is male +% gender( fileCount ) = 'M'; +% elseif( ~(isempty(strfind(thestr,'trans')))) +% % gender is trans +% gender( fileCount ) = 'T'; +% else +% disp('EEEK!'); +% pause; +% end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants + +% str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values + str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information + str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information + str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information + + +% vars = sscanf( str1, '%f', inf ); +% % extract the shimmer and jitter values +% outputValues = [ outputValues vars( columnIndices )']; + + if( getBURGFormants ) + spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str2( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + if( getAllFormants ) + spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str3( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + if( getRobustFormants ) + spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str4( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + [m n] = size( data ); + % sometimes the 'all' formants command gives us fewer formants than + % usual. If this is the case,then we will have to pad with zeros + % for now. + if( n > length( outputValues ) ) + lenDiff = n - length( outputValues ); + outputValues = [ outputValues zeros( 1, lenDiff ) ]; + elseif( n < length( outputValues ) ) + lenDiff = length( outputValues ) - n; + outputValues = [ outputValues zeros( 1, lenDiff ) ]; + end + + data( fileCount, : ) = outputValues; + + end + lineCount = lineCount + 1; + +end +fclose(inputFileID); + + + +% ------------ apply the SVM classifier ------------------------ + +resultMatrix = []; + +noOfIterations = 10; + +for n = 1:noOfIterations + % Randomly select training and test sets, perhaps we should try all and + % choose the best? + [train, test] = crossvalind('holdOut',groups); + cp = classperf(groups); + + % Use a linear support vector machine classifier + svmStruct = svmtrain(data(train,:),groups(train)); + classes = svmclassify(svmStruct,data(test,:)); + % See how well the classifier performed + classperf(cp,classes,test); + numbers = cp.CountingMatrix; + + resultMatrix (n,:,:) = cp.DiagnosticTable; +% +end + + + + +% for emotion detection give the confusion matrix as + % ----------------------------------------------------------------- + % positive correctly identified | positive incorrectly identified (1,2) + % negative incorrectly identified (2,1) | negative correctly identified + % ------------------------------------------------------------------ + +% takes the average of 10 iterations - do we want to take the best? + +meanResults(1,1) = mean( resultMatrix(:,1,1) ); +meanResults(1,2) = mean( resultMatrix(:,2,1) ); +meanResults(2,1) = mean( resultMatrix(:,1,2) ); +meanResults(2,2) = mean( resultMatrix(:,2,2) ); + +meanResults(3,:)=0; +meanResults(:,3)=0; + +meanResults(3,3) = (meanResults(1,1) + meanResults(2,2));% / sum(sum(meanResults)); + +% convert to percentages +% how many of each sample do we have? +groupNumbers = unique( groups( test )); +groupNames = unique( sampleEmotion( test )); +sampleEmotionTest = sampleEmotion( test ); +% which group is which emotion? +thisGroupNumber = groupNumbers(1); +thisGroup = find( groups( test ) == thisGroupNumber ); +thisGroupName = unique( sampleEmotionTest( thisGroup )); + +thatGroupNumber = groupNumbers(2); +thatGroup = find( groups( test ) == thatGroupNumber ); +thatGroupName = unique( sampleEmotionTest( thatGroup )); + +if(length( thisGroupName ) ~= 1 ) + disp('ARGH!'); + pause; +end + +thisGroupNumberOfSamples = length( thisGroup ); +thatGroupNumberOfSamples = length( thatGroup ); + +if( thisGroupName == 'P' ) + %swap all the variables ready for checking + temp = thisGroupNumberOfSamples; + thisGroupNumberOfSamples = thatGroupNumberOfSamples; + thatGroupNumberOfSamples = temp; + + temp = thisGroupName; + thisGroupName = thatGroupName + thatGroupName = temp; + disp('CHECK ME!'); +end + +if( thisGroupName == 'N' ) + % group 0 is negative + if( sum( meanResults(1,:) ) == thisGroupNumberOfSamples ) + %if the elements in the first row add up to the number of negative + %samples, then swap the rows because we want the top row to be the + %results for the positive samples + temp(:,1) = meanResults(1:2,2); + temp(:,2) = meanResults(1:2,1); + temp2(1,:) = temp(2,:); + temp2(2,:) = temp(1,:); + + meanResults(1:2,1) = temp2(:,1); + meanResults(1:2,2) = temp2(:,2); + + % check the number of positive samples + if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... + && ( thatGroupName == 'P' ) ) + % row 1 is positive + disp('matrix correct'); + else + disp('ARGH!'); + pause; + end + + elseif( sum( meanResults(2,:) ) == thisGroupNumberOfSamples ) + + % the elements in the second row add up to the number of negative + % samples, so the matrix is the correct way around + + % check the number of positive samples + if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... + && ( thatGroupName == 'P' ) ) + % row 0 is positive + disp('matrix correct'); + else + disp('ARGH!'); + pause; + end + end +end + +% calculate the percentages +numberOfSamples = sum(sum( meanResults(1:2,1:2))); +percentageResults = meanResults; +percentageResults(1,1) = meanResults(1,1) / numberOfSamples; +percentageResults(1,2) = meanResults(1,2) / numberOfSamples; +percentageResults(2,1) = meanResults(2,1) / numberOfSamples; +percentageResults(2,2) = meanResults(2,2) / numberOfSamples; +percentageResults(3,3) = meanResults(3,3) / numberOfSamples; + +percentageResults = percentageResults * 100 + +confusionMatrix = percentageResults; + fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3)); + + % print latex results to the screen +str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(1,1), percentageResults(1,2) ); +disp(str1); +str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(2,1), percentageResults(2,2) ); +disp(str1); +str1 = sprintf(' & & & %2.2f \\\\',percentageResults(3,3) ); +disp(str1); + +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +%------------------------------------------------------------------ + +function [ outputValues ] = stripOutFormantValues( vars, outputValues ) + + noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only + noOfFormants = vars(1); + % there are 12 measurements for the mean of all formants (so the number + % of formants is not important) for each formant measurement. + if( noOfFormants ~= (noOfFormantValues-12)/24 ) + disp('EEK!'); + pause; + else + outputValues = [ outputValues vars( 2:end )' ]; + end + +end + +%-------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/SVM_HNR_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,133 @@ +function [] = SVM_HNR_Singing( inputFileName ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 1; +% output results file name +% masterFileOutputID = fopen( 'SVM_Singing_HNR.txt', 'a' ); +outputFileName = ['SVM_' inputFileName]; +masterFileOutputID = fopen( outputFileName, 'a' ); + +% input results file name +% inputFileName = 'singingBasicHNRStats.txt'; + +% fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +% noOfArguments = length(varargin); + +% outputFileName = 'individualResults/SVM_Results_'; +% resultsFileName = 'SVM_Results_'; +% titleName = ''; +% for i=1 : noOfArguments +% titleName = [ titleName varargin{i} '_']; +% fprintf( masterFileOutputID, '%s_', varargin{i} ); +% end + +% outputFileName = [ outputFileName titleName ]; +% resultsFileName = [ resultsFileName titleName ]; + +fprintf( masterFileOutputID, '\t' ); + +% outputFileName = [ outputFileName '.txt']; +% resultsFileName = [ resultsFileName '.txt']; +% +% fileOutputID = fopen( outputFileName, 'w' ); +% fileSVMOutputID = fopen( resultsFileName, 'w' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +groups = []; + +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + groups( fileCount ) = 1; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + groups( fileCount ) = 0; + else + disp('EEEK!'); + pause; + end + + % determine whether we have a male, female or trans sample + gender( fileCount ) = '?'; + if( ~(isempty(strfind(thestr,'fem')))) + % gender is female + gender( fileCount ) = 'F'; + elseif( ~(isempty(strfind(thestr,'male')))) + % gender is male + gender( fileCount ) = 'M'; + elseif( ~(isempty(strfind(thestr,'trans')))) + % gender is trans + gender( fileCount ) = 'T'; + else + disp('EEEK!'); + pause; + end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the SVM classifier ------------------------ + +G1E1 = []; G1E2 = []; G2E1 = []; G2E2 = []; UE1 = []; UE2 = []; + +noOfIterations = 10; + +for n = 1:noOfIterations + % Randomly select training and test sets + [train, test] = crossvalind('holdOut',groups); + cp = classperf(groups); + + % Use a linear support vector machine classifier + svmStruct = svmtrain(data(train,:),groups(train),'showplot',true); + classes = svmclassify(svmStruct,data(test,:),'showplot',true); + % See how well the classifier performed + classperf(cp,classes,test); + numbers = cp.CountingMatrix; + + G1E1(n) = numbers(1,1); + G1E2(n) = numbers(1,2); + G2E1(n) = numbers(2,1); + G2E2(n) = numbers(2,2); + UE1(n) = numbers(3,1); + UE2(n) = numbers(3,2); + +end + +G1E1 = sum(G1E1) / noOfIterations; +G1E2 = sum(G1E2) / noOfIterations; +G2E1 = sum(G2E1) / noOfIterations; +G2E2 = sum(G2E2) / noOfIterations; +% +% fprintf( fileOutputID, '\n' ); +% fclose( fileOutputID ); +% fprintf( fileSVMOutputID, '\n' ); +% fclose( fileKMeansOutputID ); +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/SVM_MFCC_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,130 @@ +function [] = SVM_MFCC_Singing( varargin ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 1; +% output results file name +masterFileOutputID = fopen( 'SVM_Singing_MFCC_VoicedAndUnvoiced_Unsmoothed.txt', 'a' ); +% input results file name +inputFileName = 'singingMFCCStats_VoicedAndUnvoiced_Unsmoothed.txt'; + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +noOfArguments = length(varargin); + +outputFileName = 'individualResults/SVM_Results_'; +resultsFileName = 'SVM_Results_'; +titleName = ''; +for i=1 : noOfArguments + titleName = [ titleName varargin{i} '_']; + fprintf( masterFileOutputID, '%s_', varargin{i} ); +end + +outputFileName = [ outputFileName titleName ]; +resultsFileName = [ resultsFileName titleName ]; + +fprintf( masterFileOutputID, '\t' ); + +outputFileName = [ outputFileName '.txt']; +resultsFileName = [ resultsFileName '.txt']; + +fileOutputID = fopen( outputFileName, 'w' ); +fileSVMOutputID = fopen( resultsFileName, 'w' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +groups = []; + +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + groups( fileCount ) = 1; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + groups( fileCount ) = 0; + else + disp('EEEK!'); + pause; + end + + % determine whether we have a male, female or trans sample + gender( fileCount ) = '?'; + if( ~(isempty(strfind(thestr,'fem')))) + % gender is female + gender( fileCount ) = 'F'; + elseif( ~(isempty(strfind(thestr,'male')))) + % gender is male + gender( fileCount ) = 'M'; + elseif( ~(isempty(strfind(thestr,'trans')))) + % gender is trans + gender( fileCount ) = 'T'; + else + disp('EEEK!'); + pause; + end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the SVM classifier ------------------------ + +G1E1 = []; G1E2 = []; G2E1 = []; G2E2 = []; UE1 = []; UE2 = []; + +noOfIterations = 10; + +for n = 1:noOfIterations + % Randomly select training and test sets + [train, test] = crossvalind('holdOut',groups); + cp = classperf(groups); + + % Use a linear support vector machine classifier + svmStruct = svmtrain(data(train,:),groups(train),'showplot',true); + classes = svmclassify(svmStruct,data(test,:),'showplot',true); + % See how well the classifier performed + classperf(cp,classes,test); + numbers = cp.CountingMatrix; + + G1E1(n) = numbers(1,1); + G1E2(n) = numbers(1,2); + G2E1(n) = numbers(2,1); + G2E2(n) = numbers(2,2); + UE1(n) = numbers(3,1); + UE2(n) = numbers(3,2); + +end + +G1E1 = sum(G1E1) / noOfIterations; +G1E2 = sum(G1E2) / noOfIterations; +G2E1 = sum(G2E1) / noOfIterations; +G2E2 = sum(G2E2) / noOfIterations; + +fprintf( fileOutputID, '\n' ); +fclose( fileOutputID ); +fprintf( fileSVMOutputID, '\n' ); +fclose( fileSVMOutputID ); +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/SVM_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,242 @@ +function [] = SVM_Singing( inputFileName ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 1; +% output results file name +% masterFileOutputID = fopen( 'SVM_Singing_HNR.txt', 'a' ); +outputFileName = ['SVM_' inputFileName]; +masterFileOutputID = fopen( outputFileName, 'a' ); + +% input results file name +% inputFileName = 'singingBasicHNRStats.txt'; + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +% noOfArguments = length(varargin); + +% outputFileName = 'individualResults/SVM_Results_'; +% resultsFileName = 'SVM_Results_'; +titleName = ''; +% for i=1 : noOfArguments +% titleName = [ titleName varargin{i} '_']; +% fprintf( masterFileOutputID, '%s_', varargin{i} ); +% end + +% outputFileName = [ outputFileName titleName ]; +% resultsFileName = [ resultsFileName titleName ]; + +fprintf( masterFileOutputID, '\t' ); + +% outputFileName = [ outputFileName '.txt']; +% resultsFileName = [ resultsFileName '.txt']; +% +% fileOutputID = fopen( outputFileName, 'w' ); +% fileSVMOutputID = fopen( resultsFileName, 'w' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +groups = []; + +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + groups( fileCount ) = 1; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + groups( fileCount ) = 0; + else + disp('EEEK!'); + fileCount = fileCount - 1; +% pause; + end + + % determine whether we have a male, female or trans sample +% gender( fileCount ) = '?'; +% if( ~(isempty(strfind(thestr,'fem')))) +% % gender is female +% gender( fileCount ) = 'F'; +% elseif( ~(isempty(strfind(thestr,'male')))) +% % gender is male +% gender( fileCount ) = 'M'; +% elseif( ~(isempty(strfind(thestr,'trans')))) +% % gender is trans +% gender( fileCount ) = 'T'; +% else +% disp('EEEK!'); +% pause; +% end + + if(( ~(isempty(strfind(thestr,'pos')))) || ( ~(isempty(strfind(thestr,'neg')))) ) + %how many values are in the string? +% spaces = strfind( thestr, ' ' ); + spaces = [ strfind( thestr, sprintf('\t')) strfind( thestr, ' ' )]; + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + end + + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the SVM classifier ------------------------ + +resultMatrix = []; + +noOfIterations = 100; + +for n = 1:noOfIterations + % Randomly select training and test sets, perhaps we should try all and + % choose the best? + [train, test] = crossvalind('holdOut',groups); + cp = classperf(groups); + + % Use a linear support vector machine classifier + svmStruct = svmtrain(data(train,:),groups(train)); + classes = svmclassify(svmStruct,data(test,:)); + % See how well the classifier performed + classperf(cp,classes,test); + numbers = cp.CountingMatrix; + + resultMatrix (n,:,:) = cp.DiagnosticTable; +% +end + + + + +% for emotion detection give the confusion matrix as + % ----------------------------------------------------------------- + % positive correctly identified | positive incorrectly identified (1,2) + % negative incorrectly identified (2,1) | negative correctly identified + % ------------------------------------------------------------------ + +% takes the average of 100 iterations - do we want to take the best? + +meanResults(1,1) = mean( resultMatrix(:,1,1) ); +meanResults(1,2) = mean( resultMatrix(:,2,1) ); +meanResults(2,1) = mean( resultMatrix(:,1,2) ); +meanResults(2,2) = mean( resultMatrix(:,2,2) ); + +meanResults(3,:)=0; +meanResults(:,3)=0; + +meanResults(3,3) = (meanResults(1,1) + meanResults(2,2));% / sum(sum(meanResults)); + +% convert to percentages +% how many of each sample do we have? +groupNumbers = unique( groups( test )); +groupNames = unique( sampleEmotion( test )); +sampleEmotionTest = sampleEmotion( test ); +% which group is which emotion? +thisGroupNumber = groupNumbers(1); +thisGroup = find( groups( test ) == thisGroupNumber ); +thisGroupName = unique( sampleEmotionTest( thisGroup )); + +thatGroupNumber = groupNumbers(2); +thatGroup = find( groups( test ) == thatGroupNumber ); +thatGroupName = unique( sampleEmotionTest( thatGroup )); + +if(length( thisGroupName ) ~= 1 ) + disp('ARGH!'); + pause; +end + +thisGroupNumberOfSamples = length( thisGroup ); +thatGroupNumberOfSamples = length( thatGroup ); + +if( thisGroupName == 'P' ) + %swap all the variables ready for checking + temp = thisGroupNumberOfSamples; + thisGroupNumberOfSamples = thatGroupNumberOfSamples; + thatGroupNumberOfSamples = temp; + + temp = thisGroupName; + thisGroupName = thatGroupName + thatGroupName = temp; + disp('CHECK ME!'); +end + +if( thisGroupName == 'N' ) + % group 0 is negative + if( sum( meanResults(1,:) ) == thisGroupNumberOfSamples ) + %if the elements in the first row add up to the number of negative + %samples, then swap the rows because we want the top row to be the + %results for the positive samples + temp(:,1) = meanResults(1:2,2); + temp(:,2) = meanResults(1:2,1); + temp2(1,:) = temp(2,:); + temp2(2,:) = temp(1,:); + + meanResults(1:2,1) = temp2(:,1); + meanResults(1:2,2) = temp2(:,2); + + % check the number of positive samples + if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... + && ( thatGroupName == 'P' ) ) + % row 1 is positive + disp('matrix correct'); + else + disp('ARGH!'); + pause; + end + + elseif( sum( meanResults(2,:) ) == thisGroupNumberOfSamples ) + + % the elements in the second row add up to the number of negative + % samples, so the matrix is the correct way around + + % check the number of positive samples + if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... + && ( thatGroupName == 'P' ) ) + % row 0 is positive + disp('matrix correct'); + else + disp('ARGH!'); + pause; + end + end +end + +% calculate the percentages +numberOfSamples = sum(sum( meanResults(1:2,1:2))); +percentageResults = meanResults; +percentageResults(1,1) = meanResults(1,1) / numberOfSamples; +percentageResults(1,2) = meanResults(1,2) / numberOfSamples; +percentageResults(2,1) = meanResults(2,1) / numberOfSamples; +percentageResults(2,2) = meanResults(2,2) / numberOfSamples; +percentageResults(3,3) = meanResults(3,3) / numberOfSamples; + +percentageResults = percentageResults * 100 + +confusionMatrix = percentageResults; + fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3)); + + % print latex results to the screen +str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(1,1), percentageResults(1,2) ); +disp(str1); +str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(2,1), percentageResults(2,2) ); +disp(str1); +str1 = sprintf(' & & & %2.2f \\\\',percentageResults(3,3) ); +disp(str1); + +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/getConfusionMatrix.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,828 @@ +function [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames,... + masterFileOutputID, distanceMeasure ) + + groupNames = char(groupNames); + + % for emotion detection give the confusion matrix as + % ----------------------------------------------------------------- + % positive correctly identified | positive incorrectly identified (1,2) + % negative incorrectly identified (2,1) | negative correctly identified + % ------------------------------------------------------------------ + % which group has the most samples? + [maxValue, maxIndex] = max( groupStats ); + maxGroup = groupNames( maxIndex,: ); + + % if we are performing emotion detection + if( ~isempty(strfind( groupNames(1,:), 'N' )) ... + || ~isempty(strfind( groupNames(1,:), 'P' ))) + confusionMatrix = zeros(2,2); + + % check groups for any missing + if( length(groupStats) < 4 ) + % find the missing group + if( groupFind( groupNames, 'N1' ) == 0 ) + % missing N1 + groupNames = [groupNames; 'N1']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'N2' ) == 0 ) + % missing N2 + groupNames = [groupNames; 'N2']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'P1' ) == 0 ) + % missing P1 + groupNames = [groupNames; 'P1']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'P2' ) == 0 ) + %missing P2 + groupNames = [groupNames; 'P2']; + groupStats = [groupStats 0]; + end + end + % let the group with the maximum success (either 1 or 2) be the + % cluster for that emotion + if( strfind( maxGroup, 'N' )) + % negative samples were detected most reliably + confusionMatrix(2,2) = maxValue; + if( strfind( maxGroup, '1' )) + % group 1 is the negative group + % find the number of positive samples incorrectly identified + idx = groupFind( groupNames, 'P1' ); + confusionMatrix(1,2) = groupStats( idx ); + % group 2 is the positive group + % find the number of positive samples correctly identified + idx = groupFind( groupNames, 'P2' ); + confusionMatrix(1,1) = groupStats( idx ); + % find the number of negative samples incorrectly identified + idx = groupFind( groupNames, 'N2' ); + confusionMatrix(2,1) = groupStats( idx ); + else + % group 2 is the negative group + % find the number of positive samples incorrectly identified + idx = groupFind( groupNames, 'P2' ); + confusionMatrix(1,2) = groupStats( idx ); + % group 1 is the positive group + % find the number of positive samples correctly identified + idx = groupFind( groupNames, 'P1' ); + confusionMatrix(1,1) = groupStats( idx ); + % find the number of negative samples incorrectly identified + idx = groupFind( groupNames, 'N1' ); + confusionMatrix(2,1) = groupStats( idx ); + end + else + % positive samples were detected most reliably + confusionMatrix(1,1) = maxValue; + if( strfind( maxGroup, '1' )) + % group 1 is the positive group + % find the number of positive samples incorrectly identified + idx = groupFind( groupNames, 'P2' ); + confusionMatrix(1,2) = groupStats( idx ); + % group 2 is the negative group + % find the number of negative samples correctly identified + idx = groupFind( groupNames, 'N2' ); + confusionMatrix(2,2) = groupStats( idx ); + % find the number of negative samples incorrectly identified + idx = groupFind( groupNames, 'N1' ); + confusionMatrix(2,1) = groupStats( idx ); + else + % group 2 is the positive group + % find the number of positive samples incorrectly identified + idx = groupFind( groupNames, 'P1' ); + confusionMatrix(1,2) = groupStats( idx ); + % group 1 is the negative group + % find the number of negative samples correctly identified + idx = groupFind( groupNames, 'N1' ); + confusionMatrix(2,2) = groupStats( idx ); + % find the number of negative samples incorrectly identified + idx = groupFind( groupNames, 'N2' ); + confusionMatrix(2,1) = groupStats( idx ); + end + end + + confusionMatrix(3,3) = confusionMatrix(1,1) + confusionMatrix(2,2); + disp(distanceMeasure); + % print latex results to the screen + str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2) ); + disp(str1); + str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2) ); + disp(str1); + str1 = sprintf(' & & & %2.2f \\\\',confusionMatrix(3,3) ); + disp(str1); + disp(' '); + + fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3)); + end + + % for gender detection give the confusion matrix as + % -------------------------------------------------------------------- + % male correctly identified as male | male incorrectly identified as female | male incorrectly identified as trans + % female incorrectly identified as male | female correctly identified | female incorrectly identified as trans + % trans incorrectly identified as male | trans incorrectly identified as female | trans correctly identified + % -------------------------------------------------------------------- + + % if we are performing gender detection + if( ~isempty(strfind( groupNames(1,:), 'F' )) ... + || ~isempty(strfind( groupNames(1,:), 'M' ))... + || ~isempty(strfind( groupNames(1,:), 'T' ))) + confusionMatrix = zeros(3,3); + + % check groups for any missing + if( length(groupStats) < 9 ) + % find the missing group + if( groupFind( groupNames, 'M1' ) == 0 ) + groupNames = [groupNames; 'M1']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'M2' ) == 0 ) + groupNames = [groupNames; 'M2']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'M3' ) == 0 ) + groupNames = [groupNames; 'M3']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'F1' ) == 0 ) + groupNames = [groupNames; 'F1']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'F2' ) == 0 ) + groupNames = [groupNames; 'F2']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'F3' ) == 0 ) + groupNames = [groupNames; 'F3']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'T1' ) == 0 ) + groupNames = [groupNames; 'T1']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'T2' ) == 0 ) + groupNames = [groupNames; 'T2']; + groupStats = [groupStats 0]; + end + if( groupFind( groupNames, 'T3' ) == 0 ) + groupNames = [groupNames; 'T3']; + groupStats = [groupStats 0]; + end + + end + + + % let the group with the maximum success (either 1, 2 or 3) be the + % cluster for that gender + if( strfind( maxGroup, 'M' )) + % male samples were detected most reliably + confusionMatrix(1,1) = maxValue; + if( strfind( maxGroup, '1' )) + % group 1 is the male group + % find the female group (F2 or F3, can't be F1) + idx1 = groupFind( groupNames, 'F2' ); + idx2 = groupFind( groupNames, 'F3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % group 1 is the male group + % female is group 2 and trans group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 3 and trans is group 2 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + + elseif( strfind( maxGroup, '2' )) + % group 2 is the male group + + % find the female group (F1 or F3, can't be F2) + idx1 = groupFind( groupNames, 'F1' ); + idx2 = groupFind( groupNames, 'F3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % female is group 1 and trans group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 3 and trans is group 1 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + else + % group 3 is the male group + + % find the female group (F1 or F2, can't be F3) + idx1 = groupFind( groupNames, 'F1' ); + idx2 = groupFind( groupNames, 'F2' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % female is group 1 and trans group 2 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 2 and trans is group 1 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + end + + % -------------------------------------------------------------------- + % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans + % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans + % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) + % -------------------------------------------------------------------- + + elseif( strfind( maxGroup, 'F' )) + % female samples were detected most reliably + confusionMatrix(2,2) = maxValue; + if( strfind( maxGroup, '1' )) + % group 1 is the female group + % find the male group (F2 or F3, can't be F1) + idx1 = groupFind( groupNames, 'M2' ); + idx2 = groupFind( groupNames, 'M3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % male is group 2 and trans group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 1 + % male is group 3 and trans is group 2 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + + elseif( strfind( maxGroup, '2' )) + % group 2 is the female group + % find the male group (M1 or M3, can't be M2) + idx1 = groupFind( groupNames, 'M1' ); + idx2 = groupFind( groupNames, 'M3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % male is group 1 and trans group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % group 2 is the female group + % male is group 3 and trans is group 1 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + else + % group 3 is the female group + % find the male group (M1 or M2, can't be M3) + idx1 = groupFind( groupNames, 'M1' ); + idx2 = groupFind( groupNames, 'M2' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % male is group 1 and trans group 2 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 3 + % male is group 2 and trans is group 1 + + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,3) = groupStats( idx ); + + % trans correctly identified as trans + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,3) = groupStats( idx ); + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + end + % -------------------------------------------------------------------- + % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans + % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans + % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) + % -------------------------------------------------------------------- + + elseif( strfind( maxGroup, 'T' )) + % trans samples were detected most reliably + confusionMatrix(3,3) = maxValue; + if( strfind( maxGroup, '1' )) + % group 1 is the trans group + % find the female group (F2 or F3, can't be F1) + idx1 = groupFind( groupNames, 'F2' ); + idx2 = groupFind( groupNames, 'F3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % female is group 2 and male group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % female is group 3 and male is group 2 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + end + + elseif( strfind( maxGroup, '2' )) + % group 2 is the trans group + % find the female group (F1 or F3, can't be F2) + idx1 = groupFind( groupNames, 'F1' ); + idx2 = groupFind( groupNames, 'F3' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % female is group 1 and male group 3 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % group 2 is the trans group + % female is group 3 and male is group 1 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T3' ); + confusionMatrix(3,2) = groupStats( idx ); + + end + + else + % group 3 is the trans group + % find the female group (F1 or F2, can't be F3) + idx1 = groupFind( groupNames, 'F1' ); + idx2 = groupFind( groupNames, 'F2' ); + if( groupStats( idx1 ) > groupStats( idx2 ) ) + % female is group 1 and male group 2 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,2) = groupStats( idx ); + + else + % group 3 is the trans group + % female is group 2 and male is group 1 + % find the number of male samples incorrectly identified as female + idx = groupFind( groupNames, 'M2' ); + confusionMatrix(1,2) = groupStats( idx ); + % find the number of male samples incorrectly identified as trans + idx = groupFind( groupNames, 'M3' ); + confusionMatrix(1,3) = groupStats( idx ); + % male correctly identified as male + idx = groupFind( groupNames, 'M1' ); + confusionMatrix(1,1) = groupStats( idx ); + + % female correctly identified as female + idx = groupFind( groupNames, 'F2' ); + confusionMatrix(2,2) = groupStats( idx ); + % female incorrectly identified as male + idx = groupFind( groupNames, 'F1' ); + confusionMatrix(2,1) = groupStats( idx ); + % female incorrectly identified as trans + idx = groupFind( groupNames, 'F3' ); + confusionMatrix(1,3) = groupStats( idx ); + + % trans incorrectly identified as male + idx = groupFind( groupNames, 'T1' ); + confusionMatrix(3,1) = groupStats( idx ); + % trans incorrectly identified as female + idx = groupFind( groupNames, 'T2' ); + confusionMatrix(3,2) = groupStats( idx ); + end + + end + end + + confusionMatrix(4,4) = confusionMatrix(1,1) + confusionMatrix(2,2) + confusionMatrix(3,3); + disp(distanceMeasure); + % print latex results to the screen + str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3) ); + disp(str1); + str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3) ); + disp(str1); + str1 = sprintf(' & & & & %2.2f \\\\',confusionMatrix(4,4) ); + disp(str1); + disp(' '); + + fprintf( masterFileOutputID, '\n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3), confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3), confusionMatrix(3,1), confusionMatrix(3,2), confusionMatrix(3,3), 0, 0, 0, confusionMatrix(4,4)); + end + + + +end + +function [idx] = groupFind( groupNames, str ) + + idx = 0; + for( i=1: length( groupNames ) ) + if( ~isempty(strfind( groupNames(i,:), str(1) )) && ~isempty(strfind( groupNames(i,:), str(2) ))) + idx = i; + end + end +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/kmeans_Formants_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,436 @@ +function [] = kmeans_Formants_Singing( varargin ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 0; +% output results file name +masterFileOutputID = fopen( 'kmeans_paper_SingingFormantsStats.txt', 'a' ); +% input results file name +% inputFileName = 'paper_singingFormantsStats_ZhangShuo.txt'; +% inputFileName = 'paper_singingFormantsStats_WangXinnong.txt'; +inputFileName = 'paper_singingFormantsStats.txt'; + +% This function allows the user to stipulate which Singing voice LLD's they +% wish to forward to a k-means classifier and produces a file of +% performance characteristics. Input arguments stipulate the LLD's and +% there is a choice of:- +% +% ---- PRAAT FORMANT MEASUREMENTS ---- +% '_Formant_Burg' +% '_Formant_all' +% '_Formant_robust' +% +% A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt +% is produced that contains the results of the k-mean classification for +% the LLD's specified and named in the result document title. + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +% get the column numbers of the results that we want to classify + +% COLUMN NUMBER : METRIC +% +% ------------- BURG FORMANTS --------------- +% 11 : Number of BURG formants listed = nBF +% +% THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT +nMetrics = 24; +% +% 12 : mean frequency of the first BURG formant +% 13 : variance of the first BURG formant +% 14 : minimum frequency of the first BURG formant +% 15 : maximum frequency of the first BURG formant +% 16 : mean Frequency Derivative of the first BURG formant +% 17 : varience of the Frequency Derivative of the first BURG formant +% 18 : min of the Frequency Derivative of the first BURG formant +% 19 : max of the Frequency Derivative of the first BURG formant +% 20 : mean of the Frequency 2nd Derivative of the first BURG formant +% 21 : varience of the Frequency 2nd Derivative of the first BURG formant +% 22 : min of the Frequency 2nd Derivative of the first BURG formant +% 23 : max of the Frequency 2nd Derivative of the first BURG formant +% 24 : mean of the Bandwidth of the first BURG formant +% 25 : varience of the Bandwidth of the first BURG formant +% 26 : min of the Bandwidth of the first BURG formant +% 27 : max of the Bandwidth of the first BURG formant +% 28 : mean of the Bandwidth Derivative of the first BURG formant +% 29 : varience of the Bandwidth Derivative of the first BURG formant +% 30 : min of the Bandwidth Derivative of the first BURG formant +% 31 : max of the Bandwidth Derivative of the first BURG formant +% 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant +% 33 : var of the Bandwidth 2nd Derivative of the first BURG formant +% 34 : min of the Bandwidth 2nd Derivative of the first BURG formant +% 35 : max of the Bandwidth 2nd Derivative of the first BURG formant +% +% ....... there are nMetrics for each formant in nBF formants, so cycle +% through until the last is reached ...... +% +% 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant +% 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant +% +% FOR THE MEAN OF ALL BURG FORMANTS +% 36 + (nBF*nMetrics) : mean of all formants Frequency +% 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% +% ------------- ALL FORMANTS --------------- +% +% 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF +% +% startOfALLMeasurements = 36 + (nBF*nMetrics) + 13; +% +% startOfALLMeasurements : mean frequency of the first ALL formant +% startOfALLMeasurements + 1 : variance of the first ALL formant +% startOfALLMeasurements + 2 : minimum frequency of the first ALL formant +% startOfALLMeasurements + 3 : maximum frequency of the first ALL formant +% startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant +% startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant +% startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant +% startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant +% startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant +% +% ....... there are nMetrics for each formant in nAF formants, so cycle +% through until the last is reached ...... +% +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant +% startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant +% +% FOR THE MEAN OF ALL ALL FORMANTS +% startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% +% ------------- ROBUST FORMANTS --------------- +% +% startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF +% +% startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13; +% +% startOfROBUSTMeasurements : mean frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant +% startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant +% startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant +% startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant +% startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant +% +% ....... there are nMetrics for each formant in nRF formants, so cycle +% through until the last is reached ...... +% +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant +% +% FOR THE MEAN OF ALL ROBUST FORMANTS +% startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency +% startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative +% startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative +% + +noOfArguments = length(varargin); +columnIndices = []; + +getBURGFormants = 0; +getAllFormants=0; +getRobustFormants=0; + +for i=1 : noOfArguments + if( strcmp( varargin{i}, 'formant_Burg' )) + getBURGFormants = 1; + elseif( strcmp( varargin{i}, 'formant_all' )) + getAllFormants=1; + elseif( strcmp( varargin{i}, 'formant_robust' )) + getRobustFormants=1; + end +end + +titleName = ''; +for i=1 : noOfArguments + titleName = [ titleName varargin{i} '_']; + fprintf( masterFileOutputID, '%s_', varargin{i} ); +end + +fprintf( masterFileOutputID, '\t' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +while( ~(feof(inputFileID)) ) + + outputValues = []; +% sampleEmotion = []; +% gender = []; + + thestr = fgetl(inputFileID); + if( lineCount > 10 ) % skip the file header + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + else + disp('EEEK!'); + pause; + end + +% % determine whether we have a male, female or trans sample +% gender( fileCount ) = '?'; +% if( ~(isempty(strfind(thestr,'fem')))) +% % gender is female +% gender( fileCount ) = 'F'; +% elseif( ~(isempty(strfind(thestr,'male')))) +% % gender is male +% gender( fileCount ) = 'M'; +% elseif( ~(isempty(strfind(thestr,'trans')))) +% % gender is trans +% gender( fileCount ) = 'T'; +% else +% disp('EEEK!'); +% pause; +% end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants + +% str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values + str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information + str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information + str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information + + +% vars = sscanf( str1, '%f', inf ); +% % extract the shimmer and jitter values +% outputValues = [ outputValues vars( columnIndices )']; + + if( getBURGFormants ) + spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str2( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + if( getAllFormants ) + spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str3( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + if( getRobustFormants ) + spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants' + vars = sscanf( str4( spaces(1) : end ), '%f', inf ); + outputValues = stripOutFormantValues( vars, outputValues ); + end + + [m n] = size( data ); + % sometimes the 'all' formants command gives us fewer formants than + % usual. If this is the case,then we will have to pad with zeros + % for now. + if( n > length( outputValues ) ) + lenDiff = n - length( outputValues ); + outputValues = [ outputValues zeros( 1, lenDiff ) ]; + elseif( n < length( outputValues ) ) + lenDiff = length( outputValues ) - n; + outputValues = [ outputValues zeros( 1, lenDiff ) ]; + end + + data( fileCount, : ) = outputValues; + + end + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the k-means classifier ------------------------ + +noOfClusters = 2; % we are only trying to identify positive and negative emotions + + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +%display results grouped by emotion +fprintf( masterFileOutputID, '\n Emotion grouping \n'); +fprintf( masterFileOutputID, 'cityblock \n'); +[ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'cityblock' ); + + +fprintf( masterFileOutputID, 'sqEuclidean \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +[ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'sqEuclidean' ); + + +fprintf( masterFileOutputID, 'cosine \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cosine'); + +[ groupStats, groupNames ] = processKMeansResults( 'cosine', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID,'cosine' ); + + +fprintf( masterFileOutputID, 'correlation \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'correlation'); + +[ groupStats, groupNames ] = processKMeansResults( 'correlation', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'correlation' ); + + +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +%------------------------------------------------------------------ + +function [ outputValues ] = stripOutFormantValues( vars, outputValues ) + + noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only + noOfFormants = vars(1); + % there are 12 measurements for the mean of all formants (so the number + % of formants is not important) for each formant measurement. + if( noOfFormants ~= (noOfFormantValues-12)/24 ) + disp('EEK!'); + pause; + else + outputValues = [ outputValues vars( 2:end )' ]; + end + +end + +%-------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/kmeans_HNR_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,146 @@ +function [] = kmeans_HNR_Singing( varargin ) + +cd 'C:\Users\dawn\Dropbox\TestResults' + +DEBUG = 1; +% output results file name +masterFileOutputID = fopen( 'kmeans_Singing_MedianHNR_male01.txt', 'a' ); +% input results file name +inputFileName = 'singingMedianHNRStats_male01.txt'; + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +noOfArguments = length(varargin); + +outputFileName = 'individualResults/kmeans_Results_'; +resultsFileName = 'kmeans_Results_'; +titleName = ''; +for i=1 : noOfArguments + titleName = [ titleName varargin{i} '_']; + fprintf( masterFileOutputID, '%s_', varargin{i} ); +end + +outputFileName = [ outputFileName titleName ]; +resultsFileName = [ resultsFileName titleName ]; + +fprintf( masterFileOutputID, '\t' ); + +outputFileName = [ outputFileName '.txt']; +resultsFileName = [ resultsFileName '.txt']; + +fileOutputID = fopen( outputFileName, 'w' ); +fileKMeansOutputID = fopen( resultsFileName, 'w' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + else + disp('EEEK!'); + pause; + end + + % determine whether we have a male, female or trans sample + gender( fileCount ) = '?'; + if( ~(isempty(strfind(thestr,'fem')))) + % gender is female + gender( fileCount ) = 'F'; + elseif( ~(isempty(strfind(thestr,'male')))) + % gender is male + gender( fileCount ) = 'M'; + elseif( ~(isempty(strfind(thestr,'trans')))) + % gender is trans + gender( fileCount ) = 'T'; + else + disp('EEEK!'); + pause; + end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the k-means classifier ------------------------ + +noOfClusters = 2; % we are only trying to identify positive and negative emotions + + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +%display results grouped by emotion +fprintf( masterFileOutputID, '\n Emotion grouping \n'); +processKMeansResults( 'cityblock', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); + +if(DEBUG == 1) + disp('press space'); + pause; +end + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +processKMeansResults( 'sqEuclidean', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); + +if(DEBUG == 1) + disp('press space'); + pause; +end + +%display results grouped by gender +fprintf( masterFileOutputID, '\n Gender grouping \n'); +noOfClusters = 3; + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +processKMeansResults( 'cityblock', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); + +if(DEBUG == 1) + disp('press space'); + pause; +end + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +processKMeansResults( 'sqEuclidean', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); + +if(DEBUG == 1) + disp('press space'); + pause; +end + + +fprintf( fileOutputID, '\n' ); +fclose( fileOutputID ); +fprintf( fileKMeansOutputID, '\n' ); +fclose( fileKMeansOutputID ); +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/kmeans_MFCC_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,154 @@ +function [] = kmeans_MFCC_Singing( inputFileName, outputFileName ) + +cd 'C:\Users\dawn\Dropbox\TestResults' +inputFileName + +DEBUG = 1; +% output results file name +masterFileOutputID = fopen( outputFileName, 'a' ); %fopen( 'kmeans_Singing_MFCC.txt', 'a' ); +% % input results file name +% inputFileName = 'singingMFCCStats_VoicedAndUnvoiced.txt'; + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +% noOfArguments = length(varargin); +% +% outputFileName = 'individualResults/kmeans_Results_'; +% resultsFileName = 'kmeans_Results_'; +titleName = ''; +% for i=1 : noOfArguments +% titleName = [ titleName varargin{i} '_']; +% fprintf( masterFileOutputID, '%s_', varargin{i} ); +% end +% +% outputFileName = [ outputFileName titleName ]; +% resultsFileName = [ resultsFileName titleName ]; + +fprintf( masterFileOutputID, '\t' ); + +% outputFileName = [ outputFileName '.txt']; +% resultsFileName = [ resultsFileName '.txt']; + +% fileOutputID = fopen( outputFileName, 'w' ); +% fileKMeansOutputID = fopen( resultsFileName, 'w' ); + +% -------------------- get the data from the results file --------------- +lineCount = 0; +fileCount = 0; +data = []; +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + else + disp('EEEK!'); + pause; + end + + % determine whether we have a male, female or trans sample + gender( fileCount ) = '?'; + if( ~(isempty(strfind(thestr,'fem')))) + % gender is female + gender( fileCount ) = 'F'; + elseif( ~(isempty(strfind(thestr,'male')))) + % gender is male + gender( fileCount ) = 'M'; + elseif( ~(isempty(strfind(thestr,'trans')))) + % gender is trans + gender( fileCount ) = 'T'; + else + disp('EEEK!'); + pause; + end + + %how many values are in the string? + spaces = strfind( thestr, ' ' ); + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% try with and without different metrics classes +% data is a 162 variable array of MFCC stats +% first there are 6 metrics for each of the 13 frequency bands (mean, median, var, min, max, range) +% then there are 6 metrics for the 1st derivative of the 13 frequency bands (mean, median, var, min, max, range) +% then there are 6 metrics for the mean of all frequency bands + +% dataOptions = (1:1:(13*12)+6); % fprintf( masterFileOutputID, '\n try with all \n'); +% dataOptions = (1:1:13*6); fprintf( masterFileOutputID, '\n try with just the ordinary 13 frequency bands \n'); +% dataOptions = (1:1:13*6); fprintf( masterFileOutputID, '\n try with just the ordinary 13 frequency bands and without the median or range \n'); + +% ------------ apply the k-means classifier ------------------------ + +noOfClusters = 2; % we are only trying to identify positive and negative emotions + + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +%display results grouped by emotion +fprintf( masterFileOutputID, '\n Emotion grouping \n'); +fprintf( masterFileOutputID, 'cityblock \n'); +[ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); +% if(DEBUG == 1) +% disp('press space'); +% pause; +% end + +fprintf( masterFileOutputID, 'sqEuclidean \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +[ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); + +% if(DEBUG == 1) +% disp('press space'); +% pause; +% end + +% display results grouped by gender +fprintf( masterFileOutputID, '\n Gender grouping \n'); +noOfClusters = 3; + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +fprintf( masterFileOutputID, 'cityblock \n'); +[ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, gender, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +fprintf( masterFileOutputID, 'sqEuclidean \n'); +[ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, gender, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); + + +% fprintf( fileOutputID, '\n' ); +% fclose( fileOutputID ); +% fprintf( fileKMeansOutputID, '\n' ); +% fclose( fileKMeansOutputID ); +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- a/Code/Classifiers/kmeans_PRAAT_Singing.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Classifiers/kmeans_PRAAT_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,9 +1,10 @@ -function [] = kmeans_Singing( varargin ) +function [] = kmeans_PRAAT_Singing( varargin ) cd 'C:\Users\dawn\Dropbox\TestResults' +DEBUG = 0; % output results file name -masterFileOutputID = fopen( 'kmeans_Singing_All.txt', 'a' ); +masterFileOutputID = fopen( 'kmeans_Singing_PRAAT.txt', 'a' ); % input results file name inputFileName = 'singingPRAATStats.txt'; @@ -273,7 +274,7 @@ columnIndices = []; getBURGFormants = 0; -getAllForamnts=0; +getAllFormants=0; getRobustFormants=0; for i=1 : noOfArguments @@ -298,15 +299,15 @@ elseif( strcmp( varargin{i}, 'formant_Burg' )) getBURGFormants = 1; elseif( strcmp( varargin{i}, 'formant_all' )) - getAllForamnts=1; + getAllFormants=1; elseif( strcmp( varargin{i}, 'formant_robust' )) getRobustFormants=1; end end -outputFileName = 'individualResults/kmeans_Results_'; -resultsFileName = 'kmeans_Results_'; +% outputFileName = 'individualResults/kmeans_Results_'; +% resultsFileName = 'kmeans_Results_'; titleName = ''; for i=1 : noOfArguments % outputFileName = [ outputFileName varargin{i} '_']; @@ -316,16 +317,16 @@ end % titleName = outputFileName; -outputFileName = [ outputFileName titleName ]; -resultsFileName = [ resultsFileName titleName ]; +% outputFileName = [ outputFileName titleName ]; +% resultsFileName = [ resultsFileName titleName ]; fprintf( masterFileOutputID, '\t' ); -outputFileName = [ outputFileName '.txt']; -resultsFileName = [ resultsFileName '.txt']; +% outputFileName = [ outputFileName '.txt']; +% resultsFileName = [ resultsFileName '.txt']; -fileOutputID = fopen( outputFileName, 'w' ); -fileKMeansOutputID = fopen( resultsFileName, 'w' ); +% fileOutputID = fopen( outputFileName, 'w' ); +% fileKMeansOutputID = fopen( resultsFileName, 'w' ); % -------------------- get the data from the results file --------------- lineCount = 0; @@ -390,7 +391,7 @@ outputValues = stripOutFormantValues( vars, outputValues ); end - if( getAllForamnts ) + if( getAllFormants ) spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants' vars = sscanf( str3( spaces(1) : end ), '%f', inf ); outputValues = stripOutFormantValues( vars, outputValues ); @@ -419,33 +420,6 @@ end fclose(inputFileID); -%individual examination of the metrics does confirm that there is little -%difference in emotional content. However, singer identification is OK. - -% figure(2); subplot(211); hold off; -% -% for( i = 1 : length(data) ) -% if( sampleEmotion(i) == 'N') -% plot( i, data(i), 'b.' ); -% else -% plot( i, data(i), 'r.' ); -% end -% hold on; -% end -% -% subplot(212); hold off; -% -% for( i = 1 : length(data) ) -% if( gender(i) == 'M') -% plot( i, data(i), 'b.' ); -% elseif( gender(i) == 'F') -% plot( i, data(i), 'r.' ); -% else -% plot( i, data(i), 'g.' ); -% end -% hold on; -% end - % ------------ apply the k-means classifier ------------------------ noOfClusters = 2; % we are only trying to identify positive and negative emotions @@ -455,61 +429,55 @@ 'start', 'sample', 'Distance', 'cityblock'); %display results grouped by emotion -processKMeansResults( 'cityblock', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); +fprintf( masterFileOutputID, '\n Emotion grouping \n'); +fprintf( masterFileOutputID, 'cityblock \n'); +[ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); -disp('press space'); -pause; +fprintf( masterFileOutputID, 'sqEuclidean \n'); [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... 'start', 'sample', 'Distance', 'sqEuclidean'); -processKMeansResults( 'sqEuclidean', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); +[ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); -disp('press space'); -pause; +% ------------ +% % display results grouped by gender +% fprintf( masterFileOutputID, '\n Gender grouping \n'); +% noOfClusters = 3; +% +% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% 'start', 'sample', 'Distance', 'cityblock'); +% +% fprintf( masterFileOutputID, 'cityblock \n'); +% [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, gender, masterFileOutputID, titleName, DEBUG ); +% [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); +% +% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% 'start', 'sample', 'Distance', 'sqEuclidean'); +% +% fprintf( masterFileOutputID, 'sqEuclidean \n'); +% [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, gender, masterFileOutputID, titleName, DEBUG ); +% [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); +% +% -%display results grouped by gender +% +% % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% % 'start', 'sample', 'Distance', 'cosine'); +% % +% % processKMeansResults( 'cosine', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName); +% % +% % disp('press space'); +% % pause; +% +% % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% % 'start', 'sample', 'Distance', 'correlation'); +% % +% % processKMeansResults( 'correlation', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); -noOfClusters = 3; - -[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... - 'start', 'sample', 'Distance', 'cityblock'); - -processKMeansResults( 'cityblock', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); - -disp('press space'); -pause; - -[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... - 'start', 'sample', 'Distance', 'sqEuclidean'); - -processKMeansResults( 'sqEuclidean', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); - -disp('press space'); -pause; - - -% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... -% 'start', 'sample', 'Distance', 'cosine'); -% -% processKMeansResults( 'cosine', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName); -% -% disp('press space'); -% pause; - -% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... -% 'start', 'sample', 'Distance', 'correlation'); -% -% processKMeansResults( 'correlation', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); -% -% disp('press space'); -% pause; - -fprintf( fileOutputID, '\n' ); -fclose( fileOutputID ); -fprintf( fileKMeansOutputID, '\n' ); -fclose( fileKMeansOutputID ); fprintf( masterFileOutputID, '\n' ); fclose( masterFileOutputID ); @@ -533,41 +501,3 @@ end %------------------------------------------------------------------- - -function [] = processKMeansResults( ID, idx, groupingCriteria, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ) - - fprintf( fileKMeansOutputID, '%s\t', ID ); - fprintf( masterFileOutputID, '%s\t', ID ); - - if( length( idx ) ~= length( groupingCriteria ) ) - disp('EEEK!'); - pause; - end - - groupIDs = ''; - groupStr = ''; - for( i = 1 : length( idx )) - fprintf( fileOutputID, '%s \t %d \n', groupingCriteria(i), idx(i) ); - gID = [ groupingCriteria(i) num2str( idx(i) )]; - groupIDs = [ groupIDs ; gID ]; - groupStr = [ groupStr gID ]; - end - - % ------------- work out the confusion matrix ------------------------- - - groups = unique( groupIDs, 'rows' ); - noOfGroups = length( groups ); - orderedGroups = sort(cellstr(groups)); - groupStats = []; - for( i = 1 : noOfGroups ) - groupStats(i) = ((length( strfind( groupStr, char(orderedGroups(i)))))/length( idx ) ) * 100; - fprintf( fileKMeansOutputID, '%s \t %f \t', char(orderedGroups(i)), groupStats(i) ); - fprintf( masterFileOutputID, '%s \t %f \t', char(orderedGroups(i)), groupStats(i) ); - end - - figure(1); - bar( groupStats ); - set( gca, 'XTickLabel', orderedGroups ); - title([ titleName ' ' ID]); - -end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/kmeans_Singing.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,135 @@ +function [] = kmeans_Singing( inputFileName ) + +cd 'C:\Users\dawn\Dropbox\TestResults' +inputFileName + +DEBUG = 1; +% output results file name +outputFileName = ['kmeans_' inputFileName]; +masterFileOutputID = fopen( outputFileName, 'a' ); + +fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); +inputFileID = fopen( inputFileName ); + +titleName = ''; + +fprintf( masterFileOutputID, '\t' ); + +% -------------------- get the data from the results file --------------- + +lineCount = 0; +fileCount = 0; +data = []; +while( ~(feof(inputFileID)) ) + + outputValues = []; + thestr = fgetl(inputFileID); + fileCount = fileCount + 1; + + % determine whether we have a positive or negative sample + sampleEmotion( fileCount ) = 'U'; + if( ~(isempty(strfind(thestr,'pos')))) + % sample is positive + sampleEmotion( fileCount ) = 'P'; + elseif( ~(isempty(strfind(thestr,'neg')))) + % sample is negative + sampleEmotion( fileCount ) = 'N'; + else + disp('EEEK!'); + fileCount = fileCount - 1; +% pause; + end + + % determine whether we have a male, female or trans sample +% gender( fileCount ) = '?'; +% if( ~(isempty(strfind(thestr,'fem')))) +% % gender is female +% gender( fileCount ) = 'F'; +% elseif( ~(isempty(strfind(thestr,'male')))) +% % gender is male +% gender( fileCount ) = 'M'; +% elseif( ~(isempty(strfind(thestr,'trans')))) +% % gender is trans +% gender( fileCount ) = 'T'; +% else +% disp('EEEK!'); +% pause; +% end + + if(( ~(isempty(strfind(thestr,'pos')))) || ( ~(isempty(strfind(thestr,'neg')))) ) + %how many values are in the string? +% spaces = strfind( thestr, ' ' ); + spaces = [ strfind( thestr, sprintf('\t')) strfind( thestr, ' ' )]; + numberstr = thestr( spaces(1) : end ); % chop off the file name + vars = sscanf( numberstr, '%f', inf ); + data( fileCount, : ) = vars; + end + lineCount = lineCount + 1; + +end +fclose(inputFileID); + +% ------------ apply the k-means classifier ------------------------ + +noOfClusters = 2; % we are only trying to identify positive and negative emotions + + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +%display results grouped by emotion +fprintf( masterFileOutputID, '\n Emotion grouping \n'); +fprintf( masterFileOutputID, 'cityblock \n'); +[ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'cityblock' ); + + +fprintf( masterFileOutputID, 'sqEuclidean \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'sqEuclidean'); + +[ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'sqEuclidean' ); + + +fprintf( masterFileOutputID, 'cosine \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cosine'); + +[ groupStats, groupNames ] = processKMeansResults( 'cosine', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'cosine' ); + + +fprintf( masterFileOutputID, 'correlation \n'); +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'correlation'); + +[ groupStats, groupNames ] = processKMeansResults( 'correlation', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); +[ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'correlation' ); + +% -------------------------------------------------------------------- + +% display results grouped by gender +% fprintf( masterFileOutputID, '\n Gender grouping \n'); +% noOfClusters = 3; +% +% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% 'start', 'sample', 'Distance', 'cityblock'); +% +% fprintf( masterFileOutputID, 'cityblock \n'); +% [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, gender, masterFileOutputID, titleName, DEBUG ); +% [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); +% +% [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... +% 'start', 'sample', 'Distance', 'sqEuclidean'); +% +% fprintf( masterFileOutputID, 'sqEuclidean \n'); +% [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, gender, masterFileOutputID, titleName, DEBUG ); +% [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); + +fprintf( masterFileOutputID, '\n' ); +fclose( masterFileOutputID ); + +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Classifiers/processKMeansResults.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,35 @@ + +function [ groupStats, orderedGroups ] = processKMeansResults( ID, idx, ... + groupingCriteria, masterFileOutputID, titleName, DEBUG ) + + if( length( idx ) ~= length( groupingCriteria ) ) + disp('EEEK!'); + pause; + end + + groupIDs = ''; + groupStr = ''; + for( i = 1 : length( idx )) +% fprintf( fileOutputID, '%s \t %d \n', groupingCriteria(i), idx(i) ); + gID = [ groupingCriteria(i) num2str( idx(i) )]; + groupIDs = [ groupIDs ; gID ]; + groupStr = [ groupStr gID ]; + end + + % ------------- work out the confusion matrix ------------------------- + + groups = unique( groupIDs, 'rows' ); + noOfGroups = length( groups ); + orderedGroups = sort(cellstr(groups)); + groupStats = []; + for( i = 1 : noOfGroups ) + groupStats(i) = ((length( strfind( groupStr, char(orderedGroups(i)))))/length( idx ) ) * 100; + end + + if(DEBUG == 1) + figure(1); + bar( groupStats ); + set( gca, 'XTickLabel', orderedGroups ); + title([ titleName ' ' ID]); + end +end \ No newline at end of file
--- a/Code/Collation/basicMetricSet.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Collation/basicMetricSet.m Wed Feb 13 11:02:39 2013 +0000 @@ -5,11 +5,11 @@ meanValue = mean( frameByFrameMetric ); metrics = [metrics meanValue]; - fprintf( statsFileID, '\t %f ', meanValue ); -% % median F0 + fprintf( statsFileID, ' %f ', meanValue ); + % median (not from ShahHewlitt2008) % medianValue = median( frameByFrameMetric ); % metrics = [metrics medianValue]; -% fprintf( statsFileID, '\t %f ', medianValue ); +% fprintf( statsFileID, ' %f ', medianValue ); % % Standard deviation % stdValue = std( frameByFrameMetric ); % metrics = [metrics stdValue]; @@ -20,17 +20,17 @@ % Variance varValue = var(frameByFrameMetric); metrics = [metrics varValue]; - fprintf( statsFileID, '\t %f ', varValue ); + fprintf( statsFileID, ' %f ', varValue ); % Minimum minValue = min( frameByFrameMetric ); metrics = [metrics minValue]; - fprintf( statsFileID, '\t %f ', minValue ); + fprintf( statsFileID, ' %f ', minValue ); % Maximum maxValue = max( frameByFrameMetric ); metrics = [metrics maxValue]; - fprintf( statsFileID, '\t %f ', maxValue ); - % range + fprintf( statsFileID, ' %f ', maxValue ); + % range (not from ShahHewlitt2008) % rangeValue = max( frameByFrameMetric ) - min( frameByFrameMetric ); % metrics = [metrics rangeValue]; -% fprintf( statsFileID, '\t %f ', rangeValue ); +% fprintf( statsFileID, ' %f ', rangeValue ); end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_AudioPower.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,95 @@ +function [] = get_AudioPower( dirName, statsFileID ) + +DEBUG=0; +% this function collates the results of all HNR values + +% identify the speaker in the stats file +fprintf( statsFileID, '%s ', dirName ); + +metricName = '_AP'; +metricFileName = [ dirName metricName '.txt']; +[ metrics, nanValues ] = readValuesFromFile( statsFileID, metricFileName, metricName ); + +%---------------- GET THE VOICED FRAME VALUES ------------------- + +% only wish to consider values from voiced frames. + +% going to disregard all unvoiced frames as these produce outliers +[vuv] = detect_VoicedUnvoiced( [ dirName '.wav' ], 0 ); +% if vuv is longer than the pitch array, truncate. +if( length(vuv) ~= length(nanValues) ) + if( (length(vuv) - length(nanValues)) > 1 ) + disp('EEEK!'); + end + if( length(vuv) > length(nanValues) ) + %increase metrics + nanValues = [ nanValues; 0 ]; + else + vuv = [vuv; 0]; + end +end + + +% % remove any NaN pitch values from the voicing information +% i=1; +% while( i <= length(vuv) ) +% +% if( nanValues(i) == 1 ) +% if( i == 1 ) +% vuv = vuv(2:length(vuv)); +% nanValues = nanValues(2:length(nanValues)); +% elseif(i == length(vuv) ) +% vuv = vuv(1:length(vuv)-1); +% nanValues = nanValues(1:length(nanValues)-1); +% else +% vuv = [ vuv(1: i-1); vuv(i+1:end) ]; +% nanValues = [ nanValues(1: i-1); nanValues(i+1:end) ]; +% end +% else +% i=i+1; +% end +% +% end + +% remove the non-voiced frames (includes unvoiced and silent frames) from the metrics + +voicedFrames = find( vuv == 1 ); +unvoicedFrames = find( vuv == 2 ); + +% find the average energies for voiced and unvoiced speech +voicedEnergy = sum( metrics( voicedFrames )) / length( voicedFrames ); +unvoicedEnergy = sum( metrics( unvoicedFrames )) / length( unvoicedFrames ); + +metrics = metrics( voicedFrames ); + + +if(DEBUG) + subplot(211);hold on; + if( strfind( dirName, 'neg') ) + plot(metrics,'b'); + elseif( strfind( dirName, 'pos') ) + plot(metrics,'r'); + end +end + +% get basic metric set +[ metricSet ] = basicMetricSet( metrics, statsFileID ); + +if(DEBUG) + subplot(212); + if( strfind( dirName, 'neg') ) + plot(metrics, 'xb'); hold on; + elseif( strfind( dirName, 'pos') ) + plot(metrics, 'xr'); hold on; + end +end + + +% get basic metric set for the first derivative +firstDerivative = gradient( metrics ); +[ firstDerivativeMetricSet ] = basicMetricSet( firstDerivative, statsFileID ); + +% print the average voiced and unvoiced energy to file +fprintf( statsFileID, '\t %f \t %f ', voicedEnergy, unvoicedEnergy); + +fprintf( statsFileID, '\n'); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_Formants.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,33 @@ +function [] = get_Formants( dirName, statsFileID ) + +% this function collates the results of all values calculated using the PRAAT software + +% For jitter and shimmer PRAAT returns only a single value, not a +% frame-by-frame calculation. Therefore we cannot find the varience etc. + + + % identify the speaker in the stats file + fprintf( statsFileID, '%s ', dirName ); + + +%-------------- get the formant metrics ---------------------- +% PRAAT returns a frame-by-frame value + % need to discard all formant information for unvoiced and silent frames. + vuv = detect_VoicedUnvoiced( [dirName '.wav'], 0 ); + + metricName = '_Formant_Burg'; + metricFileName = [ dirName metricName '.txt']; + readFormantValueFromFile( statsFileID, metricFileName, metricName, vuv ); + + metricName = '_Formant_all'; + metricFileName = [ dirName metricName '.txt']; + readFormantValueFromFile( statsFileID, metricFileName, metricName, vuv ); + + metricName = '_Formant_robust'; + metricFileName = [ dirName metricName '.txt']; + readFormantValueFromFile( statsFileID, metricFileName, metricName, vuv ); + + + fprintf( statsFileID, '\n'); + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_HNR.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,61 @@ +function [] = get_HNR( dirName, statsFileID ) + +DEBUG=1; +% this function collates the results of all HNR values + +% identify the speaker in the stats file +fprintf( statsFileID, '%s ', dirName ); + +metricName = '_HNR'; +metricFileName = [ dirName metricName '.txt']; +metrics = readValuesFromFile( statsFileID, metricFileName, metricName ); + +if(DEBUG) + subplot(211); + if( strfind( dirName, 'neg') ) + plot(metrics, 'b'); hold on; + elseif( strfind( dirName, 'pos') ) + plot(metrics, 'r'); hold on; + end +end + +% get basic metric set +[ basicSet ] = basicMetricSet( metrics, statsFileID ); + + +if(DEBUG) + subplot(212); + if( strfind( dirName, 'neg') ) + plot(basicSet, 'xb'); hold on; + elseif( strfind( dirName, 'pos') ) + plot(basicSet, 'xr'); hold on; + end +end + +% calculate the ratio of voiced (HNR > 0) to unvoiced frames (HNR <= 0) +noOfUnvoicedFrames = length( find( metrics <= 0 )); +noOfVoicedFrames = length( find( metrics > 0 )); +unvoicedToVoicedRatio = ( noOfUnvoicedFrames / noOfVoicedFrames ); +fprintf( statsFileID, '\t %f ', unvoicedToVoicedRatio); + +% calculate the average duration of the voiced and unvoiced periods + +tsig = ( metrics > 0); +dsig = diff([1 tsig' 1]); +startIndex = find(dsig < 0); +endIndex = find(dsig > 0)-1; +unvoicedDuration = endIndex-startIndex+1; +meanUnvoicedDuration = mean( unvoicedDuration ) +fprintf( statsFileID, '\t %f ', meanUnvoicedDuration); + + +startIndex = find(dsig > 0); +startIndex = startIndex(1:end-1); +endIndex = find(dsig < 0)-1; +endIndex = endIndex(2:end); +voicedDuration = endIndex-startIndex+1; +meanVoicedDuration = mean( voicedDuration ) +fprintf( statsFileID, '\t %f ', meanVoicedDuration); + + +fprintf( statsFileID, '\n'); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_Jitter.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,34 @@ +function [] = get_Jitter( dirName, statsFileID ) + +% this function collates the results of all values calculated using the PRAAT software + +% For jitter and shimmer PRAAT returns only a single value, not a +% frame-by-frame calculation. Therefore we cannot find the varience etc. + + + % identify the speaker in the stats file + fprintf( statsFileID, '%s ', dirName ); + +% -------------- get the jitter metrics ------------------- +% JITTER: ddp \t local \t ppq5 \t rap \t + + metricName = '_jitter_ddp'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_jitter_local'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_jitter_ppq5'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_jitter_rap'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + + fprintf( statsFileID, '\n'); + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_MFCCS.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,73 @@ +function [] = get_MFCCS( dirName, statsFileID ) + + +% this function collates the results of all values calculated for the +% MFCCs + +DEBUG=0; + + % identify the speaker in the stats file + fprintf( statsFileID, '%s ', dirName ); + + metricName = '_MFCC'; + metricFileName = [ dirName metricName '.txt']; + numberOfValuesPerFrame = 13; % 13 MFCC's + + FileID = fopen( metricFileName ); + + %---------------- GET THE VOICED FRAME VALUES ------------------- + + % only wish to consider values from voiced frames. The MFCCs were + % calculate for only non-silent frames anyway, but now we need to + % remove the unvoiced frame values + + % going to disregard all unvoiced frames as these produce outliers + [vuv] = detect_VoicedUnvoiced( [ dirName '.wav' ], 0 ); + + % get the silent frames + segmentFrames = detect_Silence( [ dirName '.wav' ], 0 ); + [ silentFrames ] = getSilentDataArray( segmentFrames, length(vuv) ); + + % remove silent frames from vuv + non_silentFrames = find(silentFrames == 1); + vuv = vuv( non_silentFrames ); +% voicedFrames = find( vuv == 1 ); + + if( FileID <= 0 ) %does the file exist? + % if not + message = ['WARNING: MISSING ' metricName ' FILE']; + disp( message ); + fprintf( statsFileID, ' \s missing', metricName ); + + else + mfcc = readManyValuesFromFile( statsFileID, metricFileName, metricName, numberOfValuesPerFrame ); + % smooth to get rid of outliers +% for( i=1:numberOfValuesPerFrame ) +% % smoothedMfcc(:,i) = smooth( mfcc( voicedFrames,i ) ); +% smoothedMfcc(:,i) = smooth( mfcc( :,i ) ); +% end + + for( i=1:numberOfValuesPerFrame ) + % find the basic metric set for each frequency band +% [ metrics(i,:) ] = basicMetricSet( smoothedMfcc(:,i), statsFileID ); + [ metrics(i,:) ] = basicMetricSet( mfcc(:,i), statsFileID ); + mean(i) = metrics(i,1); + end + + % find the gradient of each frequency band and its basic metric set + [m,n]=size(metrics); + for( i=1:numberOfValuesPerFrame ) +% gradSmoothedMfcc(:,i) = gradient( smoothedMfcc(:,i) ); + gradMfcc(:,i) = gradient( mfcc(:,i) ); +% [ metrics(i, n+1:2*n ) ] = basicMetricSet( gradSmoothedMfcc(:,i), statsFileID ); + [ metrics(i, n+1:2*n ) ] = basicMetricSet( gradMfcc(:,i), statsFileID ); + end + + % calculate the basic metric set for the mean of all frequency + % bands + basicMetricSet( mean, statsFileID ); + end + + + fprintf( statsFileID, '\n'); + fclose(FileID); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_Pitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,90 @@ +function [] = get_Pitch( dirName, statsFileID ) + +DEBUG=0; +% this function collates the results of all HNR values + +% identify the speaker in the stats file +fprintf( statsFileID, '%s ', dirName ); + +metricName = '_YIN_pitch'; +metricFileName = [ dirName metricName '.txt']; +[ metrics, nanValues ] = readValuesFromFile( statsFileID, metricFileName, metricName ); + +%---------------- GET THE VOICED FRAME VALUES ------------------- + +% only wish to consider values from voiced frames. + +% going to disregard all unvoiced frames as these produce outliers +[vuv] = detect_VoicedUnvoiced( [ dirName '.wav' ], 0 ); +% if vuv is longer than the pitch array, truncate. +if( length(vuv) ~= length(nanValues) ) + if( (length(vuv) - length(nanValues)) > 1 ) + disp('EEEK!'); + end + if( length(vuv) > length(nanValues) ) + %increase metrics + nanValues = [ nanValues; 0 ]; + else + vuv = [vuv; 0]; + end +end + + +% remove any NaN pitch values from the voicing information +i=1; +while( i <= length(vuv) ) + + if( nanValues(i) == 1 ) + if( i == 1 ) + vuv = vuv(2:length(vuv)); + nanValues = nanValues(2:length(nanValues)); + elseif(i == length(vuv) ) + vuv = vuv(1:length(vuv)-1); + nanValues = nanValues(1:length(nanValues)-1); + else + vuv = [ vuv(1: i-1); vuv(i+1:end) ]; + nanValues = [ nanValues(1: i-1); nanValues(i+1:end) ]; + end + else + i=i+1; + end + +end + +% remove the non-voiced frames (includes unvoiced and silent frames) from the metrics + +voicedFrames = find( vuv == 1 ); +metrics = metrics( voicedFrames ); + + +if(DEBUG) + subplot(211);hold on; + if( strfind( dirName, 'neg') ) + plot(metrics,'b'); + elseif( strfind( dirName, 'pos') ) + plot(metrics,'r'); + end +end + +% get basic metric set +[ metricSet ] = basicMetricSet( metrics, statsFileID ); + +if(DEBUG) + subplot(212); + if( strfind( dirName, 'neg') ) + plot(metrics, 'xb'); hold on; + elseif( strfind( dirName, 'pos') ) + plot(metrics, 'xr'); hold on; + end +end + + +% get basic metric set for the first derivative +firstDerivative = gradient( metrics ); +[ firstDerivativeMetricSet ] = basicMetricSet( firstDerivative, statsFileID ); + +% get basic metric set for the second derivative +secondDerivative = gradient( firstDerivative ); +[ secondDerivativeMetricSet ] = basicMetricSet( secondDerivative, statsFileID ); + +fprintf( statsFileID, '\n'); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Collation/get_Shimmer.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,37 @@ +function [] = get_Shimmer( dirName, statsFileID ) + +% this function collates the results of all values calculated using the PRAAT software + +% For jitter and shimmer PRAAT returns only a single value, not a +% frame-by-frame calculation. Therefore we cannot find the varience etc. + + + % identify the speaker in the stats file + fprintf( statsFileID, '%s ', dirName ); + +%-------------- get the shimmer metrics ---------------------- +% SHIMMER: local \t dda \t apq3 \t apq5 \t apq11 + + metricName = '_shimmer_local'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_shimmer_dda'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_shimmer_apq3'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_shimmer_apq5'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + metricName = '_shimmer_apq11'; + metricFileName = [ dirName metricName '.txt']; + readValueFromFile( statsFileID, metricFileName, metricName ); + + fprintf( statsFileID, '\n'); + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/AudioSpectralBandPower.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,53 @@ +function [ASBP] = AudioSpectralBandPower(raw, fs, noOfFrames, frameLength) +% this file normalises the frequency spectrum and calculates the spectral +% power in frequency band 100 - 1000 Hz and in the top +x = buffer( raw, frameLength ); +myColor = 'rx'; + +hiEdgeSamples = getMaxFreq; % the highest fundamental +loEdgeSamples = getMinFreq; % the lowest fundamental + +hiFreqBin = ceil(((frameLength/2)/(fs/2))*hiEdgeSamples); +loFreqBin = floor(((frameLength/2)/(fs/2))*loEdgeSamples); + +bandWidth = hiFreqBin - loFreqBin; + +for n = 1:noOfFrames + spectrum = abs( fft( x(:,n) )); + spectrum = spectrum( 1 : frameLength/2 ); + % normalise +% spectrum = spectrum/max(spectrum); + % fundamental frequency band + lBand = ( loFreqBin : hiFreqBin ); + hBand = ( frameLength/2 - ( bandWidth ) : frameLength/2 ); + lBandPower = sum( spectrum( lBand )); + hBandPower = sum( spectrum( hBand )); +% gm(n) = nthroot( prod( spectrum ), frameLength ); +% am(n) = sum( spectrum )/frameLength; + ASBP(n) = lBandPower/hBandPower; +% subplot(421); plot( x(:,n) ); +% subplot(422); plot( spectrum ); hold on; +% plot( loFreqBin : hiFreqBin, spectrum( lBand ), 'r' ); +% plot( hBand, spectrum( hBand ), 'r' ); hold off +% +% % look at the frame with reference to the surrounding 10 frames +% if( n>5 ) +% startPlot = (n-5)*frameLength+1; +% endPlot = (n+5)*frameLength; +% else +% startPlot = 1; +% endPlot = 10*frameLength; +% end +% subplot(412); plot( raw( startPlot : endPlot ) ); hold on; +% plot( ((n-1)*frameLength+1) - startPlot : (n*frameLength) - startPlot, x(:,n), 'r' ); hold off; +% +% subplot(425); plot( n, lBandPower, myColor ); hold on;%plot( n, gm(n), myColor ); hold on; +% subplot(426); plot( n, hBandPower, myColor ); hold on;%plot( n, am(n), myColor ); hold on; +% subplot(414); plot( n, lBandPower / hBandPower, myColor ); hold on;%plot( n, ASF(n), myColor ); hold on; +% end +end + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/AudioSpectralBandPower_Detection.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,18 @@ +function [] = AudioSpectralBandPower_Detection( sampleWavFileName, x, fs, frameLength, noOfFrames ) + +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +FileName = [ sampleFileName '_ASBP.txt']; +FileID = fopen( FileName, 'w'); + +raw = x(:,1); +ASBP = AudioSpectralBandPower( raw, fs, noOfFrames, frameLength ); + +for i = 1 : noOfFrames + fprintf(FileID,'%d ',i); +% for j = 1: 24 + fprintf(FileID, '%s ',ASBP(i)); +% end + fprintf(FileID, '\n'); +end + +fclose( FileID ); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/SpectralCentroid.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,34 @@ +function C = SpectralCentroid( signal, windowLength, step, fs) + +% function C = SpectralCentroid(signal,windowLength, step, fs) +% +% This function computes the spectral centroid feature of an audio signal +% ARGUMENTS: +% - signal: the audio samples +% - windowLength: the length of the window analysis (in number of samples) +% - step: the step of the window analysis (in number of samples) +% - fs: the sampling frequency +% +% RETURNS: +% - C: the sequence of the spectral centroid feature +% + +signal = signal / max(abs(signal)); +curPos = 1; +L = length(signal); +numOfFrames = floor((L-windowLength)/step) + 1; +H = hamming(windowLength); +m = ((fs/(2*windowLength))*[1:windowLength])'; +C = zeros(numOfFrames,1); +for (i=1:numOfFrames) + window = H.*(signal(curPos:curPos+windowLength-1))'; + FFT = (abs(fft(window,2*windowLength))); + FFT = FFT(1:windowLength); + FFT = FFT / max(FFT); + C(i) = sum(m.*FFT)/sum(FFT); + if (sum(window.^2)<0.010) + C(i) = 0.0; + end + curPos = curPos + step; +end +C = C / (fs/2); \ No newline at end of file
--- a/Code/Descriptors/Matlab/Common/calculate_VoicedUnvoicedDecision.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Descriptors/Matlab/Common/calculate_VoicedUnvoicedDecision.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,6 +1,6 @@ function [ vuv ] = calculate_VoicedUnvoicedDecision( sampleName, x, fs, frameLength, noOfFrames, silentFrames ) -DEBUG = 0; % do we want to plot the output? +DEBUG = 1; % do we want to plot the output? y = buffer( x, frameLength );
--- a/Code/Descriptors/Matlab/Common/detect_Silence.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Descriptors/Matlab/Common/detect_Silence.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,9 +1,10 @@ -function [ silenceSegments ] = detect_Silence( currentSampleName, OVERWRITE ); +function [ silenceSegments ] = detect_Silence( sampleWavFileName, OVERWRITE ); %returns an array containing the start and end frames for non-silent segments % open original silence calculation -fileName = [ currentSampleName '_silence.txt']; +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +fileName = [ sampleFileName '_silence.txt']; % read pitch metrics from file fileID = fopen( fileName ); @@ -11,7 +12,7 @@ % no disp('WARNING: MISSING SILENCE FILE'); %calculate it - [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); + [x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); limits = calculate_Silence( x, fs, frameLength ); % create voicing metrics file fileID = fopen( fileName, 'w');
--- a/Code/Descriptors/Matlab/Common/detect_VoicedUnvoiced.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Descriptors/Matlab/Common/detect_VoicedUnvoiced.m Wed Feb 13 11:02:39 2013 +0000 @@ -10,11 +10,11 @@ % only wish to consider pitch values from voiced frames. % silent and unvoiced frames will produce pitch values that % are random and therefore will bias our results - segmentFrames = detect_Silence( sampleFileName, 0 ); + segmentFrames = detect_Silence( [sampleFileName '.wav'], 0 ); % remove the silent frames [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); - [ silentFrames ] = removeSilentData( segmentFrames, noOfFrames ); + [ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); % [vuv] = voicingByClustering( nonSilentAudio, fs, noOfFrames, frameLength ); [vuv] = calculate_VoicedUnvoicedDecision( sampleFileName, x, fs, frameLength, noOfFrames, silentFrames );
--- a/Code/Descriptors/Matlab/Common/detect_pitch.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Descriptors/Matlab/Common/detect_pitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,4 +1,4 @@ -function [ pitch ] = pitch_Detection( sampleWavFileName, OVERWRITE ) +function [ pitch ] = detect_pitch( sampleWavFileName, OVERWRITE ) % open original pitch calculation sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/findMaxima.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,91 @@ +function [Maxima, countMaxima] = findMaxima(f, step) + +% +% MAXIMA ESTIMATION +% +% function [Maxima, countMaxima] = findMaxima(f, step); +% +% This function estimates the local maxima of a sequence +% +% ARGUMENTS: +% f: the input sequence +% step: the size of the "search" window +% +% RETURN: +% Maxima: [2xcountMaxima] matrix containing: +% 1. the maxima's indeces +% 2. tha maxima's values +% countMaxima: the number of maxima +% + + + +% +% STEP 1: find maxima: +% + +countMaxima = 0; +for (i=1:length(f)-step-1) % for each element of the sequence: + if (i>step) + if (( mean(f(i-step:i-1))< f(i)) && ( mean(f(i+1:i+step))< f(i))) + % IF the current element is larger than its neighbors (2*step window) + % --> keep maximum: + countMaxima = countMaxima + 1; + Maxima(1,countMaxima) = i; + Maxima(2,countMaxima) = f(i); + end + else + if (( mean(f(1:i))<= f(i)) && ( mean(f(i+1:i+step))< f(i))) + % IF the current element is larger than its neighbors (2*step window) + % --> keep maximum: + countMaxima = countMaxima + 1; + Maxima(1,countMaxima) = i; + Maxima(2,countMaxima) = f(i); + end + + end +end + +% +% STEP 2: post process maxima: +% + +MaximaNew = []; +countNewMaxima = 0; +i = 0; +while (i<countMaxima) + % get current maximum: + i = i + 1; + curMaxima = Maxima(1,i); + curMavVal = Maxima(2,i); + + tempMax = Maxima(1,i); + tempVals = Maxima(2,i); + + % search for "neighbourh maxima": + while ((i<countMaxima) && ( Maxima(1,i+1) - tempMax(end) < step / 2)) + i = i + 1; + tempMax(end+1) = Maxima(1,i); + tempVals(end+1) = Maxima(2,i); + end + + + % find the maximum value and index from the tempVals array: + %MI = findCentroid(tempMax, tempVals); MM = tempVals(MI); + + [MM, MI] = max(tempVals); + + if (MM>0.02*mean(f)) % if the current maximum is "large" enough: + countNewMaxima = countNewMaxima + 1; % add maxima + % keep the maximum of all maxima in the region: + MaximaNew(1,countNewMaxima) = tempMax(MI); + MaximaNew(2,countNewMaxima) = f(MaximaNew(1,countNewMaxima)); + end + tempMax = []; + tempVals = []; +end + +Maxima = MaximaNew; +countMaxima = countNewMaxima; + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/getSilentDataArray.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,40 @@ +function [ silentFrames ] = getSilentDataArray( silentSegments, noOfFrames ) + +%---------------- GET THE SILENT FRAME VALUES ------------------- +% only wish to consider values from voiced frames. +% silent frames will produce data values that +% are random and therefore will bias our results +% returns an array of values where '1' indicates a non-silent frame + + silentFrames = zeros(1,noOfFrames); + [m n] = size(silentSegments); + if( silentSegments(1,1) == 0 && silentSegments(1,2) == 0 ) + % we have only one segment - the entire file + silentSegments(1,1) = 1; + silentSegments(1,2) = floor(length(x)/frameLength); + [m n] = size(silentSegments); + end + + % check for start at sample 0 + if( silentSegments(1,1) == 0) + silentSegments(1,1) = 1; + end + + for i=1:m + start = silentSegments(i,1); + stop = silentSegments(i,2); + if( stop > noOfFrames ) + stop = noOfFrames; + silentSegments(i,2) = noOfFrames; + end + + if( start == 0 ) + start = 1; + end + + + silentFrames( start : stop ) = 1; + end + +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/linearPrediction.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,6 @@ +function [coeffs]=linearPrediction( x, filterOrder ) + +% This function takes in an audio frame and calculates the nth order filter +% coefficients that minimise the prediction error. + +coeffs = lpc( x, filterOrder );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Common/voicingByClustering.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,54 @@ +function [ idx ] = voicingByClustering( x, fs, noOfFrames, frameLength ) +% attempt to classify the voiced/unvoiced frames using k-means +% clustering with the short term energy and spectral centroid +% as feature vectors +% returns an array containing voicing decision for frames +% Useful only for speech frames +% Window length and step (in seconds): +win = frameLength/fs; +step = win; + +% calculate the short term energy +Eor = ShortTimeEnergy(x, win*fs, step*fs ); +% calculate the spectral centroid +Cor = SpectralCentroid(x, win*fs, step*fs, fs ); + +% dataFileName = '../../../../../Results/VUVgrouping.txt'; +% dataFileID = fopen( dataFileName, 'w' ); + +noOfClusters = 2; %voiced, unvoiced +data = [Eor Cor]; +idArray = zeros(1, length(Eor)); + +% myColours = ['r.'; 'm.'; 'c.'; 'w.'; 'g.'; 'y.'; 'b.']; + +[idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... + 'start', 'sample', 'Distance', 'cityblock'); + +% we don't know which group will be classed as voiced +% or unvoiced. +% assume that the number of voiced frames is more than unvoiced + +noOfAFrames = length( find( idx == 1 )); +noOfBFrames = length( find( idx == 2 )); +if( noOfAFrames < noOfBFrames ) + voicedIdx = 2; + unvoicedIdx = 1; +else + voicedIdx = 1; + unvoicedIdx = 2; +end + + +% now re-number the idx array so all voiced frames = 1 and +% unvoiced = 2 + +voicedPos = find( idx == voicedIdx ); +unvoicedPos = find( idx == unvoicedIdx ); + +%replace the idx +idx( voicedPos ) = 1; +idx( unvoicedPos ) = 2; + +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/AudioSpectralFlatness.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,133 @@ +function [ASF] = AudioSpectralFlatness(raw, fs, noOfFrames, frameLength) + +check this works! + +hopSize = frameLength; +windowsize = frameLength; +FFTsize = frameLength; +windowType = hamming(frameLength); + +% bin = fs/512; +% bandsNumber = 24; +% loEdge = 250; +% hiEdege = 16000; + + +loEdge = 250; +hiEdge = 16000; % Setting default hiedge + +if (hiEdge >= fs/2) % Check if value for hiedge is valid + % sr/2-1 : Skipping extraction up to sr/2; Not possible due to 5 percent band overlap + hiEdge = min(hiEdge,fs/2-1); +end +hiEdge = 2^(floor(log2(hiEdge/1000)*4)/4)*1000 ; % Setting exact value for hiEdge, rounding to next lower frequency if necessary +if (hiEdge*1.05 >= fs/2) + hiEdge = hiEdge/2^0.25 ; +end; %Now it's possible to check if hiEdge is valid + +N = frameLength; + +numbands = floor(4*log2(hiEdge/loEdge)); +firstband = round(log2(loEdge/1000)*4); +overlap = 0.05; +grpsize = 1; + +[fftout,phase] = mpeg7getspec( raw, fs, hopSize, windowsize, windowType, FFTsize ); +band=[]; +for k = 1:numbands + f_lo = loEdge * (2^((k-1)/4)) * (1-overlap); + f_hi = loEdge * (2^((k )/4)) * (1+overlap); + + i_lo = round( f_lo/(fs/N) ) + 1; + i_hi = round( f_hi/(fs/N) ) + 1; + + fband(k,1) = f_lo; + fband(k,2) = f_hi; + + iband(k,1) = i_lo; + iband(k,2) = i_hi; + + % Rounding of upper index according due to coefficient grouping + if (k+firstband-1 >= 0) %Start grouping at 1kHz + grpsize = 2^ceil( (k+firstband )/4); + i_hi = round((i_hi-i_lo+1)/grpsize)*grpsize + i_lo-1 ; + else + grpsize = 1; + end + tmp = fftout(i_lo:i_hi,:) .^ 2; % PSD coefficients + ncoeffs = i_hi - i_lo + 1; + + if (k+firstband-1 >= 0) % Coefficient grouping + tmp2 = tmp(1:grpsize:ncoeffs,:); + for g=2:grpsize + tmp2 = tmp2 + tmp(g:grpsize:ncoeffs,:) ; + end + tmp = tmp2; + end + % Actual calculation + ncoeffs = ncoeffs/grpsize ; + tmp = tmp + 1e-50; % avoid underflow for zero signals + gm(k,:) = exp( sum(log(tmp))/ncoeffs ); % log processing avoids overflow + am(k,:) = sum(tmp) / ncoeffs; +end +ASF = (gm./am)'; + +% myColor = 'rx'; +% for i=1:(length(raw)/frameLength) +% subplot(411); plot( raw( (i-1)*frameLength+1 : (i*frameLength) )); +% subplot(412); plot( fftout(:,i) ); +% subplot(425); plot( i, ASF(i,1), myColor ); hold on; +% subplot(426); plot( i, ASF(i,2), myColor ); hold on; +% subplot(427); plot( i, ASF(i,3), myColor ); hold on; +% subplot(428); plot( i, ASF(i,4), myColor ); hold on; +% end +% lo_edge = loEdge; +% hi_edge = hiEdge; + +% for n = 1:noOfFrames +% j = (n-1) * 512 + 1; +% k = n * 512; +% if(k<=length(raw)) +% temp = raw(j:k); +% end +% if(k>length(raw)) +% +% temp = [raw(j:end)' zeros(512-length(raw(j:end)),1)']; +% end +% +% FFTX=fft(temp,hopSize); +% subplot(311); plot(abs(FFTX(1:length(FFTX)/2))); +% BW=1.5*fs*1024; +% PSD=FFTX/BW; +% +% for b = 1:24 +% floKb = 0.95*loEdge * 2^(0.25*b-0.25); +% fhiKb = 1.05*loEdge * 2^(0.25*b); +% lowKbp = round( floKb/(fs/512) ) + 1; +% hiKbp = round( fhiKb/(fs/512) ) + 1; +% +% if (b-9 >= 0) +% groupSize = 2^ceil( (b-8)/4); +% hiKbp = round((hiKbp-lowKbp+1)/groupSize)*groupSize + lowKbp -1 ; +% else +% groupSize = 1; +% end +% +% newtemp = PSD(lowKbp:hiKbp).*conj(PSD(lowKbp:hiKbp)); +% +% if (b-9 >= 0) +% temp1 = newtemp(1:groupSize:(hiKbp-lowKbp+1)) ; +% for i=2:groupSize +% temp1 = temp1 + newtemp(i:groupSize:(hiKbp-lowKbp+1)) ; +% end +% newtemp = temp1; +% end +% GM(b,n) = exp( sum(log(newtemp))/ (hiKbp-lowKbp+1)); +% AM(b,n) = sum(newtemp) / (hiKbp-lowKbp+1); +% end +% ASF = (GM./AM)'; +% subplot(312); plot(temp);subplot(313); plot(ASF(n,1:6)); +% end + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/AudioSpectralFlatness_Detection.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,18 @@ +function [] = AudioSpectralFlatness_Detection( sampleWavFileName, x, fs, frameLength, noOfFrames ) + +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +ASFFileName = [ sampleFileName '_ASF_norm.txt']; +ASFFileID = fopen( ASFFileName, 'w'); + +raw = x(:,1); +ASF = AudioSpectralFlatness( raw, fs, noOfFrames, frameLength ); + +for i = 1 : noOfFrames + fprintf(ASFFileID,'%d ',i); +% for j = 1: 24 + fprintf(ASFFileID, '%s ',ASF(i)); +% end + fprintf(ASFFileID, '\n'); +end + +fclose( ASFFileID ); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/AudioSpectrumFlatnessType.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,148 @@ +function [AudioSpectrumFlatness ,lo_edge, hi_edge, XMLFile ] = AudioSpectrumFlatnessType(audioFile,hopSize,loEdge,hiEdge,writeXML,XMLFile) + +% This function describes the spectral flatness measure of the audio signal +% The frequency range is divided into numbands logarithmically spaced bands +% of 1/4 octave width, starting at loEdge up to hiEdge + + +% Written by Melanie Jackson & Juergen Herre +% Version 2.0 25 July 2001 + +% Modified by Melanie Jackson 10 December 2001 +% Modified by MJ 17 January 2002 +% Modified 16/04/2002 by Thibaut Sacreste - add XML generation +% Modified 19/04/2002 by Thibaut Sacreste - changed to be a stand alone function +% Modified 30/04/2002 by Thorsten Kastner - changed function call (loEdge and hiEdge can be set) +% - modified check for loEdge and hiEdge +% Modified 12/06/2002 by Thorsten Kastner - adapted coefficient grouping to variable loEdge and hiEdge +% - values for loEdge and hiEdge will be recalculated if necessary +%-------------------------------------------------------------------- +% audioFile is the name of the audio file to process +% 2 types of files can be read: .wav and .au + +% writeXML is a flag for the generation of the XML file +% writeXML=0 -> no generation +% writeXML=1 -> generation + +% XMLFile is the name of the XML file to be generated (optional) + + +%-------------------------------------------------------------------- +% Initialisation: + + +% Read in audio file +if audioFile(end-3:end)=='.wav' + [audioData, sr] = wavread(audioFile); +elseif audioFile(end-2:end)=='.au' + [audioData, sr] = auread(audioFile); +else + Error = 'Incorrect filename' + return +end + +% Descriptors only deal with monaural recordings +if size(audioData,2)>1 + % in the wavread function the second dimension contains the number of channels + audioData = mean(audioData')'; +end + +% Start calculating descriptors + +% Hopsize conversion +% format PT10N1000F +hop = ''; +if (hopSize) + i = find(hopSize=='N'); + hop = [str2num(hopSize(3:i-1)) str2num(hopSize(i+1:end-1))]; +end + + +standvar = h_mpeg7init(sr,hop); + +%Check loEdge and hiEdge + +if isempty(loEdge) % variable defined but no value + loEdge = 250; +else + loEdge = 2^(floor(log2(loEdge/1000)*4)/4)*1000 ; % Setting exact value for loEdge, rounding to next lower frequency if necessary + if (loEdge < 250 ) + loEdge = 250; % No extraction below 250Hz + end +end + + +if isempty(hiEdge) % Variable defined but no value + hiEdge = 16000; % Setting default hiedge +end +if (hiEdge >= sr/2) % Check if value for hiedge is valid + hiEdge = min(hiEdge,sr/2-1); % sr/2-1 : Skipping extraction up to sr/2; Not possible due to 5 percent band overlap +end +hiEdge = 2^(floor(log2(hiEdge/1000)*4)/4)*1000 ; % Setting exact value for hiEdge, rounding to next lower frequency if necessary +if (hiEdge*1.05 >= sr/2) hiEdge = hiEdge/2^0.25 ; end; %Now it's possible to check if hiEdge is valid + %If hiedge plus band overlap greater than sr/2 skip highest band + +%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +%------------------------------------------------------------------ +% STFT with no overlap; window size equal to hopsize. +% Zero padding of the last few frames will occur, to ensure there is one spectral frame +% for each corresponding power estimate in the power descriptor. + +[fftout,phase] = h_mpeg7getspec(audioData,standvar); + +%----------------------------------- +% AudioSpectrumFlatness calculation: + +fs = standvar.fs; +N = standvar.FFTsize; + +numbands = floor(4*log2(hiEdge/loEdge)); +firstband = round(log2(loEdge/1000)*4); +overlap = 0.05; + +grpsize = 1; +for k = 1:numbands + f_lo = loEdge * (2^((k-1)/4)) * (1-overlap); + f_hi = loEdge * (2^((k )/4)) * (1+overlap); + i_lo = round( f_lo/(fs/N) ) + 1; + i_hi = round( f_hi/(fs/N) ) + 1; + + % Rounding of upper index according due to coefficient grouping + if (k+firstband-1 >= 0) %Start grouping at 1kHz + grpsize = 2^ceil( (k+firstband )/4); + i_hi = round((i_hi-i_lo+1)/grpsize)*grpsize + i_lo-1 ; + else + grpsize = 1; + end + tmp = fftout(i_lo:i_hi,:) .^ 2; % PSD coefficients + ncoeffs = i_hi - i_lo + 1; + + if (k+firstband-1 >= 0) % Coefficient grouping + tmp2 = tmp(1:grpsize:ncoeffs,:); + for g=2:grpsize + tmp2 = tmp2 + tmp(g:grpsize:ncoeffs,:) ; + end + tmp = tmp2; + end + % Actual calculation + ncoeffs = ncoeffs/grpsize ; + tmp = tmp + 1e-50; % avoid underflow for zero signals + gm(k,:) = exp( sum(log(tmp))/ncoeffs ); % log processing avoids overflow + am(k,:) = sum(tmp) / ncoeffs; +end +AudioSpectrumFlatness = (gm./am)'; +lo_edge = loEdge; +hi_edge = hiEdge; + +%--------------------- +%XML generation: + +% if writeXML +% if ~exist('XMLFile') +% +% XMLFile=h_ASFtoXML(AudioSpectrumFlatness',loEdge,hiEdge,hopSize); +% else +% XMLFile +% XMLFile=h_ASFtoXML(AudioSpectrumFlatness',loEdge,hiEdge,hopSize,XMLFile); +% end +% end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/MessageBox.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,127 @@ +function varargout = MessageBox(varargin) +% MESSAGEBOX M-file for MessageBox.fig +% MESSAGEBOX, by itself, creates a new MESSAGEBOX or raises the existing +% singleton*. +% +% H = MESSAGEBOX returns the handle to a new MESSAGEBOX or the handle to +% the existing singleton*. +% +% MESSAGEBOX('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in MESSAGEBOX.M with the given input arguments. +% +% MESSAGEBOX('Property','Value',...) creates a new MESSAGEBOX or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before MessageBox_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to MessageBox_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help MessageBox + +% Last Modified by GUIDE v2.5 02-Aug-2009 22:55:59 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @MessageBox_OpeningFcn, ... + 'gui_OutputFcn', @MessageBox_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before MessageBox is made visible. +function MessageBox_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to MessageBox (see VARARGIN) + +% Choose default command line output for MessageBox +handles.output = hObject; + +set(handles.figure_MessageBox, 'UserData', 0); + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes MessageBox wait for user response (see UIRESUME) +% uiwait(handles.figure_MessageBox); + + +% --- Outputs from this function are returned to the command line. +function varargout = MessageBox_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on selection change in listbox_messages. +function listbox_messages_Callback(hObject, eventdata, handles) +% hObject handle to listbox_messages (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_messages contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_messages + + +% --- Executes during object creation, after setting all properties. +function listbox_messages_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_messages (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_stop. +function pushbutton_stop_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_stop (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.figure_MessageBox, 'UserData', 1); +set(handles.pushbutton_close, 'Enable', 'on'); +set(hObject, 'Enable', 'off'); + + +% --- Executes on button press in pushbutton_close. +function pushbutton_close_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_close (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +delete(gcf); + + +% --- Executes when user attempts to close figure_MessageBox. +function figure_MessageBox_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure_MessageBox (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: delete(hObject) closes the figure +set(handles.figure_MessageBox, 'UserData', 1); % signal algorithm to stop +delete(hObject);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/VoiceSauce.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,159 @@ +function varargout = VoiceSauce(varargin) +% VOICESAUCE M-file for VoiceSauce.fig +% VOICESAUCE, by itself, creates a new VOICESAUCE or raises the existing +% singleton*. +% +% H = VOICESAUCE returns the handle to a new VOICESAUCE or the handle to +% the existing singleton*. +% +% VOICESAUCE('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VOICESAUCE.M with the given input arguments. +% +% VOICESAUCE('Property','Value',...) creates a new VOICESAUCE or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before VoiceSauce_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to VoiceSauce_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help VoiceSauce + +% Last Modified by GUIDE v2.5 10-Nov-2009 15:23:03 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @VoiceSauce_OpeningFcn, ... + 'gui_OutputFcn', @VoiceSauce_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before VoiceSauce is made visible. +function VoiceSauce_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to VoiceSauce (see VARARGIN) + +% Choose default command line output for VoiceSauce +handles.output = hObject; + +% YS: add initialization variables here +if (~isfield(handles, 'vars')) + vars = vs_Initialize(); + handles.vars = vars; +end + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes VoiceSauce wait for user response (see UIRESUME) +% uiwait(handles.figure_VoiceSauce); + + +% --- Outputs from this function are returned to the command line. +function varargout = VoiceSauce_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on button press in button_ParameterEstimation. +function button_ParameterEstimation_Callback(hObject, eventdata, handles) +% hObject handle to button_ParameterEstimation (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +vs_ParameterEstimation(); + + + +% --- Executes on button press in pushbutton_OutputtoText. +function pushbutton_OutputtoText_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OutputtoText (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +vs_OutputToText(); + +% --- Executes on button press in pushbutton_OutputtoEMU. +function pushbutton_OutputtoEMU_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OutputtoEMU (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of pushbutton_OutputtoEMU +vs_OutputToEMU(); + +% --- Executes on button press in pushbutton_ParameterDisplay. +function pushbutton_ParameterDisplay_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_ParameterDisplay (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of pushbutton_ParameterDisplay +vs_ParameterDisplay(); + +% --- Executes on button press in pushbutton_Settings. +function pushbutton_Settings_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Settings (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +vs_Settings(); + +% --- Executes on button press in pushbutton_Exit. +function pushbutton_Exit_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Exit (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +delete(get(0, 'Children')); + +% --- Executes on button press in pushbutton_ManualData. +function pushbutton_ManualData_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_ManualData (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +vs_ManualData(); + +% --- Executes on button press in pushbutton_About. +function pushbutton_About_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_About (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +vs_About(); + + +% --- Executes when user attempts to close figure_VoiceSauce. +function figure_VoiceSauce_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure_VoiceSauce (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: delete(hObject) closes the figure +delete(get(0, 'Children')); + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/fminsearchbnd.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,304 @@ +function [x,fval,exitflag,output]=fminsearchbnd(fun,x0,LB,UB,options,varargin) +% FMINSEARCHBND: FMINSEARCH, but with bound constraints by transformation +% usage: x=FMINSEARCHBND(fun,x0) +% usage: x=FMINSEARCHBND(fun,x0,LB) +% usage: x=FMINSEARCHBND(fun,x0,LB,UB) +% usage: x=FMINSEARCHBND(fun,x0,LB,UB,options) +% usage: x=FMINSEARCHBND(fun,x0,LB,UB,options,p1,p2,...) +% usage: [x,fval,exitflag,output]=FMINSEARCHBND(fun,x0,...) +% +% arguments: +% fun, x0, options - see the help for FMINSEARCH +% +% LB - lower bound vector or array, must be the same size as x0 +% +% If no lower bounds exist for one of the variables, then +% supply -inf for that variable. +% +% If no lower bounds at all, then LB may be left empty. +% +% Variables may be fixed in value by setting the corresponding +% lower and upper bounds to exactly the same value. +% +% UB - upper bound vector or array, must be the same size as x0 +% +% If no upper bounds exist for one of the variables, then +% supply +inf for that variable. +% +% If no upper bounds at all, then UB may be left empty. +% +% Variables may be fixed in value by setting the corresponding +% lower and upper bounds to exactly the same value. +% +% Notes: +% +% If options is supplied, then TolX will apply to the transformed +% variables. All other FMINSEARCH parameters should be unaffected. +% +% Variables which are constrained by both a lower and an upper +% bound will use a sin transformation. Those constrained by +% only a lower or an upper bound will use a quadratic +% transformation, and unconstrained variables will be left alone. +% +% Variables may be fixed by setting their respective bounds equal. +% In this case, the problem will be reduced in size for FMINSEARCH. +% +% The bounds are inclusive inequalities, which admit the +% boundary values themselves, but will not permit ANY function +% evaluations outside the bounds. These constraints are strictly +% followed. +% +% If your problem has an EXCLUSIVE (strict) constraint which will +% not admit evaluation at the bound itself, then you must provide +% a slightly offset bound. An example of this is a function which +% contains the log of one of its parameters. If you constrain the +% variable to have a lower bound of zero, then FMINSEARCHBND may +% try to evaluate the function exactly at zero. +% +% +% Example usage: +% rosen = @(x) (1-x(1)).^2 + 105*(x(2)-x(1).^2).^2; +% +% fminsearch(rosen,[3 3]) % unconstrained +% ans = +% 1.0000 1.0000 +% +% fminsearchbnd(rosen,[3 3],[2 2],[]) % constrained +% ans = +% 2.0000 4.0000 +% +% See test_main.m for other examples of use. +% +% +% See also: fminsearch, fminspleas +% +% +% Author: John D'Errico +% E-mail: woodchips@rochester.rr.com +% Release: 4 +% Release date: 7/23/06 + +% size checks +xsize = size(x0); +x0 = x0(:); +n=length(x0); + +if (nargin<3) || isempty(LB) + LB = repmat(-inf,n,1); +else + LB = LB(:); +end +if (nargin<4) || isempty(UB) + UB = repmat(inf,n,1); +else + UB = UB(:); +end + +if (n~=length(LB)) || (n~=length(UB)) + error 'x0 is incompatible in size with either LB or UB.' +end + +% set default options if necessary +if (nargin<5) || isempty(options) + options = optimset('fminsearch'); +end + +% stuff into a struct to pass around +params.args = varargin; +params.LB = LB; +params.UB = UB; +params.fun = fun; +params.n = n; +params.OutputFcn = []; + +% 0 --> unconstrained variable +% 1 --> lower bound only +% 2 --> upper bound only +% 3 --> dual finite bounds +% 4 --> fixed variable +params.BoundClass = zeros(n,1); +for i=1:n + k = isfinite(LB(i)) + 2*isfinite(UB(i)); + params.BoundClass(i) = k; + if (k==3) && (LB(i)==UB(i)) + params.BoundClass(i) = 4; + end +end + +% transform starting values into their unconstrained +% surrogates. Check for infeasible starting guesses. +x0u = x0; +k=1; +for i = 1:n + switch params.BoundClass(i) + case 1 + % lower bound only + if x0(i)<=LB(i) + % infeasible starting value. Use bound. + x0u(k) = 0; + else + x0u(k) = sqrt(x0(i) - LB(i)); + end + + % increment k + k=k+1; + case 2 + % upper bound only + if x0(i)>=UB(i) + % infeasible starting value. use bound. + x0u(k) = 0; + else + x0u(k) = sqrt(UB(i) - x0(i)); + end + + % increment k + k=k+1; + case 3 + % lower and upper bounds + if x0(i)<=LB(i) + % infeasible starting value + x0u(k) = -pi/2; + elseif x0(i)>=UB(i) + % infeasible starting value + x0u(k) = pi/2; + else + x0u(k) = 2*(x0(i) - LB(i))/(UB(i)-LB(i)) - 1; + % shift by 2*pi to avoid problems at zero in fminsearch + % otherwise, the initial simplex is vanishingly small + x0u(k) = 2*pi+asin(max(-1,min(1,x0u(k)))); + end + + % increment k + k=k+1; + case 0 + % unconstrained variable. x0u(i) is set. + x0u(k) = x0(i); + + % increment k + k=k+1; + case 4 + % fixed variable. drop it before fminsearch sees it. + % k is not incremented for this variable. + end + +end +% if any of the unknowns were fixed, then we need to shorten +% x0u now. +if k<=n + x0u(k:n) = []; +end + +% were all the variables fixed? +if isempty(x0u) + % All variables were fixed. quit immediately, setting the + % appropriate parameters, then return. + + % undo the variable transformations into the original space + x = xtransform(x0u,params); + + % final reshape + x = reshape(x,xsize); + + % stuff fval with the final value + fval = feval(params.fun,x,params.args{:}); + + % fminsearchbnd was not called + exitflag = 0; + + output.iterations = 0; + output.funcount = 1; + output.algorithm = 'fminsearch'; + output.message = 'All variables were held fixed by the applied bounds'; + + % return with no call at all to fminsearch + return +end + +% Check for an outputfcn. If there is any, then substitute my +% own wrapper function. +if ~isempty(options.OutputFcn) + params.OutputFcn = options.OutputFcn; + options.OutputFcn = @outfun_wrapper; +end + +% now we can call fminsearch, but with our own +% intra-objective function. +[xu,fval,exitflag,output] = fminsearch(@intrafun,x0u,options,params); + +% undo the variable transformations into the original space +x = xtransform(xu,params); + +% final reshape +x = reshape(x,xsize); + +% Use a nested function as the OutputFcn wrapper + function stop = outfun_wrapper(x,varargin); + % we need to transform x first + xtrans = xtransform(x,params); + + % then call the user supplied OutputFcn + stop = params.OutputFcn(xtrans,varargin{1:(end-1)}); + + end + +end % mainline end + +% ====================================== +% ========= begin subfunctions ========= +% ====================================== +function fval = intrafun(x,params) +% transform variables, then call original function + +% transform +xtrans = xtransform(x,params); + +% and call fun +fval = feval(params.fun,xtrans,params.args{:}); + +end % sub function intrafun end + +% ====================================== +function xtrans = xtransform(x,params) +% converts unconstrained variables into their original domains + +xtrans = zeros(1,params.n); +% k allows some variables to be fixed, thus dropped from the +% optimization. +k=1; +for i = 1:params.n + switch params.BoundClass(i) + case 1 + % lower bound only + xtrans(i) = params.LB(i) + x(k).^2; + + k=k+1; + case 2 + % upper bound only + xtrans(i) = params.UB(i) - x(k).^2; + + k=k+1; + case 3 + % lower and upper bounds + xtrans(i) = (sin(x(k))+1)/2; + xtrans(i) = xtrans(i)*(params.UB(i) - params.LB(i)) + params.LB(i); + % just in case of any floating point problems + xtrans(i) = max(params.LB(i),min(params.UB(i),xtrans(i))); + + k=k+1; + case 4 + % fixed variable, bounds are equal, set it at either bound + xtrans(i) = params.LB(i); + case 0 + % unconstrained variable. + xtrans(i) = x(k); + + k=k+1; + end +end + +end % sub function xtransform end + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetA1A2A3.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,190 @@ +function [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, variables, textgridfile) +% [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, variables, textgridfile) +% Input: y - input signal +% Fs - sampling frequency +% F0 - fundamental frequency (vector) +% F1-F3 - formant frequencies (vectors) +% variables - settings from VS +% textgridfile - textgrid filename if available (optional) +% Output: A1, A2, A3 - uncorrected amplitudes of the spectra at the formant +% frequencies. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +N_periods = variables.Nperiods; +sampleshift = (Fs / 1000 * variables.frameshift); + +A1 = zeros(length(F0), 1) * NaN; +A2 = zeros(length(F0), 1) * NaN; +A3 = zeros(length(F0), 1) * NaN; + +if (nargin == 7) + + for k=1:length(F0) + ks = round(k * sampleshift); + + if (ks <= 0 || ks > length(y)) + continue; + end + + F0_curr = F0(k); + + if (isnan(F0_curr) || F0_curr == 0) + continue; + end + + N0_curr = 1 / F0_curr * Fs; + + ystart = round(ks - N_periods/2*N0_curr); + yend = round(ks + N_periods/2*N0_curr) - 1; + + if (ystart <= 0) + continue; + end; + + if (yend > length(y)) + continue; + end; + + yseg = y(ystart:yend); + + % proceed if no NaNs detected + if (~isnan(F1(k)) && ~isnan(F2(k)) && ~isnan(F3(k)) && ~isnan(N0_curr)) + [A1_, fmax] = ana_GetMagnitudeMax(yseg, F1(k), Fs, 8192); + [A2_, fmax] = ana_GetMagnitudeMax(yseg, F2(k), Fs, 8192); + [A3_, fmax] = ana_GetMagnitudeMax(yseg, F3(k), Fs, 8192); + + A1(k) = A1_; + A2(k) = A2_; + A3(k) = A3_; + end + end +else + % use textgrids - get ignore string list + tbuffer = variables.tbuffer; + ignorelabels = textscan(variables.TextgridIgnoreList, '%s', 'delimiter', ','); + ignorelabels = ignorelabels{1}; + + [labels, start, stop] = func_readTextgrid(textgridfile); + labels_tmp = []; + start_tmp = []; + stop_tmp = []; + + for k=1:length(variables.TextgridTierNumber) + inx = variables.TextgridTierNumber(k); + if (inx <= length(labels)) + labels_tmp = [labels_tmp; labels{inx}]; + start_tmp = [start_tmp; start{inx}]; + stop_tmp = [stop_tmp; stop{inx}]; + end + end + + labels = labels_tmp; + start = start_tmp; + stop = stop_tmp; + + + for m=1:length(start) + switch(labels{m}) + case ignorelabels + continue; % skip anything that is within the ignore list + end + + kstart = round((start(m) * 1000 - tbuffer) / variables.frameshift); + kstop = round((stop(m) * 1000 + tbuffer) / variables.frameshift); + kstart(kstart <= 0) = 1; + kstop(kstop > length(F0)) = length(F0); + + ystart = round(kstart * sampleshift); + ystop = round(kstop * sampleshift); + ystart(ystart <= 0) = 1; + ystop(ystop > length(y)) = length(y); + + ysegment = y(ystart:ystop); + F0seg = F0(kstart:kstop); + F1seg = F1(kstart:kstop); + F2seg = F2(kstart:kstop); + F3seg = F3(kstart:kstop); + + for k=1:length(F0seg) + ks = round(k*sampleshift); + + if (ks <= 0 || ks > length(ysegment)) + continue; + end + + F0_curr = F0seg(k); + if (isnan(F0_curr) || F0_curr == 0) + continue; + end + + N0_curr = Fs/F0_curr; + ysstart = round(ks - N_periods/2 * N0_curr); + ysend = round(ks + N_periods/2 * N0_curr) - 1; + + if (isnan(F1seg(k)) || isnan(F2seg(k)) || isnan(F3seg(k))) + continue; + end + + if (ysstart <= 0) + continue; + end; + if (ysend > length(ysegment)) + continue; + end; + + yseg = ysegment(ysstart:ysend); + + [A1_, fmax] = ana_GetMagnitudeMax(yseg, F1seg(k), Fs, 8192); + [A2_, fmax] = ana_GetMagnitudeMax(yseg, F2seg(k), Fs, 8192); + [A3_, fmax] = ana_GetMagnitudeMax(yseg, F3seg(k), Fs, 8192); + + inx = kstart + k - 1; + if (inx <= length(A1)) + A1(inx) = A1_; + A2(inx) = A2_; + A3(inx) = A3_; + end + + end + + end +end + + +%------------------------------------------------------------------------ +function [M,fmax] = ana_GetMagnitudeMax(x, Fx, Fs, fftlen) +% Get maximal spectral magnitude of signal x around position Fx Hz in dB +% Fx can be a vector of frequency points +% Note that the bigger fftlen the better the resolution + +if (isnan(Fx)) + M = NaN; + fmax = NaN; +else + + len = length(x); + hamlen = min(fftlen, len); + %X = fft(hamming(hamlen).*x(1:hamlen), fftlen); + factor = 1; %/length(x); % not exactly Kosher but compatible to dfs_magn() + X = fft(x,fftlen); + X(X==0) = 0.000000001; % guard against log(0) warnings + X = 20*log10(factor*abs(X(1:fftlen/2, :))); + fstep = Fs / fftlen; + lowf = Fx-0.1*Fx; + if (lowf<0) lowf=0; end + highf = Fx+0.1*Fx; + if (highf>Fs/2-fstep) highf=Fs/2-fstep; end + + for cnt = 1:length(Fx) + [M(cnt),pos] = max(X(1+round(lowf(cnt)/fstep):1+round(highf(cnt)/fstep), :)); + fmax(cnt) = (pos-1+round(lowf(cnt)/fstep))*fstep; + end + +end + +% f=0:fstep:(Fs/2-fstep); +% plot(f,X); hold; +% plot(pos, M, 'rx'); hold off; +% fprintf('End get_magnitude_max()\n');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetCPP.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,72 @@ +function CPP = func_GetCPP(y, Fs, F0, variables) +% CPP = func_GetCPP(y, Fs, F0, variables) +% Input: y, Fs - from wavread +% F0 - vector of fundamental frequencies +% variables - global settings +% Output: CPP vector +% Notes: Calculates the CPP according to the formula from Hillenbrand, 1994. +% Currently does not use textgrid information. For very very long files this +% may be a process-bottleneck. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +N_periods = variables.Nperiods_EC; +sampleshift = (Fs / 1000 * variables.frameshift); + +CPP = zeros(length(F0), 1) * NaN; + +N_ms = round(Fs / 1000); % Quefrency below 1ms are ignored as per Hillenbrand + +for k=1:length(F0) + ks = round(k * sampleshift); + + if (ks <= 0 || ks > length(y)) + continue; + end + + F0_curr = F0(k); + + if (isnan(F0_curr)) + continue; + end + + N0_curr = Fs / F0_curr; + + ystart = round(ks - N_periods/2*N0_curr); + yend = round(ks + N_periods/2*N0_curr) - 1; + + if (ystart <= 0) + continue; + end; + + if (yend > length(y)) + continue; + end; + + yseg = y(ystart:yend); + yseg = yseg .* hamming(length(yseg)); %windowing + YSEG = fft(yseg); + yseg_c = ifft(log(abs(YSEG))); + yseg_c_db = 10*log10(yseg_c .^ 2); + + yseg_c_db = yseg_c_db(1:floor(length(yseg)/2)); + [vals, inx] = func_pickpeaks(yseg_c_db(N_ms:end)', 2*N0_curr); + [pos, pinx] = min(abs(inx - N0_curr)); + + if (~isempty(pinx)) + inx = inx(pinx(1)); + vals = yseg_c_db(inx+N_ms-1); + p = polyfit([N_ms:length(yseg_c_db)], yseg_c_db(N_ms:end)', 1); + base_val = p(1) * (inx+N_ms-1) + p(2); + CPP(k) = vals - base_val; + +% figure; +% plot(yseg_c_db); hold on; +% plot(inx+N_ms-1, vals, 'rx'); +% plot([N_ms:length(yseg_c_db)], polyval(p,[N_ms:length(yseg_c_db)]), 'g'); + + end + +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetEnergy.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,50 @@ +function E = func_GetEnergy(y, F0, Fs, variables) +% E = func_GetEnergy(y, F0, Fs, variables) +% Input: y, Fs - from wavread +% F0 - vector of fundamental frequencies +% variables - global settings +% Output: Energy vector +% Notes: Calculates the energy, normalized for F0. This is done by using a +% variable length window consisting of 5 pitch periods, according to the F0 +% at a particular point in time. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +N_periods = variables.Nperiods_EC; +sampleshift = (Fs / 1000 * variables.frameshift); + +E = zeros(length(F0), 1) * NaN; + +for k=1:length(F0) + ks = round(k * sampleshift); + + if (ks <= 0 || ks > length(y)) + continue; + end + + F0_curr = F0(k); + + if (isnan(F0_curr)) + continue; + end + + N0_curr = Fs/F0_curr; + + ystart = round(ks - N_periods/2 * N0_curr); + yend = round(ks + N_periods/2 * N0_curr) - 1; + + if (ystart <= 0) + continue; + end + + if (yend > length(y)) + continue; + end + + yseg = y(ystart:yend); + + E(k) = sum(yseg .^ 2); + +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetH1A1_H1A2_H1A3.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,41 @@ +function [H1A1, H1A2, H1A3] = func_GetH1A1_H1A2_H1A3(H1, A1, A2, A3, Fs, F0, F1, F2, F3, B1, B2, B3) +% [H1A1, H1A2, H1A3] = func_GetH1A1_H1A2_H1A3(H1, A1, A2, A3, Fs, F0, F1, F2, F3, B1, B2, B3) +% Input: H1, A1, A2, A3 vectors +% Fs - sampling frequency +% F0 - vector of fundamental frequencies +% Fx, Bx - vectors of formant frequencies and bandwidths +% Output: H1A1, H1A2, H1A3 vectors +% Notes: Function produces the corrected versions of the parameters. They +% are stored as HxAx for compatibility reasons. Use func_buildMData.m to +% recreate the mat data with the proper variable names. +% Also note that the bandwidths from the formant trackers are not currently +% used due to the variability of those measurements. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +if (nargin == 9) + B1 = func_getBWfromFMT(F1, F0, 'hm'); + B2 = func_getBWfromFMT(F2, F0, 'hm'); + B3 = func_getBWfromFMT(F3, F0, 'hm'); +end + +H1_corr = H1 - func_correct_iseli_z(F0, F1, B1, Fs); +H1_corr = H1_corr - func_correct_iseli_z(F0, F2, B2, Fs); +%H1_corr = H1_corr - func_correct_iseli_z(F0, F3, B3, Fs); + +A3_corr = A3 - func_correct_iseli_z(F3, F1, B1, Fs); +A3_corr = A3_corr - func_correct_iseli_z(F3, F2, B2, Fs); +A3_corr = A3_corr - func_correct_iseli_z(F3, F3, B3, Fs); + +A1_corr = A1 - func_correct_iseli_z(F1, F1, B1, Fs); +A1_corr = A1_corr - func_correct_iseli_z(F1, F2, B2, Fs); + +A2_corr = A2 - func_correct_iseli_z(F2, F1, B1, Fs); +A2_corr = A2_corr - func_correct_iseli_z(F2, F2, B2, Fs); + +H1A1 = H1_corr - A1_corr; +H1A2 = H1_corr - A2_corr; +H1A3 = H1_corr - A3_corr; + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetH1H2_H2H4.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,35 @@ +function [H1H2, H2H4] = func_GetH1H2_H2H4(H1, H2, H4, Fs, F0, F1, F2, B1, B2) +% [H1H2, H2H4] = func_GetH1H2_H2H4(H1, H2, H4, Fs, F0, F1, F2, B1, B2) +% Input: H1, H2, H4, vectors +% Fs - sampling frequency +% F0 - vector of fundamental frequencies +% Fx, Bx - vectors of formant frequencies and bandwidths +% Output: H1A1, H1A2, H1A3 vectors +% Notes: Function produces the corrected versions of the parameters. They +% are stored as HxHx for compatibility reasons. Use func_buildMData.m to +% recreate the mat data with the proper variable names. +% Also note that the bandwidths from the formant trackers are not currently +% used due to the variability of those measurements. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + + +if (nargin == 7) + B1 = func_getBWfromFMT(F1, F0, 'hm'); + B2 = func_getBWfromFMT(F2, F0, 'hm'); +end + + +H1_corr = H1 - func_correct_iseli_z(F0, F1, B1, Fs); +H1_corr = H1_corr - func_correct_iseli_z(F0, F2, B2, Fs); +H2_corr = H2 - func_correct_iseli_z(2*F0, F1, B1, Fs); +H2_corr = H2_corr - func_correct_iseli_z(2*F0, F2, B2, Fs); +H4_corr = H4 - func_correct_iseli_z(4*F0, F1, B1, Fs); +H4_corr = H4_corr - func_correct_iseli_z(4*F0, F2, B2, Fs); + +H1H2 = H1_corr - H2_corr; +H2H4 = H2_corr - H4_corr; + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetH1_H2_H4.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,224 @@ +function [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, handles, variables, textgridfile) +% [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, handles, variables, textgridfile) +% Input: y, Fs - from wavread +% F0 - vector of fundamental frequencies +% handles - from MessageBox, detects if user has pressed stop +% variables - global settings +% textgridfile - this is optional +% Output: H1, H2, H4 vectors +% isComplete - flag to indicate if the process was allowed to +% finish +% Notes: Function is quite slow! Use textgrid segmentation to speed up the +% process. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +N_periods = variables.Nperiods; +sampleshift = (Fs / 1000 * variables.frameshift); + +H1 = zeros(length(F0), 1) * NaN; +H2 = zeros(length(F0), 1) * NaN; +H4 = zeros(length(F0), 1) * NaN; + +isComplete = 0; + +if (nargin == 5) + + for k=1:length(F0) + %fprintf('%d of %d\n', k, length(y)); + ks = round(k * sampleshift); + + if (ks <= 0 || ks > length(y)) + continue; + end + + F0_curr = F0(k); + + if (isnan(F0_curr) || F0_curr == 0) + continue; + end + + N0_curr = 1 / F0_curr * Fs; + + ystart = round(ks - N_periods/2*N0_curr); + yend = round(ks + N_periods/2*N0_curr) - 1; + + if (ystart <= 0) + continue; + end; + + if (yend > length(y)) + continue; + end; + + yseg = y(ystart:yend)'; + + % check if "stop" button has been pressed + if (~ishandle(handles.figure_MessageBox) || get(handles.figure_MessageBox, 'UserData') == 1) + return; + end + + [h1, f0] = func_GetHarmonics(yseg, F0_curr, Fs); + [h2, dummy] = func_GetHarmonics(yseg, 2*F0_curr, Fs); + [h4, dummy] = func_GetHarmonics(yseg, 4*F0_curr, Fs); + + H1(k) = h1; + H2(k) = h2; + H4(k) = h4; + end + +else + % get the labels to ignore from the settings + ignorelabels = textscan(variables.TextgridIgnoreList, '%s', 'delimiter', ','); + ignorelabels = ignorelabels{1}; + + tbuffer = variables.tbuffer; + + [labels, start, stop] = func_readTextgrid(textgridfile); + labels_tmp = []; + start_tmp = []; + stop_tmp = []; + + for k=1:length(variables.TextgridTierNumber) + inx = variables.TextgridTierNumber(k); + if (inx <= length(labels)) + labels_tmp = [labels_tmp; labels{inx}]; + start_tmp = [start_tmp; start{inx}]; + stop_tmp = [stop_tmp; stop{inx}]; + end + end + + labels = labels_tmp; + start = start_tmp; + stop = stop_tmp; + + + for m=1:length(start) + + switch(labels{m}) + case ignorelabels + continue; % skip anything that is within the ignore list + end + + kstart = round((start(m) * 1000 - tbuffer) / variables.frameshift); + kstop = round((stop(m) * 1000 + tbuffer) / variables.frameshift); + kstart(kstart <= 0) = 1; + kstop(kstop > length(F0)) = length(F0); + + ystart = round(kstart * sampleshift); + ystop = round(kstop * sampleshift); + ystart(ystart <= 0) = 1; + ystop(ystop > length(y)) = length(y); + + F0seg = F0(kstart:kstop); + ysegment = y(ystart:ystop); + + for k=1:length(F0seg) + ks = round(k*sampleshift); + + if (ks <= 0 || ks > length(ysegment)) + continue; + end + + F0_curr = F0seg(k); + if (isnan(F0_curr) || F0_curr == 0) + continue; + end + + N0_curr = Fs/F0_curr; + ysstart = round(ks - N_periods/2 * N0_curr); + ysend = round(ks + N_periods/2 * N0_curr) - 1; + + if (ysstart <= 0) + continue; + end; + if (ysend > length(ysegment)) + continue; + end; + + yseg = ysegment(ysstart:ysend)'; + + % check if "stop" button has been pressed + if (~ishandle(handles.figure_MessageBox) || get(handles.figure_MessageBox, 'UserData') == 1) + return; + end + + [h1, f0] = func_GetHarmonics(yseg, F0_curr, Fs); + [h2, dummy] = func_GetHarmonics(yseg, 2*F0_curr, Fs); + [h4, dummy] = func_GetHarmonics(yseg, 4*F0_curr, Fs); + + inx = kstart + k - 1; + if (inx <= length(H1)) + H1(inx) = h1; + H2(inx) = h2; + H4(inx) = h4; + end + + end + + end + +end + +isComplete = 1; + + +% this function is used from 1/8/09 onwards - optimization used +%-------------------------------------------------------------------------- +function [h,fh]=func_GetHarmonics(data,f_est,Fs) +% find harmonic magnitudes in dB of time signal x +% around a frequency estimate f_est +% Fs, sampling rate +% x, input row vector (is truncated to the first 25ms) +% df_range, optional, default +-5% of f_est + +df = 0.1; % search around f_est in steps of df (in Hz) +df_range = round(f_est*df); % search range (in Hz) + +f_min = f_est - df_range; +f_max = f_est + df_range; + +f = @(x)func_EstMaxVal(x, data, Fs); +options = optimset('Display', 'off'); +warning off; +%[x, val, exitflag, output] = fmincon(f, f_est, [], [], [], [], f_min, f_max, [], options); +[x, val, exitflag, output] = fminsearchbnd(f, f_est, f_min, f_max, options); + +h = -1 * val; +fh = x; + + + +function val = func_EstMaxVal(x, data, Fs) +% x is the F0 estimate +n = 0:length(data)-1; +v = exp(-1i*2*pi*x*n/Fs); +val = -1 * 20*log10(abs(data * v')); + + + +% This function was used up to 1/8/09 +% %-------------------------------------------------------------------------- +% function [h,f]=func_GetHarmonics_old(x,f_est,Fs,df_range) +% % find harmonic magnitudes in dB of time signal x +% % around a frequency estimate f_est +% % Fs, sampling rate +% % x, input row vector (is truncated to the first 25ms) +% % df_range, optional, default +-5% of f_est +% +% df = 0.1; % search around f_est in steps of df (in Hz) +% if nargin<4 +% df_range = round(f_est*0.1); % search range (in Hz) +% end +% f = f_est-df_range:df:f_est+df_range; +% f = f(:); % make column vector +% +% %x = x(1:round(Fs*0.025)); % analyze 25ms +% %x = hamming(length(x)).*x; +% n = 0:length(x)-1; +% v = exp(-i*2*pi*f*n/Fs); +% h = 20*log10(abs(x' * v.' )); +% %figure; plot(f,h); +% [h,inx]=max(h); +% f=f(inx);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetHNR.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,127 @@ +function [HNR05, HNR15, HNR25, HNR35] = func_GetHNR(y, Fs, F0, variables) +% N = func_GetHNR(y, Fs, F0, variables, textgridfile +% Input: y, Fs - from wavread +% F0 - vector of fundamental frequencies +% variables - global settings +% textgridfile - this is optional +% Output: N vectors +% Notes: Calculates the Harmonic to noise ratio based on the method +% described in de Krom, 1993 - A cepstrum-based technique for determining a +% harmonic-to-noise ratio in speech signals, JSHR. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +N_periods = variables.Nperiods_EC; +sampleshift = (Fs / 1000 * variables.frameshift); + +HNR05 = zeros(length(F0), 1) * NaN; +HNR15 = zeros(length(F0), 1) * NaN; +HNR25 = zeros(length(F0), 1) * NaN; +HNR35 = zeros(length(F0), 1) * NaN; + + +for k=1:length(F0) + ks = round(k * sampleshift); + + if (ks <= 0 || ks > length(y)) + continue; + end + + F0_curr = F0(k); + N0_curr = 1 / F0_curr * Fs; + + if (isnan(F0_curr)) + continue; + end + + ystart = round(ks - N_periods/2*N0_curr); + yend = round(ks + N_periods/2*N0_curr) - 1; + + if (mod(yend - ystart + 1, 2) == 0) % length is even, make it odd + yend = yend - 1; + end + + if (ystart <= 0) + continue; + end; + + if (yend > length(y)) + continue; + end; + + yseg = y(ystart:yend); + + + hnr = getHNR(yseg, F0_curr, Fs, [500 1500 2500 3500]); + + HNR05(k) = hnr(1); + HNR15(k) = hnr(2); + HNR25(k) = hnr(3); + HNR35(k) = hnr(4); + +end + + +% main processing function +function n = getHNR(y, F0, Fs, Nfreqs) + +NBins = length(y); +N0 = round(Fs / F0); +N0_delta = round(N0 * 0.1); % search 10% either side + +y = y .* hamming(length(y)); +Y = fft(y, NBins); +aY = log10(abs(Y)); +ay = ifft(aY); + +% find possible rahmonic peaks +peakinx = zeros(floor(length(y)/ 2 / N0), 1); +for k=1:length(peakinx) + ayseg = ay(k*N0 - N0_delta : k*N0 + N0_delta); + [val, inx] = max(abs(ayseg)); + peakinx(k) = inx + k*N0 - N0_delta - 1; + + % lifter out each rahmonic peak + s_ayseg = sign(diff(ayseg)); + + % find first derivative sign change + l_inx = inx - find((s_ayseg(inx-1:-1:1) ~= sign(inx)), 1) + 1; + r_inx = inx + find((s_ayseg(inx+1:end) == sign(inx)), 1); + + l_inx = l_inx + k*N0 - N0_delta - 1; + r_inx = r_inx + k*N0 - N0_delta - 1; + + % lifter out the peak + ay(l_inx:r_inx) = 0; + +end + +% put the signal back together +midL = round(length(y) / 2) + 1; +ay(midL : end) = ay(midL - 1: -1 : midL - 1 - (length(ay) - midL)); + +Nap = real(fft(ay)); +N = Nap; +Ha = aY - Nap; % approximated harmonic spectrum + +% calculate baseline corrections +Hdelta = F0 / Fs * length(y); +for f=Hdelta+0.0001:Hdelta:round(length(y)/2) + fstart = ceil(f - Hdelta); + + Bdf = abs(min(Ha(fstart:round(f)))); + N(fstart:round(f)) = N(fstart:round(f)) - Bdf; +end + +% calculate the average HNR for Nfreqs +H = aY - N; %note that N is valid only for 1:length(N)/2 +n = zeros(length(Nfreqs), 1); +for k=1:length(Nfreqs) + Ef = round(Nfreqs(k) / Fs * length(y)); % equivalent cut off frequency + n(k) = 20*mean(H(1:Ef)) - 20*mean(N(1:Ef)); +end + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetSHRP.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,81 @@ +function [SHR,F0]=func_GetSHRP(y,Fs, variables, datalen) +%function [f0_time,f0_value,SHR,f0_candidates]=func_GetSHRP(y,Fs,F0MinMax,timestep,SHR_Threshold) +% Input: y, Fs - from wavread +% variables - settings from initialization/setting +% datalen - output data length +% Output: F0 - F0 values +% SHR - Subharmonic-harmonic ratio values +% (and eventually, F0 candidates?) +% Author: Kristine Yu, Department of Linguistics, UCLA, based off code +% by Yen-Liang Shue for func_PraatPitch.m + + +%%%%%%%%%%% Get/set arguments to shrp.m + +% TESTING +% [y,Fs]=wavread('work/beijing_f3_50_a.wav'); % for testing +% F0MinMax = [vars.SHRmin, vars.SHRmax]; % For testing +% windowsize = vars.windowsize; % Set frame_length to 25ms, the VS default, for testing +% frameshift = vars.frameshift; % Set 10 ms frameshift, for testing +% SHR_Threshold = 0.4; % +% frame_precision = 1; % fudge factor for time alignment +% ceiling = 1250; +% med_smooth = 0; CHECK_VOICING = 0; % Leave default: no smoothing, no voice detection + +%%% Get settings + +F0MinMax = [variables.SHRmin, variables.SHRmax]; % Set lower and + % upper bounds for + % f0 estimation + +frameshift = variables.frameshift; % this is in ms +windowsize = variables.windowsize; % also in ms + +SHR_Threshold = variables.SHRThreshold; % Set subharmonic-to-harmonic ratio + +ceiling = 1250; % Leave default 1250 Hz + +med_smooth = 0; CHECK_VOICING = 0; % Leave default: no smoothing, no voice detection + +frame_precision = variables.frame_precision; % how many frames can + % time-alignment be off by, + % when outputting data vectors? + +%%%%%%%%%%% Calculate subharmonic-harmonic ratios and f0 tracks +% Call Xuejing Sun's subharmonic-harmonic ratio based pitch detection +% algorithm shrp.m +% Available for download here +%http://www.mathworks.com/matlabcentral/fileexchange/1230-pitch-determination-algorithm +%http://www.speakingx.com/blog/2008/01/02/pitch-determination + +[f0_time,f0_value,SHR_value,f0_candidates]=shrp(y,Fs,F0MinMax,windowsize,frameshift,SHR_Threshold,ceiling,med_smooth,CHECK_VOICING); + + +%%%%%%%%%%% Postprocess subharmonic-harmonic ratios and f0 tracks + +% Initialize F0 and subharmonic-harmonic ratio values +F0 = zeros(datalen, 1) * NaN; +SHR = zeros(datalen, 1) * NaN; + +t = round(f0_time); % time locations rounded to nearest ms + +start = 0; % Like timecoures from Praat, we might have missing values so pad with NaNs at + % beginning and end if necessary. +finish = t(end); +increment = frameshift; + +for k=start:increment:finish + [val, inx] = min(abs(t - k)); % try to find the closest value + if (abs(t(inx) - k) > frame_precision * frameshift) % no valid value found + continue; + end + + n = round(k / frameshift) + 1; % KY I added a 1 because Matlab index starts at 1, not 0 + if (n < 1 || n > datalen) + continue; + end + + F0(n+1) = f0_value(inx); % f0 values + SHR(n+1) = SHR_value(inx); % SHR values + % I eventually would like to get candidates as well +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_OtherFormants.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,79 @@ +function [F1, F2, F3, F4, B1, B2, B3, B4, err_msg] = func_OtherFormants(wavfile, handles) +% [F0, err] = func_SnackPitch(wavfile, windowsize, frameshift, maxF0, minF0) +% Input: wavfile - input wav file +% Output: F1, F2, F3, F4, B1, B2, B3, B4 +% err_msg - message of error +% Notes: Function attempts to call an external command to produce a formant +% output file which is read back as a vector. Formant output file format should +% be 8 columns of formant values for each frame +% +% Warning: experimental function +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +% get settings and commands +VSData = guidata(handles.VSHandle); +outfile = [wavfile(1:end-3) 'fmt']; + +C = textscan(VSData.vars.FormantsOtherCommand, '%s', 'delimiter', ' '); +C = C{1}; + +command = []; +F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN; +B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN; +err_msg = []; + +for k=1:length(C) + if (strcmp(C{k}, '$wavfile')) + command = [command wavfile ' ']; + elseif (strcmp(C{k}, '$outfile')) + command = [command outfile ' ']; + else + command = [command C{k} ' ']; + end +end + +% attempt to run command +[status, results] = system(command); + +% error occured, exit +if (status ~= 0) + err_msg = 'Unable to execute command.'; + + % try to clean up files + if (exist(outfile, 'file') ~= 0) + delete(outfile); + end + + return; +end + +% now check if outfile exists +if (exist(outfile, 'file') == 0) + err_msg = 'Unable to find formant file.'; + return; +end + +% if file exists, read in the vectors +fid = fopen(outfile, 'rt'); +if (fid == -1) + err_msg = 'Unable to open formant file.'; + return; +end + +C = textscan(fid, '%f %f %f %f %f %f %f %f', 'delimiter', '\n'); +fclose(fid); +F1 = C{1}; +F2 = C{2}; +F3 = C{3}; +F4 = C{4}; +B1 = C{5}; +B2 = C{6}; +B3 = C{7}; +B4 = C{8}; + + +% clean up +delete(outfile); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_OtherPitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,71 @@ +function [F0, err_msg] = func_OtherPitch(wavfile, handles) +% [F0, err] = func_SnackPitch(wavfile, windowsize, frameshift, maxF0, minF0) +% Input: wavfile - input wav file +% Output: F0 +% err_msg - message of error +% Notes: Function attempts to call an external command to produce an F0 +% output file which is read back as a vector. F0 output file format should +% be a column of F0 values for each frame +% +% Warning: experimental function +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +% get settings and commands +VSData = guidata(handles.VSHandle); +outfile = [wavfile(1:end-3) 'f0']; + +C = textscan(VSData.vars.F0OtherCommand, '%s', 'delimiter', ' '); +C = C{1}; + +command = []; +F0 = NaN; +err_msg = []; + +for k=1:length(C) + if (strcmp(C{k}, '$wavfile')) + command = [command wavfile ' ']; + elseif (strcmp(C{k}, '$outfile')) + command = [command outfile ' ']; + else + command = [command C{k} ' ']; + end +end + +% attempt to run command +[status, results] = system(command); + +% error occured, exit +if (status ~= 0) + err_msg = 'Unable to execute command.'; + + % try to clean up files + if (exist(outfile, 'file') ~= 0) + delete(outfile); + end + + return; +end + +% now check if outfile exists +if (exist(outfile, 'file') == 0) + err_msg = 'Unable to find F0 file.'; + return; +end + +% if file exists, read in the vectors +fid = fopen(outfile, 'rt'); +if (fid == -1) + err_msg = 'Unable to open F0 file.'; + return; +end + +C = textscan(fid, '%f'); +fclose(fid); +F0 = C{1}; + + +% clean up +delete(outfile); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_PraatFormants.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,136 @@ +function [F1, F2, F3, F4, B1, B2, B3, B4, err] = func_PraatFormants(wavfile, ... + windowlength, frameshift, frameprecision, datalen) +% [F1, F2, F3, F4, B1, B2, B3, B4, err] = func_PraatFormants(wavfile, windowlength, frameshift, frameprecision, datalen) +% KY Time-stamp: <2010-10-16 21:47:24 amoebe> +% Input: wavfile - input wav file +% windowlength - windowlength in seconds +% frameshift - in seconds +% frameprecision - unitless +% datalen - output data length +% Output: Fx, Bx - formant and bandwidth vectors +% err - error flag +% Notes: This currently only works on a PC. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Modified by Kristine Yu, 2010-10-16 to allow for variable precision in +% matching up time alignment between data vectors. +% +% Copyright UCLA SPAPL 2010 + +% settings +maxFormant = 6000; +iwantfilecleanup = 1; %delete pfmt files when done + +% check if we need to put double quotes around wavfile +if (wavfile(1) ~= '"') + pwavfile = ['"' wavfile '"']; +else + pwavfile = wavfile; +end + +if (ispc) % pc can run praatcon.exe + cmd = sprintf('Windows\\praatcon.exe Windows\\praatformants.praat %s %.3f %.3f %d', pwavfile, frameshift, windowlength, maxFormant); + +elseif (ismac) % mac osx can run Praat using terminal, call Praat from + % Nix/ folder + curr_dir = pwd; + curr_wav = [curr_dir wavfile(2:end)]; + + cmd = sprintf(['MacOS/Praat Windows/praatformants.praat ' ... + '%s %.3f %.3f %d'], curr_wav, frameshift, windowlength, maxFormant); + +else + F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN; + B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN; + err = -1; + return; +end + +% Set name of formant track file +fmtfile = [wavfile '.pfmt']; + +%call up praat + +% for pc +if (ispc) + err = system(cmd); + + if (err ~= 0) % oops, error, exit now + F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN; + B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN; + if (iwantfilecleanup) + if (exist(fmtfile, 'file') ~= 0) + delete(fmtfile); + end + end + return; + end +end + + +% for mac +if (ismac) + err = unix(cmd); + + if (err ~= 0) % oops, error, exit now + F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN; + B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN; + if (iwantfilecleanup) + if (exist(fmtfile, 'file') ~= 0) + delete(fmtfile); + end + end + return; + end +end + +% praat call was successful, return fmt values +F1 = zeros(datalen, 1) * NaN; B1 = zeros(datalen, 1) * NaN; +F2 = zeros(datalen, 1) * NaN; B2 = zeros(datalen, 1) * NaN; +F3 = zeros(datalen, 1) * NaN; B3 = zeros(datalen, 1) * NaN; +F4 = zeros(datalen, 1) * NaN; B4 = zeros(datalen, 1) * NaN; + +% Get formant file + +fid = fopen(fmtfile, 'rt'); + +% read and discard the header +C = textscan(fid, '%s', 1, 'delimiter', '\n'); + +% read the rest +C = textscan(fid, '%f %f %f %f %f %f %f %f %f %f', 'delimiter', '\n', 'TreatAsEmpty', '--undefined--'); +fclose(fid); +t = round(C{1} * 1000); % time locations + +start = 0; % KY changed since Praat doesn't necessarily have data start + % at time = 0 +finish = t(end); +increment = frameshift * 1000; + +for k=start:increment:finish + [val, inx] = min(abs(t - k)); % try to find the closest value + if (abs(t(inx) - k) > frameprecision * frameshift * 1000) % no valid value found + continue; + end + + n = round(k / (frameshift * 1000)) + 1; % KY I added 1 since Matlab + % index starts at 1, not 0 + if (n < 1 || n > datalen) + continue; + end + + F1(n) = C{3}(inx); + B1(n) = C{4}(inx); + F2(n) = C{5}(inx); + B2(n) = C{6}(inx); + F3(n) = C{7}(inx); + B3(n) = C{8}(inx); + F4(n) = C{9}(inx); + B4(n) = C{10}(inx); +end + +if (iwantfilecleanup) + if (exist(fmtfile, 'file') ~= 0) + delete(fmtfile); + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_PraatPitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,136 @@ +function [F0, err] = func_PraatPitch(wavfile, frameshift, frameprecision, minF0, maxF0, ... + silthres, voicethres, octavecost, ... + octavejumpcost, voiunvoicost, ... + killoctavejumps, smooth, smoothbw, ... + interpolate, method, datalen) +% [F0, err = func_PraatPitch(wavfile, frameshift, maxF0, minF0, +% voicethres, octavecost, octavejumpcost, voiunvoicost, datalen) +% Input: wavfile - input wav file +% frameshift - in seconds +% maxF0 - maximum F0 +% minF0 - minimum F0 +% silthres - Silence threshold (Praat specific) +% voicethres - Voice threshold (Praat specific) +% octavecost - Octave Cost (Praat specific) +% octavejumpcost - Octave Jump Cost (Praat specific) +% voiunvoicost - Voiced/unvoiced Cost (Praat specific) +% killoctavejumps - Kill octave jumps? (Praat specific) +% smooth - Smooth? (Praat specific) +% smoothbw - Smoothing bandwidth (Hz) (Praat specific) +% interpolate - Interpolate? (Praat specific) +% method - autocorrelation (ac) or cross-correlation (cc) +% datalen - output data length +% Output: F0 - F0 values +% err - error flag +% Notes: This currently only works on PC and Mac. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Modified by Kristine Yu 2010-10-16 +% Copyright UCLA SPAPL 2010 + +% settings +iwantfilecleanup = 1; %delete files when done + +% check if we need to put double quotes around wavfile +if (wavfile(1) ~= '"') + pwavfile = ['"' wavfile '"']; +else + pwavfile = wavfile; +end + +if (ispc) % pc can run praatcon.exe + cmd = sprintf(['Windows\\praatcon.exe Windows\\praatF0.praat %s %.3f ' ... + '%.3f %.3f %.3f %.3f %.3f %.3f %.3f %d %d %.3f %d %s'], pwavfile, frameshift, minF0, maxF0, silthres, ... + voicethres, octavecost, octavejumpcost, voiunvoicost, ... + killoctavejumps, smooth, smoothbw, interpolate, method); + elseif (ismac) % mac osx can run Praat using terminal, call Praat from + % Nix/ folder + curr_dir = pwd; + curr_wav = [curr_dir wavfile(2:end)]; + + cmd = sprintf(['MacOS/Praat Windows/praatF0.praat %s %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %d %d %.3f %d %s'], curr_wav, frameshift, minF0, maxF0, silthres, voicethres, octavecost, octavejumpcost, voiunvoicost, killoctavejumps, smooth, smoothbw, interpolate, method); + +else % otherwise + F0 = NaN; + err = -1; + return; +end + +%call up praat for pc +if (ispc) + err = system(cmd); + + if (err ~= 0) % oops, error, exit now + F0 = NaN; + if (iwantfilecleanup) + if (exist(f0file, 'file') ~= 0) + delete(f0file); + end + end + return; + end +end + +%call up praat for Mac OSX +if (ismac) + err = unix(cmd); + + if (err ~= 0) % oops, error, exit now + F0 = NaN; + if (iwantfilecleanup) + if (exist(f0file, 'file') ~= 0) + delete(f0file); + end + end + return; + end +end + + +% Get f0 file +if strcmp(method, 'ac') %if autocorrelation, get .praatac file + f0file = [wavfile '.praatac']; +else + f0file = [wavfile '.praatcc']; % else, cross-correlation, get .praatcc file +end + + +% praat call was successful, return F0 values +F0 = zeros(datalen, 1) * NaN; + +fid = fopen(f0file, 'rt'); + +% read the rest +C = textscan(fid, '%f %f', 'delimiter', '\n', 'TreatAsEmpty', '--undefined--'); +fclose(fid); + +t = round(C{1} * 1000); % time locations from praat pitch track + +%KY Since Praat outputs no values in silence/if no f0 value returned, must pad with leading +% undefined values if needed, so we set start time to 0, rather than t(1) + +start = 0; +finish = t(end); +increment = frameshift * 1000; + +for k=start:increment:finish + [val, inx] = min(abs(t - k)); % try to find the closest value + if (abs(t(inx) - k) > frameprecision * frameshift * 1000) % no valid value found + continue; + end + + n = round(k / (frameshift * 1000)) + 1; % KY I added a one since + % Matlab indexing starts at 1 + % not 0 + if (n < 1 || n > datalen) + continue; + end + + F0(n) = C{2}(inx); +end + +if (iwantfilecleanup) + if (exist(f0file, 'file') ~= 0) + delete(f0file); + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_SnackFormants.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,86 @@ +function [F1, F2, F3, F4, B1, B2, B3, B4, err] = func_SnackFormants(wavfile, windowlength, frameshift, preemphasis) +% [F1, F2, F3, F4, B1, B2, B3, B4, err] = func_SnackFormants(wavfile, windowlength, frameshift, preemphasis) +% Input: wavfile - input wav file +% windowlength - windowlength in seconds +% frameshift - in seconds +% preemphasis - wonder what this could be? +% Output: Fx, Bx - formant and bandwidth vectors +% err - error flag +% Notes: If on Windows/PC, this function will call up the Snack executable +% in the Windows folder. Otherwise, it will try to call up Snack - this +% require Snack to be installed beforehand. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +% settings +iwantfilecleanup = 1; %delete tcl,f0,frm files when done +tclfilename = 'tclforsnackformant.tcl'; %produce tcl file to call snack + +% make the wavfile acceptable to tcl in Snack +formantfile = [wavfile(1:end-3) 'frm']; +wavfile = strrep(wavfile, '[', '\['); +wavfile = strrep(wavfile, ']', '\]'); +wavfile = ['"' wavfile '"']; +%wavfile = strrep(wavfile, '\', '\\'); % for PC + +if (ispc) % pc can run snack.exe + wavfile = strrep(wavfile, '\', '\\'); + cmds = sprintf('-windowlength %.3f -framelength %.3f -windowtype Hamming -lpctype 1 -preemphasisfactor %.3f -ds_freq 10000', windowlength, frameshift, preemphasis); + err = system(['Windows\snack.exe formant ' wavfile ' ' cmds]); + +else % for macs and possibly others + %cmd = 'tclsh'; % this is for older macs + cmd = 'wish8.4'; % seems to work for OSX Snow Leopard + %cmd = 'wish84'; % for PC + + fid = fopen(tclfilename, 'wt'); + fprintf(fid, '#!/bin/sh\n'); + fprintf(fid, '# the next line restarts with wish \\\n'); + fprintf(fid, 'exec wish8.4 "$0" "$@"\n\n'); + fprintf(fid, 'package require snack\n\n'); + fprintf(fid, 'snack::sound s\n\n'); + fprintf(fid, 's read %s\n\n', wavfile); + fprintf(fid, 'set fd [open [file rootname %s].frm w]\n', wavfile); + fprintf(fid, 'puts $fd [join [s formant -windowlength %.3f -framelength %.3f -windowtype 1 -lpctype 1 -preemphasisfactor %.3f -ds_freq 10000] \\n]\n', windowlength, frameshift, preemphasis); + fprintf(fid, 'close $fd\n\n'); + fprintf(fid, 'exit'); + fclose(fid); + + err = system([cmd ' ' tclfilename]); +end + +% change back into original file +wavfile = strrep(wavfile, '\[', '['); +wavfile = strrep(wavfile, '\]', ']'); + +% oops, error, exit now +if (err~=0) + F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN; + B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN; + if (iwantfilecleanup) + formantfile = strrep(formantfile, '\\', '\'); + if (exist(formantfile, 'file') ~= 0) + delete(formantfile); + end + + if (exist(tclfilename, 'file') ~= 0) + delete(tclfilename); + end + end + return; +end + +% snack call was successful, read out formant values +[F1,F2,F3,F4,B1,B2,B3,B4] = textread(formantfile, '%f %f %f %f %f %f %f %f'); + +if (iwantfilecleanup) + formantfile = strrep(formantfile, '\\', '\'); + if (exist(formantfile, 'file') ~= 0) + delete(formantfile); + end + + if (exist(tclfilename, 'file') ~= 0) + delete(tclfilename); + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_SnackPitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,90 @@ +function [F0, V, err] = func_SnackPitch(wavfile, windowsize, frameshift, maxF0, minF0) +% [F0, V, err] = func_SnackPitch(wavfile, windowsize, frameshift, maxF0, minF0) +% Input: wavfile - input wav file +% windowlength - windowlength in seconds +% frameshift - in seconds +% maxF0/minF0 - max and min thresholds +% Output: F0, V - F0 and voicing vectors +% err - error flag +% Notes: If on Windows/PC, this function will call up the Snack executable +% in the Windows folder. Otherwise, it will try to call up Snack - this +% require Snack to be installed beforehand. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + + +%settings +iwantfilecleanup = 1; %delete tcl,f0,frm files when done +tclfilename = 'tclforsnackpitch.tcl'; %produce tcl file to call snack + +% make the wavfile acceptable to tcl in Snack +wavfile = strrep(wavfile, '[', '\['); +wavfile = strrep(wavfile, ']', '\]'); +wavfile = ['"' wavfile '"']; +%wavfile = strrep(wavfile, '\', '\\'); % for PC + +if (ispc) % pc can run snack.exe + wavfile = strrep(wavfile, '\', '\\'); + err = system(['Windows\snack.exe pitch ' wavfile ' -method esps -framelength ' num2str(frameshift) ' -windowlength ' num2str(windowsize) ' -maxpitch ' num2str(maxF0) ' -minpitch ' num2str(minF0)]); + +else % for macs and possibly others + %cmd = 'tclsh'; % for older Macs and 'nixes + cmd = 'wish8.4'; % seems to work for OSX Snow Leopard + %cmd = 'wish84'; % for pc + + fid = fopen(tclfilename, 'wt'); + + fprintf(fid, '#!/bin/sh\n'); + fprintf(fid, '# the next line restarts with wish \\\n'); + fprintf(fid, 'exec wish8.4 "$0" "$@"\n\n'); + fprintf(fid, 'package require snack\n\n'); + fprintf(fid, 'snack::sound s\n\n'); + fprintf(fid, 's read %s\n\n', wavfile); + fprintf(fid, 'set fd [open [file rootname %s].f0 w]\n', wavfile); + fprintf(fid, 'puts $fd [join [s pitch -method esps -framelength %f -windowlength %f -maxpitch %d -minpitch %d] \\n]\n', frameshift, windowsize, maxF0, minF0); + fprintf(fid, 'close $fd\n\n'); + fprintf(fid, 'exit'); + fclose(fid); + + err = system([cmd ' ' tclfilename]); + +end + +% change back into original file +wavfile = strrep(wavfile, '\[', '['); +wavfile = strrep(wavfile, '\]', ']'); +pitchfile = [wavfile(2:end-4) 'f0']; % this should be where the F0's are stored + +% oops, exit now +if (err ~= 0) + F0 = NaN; + V = NaN; + if (iwantfilecleanup) + pitchfile = strrep(pitchfile, '\\', '\'); + if (exist(pitchfile, 'file') ~= 0) + delete(pitchfile); + end + + if (exist(tclfilename, 'file') ~= 0) + delete(tclfilename); + end + end + return; +end + +% snack executed successfully, read out the F0 values +[F0, V, dummy1, dummy2] = textread(pitchfile, '%f %f %f %f'); + +if (iwantfilecleanup) + pitchfile = strrep(pitchfile, '\\', '\'); + if (exist(pitchfile, 'file') ~= 0) + delete(pitchfile); + end + + if (exist(tclfilename, 'file') ~= 0) + delete(tclfilename); + end +end + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_StraightPitch.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,153 @@ +function [F0, V] = func_StraightPitch(y, Fs, variables, textgridfile) +% [F0, V] = func_StraightPitch(y, Fs, variables, textgridfile) +% Input: y, Fs - from wavread +% variables - settings +% textgridfile - this is optional +% Output: F0, V - F0 and voicing vectors +% Notes: This function calls the Straight functions. Using textgrid +% segmentation helps to speed up the processing. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +maxF0 = variables.maxstrF0; +minF0 = variables.minstrF0; +maxdur = variables.maxstrdur; + +prmF0in.DisplayPlots = 0; +prmF0in.ThresholdForVUV = 0.1; +prmF0in.ThresholdForSilence = 1; +prmF0in.F0searchLowerBound = minF0; +prmF0in.F0searchUpperBound = maxF0; +%prmF0in.VUVthresholdofAC1 = 0.9000; + +warning off + +% break up the file if it is too big (i.e. > 15sec) +if (nargin == 3) % do the whole file, no textgrid data available + L = floor(length(y)/Fs * 1000) - 1; + F0 = zeros(L, 1); + + if (length(y) / Fs > maxdur) + % find suitable places to chop + cnt = 1; + startx = 1; + endx = startx + floor(maxdur*Fs); + isgood = 1; + + while(startx < length(y)) + if (startx == 1) + yseg = y(startx : endx); % extra millisecond + else + yseg = y(startx - floor(F0 / 1000) - 10 : endx); % extra millisecond + end + %fprintf('Processing segment %d to %d\n', startx, endx); + + try + [F0seg, V, auxouts, prmF0out] = MulticueF0v14(yseg,Fs,prmF0in); + catch + isgood = 0; + break; + end + + F0(cnt:cnt+length(F0seg)-1) = F0seg; + cnt = cnt + length(F0seg); + startx = endx + 1; + + remainder = length(y) - endx - 1; + if (remainder > maxdur*Fs) + endx = startx + floor(maxdur*Fs); + else + endx = length(y); + end + end + + if (~isgood) % multicue failed + fprintf('Multicue failed: switching to exstraightsource\n'); + F0 = exstraightsource(y,Fs,prmF0in); + F0 = F0(1:L)'; + V = ones(size(F0seg)); + end + + else + try + [F0, V, auxouts, prmF0out] = MulticueF0v14(y,Fs,prmF0in); + catch + fprintf('Multicue failed: switching to exstraightsource\n'); + F0 = exstraightsource(y,Fs, prmF0in); + F0 = F0(1:L)'; + V = ones(size(F0)); + end + end +else % use textgrid data + % get the labels to ignore from the settings + tbuffer = variables.tbuffer; + ignorelabels = textscan(variables.TextgridIgnoreList, '%s', 'delimiter', ','); + ignorelabels = ignorelabels{1}; + + [labels, start, stop] = func_readTextgrid(textgridfile); + + labels_tmp = []; + start_tmp = []; + stop_tmp = []; + + for k=1:length(variables.TextgridTierNumber) + inx = variables.TextgridTierNumber(k); + if (inx <= length(labels)) + labels_tmp = [labels_tmp; labels{inx}]; + start_tmp = [start_tmp; start{inx}]; + stop_tmp = [stop_tmp; stop{inx}]; + end + end + + labels = labels_tmp; + start = start_tmp * 1000; % milliseconds + stop = stop_tmp * 1000; % milliseconds + + L = floor(length(y) / Fs * 1000) - 1; + + F0 = zeros(L, 1) * NaN; + V = zeros(L, 1) * NaN; + + for k=1:length(start) + + switch(labels{k}) + case ignorelabels + continue; % skip anything that is within the ignore list + end + + tstart = start(k) - tbuffer; + tstop = stop(k) + tbuffer; + + sstart = floor(tstart / 1000 * Fs); + sstop = ceil(tstop / 1000 * Fs); + + sstart(sstart <= 0) = 1; + sstop(sstop > length(y)) = length(y); + + yseg = y(sstart:sstop); + + try + [F0seg, Vseg, auxouts, prmF0out] = MulticueF0v14(yseg,Fs,prmF0in); + catch + fprintf('Multicue failed: switching to exstraightsource\n'); + F0seg = exstraightsource(yseg,Fs,prmF0in); + F0seg = F0seg(2:end-1)'; + Vseg = ones(size(F0seg)); + end + + tstart = floor(tstart); + tstart(tstart <= 0) = 1; + F0(tstart:tstart+length(F0seg)-1) = F0seg; + V(tstart:tstart+length(Vseg)-1) = Vseg; + + if (length(F0) > L) + F0 = F0(1:L); + end + + end + +end + +% sometimes Straight outputs 0s for F0 +F0(F0 == 0) = NaN; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_VS2ssff.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,42 @@ +function func_VS2ssff(data, id, outfile, variables) +% func_VS2ssff(data, id, outfile, variables) +% Notes: Saves the contents of a matfile into an EMU compatible output. +% +% Author: Yen-Liang Shue and Henry Tehrani, UCLA +% Copyright UCLA SPAPL 2009 + +% ssffsize=str2mat('CHAR', 'BYTE', 'SHORT', 'LONG', 'FLOAT', 'DOUBLE'); +% matsize =str2mat('uchar', 'int8', 'int16', 'int32', 'float32', 'float64'); + +%create ssff header +samplerate = 1000 / variables.frameshift; +starttime = 0.0; +hdr=sprintf('%s\n', 'SSFF -- (c) SHLRC'); +hdr=sprintf('%s%s\n', hdr, 'Machine IBM-PC'); +hdr=sprintf('%s%s %i\n', hdr, 'Record_Freq', samplerate); +hdr=sprintf('%s%s %5.2f\n', hdr, 'Start_Time',starttime); +%hdr=sprintf('%s%s %s\n', hdr, 'Comment', comment); + +hdr = sprintf('%s%s %s %s %i\n', hdr, 'Column', id, 'FLOAT', 1); +hdr=sprintf('%s%s\n', hdr, '-----------------'); +%done with ssff header + +% added 3/17/2010 - EMU is unable to read NaN +NaNvalue = str2double(variables.NotANumber); +if (isnan(NaNvalue)) + NaNvalue = 0; % this is the default NaN value +end + +data(isnan(data)) = NaNvalue; +data(isinf(data)) = NaNvalue; + +fid=fopen(outfile,'w'); +%write the header +fprintf(fid, '%s', hdr); +%write the parameter +fwrite(fid,data,'float32', 0,'ieee-le'); + +fclose(fid); + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_buildMData.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,217 @@ +function mdata = func_buildMData(matfile, smoothwin) +% mdata = func_buildMData(matfile, smoothwin) +% Input: mat filename +% smoothing window size (0 denotes no smoothing) +% Output: mat data structure +% Notes: Function tries to construct as many parameters as possible based +% on the parameters currently in the mat file. Some parameters will have a +% different variable name to what is originally stored in the mat file: +% e.g. H1 is actually the uncorrected harmonic (H1u), it is stored this way +% for compatability reasons. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +mdata = load(matfile); + +% these are for compatibility with VS0 matfiles +if (~isfield(mdata, 'HF0algorithm')) + mdata.HF0algorithm = 'F0 (Straight)'; +end + +if (~isfield(mdata, 'AFMTalgorithm')) + mdata.AFMTalgorithm = 'F1, F2, F3, F4 (Snack)'; +end + +if (~isfield(mdata, 'Fs')) + mdata.Fs = 16000; +end + +% get the right F0 +F0 = func_parseF0(mdata, mdata.HF0algorithm); +[F1, F2, F3] = func_parseFMT(mdata, mdata.AFMTalgorithm); + +% can't do much without F0 or FMTs +if (isempty(F0) || isempty(F1)) + return; +end + +% get bandwidth mapping +B1 = func_getBWfromFMT(F1, F0, 'hm'); +B2 = func_getBWfromFMT(F2, F0, 'hm'); +B3 = func_getBWfromFMT(F3, F0, 'hm'); + +% Hx +if (isfield(mdata, 'H1')) + mdata.H1u = mdata.H1; % H1 is actually the uncorrected harmonic + mdata.H1c = mdata.H1u - func_correct_iseli_z(F0, F1, B1, mdata.Fs); % correct for F1 + mdata.H1c = mdata.H1c - func_correct_iseli_z(F0, F2, B2, mdata.Fs); % correct for F2 + if (smoothwin~=0) + mdata.H1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1u); + mdata.H1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1c); + end + %mdata = rmfield(mdata, 'H1'); % remove H1 to remove confusion +end + +if (isfield(mdata, 'H2')) + mdata.H2u = mdata.H2; % H2 is actually the uncorrected harmonic + mdata.H2c = mdata.H2u - func_correct_iseli_z(2*F0, F1, B1, mdata.Fs); + mdata.H2c = mdata.H2c - func_correct_iseli_z(2*F0, F2, B2, mdata.Fs); + if (smoothwin~=0) + mdata.H2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2u); + mdata.H2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2c); + end + %mdata = rmfield(mdata, 'H2'); +end + +if (isfield(mdata, 'H4')) + mdata.H4u = mdata.H4; % H4 is actually the uncorrected harmonic + mdata.H4c = mdata.H4u - func_correct_iseli_z(4*F0, F1, B1, mdata.Fs); + mdata.H4c = mdata.H4c - func_correct_iseli_z(4*F0, F2, B2, mdata.Fs); + if (smoothwin~=0) + mdata.H4u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H4u); + mdata.H4c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H4c); + end + %mdata = rmfield(mdata, 'H4'); +end + + +% Ax +if (isfield(mdata, 'A1')) + mdata.A1u = mdata.A1; % A1 is actually the uncorrected amplitude + mdata.A1c = mdata.A1u - func_correct_iseli_z(F1, F1, B1, mdata.Fs); + mdata.A1c = mdata.A1c - func_correct_iseli_z(F1, F2, B3, mdata.Fs); + if (smoothwin~=0) + mdata.A1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A1u); + mdata.A1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A1c); + end + %mdata = rmfield(mdata, 'A1'); +end + +if (isfield(mdata, 'A2')) + mdata.A2u = mdata.A2; % A2 is acutally the uncorrected amplitude + mdata.A2c = mdata.A2u - func_correct_iseli_z(F2, F1, B1, mdata.Fs); + mdata.A2c = mdata.A2c - func_correct_iseli_z(F2, F2, B2, mdata.Fs); + if (smoothwin~=0) + mdata.A2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A2u); + mdata.A2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A2c); + end + %mdata = rmfield(mdata, 'A2'); +end + +if (isfield(mdata, 'A3')) + mdata.A3u = mdata.A3; % A3 is actually the uncorrected amplitude + mdata.A3c = mdata.A3u - func_correct_iseli_z(F3, F1, B1, mdata.Fs); + mdata.A3c = mdata.A3c - func_correct_iseli_z(F3, F2, B2, mdata.Fs); + mdata.A3c = mdata.A3c - func_correct_iseli_z(F3, F3, B3, mdata.Fs); + if (smoothwin~=0) + mdata.A3u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A3u); + mdata.A3c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A3c); + end + %mdata = rmfield(mdata, 'A3'); +end + + +% the uncorrected combo parameters +if (isfield(mdata, 'H1') && isfield(mdata, 'H2')) + mdata.H1H2u = mdata.H1 - mdata.H2; + if (smoothwin ~= 0) + mdata.H1H2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1H2u); + end +end + +if (isfield(mdata, 'H2') && isfield(mdata, 'H4')) + mdata.H2H4u = mdata.H2 - mdata.H4; + if (smoothwin ~= 0) + mdata.H2H4u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2H4u); + end +end + +if (isfield(mdata, 'H1') && isfield(mdata, 'A1')) + mdata.H1A1u = mdata.H1 - mdata.A1; + if (smoothwin ~= 0) + mdata.H1A1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A1u); + end +end + +if (isfield(mdata, 'H1') && isfield(mdata, 'A2')) + mdata.H1A2u = mdata.H1 - mdata.A2; + if (smoothwin ~= 0) + mdata.H1A2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A2u); + end +end + +if (isfield(mdata, 'H1') && isfield(mdata, 'A3')) + mdata.H1A3u = mdata.H1 - mdata.A3; + if (smoothwin ~= 0) + mdata.H1A3u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A3u); + end +end + +% this section is included for old VS compatibility, previously, the +% corrected versions of HxHx and HxAx were stored as HxHx and HxAx (i.e. +% without the "c" +if (isfield(mdata, 'H1H2')) + mdata.H1H2c = mdata.H1H2; +end + +if (isfield(mdata, 'H2H4')) + mdata.H2H4c = mdata.H2H4; +end + +if (isfield(mdata, 'H1A1')) + mdata.H1A1c = mdata.H1A1; +end + +if (isfield(mdata, 'H1A2')) + mdata.H1A2c = mdata.H1A2; +end + +if (isfield(mdata, 'H1A3')) + mdata.H1A3c = mdata.H1A3; +end + + +% check if the others require smoothing +if (smoothwin ~= 0) + if (isfield(mdata, 'H1H2c')) + mdata.H1H2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1H2c); + end + + if (isfield(mdata, 'H2H4c')) + mdata.H2H4c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2H4c); + end + + if (isfield(mdata, 'H1A1c')) + mdata.H1A1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A1c); + end + + if (isfield(mdata, 'H1A2c')) + mdata.H1A2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A2c); + end + + if (isfield(mdata, 'H1A3c')) + mdata.H1A3c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A3c); + end + + if (isfield(mdata, 'CPP')) + mdata.CPP = filter(ones(smoothwin,1)/smoothwin, 1, mdata.CPP); + end + + if (isfield(mdata, 'HNR05')) + mdata.HNR05 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR05); + end + + if (isfield(mdata, 'HNR15')) + mdata.HNR15 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR15); + end + + if (isfield(mdata, 'HNR25')) + mdata.HNR25 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR25); + end + + if (isfield(mdata, 'HNR35')) + mdata.HNR35 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR35); + end + +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_correct_iseli_z.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,33 @@ +function corr = func_correct_iseli_z(f, Fx, Bx, Fs) +% function corr = correct_iseli_z(f, Fx, Bx, Fs) +% Inverse-filtering of vocal tract resonance (formant). Correction is in dB, and dependent on Fs +% f [Hz]: the frequency in question, e.g. Fo for the first harmonic, 2Fo for the second harmonic, or any other frequency +% Fx [Hz]: x-th formant frequency +% Bx [Hz]: x-th formant bandwidth (if you don't know the exact value, try an estimate) +% Fs [Hz]: sampling frequency +% Usage example for correction of first two harmonics regarding first formant F1/B1: +% H1_corr = H1 - correct_iseli_z(Fo,F1,B1_c,Fs); +% H2_corr = H2 - correct_iseli_z(2*Fo,F1,B1_c,Fs); +% +% Author: Markus Iseli, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2003 +% BibTex entry: +% @INPROCEEDINGS{Iseli04, +% AUTHOR = "M. Iseli and A. Alwan", +% TITLE = "AN IMPROVED CORRECTION FORMULA FOR THE ESTIMATION OF HARMONIC MAGNITUDES AND ITS APPLICATION TO OPEN QUOTIENT ESTIMATION", +% YEAR = "1999", +% volume = "", +% pages = "", +% address = "Montreal, Canada", +% month = "May", +% } + +r = exp(-pi*Bx/Fs); +omega_x = 2*pi*Fx/Fs; +omega = 2*pi*f/Fs; +a = r.^2 + 1 - 2*r.*cos(omega_x + omega); +b = r.^2 + 1 - 2*r.*cos(omega_x - omega); +corr = -10*(log10(a)+log10(b)); % not normalized: H(z=0)~=0 + +num = r.^2 + 1 - 2*r.*cos(omega_x); % sqrt of numerator, omega=0 +corr = -10*(log10(a)+log10(b)) + 20*log10(num); % normalized: H(z=0)=1 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_getBWfromFMT.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,37 @@ +function BW = func_getBWfromFMT(FMT, voiced, method) +% formant to bandwidth mapping function +% +% Author: Yen-Liang Shue and Markus Iseli, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +if (nargin == 2) % use the Mannell formula + BW = (80 + 120 * FMT/5000) * (2 - voiced); + +elseif (nargin == 3 && strcmp(method, 'hm')) % use the Hawks and Miller formula + F0 = voiced; + BW = getbw_HawksMiller(FMT, F0)'; + +end + + +%------------------------------------------------------------------------- +function BW = getbw_HawksMiller(FMT,F0) +% Reference: Hawks, Miller, "A formant bandwidth estimation procedure for vowel +% synthesis," JASA, vol 97, no. 2, 1995 + +[r, c] = size(FMT); +if (r > c) + FMT = FMT'; +end + +S = 1+0.25*(F0-132)/88; % bandwidth scaling factor as a function of F0 + +% coefficients C1 (for Fx<500 Hz) and C2 (Fx>=500Hz) +C1 = [165.327516, -6.73636734e-1, 1.80874446e-3, -4.52201682e-6, 7.49514000e-9, -4.70219241e-12]; +C2 = [15.8146139, 8.10159009e-2, -9.79728215e-5, 5.28725064e-8, -1.07099364e-11, 7.91528509e-16]; + +F = [ones(1, length(FMT)); FMT; FMT.^2; FMT.^3; FMT.^4; FMT.^5]; +mask = FMT<500; % Fx < 500 Hz +mask = repmat(mask,length(C1),1); + +BW = S' .* (C1*(F .* mask) + C2*(F .* ~mask));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_getfileinx.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,23 @@ +function fileinx = func_getfileinx(param) +% fileinx = func_getfileinx(param) +% Input: param +% Output: file index +% Notes: Function is a helper function for outputting to text. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +switch (param) + case {'F0 - Straight (strF0)', 'F0 - Snack (sF0)', 'F0 - Praat (pF0)', 'F0 - Other (oF0)', 'shrF0 (shrF0)', 'CPP (CPP)', 'Energy (Energy)', 'HNR05 (HNR05)', 'HNR15 (HNR15)', 'HNR25 (HNR25)', 'HNR35 (HNR35)'} + fileinx = 1; + case {'F1 - Snack (sF1)', 'F2 - Snack (sF2)', 'F3 - Snack (sF3)', 'F4 - Snack (sF4)', 'F1 - Praat (pF1)', 'F2 - Praat (pF2)', 'F3 - Praat (pF3)', 'F4 - Praat (pF4)', 'F1 - Other (oF1)', 'F2 - Other (oF2)', 'F3 - Other (oF3)', 'F4 - Other (oF4)', 'B1 - Snack (sB1)', 'B2 - Snack (sB2)', 'B3 - Snack (sB3)', 'B4 - Snack (sB4)', 'B1 - Other (oB1)', 'B2 - Other (oB2)', 'B3 - Other (oB3)', 'B4 - Other (oB4)'} + fileinx = 2; + case {'H1* (H1c)', 'H2* (H2c)', 'H4* (H4c)', 'A1* (A1c)', 'A2* (A2c)', 'A3* (A3c)', 'H1 (H1u)', 'H2 (H2u)', 'H4 (H4u)', 'A1 (A1u)', 'A2 (A2u)', 'A3 (A3u)'} + fileinx = 3; + case {'H1*-H2* (H1H2c)', 'H2*-H4* (H2H4c)', 'H1-H2 (H1H2u)', 'H2-H4 (H2H4u)', 'SHR (SHR)'} + fileinx = 4; + case {'H1*-A1* (H1A1c)', 'H1*-A2* (H1A2c)', 'H1*-A3* (H1A3c)', 'H1-A1 (H1A1u)', 'H1-A2 (H1A2u)', 'H1-A3 (H1A3u)'} + fileinx = 5; + otherwise + fileinx = -1; +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_getmanualdataparameterlist.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,66 @@ +function paramlist = func_getmanualdataparameterlist(param) +% paramlist = func_getmanualdataparameterlist(param) +% Input: param - parameter (optional) +% Output: paramlist - list of parameters; or +% index of the parameter in the list +% Notes: Dual purpose function +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +paramlist = {'H1u (H1)', ... + 'H2u (H2)', ... + 'H4u (H4)', ... + 'A1u (A1)', ... + 'A2u (A2)', ... + 'A3u (A3)', ... + 'H1*-H2* (H1H2c)', ... + 'H2*-H4* (H2H4c)', ... + 'H1*-A1* (H1A1c)', ... + 'H1*-A2* (H1A2c)', ... + 'H1*-A3* (H1A3c)', ... + 'CPP (CPP)', ... + 'Energy (Energy)', ... + 'HNR05 (HNR05)', ... + 'HNR15 (HNR15)', ... + 'HNR25 (HNR25)', ... + 'HNR35 (HNR35)', ... + 'SHR (SHR)', ... + 'shrF0 (shrF0)', ... + 'F0 - Straight (strF0)', ... + 'F0 - Snack (sF0)', ... + 'F0 - Praat (pF0)', ... + 'F0 - Other (oF0)', ... + 'F1 - Snack (sF1)', ... + 'F2 - Snack (sF2)', ... + 'F3 - Snack (sF3)', ... + 'F4 - Snack (sF4)', ... + 'F1 - Praat (pF1)', ... + 'F2 - Praat (pF2)', ... + 'F3 - Praat (pF3)', ... + 'F4 - Praat (pF4)', ... + 'F1 - Other (oF1)', ... + 'F2 - Other (oF2)', ... + 'F3 - Other (oF3)', ... + 'F4 - Other (oF4)', ... + 'B1 - Snack (sB1)', ... + 'B2 - Snack (sB2)', ... + 'B3 - Snack (sB3)', ... + 'B4 - Snack (sB4)', ... + 'B1 - Other (oB1)', ... + 'B2 - Other (oB2)', ... + 'B3 - Other (oB3)', ... + 'B4 - Other (oB4)', ... + }; + +% user is asking for index to a param +if (nargin == 1) + for k=1:length(paramlist) + if (strcmp(paramlist{k}, param)) + paramlist = k; + return; + end + end + paramlist = -1; % param not found in list +end + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_getoutputparameterlist.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,77 @@ +function paramlist = func_getoutputparameterlist(param) +% paramlist = func_getoutputparameterlist(param) +% Input: param - parameter (optional) +% Output: paramlist - list of parameters; or +% index of the parameter in the list +% Notes: Dual purpose function +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +paramlist = {'H1* (H1c)', ... + 'H2* (H2c)', ... + 'H4* (H4c)', ... + 'A1* (A1c)', ... + 'A2* (A2c)', ... + 'A3* (A3c)', ... + 'H1*-H2* (H1H2c)', ... + 'H2*-H4* (H2H4c)', ... + 'H1*-A1* (H1A1c)', ... + 'H1*-A2* (H1A2c)', ... + 'H1*-A3* (H1A3c)', ... + 'CPP (CPP)', ... + 'Energy (Energy)', ... + 'HNR05 (HNR05)', ... + 'HNR15 (HNR15)', ... + 'HNR25 (HNR25)', ... + 'HNR35 (HNR35)', ... + 'SHR (SHR)', ... + 'shrF0 (shrF0)', ... + 'H1 (H1u)', ... + 'H2 (H2u)', ... + 'H4 (H4u)', ... + 'A1 (A1u)', ... + 'A2 (A2u)', ... + 'A3 (A3u)', ... + 'H1-H2 (H1H2u)', ... + 'H2-H4 (H2H4u)', ... + 'H1-A1 (H1A1u)', ... + 'H1-A2 (H1A2u)', ... + 'H1-A3 (H1A3u)', ... + 'F0 - Straight (strF0)', ... + 'F0 - Snack (sF0)', ... + 'F0 - Praat (pF0)', ... + 'F0 - Other (oF0)', ... + 'F1 - Snack (sF1)', ... + 'F2 - Snack (sF2)', ... + 'F3 - Snack (sF3)', ... + 'F4 - Snack (sF4)', ... + 'F1 - Praat (pF1)', ... + 'F2 - Praat (pF2)', ... + 'F3 - Praat (pF3)', ... + 'F4 - Praat (pF4)', ... + 'F1 - Other (oF1)', ... + 'F2 - Other (oF2)', ... + 'F3 - Other (oF3)', ... + 'F4 - Other (oF4)', ... + 'B1 - Snack (sB1)', ... + 'B2 - Snack (sB2)', ... + 'B3 - Snack (sB3)', ... + 'B4 - Snack (sB4)', ... + 'B1 - Other (oB1)', ... + 'B2 - Other (oB2)', ... + 'B3 - Other (oB3)', ... + 'B4 - Other (oB4)', ... + }; + +% user is asking for index to a param +if (nargin == 1) + for k=1:length(paramlist) + if (strcmp(paramlist{k}, param)) + paramlist = k; + return; + end + end + paramlist = -1; % param not found in list +end + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_getparameterlist.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,40 @@ +function paramlist = func_getparameterlist(param) +% paramlist = func_getparameterlist(param) +% Input: param - parameter (optional) +% Output: paramlist - list of parameters; or +% index of the parameter in the list +% Notes: Dual purpose function +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + + +paramlist = {'F0 (Straight)', ... + 'F0 (Snack)', ... + 'F0 (Praat)', ... + 'F0 (Other)', ... + 'F1, F2, F3, F4 (Snack)', ... + 'F1, F2, F3, F4 (Praat)', ... + 'F1, F2, F3, F4 (Other)', ... + 'H1, H2, H4', ... + 'A1, A2, A3' ... + 'H1*-H2*, H2*-H4*', ... + 'H1*-A1*, H1*-A2*, H1*-A3*', ... + 'Energy', ... + 'CPP', ... + 'Harmonic to Noise Ratios - HNR', ... + 'Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0', ... + }; + + +% user is asking for index to a param +if (nargin == 1) + for k=1:length(paramlist) + if (strcmp(paramlist{k}, param)) + paramlist = k; + return; + end + end + paramlist = -1; % param not found in list +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_parseF0.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,30 @@ +function F0 = func_parseF0(matdata, F0algorithm) +% F0 = func_parseF0(matdata, F0algorithm) +% Input: matdata - mat data +% F0algorithm - F0 algorithm to use +% Output: F0 vectir +% Notes: choose the F0 depending on what is specified +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 +F0 = []; +switch(F0algorithm) + case {'F0 (Straight)'} + if (isfield(matdata, 'strF0')) + F0 = matdata.strF0; + end + case {'F0 (Snack)'} + if (isfield(matdata, 'sF0')) + F0 = matdata.sF0; + end + case {'F0 (Praat)'} + if (isfield(matdata, 'pF0')) + F0 = matdata.pF0; + end + case {'F0 (Other)'} + if (isfield(matdata, 'oF0')) + F0 = matdata.oF0; + end + otherwise + F0 = []; +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_parseFMT.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,40 @@ +function [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm) +% [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm) +% Input: matdata - mat data +% FMTalgorithm - FMT algorithm to use +% Output: F1, F2, F3 vectir +% Notes: choose the FMT vectors depending on what is specified +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +F1 = []; F2 = []; F3 = []; + +switch(FMTalgorithm) + case {'F1, F2, F3, F4 (Snack)'} + if (isfield(matdata, 'sF1') && isfield(matdata, 'sF2') && isfield(matdata, 'sF3')) + F1 = matdata.sF1; + F2 = matdata.sF2; + F3 = matdata.sF3; + end + + case {'F1, F2, F3, F4 (Praat)'} + if (isfield(matdata, 'pF1') && isfield(matdata, 'pF2') && isfield(matdata, 'pF3')) + F1 = matdata.pF1; + F2 = matdata.pF2; + F3 = matdata.pF3; + end + + case {'F1, F2, F3, F4 (Other)'} + if (isfield(matdata, 'oF1') && isfield(matdata, 'oF2') && isfield(matdata, 'oF3')) + F1 = matdata.oF1; + F2 = matdata.oF2; + F3 = matdata.oF3; + end + + otherwise + F1 = []; + F2 = []; + F3 = []; + +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_parseParameters.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,223 @@ +function new_paramlist = func_parseParameters(paramlist, handles, matfile, data_len) +% new_paramlist = func_parseParameters(paramlist, handles, matfile, data_len) +% sort through the parameter list and find dependencies, then output a new +% parameter list with the new param list +% also check data_len to ensure existing parameters have the same length +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +VSData = guidata(handles.VSHandle); + +% handles carries the F0 and FMT methods +F0algorithm = VSData.vars.F0algorithm; +FMTalgorithm = VSData.vars.FMTalgorithm; + +% vector stores which param to enable: +%0 = disable, 1 = calculate, 2 = conditional calculate +new_param_vec = zeros(length(func_getparameterlist()), 1); + +for k=1:length(paramlist) + if (strcmp(paramlist{k}, 'H1*-A1*, H1*-A2*, H1*-A3*')) + new_param_vec(func_getparameterlist('H1*-A1*, H1*-A2*, H1*-A3*')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + new_param_vec(func_getparameterlist(FMTalgorithm)) = new_param_vec(func_getparameterlist(FMTalgorithm)) + 2; + new_param_vec(func_getparameterlist('H1, H2, H4')) = new_param_vec(func_getparameterlist('H1, H2, H4')) + 2; + new_param_vec(func_getparameterlist('A1, A2, A3')) = new_param_vec(func_getparameterlist('A1, A2, A3')) + 2; + + elseif (strcmp(paramlist{k}, 'H1*-H2*, H2*-H4*')) + new_param_vec(func_getparameterlist('H1*-H2*, H2*-H4*')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + new_param_vec(func_getparameterlist(FMTalgorithm)) = new_param_vec(func_getparameterlist(FMTalgorithm)) + 2; + new_param_vec(func_getparameterlist('H1, H2, H4')) = new_param_vec(func_getparameterlist('H1, H2, H4')) + 2; + + elseif (strcmp(paramlist{k}, 'Energy')) + new_param_vec(func_getparameterlist('Energy')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + + elseif (strcmp(paramlist{k}, 'CPP')) + new_param_vec(func_getparameterlist('CPP')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + + elseif (strcmp(paramlist{k}, 'Harmonic to Noise Ratios - HNR')) + new_param_vec(func_getparameterlist('Harmonic to Noise Ratios - HNR')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + + elseif (strcmp(paramlist{k}, 'Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0')) + new_param_vec(func_getparameterlist('Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0')) = 1; + + elseif (strcmp(paramlist{k}, 'A1, A2, A3')) + new_param_vec(func_getparameterlist('A1, A2, A3')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + new_param_vec(func_getparameterlist(FMTalgorithm)) = new_param_vec(func_getparameterlist(FMTalgorithm)) + 2; + + elseif (strcmp(paramlist{k}, 'H1, H2, H4')) + new_param_vec(func_getparameterlist('H1, H2, H4')) = 1; + new_param_vec(func_getparameterlist(F0algorithm)) = new_param_vec(func_getparameterlist(F0algorithm)) + 2; + + elseif (strcmp(paramlist{k}, 'F1, F2, F3, F4 (Snack)')) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Snack)')) = 1; + + elseif (strcmp(paramlist{k}, 'F1, F2, F3, F4 (Praat)')) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Praat)')) = 1; + + elseif (strcmp(paramlist{k}, 'F1, F2, F3, F4 (Other)') && VSData.vars.FormantsOtherEnable == 1) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Other)')) = 1; + + elseif (strcmp(paramlist{k}, 'F0 (Straight)')) + new_param_vec(func_getparameterlist('F0 (Straight)')) = 1; + + elseif (strcmp(paramlist{k}, 'F0 (Snack)')) + new_param_vec(func_getparameterlist('F0 (Snack)')) = 1; + + elseif (strcmp(paramlist{k}, 'F0 (Praat)')) + new_param_vec(func_getparameterlist('F0 (Praat)')) = 1; + + elseif (strcmp(paramlist{k}, 'F0 (Other)') && VSData.vars.F0OtherEnable == 1) + new_param_vec(func_getparameterlist('F0 (Other)')) = 1; + end + +end + +% check the conditional parameters to see whether they already exist in the +% matfile +if (exist(matfile, 'file')) + matdata = load(matfile); + + if (mod(new_param_vec(func_getparameterlist('F0 (Straight)')), 2) == 0 && isfield(matdata, 'strF0')) + if (length(matdata.strF0) == data_len) + new_param_vec(func_getparameterlist('F0 (Straight)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F0 (Snack)')), 2) == 0 && isfield(matdata, 'sF0')) + if (length(matdata.sF0) == data_len) + new_param_vec(func_getparameterlist('F0 (Snack)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F0 (Praat)')), 2) == 0 && isfield(matdata, 'pF0')) + if (length(matdata.pF0) == data_len) + new_param_vec(func_getparameterlist('F0 (Praat)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F0 (Other)')), 2) == 0 && isfield(matdata, 'oF0')) + if (length(matdata.sF0) == data_len) + new_param_vec(func_getparameterlist('F0 (Other)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Snack)')), 2) == 0 && isfield(matdata, 'sF1')) + if (length(matdata.sF1) == data_len) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Snack)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Praat)')), 2) == 0 && isfield(matdata, 'pF1')) + if (length(matdata.sF1) == data_len) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Praat)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Other)')), 2) == 0 && isfield(matdata, 'oF1')) + if (length(matdata.sF1) == data_len) + new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Other)')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('A1, A2, A3')), 2) == 0 && isfield(matdata, 'A1')) + if (length(matdata.A1) == data_len) + new_param_vec(func_getparameterlist('A1, A2, A3')) = 0; + end + end + + if (mod(new_param_vec(func_getparameterlist('H1, H2, H4')), 2) == 0 && isfield(matdata, 'H1')) + if (length(matdata.H1) == data_len) + new_param_vec(func_getparameterlist('H1, H2, H4')) = 0; + end + end + +end + +new_param_vec(new_param_vec ~= 0) = 1; + +% now build list with the proper processing order of the parameters +new_paramlist = cell(sum(new_param_vec), 1); +cnt = 1; + +if (new_param_vec(func_getparameterlist('F0 (Straight)')) == 1) + new_paramlist{cnt} = 'F0 (Straight)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F0 (Snack)')) == 1) + new_paramlist{cnt} = 'F0 (Snack)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F0 (Praat)')) == 1) + new_paramlist{cnt} = 'F0 (Praat)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F0 (Other)')) == 1 && VSData.vars.F0OtherEnable == 1) + new_paramlist{cnt} = 'F0 (Other)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Snack)')) == 1) + new_paramlist{cnt} = 'F1, F2, F3, F4 (Snack)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Praat)')) == 1) + new_paramlist{cnt} = 'F1, F2, F3, F4 (Praat)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('F1, F2, F3, F4 (Other)')) == 1 && VSData.vars.FormantsOtherEnable == 1) + new_paramlist{cnt} = 'F1, F2, F3, F4 (Other)'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('A1, A2, A3')) == 1) + new_paramlist{cnt} = 'A1, A2, A3'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('H1, H2, H4')) == 1) + new_paramlist{cnt} = 'H1, H2, H4'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('Energy')) == 1) + new_paramlist{cnt} = 'Energy'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('CPP')) == 1) + new_paramlist{cnt} = 'CPP'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('Harmonic to Noise Ratios - HNR')) == 1) + new_paramlist{cnt} = 'Harmonic to Noise Ratios - HNR'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0')) == 1) + new_paramlist{cnt} = 'Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('H1*-H2*, H2*-H4*')) == 1) + new_paramlist{cnt} = 'H1*-H2*, H2*-H4*'; + cnt = cnt + 1; +end + +if (new_param_vec(func_getparameterlist('H1*-A1*, H1*-A2*, H1*-A3*')) == 1) + new_paramlist{cnt} = 'H1*-A1*, H1*-A2*, H1*-A3*'; + cnt = cnt + 1; +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_pickpeaks.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,49 @@ +function [ymax,inx] = func_pickpeaks(y, winlen) +% [ymax,inx] = func_pickpeaks(y, winlen) +% Input: y - from wavread +% winlen - size of window to use +% Output: ymax - peak values +% inx - peak positions +% Notes: +% +% Author: Yen-Liang Shue and Markus Iseli, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +% first, get all maxima +ymin = min(y); +y = y - ymin; +dy = [y(1); transpose(diff(y))]; % diff() gives a shift by 1: insert one sample +inx1 = diff(dy < 0); % is +1 for maxima, -1 for minima +inx1(1) = 0; % do not accept maxima at begining +inx1(end) = 0; % do not accept maxima at end +inx = inx1 > 0; % choose maxima only +ymax= y(inx); +inx = find(inx); +%plot(y); +%hold on; +%plot(inx,ymax,'or'); +%hold off; + +nofmax = length(ymax); +if nofmax==1 + return; +end +% now filter maxima with window of length winlen +for cnt = 1 : nofmax + arr = inx(1:cnt); + cmp = inx(cnt)-winlen; + arr2 = arr>cmp; + %ymax(arr2) + [m, mi] = max(ymax(arr2)); + ymax(arr2)=-60000; + ymax(mi+length(arr2)-sum(arr2))=m; + %ymax(arr2) +end +temp = find(ymax>0); +inx = inx(temp); +ymax = ymax(temp); +%plot(y); +%hold on; +%plot(inx,ymax,'or'); +%hold off; +ymax = ymax + ymin;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_readEGGfile.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,102 @@ +function [EGGData, FrameT] = func_readEGGfile(EGGfile, EGGheaders, EGGtimelabel) +% [EGGData, FrameT] = func_readEGGfile(EGGfile, EGGheaders, EGGtimelabel) +% Input: EGGfile - .egg file name +% EGGheaders - headers to look for in the .egg file +% EGGtimelabel - label representing time +% Output: EGGData +% FrameT - time vector +% Notes: +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +fid = fopen(EGGfile, 'r'); +tmp = textscan(fid, '%s', 1, 'delimiter', '\n'); +data = textscan(fid, '%s', 'delimiter', '\n'); +fclose(fid); + +EGGheaders = textscan(EGGheaders, '%s', 'delimiter', ','); +EGGheaders = EGGheaders{1}; + +% find the index of the "Entry definition and order" header +headers = textscan(tmp{1}{1}, '%s', 'delimiter', '\t'); +inx = 0; +for k=1:length(headers{1}) + if (strcmp(removeExtraSpace(headers{1}{k}), 'Entry definition and order')) + inx = k; + break; + end +end + +% now extract the entry definition from the next data +defn = textscan(data{1}{1}, '%s', 'delimiter', '\t'); +defn = defn{1}{inx}; + +defn_headers = textscan(defn, '%s', 'delimiter', ':,'); +EGGInx = []; + +for k=1:length(EGGheaders) + for n=1:length(defn_headers{1}) + str = removeExtraSpace(defn_headers{1}{n}); + if (strcmp(EGGheaders{k}, str) == 1) + EGGInx = [EGGInx n]; + break; + end + + if (n==length(defn_headers{1})) + EGGInx = [EGGInx -1]; % header was not found, set err code + end + end +end + +% now extract the time data +for k=1:length(defn_headers{1}) + if (strcmp(EGGtimelabel, defn_headers{1}{k}) == 1) + FrameInx = k; + break; + end +end + +EGGInx = EGGInx + 1; +FrameInx = FrameInx + 1; + +FrameT = zeros(1, length(data{1})); +EGGData = cell(1, length(EGGInx)); +for k=1:length(EGGInx) + EGGData{k} = zeros(1, length(data{1})); +end + +for k=1:length(data{1}) + dat = textscan(data{1}{k}, '%s', 'delimiter', '\t'); + FrameT(k) = str2num(dat{1}{FrameInx}); + + for n=1:length(EGGInx) + if (EGGInx(n) ~= 0) + val = str2double(dat{1}{EGGInx(n)}); + if (isnan(val)) + val = 0; + end + EGGData{n}(k) = val; + end + end +end + + +% removes extra spaces at the start and end of words +function str = removeExtraSpace(s) +str = s; +while (1) + if (str(1) == ' ') + str = str(2:end); + else + break; + end +end + +while(1) + if (str(end) == ' ') + str = str(1:end-1); + else + break; + end +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_readTextgrid.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,118 @@ +function [labels, start, stop] = func_readTextgrid(filename) +% [labels, start, stop] = func_readTextgrid(filename) +% Input: filename - textgrid file +% Output: labels, start, stop - vectors containing textgrid data +% Notes: Functions seeks out the "xmin", "xmax", and "text" labels within +% a textgrid file. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +POINT_BUFFER = 0.025; % 25 ms buffer on either side of the point + +if (exist(filename, 'file') == 0) + fprintf('Error: %s not found\n', filename); + labels = NaN; start = NaN; stop = NaN; + return; +end + +fid = fopen(filename, 'rt'); +C = textscan(fid, '%s', 'delimiter', '\n'); +fclose(fid); + +C = C{1}; +tiers = 0; +proceed_int = 0; % proceed with intervals +proceed_pnt = 0; % proceed with point-sources +xmin = 0; +xmax = 1; + +for k=1:length(C) + % try to read a string in the format: %s = %s + if (isempty(C{k})) + continue; + end + + A = textscan(C{k}, '%[^=] = %s', 'delimiter', '\n'); + + if (~isempty(A{1}{1})) + switch A{1}{1} + % intervals + case {'intervals: size '} % we found the start of a new tier, now allocate mem + tiers = tiers + 1; + tier_len = str2num(A{2}{1}); + labels{tiers} = cell(tier_len, 1); + start{tiers} = zeros(tier_len, 1); + stop{tiers} = zeros(tier_len, 1); + cnt = 1; + proceed_int = 1; + case {'xmin '} + if (proceed_int) + start{tiers}(cnt) = str2num(A{2}{1}); + else + xmin = str2num(A{2}{1}); + end + case {'xmax '} + if (proceed_int) + stop{tiers}(cnt) = str2num(A{2}{1}); + else + xmax = str2num(A{2}{1}); + end + case {'text '} + if (proceed_int) + lab = A{2}{1}; + if (lab(end) ~= '"') + lab = lab(1:end-1); + end + + labels{tiers}{cnt} = lab; + cnt = cnt + 1; + if (cnt > tier_len) + proceed_int = 0; + end + end + % point-sources + case {'points: size '} % we found the start of a new tier, now allocate mem + tiers = tiers + 1; + tier_len = str2num(A{2}{1}); + labels{tiers} = cell(tier_len, 1); + start{tiers} = zeros(tier_len, 1); + stop{tiers} = zeros(tier_len, 1); + cnt = 1; + proceed_pnt = 1; + case {'time '} + if (proceed_pnt) + start{tiers}(cnt) = str2num(A{2}{1}) - POINT_BUFFER; + stop{tiers}(cnt) = str2num(A{2}{1}) + POINT_BUFFER; + + if (start{tiers}(cnt) < xmin) + start{tiers}(cnt) = xmin; + end + + if (stop{tiers}(cnt) > xmax) + stop{tiers}(cnt) = xmas; + end + end + case {'mark '} + if (proceed_pnt) + lab = A{2}{1}; + if (lab(end) ~= '"') + lab = lab(1:end-1); + end + + labels{tiers}{cnt} = lab; + cnt = cnt + 1; + if (cnt > tier_len) + proceed_pnt = 0; + end + end + + + end + end + +end + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_setlistbox.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,56 @@ +function func_setlistbox(h_listbox, wavfiledir, mode, vars, filetype) +% func_setlistbox(h_listbox, wavfiledir, mode, vars, filetype) +% Notes: Fills a listbox with folder listings. Allows for recursive +% searches. +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +if (nargin == 4) + filetype = '*.wav'; +end + +fnames = dir([wavfiledir vars.dirdelimiter filetype]); +wavlist = {}; + +if (nargin == 2) + mode = 'none'; +end + +if (strcmp(mode, 'none')) + % add the files that are in the present directory + for k=1:length(fnames) + wavlist{k} = [wavfiledir vars.dirdelimiter fnames(k).name]; + end +end + +if (strcmp(mode, 'recurse')) + % now recurse down the directory tree + wavlist = recurseWavSearch(wavfiledir, wavlist, filetype, vars); +end + +for k=1:length(wavlist) + wavlist{k} = wavlist{k}(length(wavfiledir)+2:end); +end + +set(h_listbox, 'String', wavlist, 'Value', 1); + + +%------------------------------------------------------------------------- +function newfiles = recurseWavSearch(wavfiledir, files, filetype, vars) + +fnames = dir([wavfiledir vars.dirdelimiter filetype]); +files_len = length(files); + +for k=1:length(fnames) + files{files_len+k} = [wavfiledir vars.dirdelimiter fnames(k).name]; +end + +fdir = dir([wavfiledir vars.dirdelimiter '*']); +for k=1:length(fdir) + if (~strcmp(fdir(k).name, '.') && ~strcmp(fdir(k).name, '..') && fdir(k).isdir) + files = recurseWavSearch([wavfiledir vars.dirdelimiter fdir(k).name], files, filetype, vars); + end +end + +newfiles = files;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_setmatdir.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,27 @@ +function VSData = func_setmatdir(whoami, new_dir, VSData) +% VSData = func_setmatdir(whoami, new_dir, VSData) +% Notes: Conditionally sets the global settings for mat directories +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +if (VSData.vars.linkmatdir) + VSData.vars.matdir = new_dir; + VSData.vars.PD_matdir = new_dir; + VSData.vars.OT_matdir = new_dir; + VSData.vars.OT_EGGdir = new_dir; + VSData.vars.OTE_matdir = new_dir; + VSData.vars.MD_matdir = new_dir; + VSData.vars.OT_Textgriddir = new_dir; + VSData.vars.OT_outputdir = new_dir; + + if (VSData.vars.OTE_saveEMUwithmat) + VSData.vars.OTE_outputdir = new_dir; + end + +else % not linked, just update the requesting function + VSData.vars.(whoami) = new_dir; +end + + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_setwavdir.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,15 @@ +function VSData = func_setwavdir(whoami, new_dir, VSData) +% VSData = func_setmatdir(whoami, new_dir, VSData) +% Notes: Conditionally sets the global settings for wav directories +% +% Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA +% Copyright UCLA SPAPL 2009 + +if (VSData.vars.linkwavdir) + VSData.vars.PD_wavdir = new_dir; + VSData.vars.MD_wavdir = new_dir; + VSData.vars.wavdir = new_dir; +else + VSData.vars.(whoami) = new_dir; +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/shrp.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,477 @@ +function [f0_time,f0_value,SHR,f0_candidates]=shrp(Y,Fs,F0MinMax,frame_length,timestep,SHR_Threshold,ceiling,med_smooth,CHECK_VOICING) +% SHRP - a pitch determination algorithm based on Subharmonic-to-Harmonic Ratio (SHR) +% [f0_time,f0_value,SHR,f0_candidates]=shrp(Y,Fs[,F0MinMax,frame_length,TimeStep,SHR_Threshold,Ceiling,med_smooth,CHECK_VOICING]) +% +% Input parameters (There are 9): +% +% Y: Input data +% Fs: Sampling frequency (e.g., 16000 Hz) +% F0MinMax: 2-d array specifies the F0 range. [minf0 maxf0], default: [50 550] +% Quick solutions: +% For male speech: [50 250] +% For female speech: [120 400] +% frame_length: length of each frame in millisecond (default: 40 ms) +% TimeStep: Interval for updating short-term analysis in millisecond (default: 10 ms) +% SHR_Threshold: Subharmonic-to-harmonic ratio threshold in the range of [0,1] (default: 0.4). +% If the estimated SHR is greater than the threshold, the subharmonic is regarded as F0 candidate, +% Otherwise, the harmonic is favored. +% Ceiling: Upper bound of the frequencies that are used for estimating pitch. (default: 1250 Hz) +% med_smooth: the order of the median smoothing (default: 0 - no smoothing); +% CHECK_VOICING: check voicing. Current voicing determination algorithm is kind of crude. +% 0: no voicing checking (default) +% 1: voicing checking +% Output parameters: +% +% f0_time: an array stores the times for the F0 points +% f0_value: an array stores F0 values +% SHR: an array stores subharmonic-to-harmonic ratio for each frame +% f0_candidates: a matrix stores the f0 candidates for each frames, currently two f0 values generated for each frame. +% Each row (a frame) contains two values in increasing order, i.e., [low_f0 higher_f0]. +% For SHR=0, the first f0 is 0. The purpose of this is that when you want to test different SHR +% thresholds, you don't need to re-run the whole algorithm. You can choose to select the lower or higher +% value based on the shr value of this frame. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Permission to use, copy, modify, and distribute this software without fee is hereby granted +% FOR RESEARCH PURPOSES only, provided that this copyright notice appears in all copies +% and in all supporting documentation. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +% +% For details of the algorithm, please see +% Sun, X.,"Pitch determination and voice quality analysis using subharmonic-to-harmonic ratio" To appear in the Proc. of ICASSP2002, Orlando, Florida, May 13 -17, 2002. +% For update information, please check http://mel.speech.nwu.edu/sunxj/pda.htm. +% +% Copyright (c) 2001 Xuejing Sun +% Department of Communication Sciences and Disorders +% Northwestern University, USA +% sunxj@northwestern.edu +% +% Update history: +% Added "f0_candidates" as a return value, Dec. 21, 2001 +% Changed default median smoothing order from 5 to 0, Jan. 9, 2002 +% Modified the GetLogSpectrum function, bug fixed due to Herbert Griebel. Jan. 15, 2002 +% Several minor changes. Jan. 15,2002. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%t0 = clock; +%------------------ Get input arguments values and set default values ------------------------- +if nargin<9 + CHECK_VOICING=0; +end +if nargin<8 + med_smooth=0; +end +if nargin<7 + ceiling=1250; +end +if nargin<6 + SHR_Threshold=0.4; % subharmonic to harmonic ratio threshold +end +if nargin<5 + timestep=10; + %timestep=6.4; +end +if nargin<4 + frame_length=40; % default 40 ms +end +if nargin<3 + minf0=50; + maxf0=500; +else + minf0=F0MinMax(1); + maxf0=F0MinMax(2); +end +if nargin<2 + error('Sampling rate must be supplied!') +end +segmentduration=frame_length; + +%------------------- pre-processing input signal ------------------------- +Y=Y-mean(Y); % remove DC component +Y=Y/max(abs(Y)); %normalization +total_len=length(Y); +%------------------ specify some algorithm-specific thresholds ------------------------- +interpolation_depth=0.5; % for FFT length +%--------------- derived thresholds specific to the algorithm ------------------------------- +maxlogf=log2(maxf0/2); +minlogf=log2(minf0/2); % the search region to compute SHR is as low as 0.5 minf0. +N=floor(ceiling/minf0); % maximum number harmonics +m=mod(N,2); +N=N-m; +N=N*4; %In fact, in most cases we don't need to multiply N by 4 and get equally good results yet much faster. +% derive how many frames we have based on segment length and timestep. +segmentlen=round(segmentduration*(Fs/1000)); +inc=round(timestep*(Fs/1000)); +nf = fix((total_len-segmentlen+inc)/inc); +n=(1:nf); +f0_time=((n-1)*timestep+segmentduration/2)'; % anchor time for each frame, the middle point +%f0_time=((n-1)*timestep)'; % anchor time for each frame, starting from zero +%------------------ determine FFT length --------------------- +fftlen=1; +while (fftlen < segmentlen * (1 +interpolation_depth)) + fftlen =fftlen* 2; +end +%----------------- derive linear and log frequency scale ---------------- +frequency=Fs*(1:fftlen/2)/fftlen; % we ignore frequency 0 here since we need to do log transformation later and won't use it anyway. +limit=find(frequency>=ceiling); +limit=limit(1); % only the first is useful +frequency=frequency(1:limit); +logf=log2(frequency); +%% clear some variables to save memory +clear frequency; +min_bin=logf(end)-logf(end-1); % the minimum distance between two points after interpolation +shift=log2(N); % shift distance +shift_units=round(shift/min_bin); %the number of unit on the log x-axis +i=(2:N); +% ------------- the followings are universal for all the frames ---------------%% +startpos=shift_units+1-round(log2(i)/min_bin); % find out all the start position of each shift +index=find(startpos<1); % find out those positions that are less than 1 +startpos(index)=1; % set them to 1 since the array index starts from 1 in matlab +interp_logf=logf(1):min_bin:logf(end); +interp_len=length(interp_logf);% new length of the amplitude spectrum after interpolation +totallen=shift_units+interp_len; +endpos=startpos+interp_len-1; %% note that : totallen=shift_units+interp_len; +index=find(endpos>totallen); +endpos(index)=totallen; % make sure all the end positions not greater than the totoal length of the shift spectrum + +newfre=2.^(interp_logf); % the linear Hz scale derived from the interpolated log scale +upperbound=find(interp_logf>=maxlogf); % find out the index of upper bound of search region on the log frequency scale. +upperbound=upperbound(1);% only the first element is useful +lowerbound=find(interp_logf>=minlogf); % find out the index of lower bound of search region on the log frequency scale. +lowerbound=lowerbound(1); + +%----------------- segmentation of speech ------------------------------ +curpos=round(f0_time/1000*Fs); % position for each frame in terms of index, not time +frames=toframes(Y,curpos,segmentlen,'hamm'); +[nf framelen]=size(frames); +clear Y; +%----------------- initialize vectors for f0 time, f0 values, and SHR +f0_value=zeros(nf,1); +SHR=zeros(nf,1); +f0_time=f0_time(1:nf); +f0_candidates=zeros(nf,2); +%----------------- voicing determination ---------------------------- +if (CHECK_VOICING) + NoiseFloor=sum(frames(1,:).^2); + voicing=vda(frames,segmentduration/1000,NoiseFloor); +else + voicing=ones(nf,1); +end +%------------------- the main loop ----------------------- +curf0=0; +cur_SHR=0; +cur_cand1=0; +cur_cand2=0; +for n=1:nf + segment=frames(n,:); + curtime=f0_time(n); + if voicing(n)==0 + curf0=0; + cur_SHR=0; + else + [log_spectrum]=GetLogSpectrum(segment,fftlen,limit,logf,interp_logf); + [peak_index,cur_SHR,shshift,all_peak_indices]=ComputeSHR(log_spectrum,min_bin,startpos,endpos,lowerbound,upperbound,N,shift_units,SHR_Threshold); + if (peak_index==-1) % -1 indicates a possibly unvoiced frame, if CHECK_VOICING, set f0 to 0, otherwise uses previous value + if (CHECK_VOICING) + curf0=0; + cur_cand1=0; + cur_cand2=0; + end + + else + curf0=newfre(peak_index)*2; + if (curf0>maxf0) + curf0=curf0/2; + end + if (length(all_peak_indices)==1) + cur_cand1=0; + cur_cand2=newfre(all_peak_indices(1))*2; + else + cur_cand1=newfre(all_peak_indices(1))*2; + cur_cand2=newfre(all_peak_indices(2))*2; + end + if (cur_cand1>maxf0) + cur_cand1=cur_cand1/2; + end + if (cur_cand2>maxf0) + cur_cand2=cur_cand2/2; + end + if (CHECK_VOICING) + voicing(n)=postvda(segment,curf0,Fs); + if (voicing(n)==0) + curf0=0; + end + end + end + end + f0_value(n)=curf0; + SHR(n)=cur_SHR; + f0_candidates(n,1)=cur_cand1; + f0_candidates(n,2)=cur_cand2; + DEBUG=0; + if DEBUG + figure(9) + %subplot(5,1,1),plot(segment,'*') + %title('windowed waveform segment') + subplot(2,2,1),plot(interp_logf,log_spectrum,'k*') + title('(a)') + grid + %('spectrum on log frequency scale') + %grid + shsodd=sum(shshift(1:2:N-1,:),1); + shseven=sum(shshift(2:2:N,:),1); + difference=shseven-shsodd; + subplot(2,2,2),plot(interp_logf,shseven,'k*') + title('(b)') + %title('even') + grid + subplot(2,2,3),plot(interp_logf,shsodd,'k*') + title('(c)') + %title('odd') + grid + subplot(2,2,4), plot(interp_logf,difference,'k*') + title('(d)') + %title('difference (even-odd)') + grid + curtime + curf0 + cur_SHR + pause + end +end +%-------------- post-processing ------------------------------- +if (med_smooth > 0) + f0_value=medsmooth(f0_value,med_smooth); +end +%f0=linsmooth(f0,5); % this is really optional. + +%***************************************************************************************** +%-------------- do FFT and get log spectrum --------------------------------- +%***************************************************************************************** +function [interp_amplitude]=GetLogSpectrum(segment,fftlen,limit,logf,interp_logf) +Spectra=fft(segment,fftlen); +amplitude = abs(Spectra(1:fftlen/2+1)); % fftlen is always even here. Note: change fftlen/2 to fftlen/2+1. bug fixed due to Herbert Griebel +amplitude=amplitude(2:limit+1); % ignore the zero frequency component +%amplitude=log10(amplitude+1); +interp_amplitude=interp1(logf,amplitude,interp_logf,'linear'); +interp_amplitude=interp_amplitude-min(interp_amplitude); +%***************************************************************************************** +%-------------- compute subharmonic-to-harmonic ratio --------------------------------- +%***************************************************************************************** +function [peak_index,SHR,shshift,index]=ComputeSHR(log_spectrum,min_bin,startpos,endpos,lowerbound,upperbound,N,shift_units,SHR_Threshold) +% computeshr: compute subharmonic-to-harmonic ratio for a short-term signal +len_spectrum=length(log_spectrum); +totallen=shift_units+len_spectrum; +shshift=zeros(N,totallen); %initialize the subharmonic shift matrix; each row corresponds to a shift version +shshift(1,(totallen-len_spectrum+1):totallen)=log_spectrum; % place the spectrum at the right end of the first row +% note that here startpos and endpos has N-1 rows, so we start from 2 +% the first row in shshift is the original log spectrum +for i=2:N + shshift(i,startpos(i-1):endpos(i-1))=log_spectrum(1:endpos(i-1)-startpos(i-1)+1); % store each shifted sequence +end +shshift=shshift(:,shift_units+1:totallen); % we don't need the stuff smaller than shift_units +shsodd=sum(shshift(1:2:N-1,:),1); +shseven=sum(shshift(2:2:N,:),1); +difference=shseven-shsodd; +% peak picking process +SHR=0; +[mag,index]=twomax(difference,lowerbound,upperbound,min_bin); % only find two maxima +% first mag is always the maximum, the second, if there is, is the second max +NumPitchCandidates=length(mag); +if (NumPitchCandidates == 1) % this is possible, mainly due to we put a constraint on search region, i.e., f0 range + if (mag <=0) % this must be an unvoiced frame + peak_index=-1; + return + end + peak_index=index; + SHR=0; +else + SHR=(mag(1)-mag(2))/(mag(1)+mag(2)); + if (SHR<=SHR_Threshold) + peak_index=index(2); % subharmonic is weak, so favor the harmonic + else + peak_index=index(1); % subharmonic is strong, so favor the subharmonic as F0 + end +end +%%***************************************************************************************** +%****************** this function only finds two maximum peaks ************************ +function [mag,index]=twomax(x,lowerbound,upperbound,unitlen) +%In descending order, the magnitude and index are returned in [mag,index], respectively +lenx=length(x); +halfoct=round(1/unitlen/2); % compute the number of units of half octave. log2(2)=1; 1/unitlen +[mag,index]=max(x(lowerbound:upperbound));%find the maximum value +if (mag<=0) + % error('max is smaller than zero!') % return it! + return +end +index=index+lowerbound-1; +harmonics=2; +LIMIT=0.0625; % 1/8 octave +startpos=index+round(log2(harmonics-LIMIT)/unitlen); +if (startpos<=min(lenx,upperbound)) + endpos=index+round(log2(harmonics+LIMIT)/unitlen); % for example, 100hz-200hz is one octave, 200hz-250hz is 1/4octave + if (endpos> min(lenx,upperbound)) + endpos=min(lenx,upperbound); + end + [mag1,index1]=max(x(startpos:endpos));%find the maximum value at right side of last maximum + if (mag1>0) + index1=index1+startpos-1; + mag=[mag;mag1]; + index=[index;index1]; + end +end +%***************************************************************************************** +%%---------------------------------------------------------------------------------------- +%%-----------------------------------voicing determination ------------------------------- +function voice=vda(x,segmentdur,noisefloor,minzcr) +%voice=vda(x) determine whether the segment is voiced, unvoiced or silence +%this VDA is independent from the PDA process, and does not take advantage of the info derived from PDA +%thus, it requires more computation load. +if nargin<4 + %minzcr=2500; %unit: hertz + minzcr=3000; +end +if nargin<3 + noisefloor=0.01; +end +[nf, len]=size(x); +voice=ones(nf,1); +engergy=sum(x.^2,2); +index=find(engergy<=noisefloor*3); +voice(index)=0; + +%***************************************************************************************** +%% --------------------------------- determine the energy threshold for silence------------------------- +function thr=ethreshold(frames) +%%%%% use Rabiner and Sambur (1975) method +[nf,len]=size(frames); +lastpoint=1; +emax=0; +emin=0; +e=sum(frames.^2,2); +emax=max(e); +emin=min(e); +I1=0.03*(emax-emin)+emin; +I2=4*emin; +thr=25*min(I1,I2); + +%***************************************************************************************** +%% ------------------- split signal into frames --------------- +function frames=toframes(input,curpos,segmentlen,wintype) +len=length(input); +numFrames=length(curpos); +frames=zeros(numFrames,segmentlen); +start=curpos-round(segmentlen/2); +offset=(0:segmentlen-1); +index_start=find(start<1); % find out those frames beyond the first point +start(index_start)=1; % for those, just use the first frame +endpos=start+segmentlen-1; +index=find(endpos>len); +endpos(index)=len; % duplicate the last several frames if window is over the limit. +start(index)=len+1-segmentlen; +frames(:)=input(start(:,ones(1,segmentlen))+offset(ones(numFrames,1),:)); +[nf, len]=size(frames); +win=window(segmentlen,wintype); +frames = frames .* win(ones(nf,1),:); +%***************************************************************************************** +%-------------- post voicing checking --------------------------------------------- +function voicing=postvda(segment, curf0,Fs,r_threshold) +%%% check voicing again using estimated F0, which follows Hermes, SHS algorithm, JASA, 1988 +if nargin<4 + r_threshold=0.2; +end +estimated_period=1/curf0; +mid_point=round(length(segment)/2); +num_points=round(estimated_period*Fs); % number of points in each period +start_point=mid_point-num_points; +end_point=mid_point+num_points; +if (start_point <1) + start_point=1; + mid_point=start_point+num_points; + if (mid_point>length(segment)) % this is unreasonable, set f0 to zero + voicing=0; + return; + end +end +segment1=segment(start_point:mid_point); +if (end_point>length(segment)) + end_point=length(segment); + mid_point=end_point-num_points; + if (mid_point<1) % this is unreasonable, set f0 to zero + voicing=0; + return; + end +end +segment2=segment(mid_point:end_point); +len=min(length(segment1),length(segment2)); +r=corrcoef(segment1(1:len),segment2(1:len)); +r1=r(1,2); +if (r1<r_threshold) % correlation threshold + voicing=0; +else + voicing=1; +end +USE_ZCR=1; +if(USE_ZCR & voicing) + zcr1=zcr(segment1,estimated_period); + zcr2=zcr(segment2,estimated_period); + %minzcr=2500; + minzcr=3500; + if (zcr1<minzcr | zcr2<minzcr) + voicing=1; + else + voicing=0; + end +end +%%***************************************************************************************** +%--------------------- Compute zero-crossing rate ------------------------------------------- +function zcr=zcr(x,dur) +% function zcr=zcr(x,dur) : compute zero-crossing rate +% x: input data +% x: duration of the input data +[nf,len]=size(x); +zcr=sum(0.5*abs(sign(x(:,2:len))-sign(x(:,1:len-1))))/dur; +%%************************************************************************************* +%--------------------- Window function ------------------------------------------- +function w = window(N,wt,beta) +% +% w = window(N,wt) +% +% generate a window function +% +% N = length of desired window +% wt = window type desired +% 'rect' = rectangular 'tria' = triangular (Bartlett) +% 'hann' = Hanning 'hamm' = Hamming +% 'blac' = Blackman +% 'kais' = Kaiser +% +% w = row vector containing samples of the desired window +% beta : used in Kaiser window + +nn = N-1; +n=0:nn; +pn = 2*pi*(0:nn)/nn; +if wt(1,1:4) == 'rect', + w = ones(1,N); +elseif wt(1,1:4) == 'tria', + m = nn/2; + w = (0:m)/m; + w = [w w(ceil(m):-1:1)]; +elseif wt(1,1:4) == 'hann', + w = 0.5*(1 - cos(pn)); +elseif wt(1,1:4) == 'hamm', + w = .54 - .46*cos(pn); +elseif wt(1,1:4) == 'blac', + w = .42 -.5*cos(pn) + .08*cos(2*pn); +elseif wt(1,1:4) == 'kais', + if nargin<3 + error('you need provide beta!') + end + w =bessel1(beta*sqrt(1-((n-N/2)/(N/2)).^2))./bessel1(beta); +else + disp('Incorrect Window type requested') +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_Initialize.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,136 @@ +function vars = vs_Initialize() + +% check if program is running on PC or a max/unix +if (ispc) + vars.dirdelimiter = '\'; +else + vars.dirdelimiter = '/'; +end + +vars.wavdir = ['.' vars.dirdelimiter]; +vars.matdir = ['.' vars.dirdelimiter]; + +vars.windowsize = 25; +vars.frameshift = 1; +vars.preemphasis = 0.96; +vars.NotANumber = '0'; +vars.maxstrF0 = 500; % straight takes longer for higher F0 +vars.minstrF0 = 40; +vars.maxF0 = 500; % snack settings +vars.minF0 = 40; +vars.maxstrdur = 10; % 10 seconds +vars.tbuffer = 25; % extend this amount if using textgrid segmentation +vars.F0OtherEnable = 0; +vars.F0OtherOffset = 0; +vars.F0OtherCommand = ''; +vars.FormantsOtherEnable = 0; +vars.FormantsOtherOffset = 0; +vars.FormantsOtherCommand = ''; +vars.TextgridIgnoreList = '"", " ", "SIL"'; +vars.TextgridTierNumber = 1; +vars.frame_precision = 1; % [KY 20101016]: how many frames can you be off by in aligning data vectors by timepoint + +%F0 Praat stuff +vars.F0Praatmax = 500; % praat F0 settings +vars.F0Praatmin = 40; +vars.F0PraatVoiceThreshold = 0.45; +vars.F0PraatOctiveJumpCost = 0.35; +vars.F0PraatSilenceThreshold = 0.03; +vars.F0PraatVoiceThreshold = 0.45; +vars.F0PraatOctaveCost = 0.01; +vars.F0PraatOctaveJumpCost = 0.35; +vars.F0PraatVoicedUnvoicedCost = 0.14; +vars.F0PraatKillOctaveJumps = 0; +vars.F0PraatSmooth = 0; +vars.F0PraatSmoothingBandwidth = 5; +vars.F0PraatInterpolate = 0; % interpolate over missing values +vars.F0Praatmethod = 'cc'; % set cross-correlation as default for Praat f0 estimation + +vars.recursedir = 0; +vars.linkmatdir = 1; +vars.linkwavdir = 1; + +vars.Nperiods = 3; % this sets out many pulses to use in the parameter estimation +vars.Nperiods_EC = 5; % both energy, CPP and HNR calculations use this - larger window, more averaging + +% Set subharmonic-to-harmonic ratio (SHR) parameters (KY) +vars.SHRmax = 500; % upper bound for f0 candidates +vars.SHRmin = 40; % lower bound for f0 candidates +vars.SHRThreshold = 0.4; % threshold for SHR for choosing pitch halved candidate + +vars.EGGheaders = 'CQ, CQ_H, CQ_PM, CQ_HT, peak_Vel, peak_Vel_Time, min_Vel, min_Vel_Time, SQ2-SQ1, SQ4-SQ3, ratio'; +vars.EGGtimelabel = 'Frame'; + +% default parameters +vars.F0algorithm = 'F0 (Straight)'; +vars.FMTalgorithm = 'F1, F2, F3, F4 (Snack)'; + +% Parameters from Parameter Estimation (PE) +%vars.PE_searchsubdir = 1; +vars.PE_savematwithwav = 1; +vars.PE_processwith16k = 1; +vars.PE_useTextgrid = 1; +vars.PE_showwaveforms = 0; +vars.PE_params = func_getparameterlist(); + +% Parameters from Parameter Display (PD) +vars.PD_wavdir = vars.wavdir; +vars.PD_matdir = vars.matdir; +vars.PD_paramselection = []; + +% Parameters from Output to Text (OT) +vars.OT_selectedParams = []; +vars.OT_matdir = vars.matdir; % default to the mat dir +vars.OT_includesubdir = 1; +vars.OT_Textgriddir = vars.matdir; +vars.OT_includeEGG = 0; +vars.OT_EGGdir = vars.matdir; +vars.OT_outputdir = vars.matdir; +vars.OT_includeTextgridLabels = 1; +vars.OT_columndelimiter = 1; % default is tab +vars.OT_noSegments = 1; +vars.OT_useSegments = 0; +vars.OT_numSegments = 9; +vars.OT_singleFile = 1; +vars.OT_multipleFiles = 0; + +vars.OT_singleFilename = 'output.txt'; +vars.OT_F0CPPEfilename = 'F0_CPP_E_HNR.txt'; +vars.OT_Formantsfilename = 'Formants.txt'; +vars.OT_Hx_Axfilename = 'HA.txt'; +vars.OT_HxHxfilename = 'HxHx.txt'; +vars.OT_HxAxfilename = 'HxAx.txt'; +vars.OT_EGGfilename = 'EGG.txt'; + +vars.OT_Single = [vars.OT_outputdir vars.OT_singleFilename]; +vars.OT_F0CPPE = [vars.OT_outputdir vars.OT_F0CPPEfilename]; +vars.OT_Formants = [vars.OT_outputdir vars.OT_Formantsfilename]; +vars.OT_HA = [vars.OT_outputdir vars.OT_Hx_Axfilename]; +vars.OT_HxHx = [vars.OT_outputdir vars.OT_HxHxfilename]; +vars.OT_HxAx = [vars.OT_outputdir vars.OT_HxAxfilename]; +vars.OT_EGG = [vars.OT_outputdir vars.OT_EGGfilename]; + +% parameters for Manual Data +vars.MD_wavdir = vars.wavdir; +vars.MD_matdir = vars.matdir; +vars.MD_offset = 0; +vars.MD_resample = 0; +vars.MD_invalidentry = '0, NaN'; +vars.MD_matwithwav = 1; + +% parameters for Output To EMU +vars.OTE_matdir = vars.matdir; +vars.OTE_outputdir = vars.matdir; +vars.OTE_paramselection = []; +vars.OTE_saveEMUwithmat = 1; + +% parameters for Outputs +vars.O_smoothwinsize = 20; + +% parameters for Input (wav) files +vars.I_searchstring = '*.wav'; + +% these variables are not set in the gui +vars.PD_plottype = {'b', 'r', 'g', 'k', 'c', 'b:', 'r:', 'g:', 'k:', 'c:', 'b--', 'r--', 'g--', 'k--', 'c--'}; +vars.PD_maxplots = length(vars.PD_plottype); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ManualData.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,787 @@ +function varargout = vs_ManualData(varargin) +% VS_MANUALDATA M-file for vs_ManualData.fig +% VS_MANUALDATA, by itself, creates a new VS_MANUALDATA or raises the existing +% singleton*. +% +% H = VS_MANUALDATA returns the handle to a new VS_MANUALDATA or the handle to +% the existing singleton*. +% +% VS_MANUALDATA('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_MANUALDATA.M with the given input arguments. +% +% VS_MANUALDATA('Property','Value',...) creates a new VS_MANUALDATA or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_ManualData_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_ManualData_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_ManualData + +% Last Modified by GUIDE v2.5 22-Oct-2009 12:22:59 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_ManualData_OpeningFcn, ... + 'gui_OutputFcn', @vs_ManualData_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_ManualData is made visible. +function vs_ManualData_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_ManualData (see VARARGIN) + +% Choose default command line output for vs_ManualData +handles.output = hObject; + +% YS: get the settings from the main figure +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +VSData = guidata(handles.VSHandle); + +set(handles.edit_wavdir, 'String', VSData.vars.MD_wavdir); +set(handles.edit_matdir, 'String', VSData.vars.MD_matdir); + +set(handles.checkbox_matwithwav, 'Value', VSData.vars.MD_matwithwav); + +if (VSData.vars.MD_matwithwav) + set(handles.edit_matdir, 'Enable', 'Off'); + set(handles.pushbutton_matfile_browse, 'Enable', 'Off'); +else + set(handles.edit_matdir, 'Enable', 'On'); + set(handles.pushbutton_matfile_browse, 'Enable', 'On'); +end + +if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring); +else + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring); +end + +set(handles.listbox_Data_paramlist, 'String', func_getmanualdataparameterlist()); +set(handles.edit_Data_invalid, 'String', VSData.vars.MD_invalidentry); +set(handles.checkbox_resample, 'Value', VSData.vars.MD_resample); + +% Update handles structure +guidata(hObject, handles); + +checkParameters(handles); +plotParam(handles); + +% UIWAIT makes vs_ManualData wait for user response (see UIRESUME) +% uiwait(handles.figure_ManualData); + + +% -- plot the current selected parameter +function plotParam(handles) +VSData = guidata(handles.VSHandle); +contents = get(handles.listbox_wavfilelist, 'String'); +OF = str2double(get(handles.edit_Data_offset, 'String')); + +if (isempty(contents)) + return; +end + +shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')}; +wavfile = [VSData.vars.MD_wavdir VSData.vars.dirdelimiter shortwavfile]; + +[y,Fs] = wavread(wavfile); +L = floor((length(y) / Fs * 1000) / VSData.vars.frameshift) - 1; +set(handles.edit_Data_explen, 'String', num2str(L)); + +% set the amount of padding needed +figdata = guidata(handles.figure_ManualData); +NL = str2double(get(handles.edit_Data_newlen, 'String')); +set(handles.edit_Data_pad, 'String', num2str(L - NL - OF)); + + +if (isfield(figdata, 'mdata')) + contents = get(handles.listbox_Data_paramlist, 'String'); + + if (isempty(contents)) + return; + end + + label = contents{get(handles.listbox_Data_paramlist, 'Value')}; + C = textscan(label, '%s %s', 'delimiter', '('); + param = C{2}{1}(1:end-1); + + % if the parameter exists, plot it in blue + if (isfield(figdata.mdata, param)) + plot(handles.axes_main, figdata.mdata.(param)); % plot the existing param + L = length(figdata.mdata.(param)); + set(handles.edit_Data_explen, 'String', num2str(L)); + set(handles.edit_Data_pad, 'String', num2str(L - NL - OF)); + axis(handles.axes_main, 'tight'); + else + cla(handles.axes_main); + end +end + +if (VSData.vars.MD_resample && isfield(figdata, 'newdata_resamp')) + hold(handles.axes_main, 'on'); + newdata = zeros(L, 1) * NaN; + if (OF >= 0) + newdata(OF+1:L) = figdata.newdata_resamp; + else + newdata(1:length(figdata.newdata_resamp) + OF) = figdata.newdata_resamp(abs(OF)+1:end); + end + plot(handles.axes_main, newdata, 'r'); + hold(handles.axes_main, 'off'); + axis(handles.axes_main, 'tight'); + hold(handles.axes_main, 'off'); + +elseif (isfield(figdata, 'newdata')) + hold(handles.axes_main, 'on'); + % create new vector + newdata = zeros(L, 1) * NaN; + if (length(figdata.newdata) + OF >= L) + newdata(OF+1:L) = figdata.newdata(1:L-OF); + else + if (OF >=0) + newdata(OF+1:OF+length(figdata.newdata)) = figdata.newdata; + else + newdata(1:length(figdata.newdata)+OF) = figdata.newdata(abs(OF)+1:end); + end + end + + plot(handles.axes_main, newdata, 'r'); + hold(handles.axes_main, 'off'); + axis(handles.axes_main, 'tight'); + %legend(handles.axes_main, {'Original', 'New'}); +end + + +% -- build up the matfile if it exists +function checkParameters(handles) +VSData = guidata(handles.VSHandle); +contents = get(handles.listbox_wavfilelist, 'String'); + +if (isempty(contents)) + return; +end + +shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')}; +matfile = [VSData.vars.MD_matdir VSData.vars.dirdelimiter, shortwavfile(1:end-3) 'mat']; + +if (exist(matfile, 'file') == 0) + mdata = []; +else + mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize); +end + +% store mdata so it can be accessed by plotData +figdata = guidata(handles.figure_ManualData); +figdata.mdata = mdata; +guidata(handles.figure_ManualData, figdata); + + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_ManualData_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +function edit_wavdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_wavdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +new_dir = get(hObject, 'String'); + +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData = func_setwavdir('MD_wavdir', new_dir, VSData); + + if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + else + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring); + end + + if (VSData.vars.PE_savematwithwav) + set(handles.edit_matdir, 'String', new_dir); + VSData = func_setmatdir('MD_matdir', new_dir, VSData); + end + guidata(handles.VSHandle, VSData); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.MD_wavdir); +end + +% --- Executes during object creation, after setting all properties. +function edit_wavdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_wavdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_wavfile_browse. +function pushbutton_wavfile_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_wavfile_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_wavdir, 'String'); +new_dir = uigetdir(current_dir); + +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + VSData = func_setwavdir('MD_wavdir', new_dir, VSData); + set(handles.edit_wavdir, 'String', new_dir); + + if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + else + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring); + end + + % assume that mat files are saved with wavs + if (VSData.vars.MD_matwithwav == 1) + set(handles.edit_matdir, 'String', new_dir); + VSData = func_setmatdir('MD_matdir', new_dir, VSData); + end + + guidata(handles.VSHandle, VSData); + +end + +checkParameters(handles); +plotParam(handles); + + + +% --- Executes on selection change in listbox_wavfilelist. +function listbox_wavfilelist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_wavfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_wavfilelist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_wavfilelist +checkParameters(handles); +plotParam(handles); + + +% --- Executes during object creation, after setting all properties. +function listbox_wavfilelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_wavfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on selection change in listbox_Data_paramlist. +function listbox_Data_paramlist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_Data_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_Data_paramlist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_Data_paramlist +%checkParameters(handles); +plotParam(handles); + + +% --- Executes during object creation, after setting all properties. +function listbox_Data_paramlist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_Data_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Data_datafile_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_datafile (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +L = str2double(get(handles.edit_Data_explen, 'String')); +OF = str2double(get(handles.edit_Data_offset, 'String')); + +filename = get(hObject, 'String'); + +if (exist(filename,'file') == 2) + % try to read in the file + fid = fopen(filename, 'rt'); + set(handles.edit_Data_datafile, 'String', [pathname filename]); + + if (fid == -1) + msgbox('Error: Unable to open data file', 'Error', 'error', 'modal'); + return; + end + + data = textscan(fid, '%s', 'delimiter', '\n'); + fclose(fid); + + % get the specified labels for invalid entry + delimiters = textscan(VSData.vars.MD_invalidentry, '%s', 'delimiter', ','); + + % now check each entry + data = data{1}; + newdata = zeros(length(data), 1) * NaN; + + for k=1:length(data) + switch(data{k}) + case delimiters + + otherwise + newdata(k) = str2double(data{k}); + end + end + + figdata = guidata(handles.figure_ManualData); + figdata.newdata = newdata; + + if (VSData.vars.MD_resample) + guidata(handles.figure_ManualData, figdata); + end + + guidata(handles.figure_ManualData, figdata); + + plotParam(handles); + + set(handles.edit_Data_newlen, 'String', num2str(length(newdata))); + set(handles.edit_Data_pad, 'String', num2str(L - OF - length(newdata))); + +end + + +% --- Executes during object creation, after setting all properties. +function edit_Data_datafile_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_datafile (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_datafile_browse. +function pushbutton_datafile_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_datafile_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +L = str2double(get(handles.edit_Data_explen, 'String')); +OF = str2double(get(handles.edit_Data_offset, 'String')); +current_dir = get(handles.edit_wavdir, 'String'); + +[filename, pathname] = uigetfile({'*.txt'; '*.*'}, 'Select data file', current_dir); + +if (filename ~= 0) + % try to read in the file + fid = fopen([pathname filename], 'rt'); + set(handles.edit_Data_datafile, 'String', [pathname filename]); + + if (fid == -1) + msgbox('Error: Unable to open data file', 'Error', 'error', 'modal'); + return; + end + + data = textscan(fid, '%s', 'delimiter', '\n'); + fclose(fid); + + % get the specified labels for invalid entry + delimiters = textscan(VSData.vars.MD_invalidentry, '%s', 'delimiter', ','); + + % now check each entry + data = data{1}; + newdata = zeros(length(data), 1) * NaN; + + for k=1:length(data) + switch(data{k}) + case delimiters + + otherwise + newdata(k) = str2double(data{k}); + end + end + + figdata = guidata(handles.figure_ManualData); + figdata.newdata = newdata; + + if (VSData.vars.MD_resample) + figdata = resample_signal(figdata, handles); + end + guidata(handles.figure_ManualData, figdata); + + plotParam(handles); + + set(handles.edit_Data_newlen, 'String', num2str(length(newdata))); + set(handles.edit_Data_pad, 'String', num2str(L - OF - length(newdata))); + +end + + + +function edit_Data_offset_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +num = str2double(str); +if (isnan(num)) + set(hObject, 'String', num2str(VSData.vars.MD_offset)); +else + VSData.vars.MD_offset = num; + guidata(handles.VSHandle, VSData); + + % update the other numbers + L = str2double(get(handles.edit_Data_explen, 'String')); + NDL = str2double(get(handles.edit_Data_newlen, 'String')); + set(handles.edit_Data_pad, 'String', num2str(L - num - NDL)); + + if (VSData.vars.MD_resample) + figdata = guidata(handles.figure_ManualData); + figdata = resample_signal(figdata, handles); + guidata(handles.figure_ManualData, figdata); + end + + plotParam(handles); +end + +% --- Executes during object creation, after setting all properties. +function edit_Data_offset_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_matdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +new_dir = get(hObject, 'String'); +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData = func_setmatdir('MD_matdir', new_dir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + guidata(handles.VSHandle, VSData); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.MD_matdir); +end + + +% --- Executes during object creation, after setting all properties. +function edit_matdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_matfile_browse. +function pushbutton_matfile_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_matfile_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_matdir, 'String'); +new_dir = uigetdir(current_dir); + +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + VSData = func_setmatdir('MD_matdir', new_dir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + guidata(handles.VSHandle, VSData); +end + +checkParameters(handles); +plotParam(handles); + + +% --- Executes on button press in pushbutton_Data_save. +function pushbutton_Data_save_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Data_save (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +figdata = guidata(handles.figure_ManualData); + +L = str2double(get(handles.edit_Data_explen, 'String')); +OF = VSData.vars.MD_offset; + +% check we have something to save to +wavfilelist = get(handles.listbox_wavfilelist, 'String'); +if (isempty(wavfilelist)) + msgbox('Error: no wav files found.', 'Error', 'error', 'modal'); + return; +end + +paramlist = get(handles.listbox_Data_paramlist, 'String'); +if (isempty(paramlist)) + msgbox('Error: no parameters found.', 'Error', 'error', 'modal'); + return; +end + +% get the parameter +label = paramlist{get(handles.listbox_Data_paramlist, 'Value')}; +C = textscan(label, '%s %s', 'delimiter', '('); +param = C{2}{1}(1:end-1); + +shortwavfile = wavfilelist{get(handles.listbox_wavfilelist, 'Value')}; +matfile = [VSData.vars.MD_matdir VSData.vars.dirdelimiter shortwavfile(1:end-3) 'mat']; + + +if (VSData.vars.MD_resample && isfield(figdata, 'newdata_resamp')) + data = figdata.newdata_resamp; +elseif (~VSData.vars.MD_resample && isfield(figdata, 'newdata')) + data = figdata.newdata; +else + msgbox('Error: no new data loaded.', 'Error', 'error', 'modal'); + return; +end + +newdata = zeros(L, 1) * NaN; +if (length(data) + OF >= L) + newdata(OF+1:L) = data; +else + if (OF >= 0) + newdata(OF+1:OF+length(data)) = data; + else + newdata(1:length(data)+OF) = data(abs(OF)+1:end); + end +end + + +% create the new parameter here +eval([sprintf(param) '= newdata;']); +if (exist(matfile, 'file') == 2) % mat file already exist + save(matfile, param, '-append'); +else + save(matfile, param); +end + +msgbox('Save complete.', 'Save', 'help', 'modal'); + + + + +function edit_Data_explen_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_explen (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Data_explen as text +% str2double(get(hObject,'String')) returns contents of edit_Data_explen as a double + + +% --- Executes during object creation, after setting all properties. +function edit_Data_explen_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_explen (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Data_pad_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_pad (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Data_pad as text +% str2double(get(hObject,'String')) returns contents of edit_Data_pad as a double + + +% --- Executes during object creation, after setting all properties. +function edit_Data_pad_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_pad (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Data_newlen_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_newlen (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Data_newlen as text +% str2double(get(hObject,'String')) returns contents of edit_Data_newlen as a double + + +% --- Executes during object creation, after setting all properties. +function edit_Data_newlen_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_newlen (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Data_invalid_Callback(hObject, eventdata, handles) +% hObject handle to edit_Data_invalid (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Data_invalid as text +% str2double(get(hObject,'String')) returns contents of edit_Data_invalid as a double +VSData = guidata(handles.VSHandle); +VSData.vars.MD_invalidentry = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Data_invalid_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Data_invalid (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +% --- Executes on button press in checkbox_resample. +function checkbox_resample_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_resample (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +VSData.vars.MD_resample = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + +if (VSData.vars.MD_resample) + figdata = guidata(handles.figure_ManualData); + figdata = resample_signal(figdata, handles); + guidata(handles.figure_ManualData, figdata); +end + +plotParam(handles); + + + + +% -- resample the signal if required +function figdata = resample_signal(figdata, handles) +VSData = guidata(handles.VSHandle); + +if (~isfield(figdata, 'newdata')) + return; +end + +newL = str2double(get(handles.edit_Data_explen, 'String')); + +if (length(figdata.newdata)==1) + figdata.newdata_resamp = ones(newL, 1) * figdata.newdata; + +else + try + figdata.newdata_resamp = resample(figdata.newdata, newL, length(figdata.newdata)); + catch ME + msgbox({'Error: Unable to run resample function.', '(Requires Signal Processing Toolbox)'}, 'Error', 'error', 'modal'); + end +end + + +% --- Executes on button press in checkbox_matwithwav. +function checkbox_matwithwav_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_matwithwav (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +VSData.vars.MD_matwithwav = get(hObject, 'Value'); + +if (VSData.vars.MD_matwithwav) + set(handles.edit_matdir, 'Enable', 'Off'); + set(handles.pushbutton_matfile_browse, 'Enable', 'Off'); +else + set(handles.edit_matdir, 'Enable', 'On'); + set(handles.pushbutton_matfile_browse, 'Enable', 'On'); +end + +guidata(handles.VSHandle, VSData); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_OutputToEMU.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,438 @@ +function varargout = vs_OutputToEMU(varargin) +% VS_OUTPUTTOEMU M-file for vs_OutputToEMU.fig +% VS_OUTPUTTOEMU, by itself, creates a new VS_OUTPUTTOEMU or raises the existing +% singleton*. +% +% H = VS_OUTPUTTOEMU returns the handle to a new VS_OUTPUTTOEMU or the handle to +% the existing singleton*. +% +% VS_OUTPUTTOEMU('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_OUTPUTTOEMU.M with the given input arguments. +% +% VS_OUTPUTTOEMU('Property','Value',...) creates a new VS_OUTPUTTOEMU or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_OutputToEMU_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_OutputToEMU_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_OutputToEMU + +% Last Modified by GUIDE v2.5 15-Oct-2009 12:44:26 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_OutputToEMU_OpeningFcn, ... + 'gui_OutputFcn', @vs_OutputToEMU_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_OutputToEMU is made visible. +function vs_OutputToEMU_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_OutputToEMU (see VARARGIN) + +% Choose default command line output for vs_OutputToEMU +handles.output = hObject; + +% YS: get the settings from the main figure +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +% Update handles structure +guidata(hObject, handles); + +VSData = guidata(handles.VSHandle); +set(handles.edit_matdir, 'String', VSData.vars.OTE_matdir); +set(handles.edit_outputdir, 'String', VSData.vars.OTE_outputdir); + +if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat'); +else + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat'); +end + +paramlist = func_getoutputparameterlist(); + +% default is everything selected +if (isempty(VSData.vars.OTE_paramselection)) + VSData.vars.OTE_paramselection = 1:length(paramlist); + guidata(handles.VSHandle, VSData); +end + +set(handles.listbox_paramlist, 'String', paramlist, 'Value', VSData.vars.OTE_paramselection); + +set(handles.checkbox_saveEMUwithmat, 'Value', VSData.vars.OTE_saveEMUwithmat); + +if (VSData.vars.OTE_saveEMUwithmat) + set(handles.edit_outputdir, 'Enable', 'Off'); + set(handles.pushbutton_outputdir_browse, 'Enable', 'Off'); +else + set(handles.edit_outputdir, 'Enable', 'On'); + set(handles.pushbutton_outputdir_browse, 'Enable', 'On'); +end + +set(handles.listbox_matfilelist, 'KeyPressFcn', @filelist_listbox_KeyPressFcn); + + + +% UIWAIT makes vs_OutputToEMU wait for user response (see UIRESUME) +% uiwait(handles.figure_OutputToEMU); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_OutputToEMU_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +function edit_matdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +new_dir = get(handles.edit_matdir, 'String'); +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData = func_setmatdir('OTE_matdir', new_dir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat'); + else + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat'); + end + + if (VSData.vars.OTE_saveEMUwithmat) + set(handles.edit_outputdir, 'String', new_dir); + VSData.vars.OTE_outputdir = new_dir; + end + + guidata(handles.VSHandle, VSData); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.OTE_matdir); +end + +% --- Executes during object creation, after setting all properties. +function edit_matdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_matdir_browse. +function pushbutton_matdir_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_matdir_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_matdir, 'String'); +new_dir = uigetdir(current_dir); +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + VSData = func_setmatdir('OTE_matdir', new_dir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat'); + else + func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat'); + end + + if (VSData.vars.OTE_saveEMUwithmat) + set(handles.edit_outputdir, 'String', new_dir); + VSData.vars.OTE_outputdir = new_dir; + end + + guidata(handles.VSHandle, VSData); +end + + + +% --- Executes on selection change in listbox_matfilelist. +function listbox_matfilelist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_matfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_matfilelist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_matfilelist + + +% --- Executes during object creation, after setting all properties. +function listbox_matfilelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_matfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on selection change in listbox_paramlist. +function listbox_paramlist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +inx = get(hObject, 'Value'); +VSData.vars.OTE_paramselection = setxor(VSData.vars.OTE_paramselection, inx); +set(hObject, 'Value', [VSData.vars.OTE_paramselection]); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function listbox_paramlist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_outputdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_outputdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +new_dir = get(handles.edit_outputdir, 'String'); +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData.vars.OTE_outputdir = new_dir; + set(handles.edit_outputdir, 'String', new_dir); + guidata(handles.VSHandle, VSData); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); +end + +% --- Executes during object creation, after setting all properties. +function edit_outputdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_outputdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_outputdir_browse. +function pushbutton_outputdir_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_outputdir_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_outputdir, 'String'); +new_dir = uigetdir(current_dir); +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + VSData.vars.OTE_outputdir = new_dir; + set(handles.edit_outputdir, 'String', new_dir); + + guidata(handles.VSHandle, VSData); +end + + +% --- Executes on button press in togglebutton_start. +function togglebutton_start_Callback(hObject, eventdata, handles) +% hObject handle to togglebutton_start (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +matfilelist = get(handles.listbox_matfilelist, 'String'); +if (isempty(matfilelist)) + msgbox('Error: no mat files found.', 'Error', 'error', 'modal'); + return; +end + +if (isempty(VSData.vars.OTE_paramselection)) + msgbox('Error: no parameters selected.', 'Error', 'error', 'modal'); + return; +end + +if (get(hObject, 'Value') == 1) % start the process + set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red'); + + WriteEMUfiles(handles); + + set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0); +end + + + + +function filelist_listbox_KeyPressFcn(hObject, eventdata) +handles = guidata(hObject); + +key = double(get(gcbf, 'CurrentCharacter')); +if (gcbo == handles.listbox_matfilelist) + if (key == 127) % delete key + + inx = get(handles.listbox_matfilelist, 'Value'); + contents = get(handles.listbox_matfilelist, 'String'); + + %nothing to do + if (isempty(contents)) + return; + end + + newinx = setxor(inx, [1:length(contents)]); + + newcontents = contents(newinx); + set(handles.listbox_matfilelist, 'String', newcontents); + + if (inx(end) > length(newcontents)) + set(handles.listbox_matfilelist, 'Value', length(newcontents)); + else + set(handles.listbox_matfilelist, 'Value', inx(end)); + end + end +end + + +% --- Executes on button press in checkbox_saveEMUwithmat. +function checkbox_saveEMUwithmat_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_saveEMUwithmat (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_saveEMUwithmat +VSData = guidata(handles.VSHandle); +VSData.vars.OTE_saveEMUwithmat = get(hObject, 'Value'); + +if (VSData.vars.OTE_saveEMUwithmat) + set(handles.edit_outputdir, 'Enable', 'Off'); + set(handles.pushbutton_outputdir_browse, 'Enable', 'Off'); + + set(handles.edit_outputdir, 'String', VSData.vars.OTE_matdir); + VSData.vars.OTE_outputdir = VSData.vars.OTE_matdir; + +else + set(handles.edit_outputdir, 'Enable', 'On'); + set(handles.pushbutton_outputdir_browse, 'Enable', 'On'); +end + +guidata(handles.VSHandle, VSData); + + +% -- main outputting function +function WriteEMUfiles(handles) + +VSData = guidata(handles.VSHandle); +MBox = MessageBox; +MBoxHandles = guidata(MBox); + +matfilelist = get(handles.listbox_matfilelist, 'String'); +messages = cell(length(matfilelist) + 1, 1); + +paramlist = get(handles.listbox_paramlist, 'String'); +params = paramlist(VSData.vars.OTE_paramselection); + +errcnt = 0; + +for k=1:length(matfilelist) + messages{k} = sprintf('%d/%d. %s: ', k, length(matfilelist), matfilelist{k}); + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + set(handles.listbox_matfilelist, 'Value', k); + drawnow; + + matfile = [VSData.vars.OTE_matdir VSData.vars.dirdelimiter matfilelist{k}]; + mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize); + + for n=1:length(params) + C = textscan(params{n}, '%s %s', 'delimiter', '('); + param = C{2}{1}(1:end-1); + + if (~isfield(mdata, param)) + messages{k} = [messages{k} param ' not found, ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + set(handles.listbox_matfilelist, 'Value', k); + drawnow; + errcnt = errcnt + 1; + continue; + end + + messages{k} = [messages{k} param ', ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + set(handles.listbox_matfilelist, 'Value', k); + drawnow; + + outfile = [VSData.vars.OTE_outputdir VSData.vars.dirdelimiter matfilelist{k}(1:end-3) param]; + + % check that the outputdir exists + pathname = fileparts(outfile); + if (exist(pathname, 'dir') ~= 7) + mkdir(pathname); + end + + func_VS2ssff(mdata.(param), param, outfile, VSData.vars); + + % check if user has requested a halt + if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1) + messages{k+1} = 'Stop button pressed.'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + break; + end + + end + + if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1) + break; + end + +end + +messages{length(matfilelist)+1} = sprintf('Completed. %d errors found.', errcnt); +set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); +set(handles.listbox_matfilelist, 'Value', k); +drawnow; + +set(MBoxHandles.pushbutton_close, 'Enable', 'On'); +set(MBoxHandles.pushbutton_stop, 'Enable', 'Off'); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_OutputToText.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,1633 @@ +function varargout = vs_OutputToText(varargin) +% VS_OUTPUTTOTEXT M-file for vs_OutputToText.fig +% VS_OUTPUTTOTEXT, by itself, creates a new VS_OUTPUTTOTEXT or raises +% the existing +% singleton*. +% +% H = VS_OUTPUTTOTEXT returns the handle to a new VS_OUTPUTTOTEXT or the handle to +% the existing singleton*. +% +% VS_OUTPUTTOTEXT('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_OUTPUTTOTEXT.M with the given input arguments. +% +% VS_OUTPUTTOTEXT('Property','Value',...) creates a new VS_OUTPUTTOTEXT or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_OutputToText_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_OutputToText_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_OutputToText + +% Last Modified by GUIDE v2.5 08-Oct-2009 00:50:59 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_OutputToText_OpeningFcn, ... + 'gui_OutputFcn', @vs_OutputToText_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_OutputToText is made visible. +function vs_OutputToText_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_OutputToText (see VARARGIN) + +% Choose default command line output for vs_OutputToText +handles.output = hObject; + +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +% restore the variables from initialization +setGUIVariables(handles); + +set(handles.uipanel_Segments,'SelectionChangeFcn',@segments_buttongroup_SelectionChangeFcn); +set(handles.uipanel_OutputOptions,'SelectionChangeFcn',@outputoptions_buttongroup_SelectionChangeFcn); +set(handles.listbox_Parameters_matfilelist, 'KeyPressFcn', @matfiles_listbox_KeyPressFcn); + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_OutputToText wait for user response (see UIRESUME) +% uiwait(handles.figure_OutputToText); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_OutputToText_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +function setGUIVariables(handles) +VSData = guidata(handles.VSHandle); +vars = VSData.vars; + +paramlist = func_getoutputparameterlist(); +set(handles.listbox_Parameters_paramlist, 'String', paramlist); + +% update output file names +VSData.vars.OT_Single = [vars.OT_outputdir vars.dirdelimiter vars.OT_singleFilename]; +VSData.vars.OT_F0CPPE = [vars.OT_outputdir vars.dirdelimiter vars.OT_F0CPPEfilename]; +VSData.vars.OT_Formants = [vars.OT_outputdir vars.dirdelimiter vars.OT_Formantsfilename]; +VSData.vars.OT_HA = [vars.OT_outputdir vars.dirdelimiter vars.OT_Hx_Axfilename]; +VSData.vars.OT_HxHx = [vars.OT_outputdir vars.dirdelimiter vars.OT_HxHxfilename]; +VSData.vars.OT_HxAx = [vars.OT_outputdir vars.dirdelimiter vars.OT_HxAxfilename]; +VSData.vars.OT_EGG = [vars.OT_outputdir vars.dirdelimiter vars.OT_EGGfilename]; +guidata(handles.VSHandle, VSData); +VSData = guidata(handles.VSHandle); +vars = VSData.vars; + +% default is everything selected +if (isempty(vars.OT_selectedParams)) + vars.OT_selectedParams = 1:length(paramlist); + VSData.vars = vars; + guidata(handles.VSHandle, VSData); +end + +set(handles.listbox_Parameters_paramlist, 'Value', vars.OT_selectedParams); +set(handles.edit_Parameters_num, 'String', num2str(sum(vars.OT_selectedParams > 0))); + +set(handles.edit_Parameters_matdir, 'String', vars.OT_matdir); +set(handles.checkbox_Parameters_includesubdir, 'Value', vars.OT_includesubdir); + +if (vars.OT_includesubdir == 1) + func_setlistbox(handles.listbox_Parameters_matfilelist, vars.OT_matdir, 'recurse', vars, '*.mat'); +else + func_setlistbox(handles.listbox_Parameters_matfilelist, vars.OT_matdir, 'none', vars, '*.mat'); +end + +set(handles.edit_Parameters_Textgriddir, 'String', vars.OT_Textgriddir); +set(handles.checkbox_Parameters_includeEGG, 'Value', vars.OT_includeEGG); + +if (vars.OT_includeEGG == 1) + set(handles.edit_Parameters_EGGdir, 'Enable', 'On'); + set(handles.pushbutton_Parameters_outBrowse, 'Enable', 'On'); +end + +set(handles.edit_Parameters_EGGdir, 'String', vars.OT_EGGdir); +set(handles.edit_Parameters_outdir, 'String', vars.OT_outputdir); + +set(handles.checkbox_Parameters_includeTextgrids, 'Value', vars.OT_includeTextgridLabels); +set(handles.popupmenu_Parameters_delimiter, 'Value', vars.OT_columndelimiter); + +set(handles.radiobutton_noSegments, 'Value', vars.OT_noSegments); +set(handles.radiobutton_useSegments, 'Value', vars.OT_useSegments); + +if (vars.OT_useSegments == 1) + set(handles.edit_numSegments, 'String', num2str(vars.OT_numSegments)); + set(handles.edit_numSegments, 'Enable', 'On'); +end + +set(handles.radiobutton_Singlefile, 'Value', vars.OT_singleFile); +set(handles.radiobutton_Multiplefiles, 'value', vars.OT_multipleFiles); + +set(handles.edit_OutputOptions_SingleFile, 'String', vars.OT_Single); +set(handles.edit_OutputOptions_F0CPPE, 'String', vars.OT_F0CPPE); +set(handles.edit_OutputOptions_Formants, 'String', vars.OT_Formants); +set(handles.edit_OutputOptions_Hx_Ax, 'String', vars.OT_HA); +set(handles.edit_OutputOptions_HxHx, 'String', vars.OT_HxHx); +set(handles.edit_OutputOptions_HxAx, 'String', vars.OT_HxAx); +set(handles.edit_OutputOptions_EGG, 'String', vars.OT_EGG); + +if (vars.OT_multipleFiles == 1) + set(handles.edit_OutputOptions_SingleFile, 'Enable', 'Off'); + set(handles.pushbutton_OutputOptions_SingleBrowse, 'Enable', 'Off'); + + set(handles.edit_OutputOptions_F0CPPE, 'Enable', 'On'); + set(handles.edit_OutputOptions_Formants, 'Enable', 'On'); + set(handles.edit_OutputOptions_Hx_Ax, 'Enable', 'On'); + set(handles.edit_OutputOptions_HxHx, 'Enable', 'On'); + set(handles.edit_OutputOptions_HxAx, 'Enable', 'On'); + set(handles.edit_OutputOptions_EGG, 'Enable', 'On'); + + set(handles.pushbutton_OO_F0CPPEBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_FormantsBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_Hx_AxBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_HxHxBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_HxAxBrowse', 'Enable', 'On'); + set(handles.pushbutton_OO_EGGBrowse', 'Enable', 'On'); +end + + +% --- Executes on selection change in listbox_Parameters_paramlist. +function listbox_Parameters_paramlist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_Parameters_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +inx = get(hObject, 'Value'); + +% now add the new entries and remove the old ones which are already +% selected +VSData.vars.OT_selectedParams = setxor(VSData.vars.OT_selectedParams, inx); +set(hObject, 'Value', VSData.vars.OT_selectedParams); +guidata(handles.VSHandle, VSData); +set(handles.edit_Parameters_num, 'String', num2str(sum(VSData.vars.OT_selectedParams > 0))); + + +% Hints: contents = get(hObject,'String') returns listbox_Parameters_paramlist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_Parameters_paramlist + + +% --- Executes during object creation, after setting all properties. +function listbox_Parameters_paramlist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_Parameters_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Parameters_num_Callback(hObject, eventdata, handles) +% hObject handle to edit_Parameters_num (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Parameters_num as text +% str2double(get(hObject,'String')) returns contents of edit_Parameters_num as a double + + +% --- Executes during object creation, after setting all properties. +function edit_Parameters_num_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Parameters_num (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Parameters_outdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_Parameters_outdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Parameters_outdir as text +% str2double(get(hObject,'String')) returns contents of edit_Parameters_outdir as a double +VSData = guidata(handles.VSHandle); +newdir = get(hObject, 'String'); +if (exist(newdir, 'dir') == 7) % new dir exists + if (newdir(end) ~= VSData.vars.dirdelimiter) + newdir(end + 1) = VSData.vars.dirdelimiter; + end + VSData.vars.OT_outputdir = newdir; + updateOutputFiles(handles); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.OT_outputdir); +end +guidata(handles.VSHandle, VSData); + + +% update the filenames in Output Options +function updateOutputFiles(handles) +VSData = guidata(handles.VSHandle); + +VSData.vars.OT_Single = [VSData.vars.OT_outputdir VSData.vars.OT_singleFilename]; +VSData.vars.OT_F0CPPE = [VSData.vars.OT_outputdir VSData.vars.OT_F0CPPEfilename]; +VSData.vars.OT_Formants = [VSData.vars.OT_outputdir VSData.vars.OT_Formantsfilename]; +VSData.vars.OT_HA = [VSData.vars.OT_outputdir VSData.vars.OT_Hx_Axfilename]; +VSData.vars.OT_HxHx = [VSData.vars.OT_outputdir VSData.vars.OT_HxHxfilename]; +VSData.vars.OT_HxAx = [VSData.vars.OT_outputdir VSData.vars.OT_HxAxfilename]; +VSData.vars.OT_EGG = [VSData.vars.OT_outputdir VSData.vars.OT_EGGfilename]; + +set(handles.edit_OutputOptions_SingleFile, 'String', VSData.vars.OT_Single); +set(handles.edit_OutputOptions_F0CPPE, 'String', VSData.vars.OT_F0CPPE); +set(handles.edit_OutputOptions_Formants, 'String', VSData.vars.OT_Formants); +set(handles.edit_OutputOptions_Hx_Ax, 'String', VSData.vars.OT_HA); +set(handles.edit_OutputOptions_HxHx, 'String', VSData.vars.OT_HxHx); +set(handles.edit_OutputOptions_HxAx, 'String', VSData.vars.OT_HxAx); +set(handles.edit_OutputOptions_EGG, 'String', VSData.vars.OT_EGG); +set(handles.edit_Parameters_outdir, 'String', VSData.vars.OT_outputdir); +set(handles.edit_Parameters_EGGdir, 'String', VSData.vars.OT_EGGdir); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Parameters_outdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Parameters_outdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_Parameters_outBrowse. +function pushbutton_Parameters_outBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Parameters_outBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +newdir = uigetdir(VSData.vars.OT_outputdir); +if (ischar(newdir) == 1) + VSData.vars.OT_outputdir = [newdir VSData.vars.dirdelimiter]; + set(handles.edit_Parameters_outdir, 'String', VSData.vars.OT_outputdir); + guidata(handles.VSHandle, VSData); + updateOutputFiles(handles); +end + + +% --- Executes on selection change in popupmenu_Parameters_delimiter. +function popupmenu_Parameters_delimiter_Callback(hObject, eventdata, handles) +% hObject handle to popupmenu_Parameters_delimiter (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns popupmenu_Parameters_delimiter contents as cell array +% contents{get(hObject,'Value')} returns selected item from popupmenu_Parameters_delimiter +VSData = guidata(handles.VSHandle); +VSData.vars.OT_columndelimiter = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function popupmenu_Parameters_delimiter_CreateFcn(hObject, eventdata, handles) +% hObject handle to popupmenu_Parameters_delimiter (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_Parameters_includeEGG. +function checkbox_Parameters_includeEGG_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Parameters_includeEGG (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); + +if (get(hObject, 'Value') == 1) + set(handles.edit_Parameters_EGGdir, 'Enable', 'On'); + set(handles.pushbutton_Parameters_EGGBrowse, 'Enable', 'On'); + VSData.vars.OT_includeEGG = 1; +else + set(handles.edit_Parameters_EGGdir, 'Enable', 'Off'); + set(handles.pushbutton_Parameters_EGGBrowse, 'Enable', 'Off'); + VSData.vars.OT_includeEGG = 0; +end +guidata(handles.VSHandle, VSData); + + +function edit_Parameters_matdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_Parameters_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Parameters_matdir as text +% str2double(get(hObject,'String')) returns contents of edit_Parameters_matdir as a double +VSData = guidata(handles.VSHandle); +newdir = get(hObject, 'String'); +if (exist(newdir, 'dir') == 7) % new dir exists + VSData = func_setmatdir('OT_matdir', newdir, VSData); + set(handles.edit_Parameters_Textgriddir, 'String', newdir); + + if (newdir(end) ~= VSData.vars.dirdelimiter) + newdir(end + 1) = VSData.vars.dirdelimiter; + end + VSData.vars.OT_outputdir = newdir; + guidata(handles.VSHandle, VSData); + updateOutputFiles(handles); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.OT_matdir); +end +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Parameters_matdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Parameters_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_Parameters_matBrowse. +function pushbutton_Parameters_matBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Parameters_matBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +newdir = uigetdir(VSData.vars.OT_matdir); +if (ischar(newdir) == 1) + VSData = func_setmatdir('OT_matdir', newdir, VSData); + set(handles.edit_Parameters_matdir, 'String', newdir); + set(handles.edit_Parameters_Textgriddir, 'String', newdir); + + if (newdir(end) ~= VSData.vars.dirdelimiter) + newdir(end + 1) = VSData.vars.dirdelimiter; + end + VSData.vars.OT_outputdir = newdir; + guidata(handles.VSHandle, VSData); + updateOutputFiles(handles); + + if (get(handles.checkbox_Parameters_includesubdir, 'Value') == 1) + func_setlistbox(handles.listbox_Parameters_matfilelist, VSData.vars.OT_matdir, 'recurse', VSData.vars, '*.mat'); + else + func_setlistbox(handles.listbox_Parameters_matfilelist, VSData.vars.OT_matdir, 'none', VSData.vars, '*.mat'); + end + guidata(handles.VSHandle, VSData); +end + + + +function edit_Parameters_Textgriddir_Callback(hObject, eventdata, handles) +% hObject handle to edit_Parameters_Textgriddir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Parameters_Textgriddir as text +% str2double(get(hObject,'String')) returns contents of edit_Parameters_Textgriddir as a double +VSData = guidata(handles.VSHandle); +newdir = get(hObject, 'String'); +if (exist(newdir, 'dir') == 7) % new dir exists + VSData.vars.OT_Textgriddir = newdir; +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.OT_Textgriddir); +end +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Parameters_Textgriddir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Parameters_Textgriddir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_Parameters_TextgridBrowse. +function pushbutton_Parameters_TextgridBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Parameters_TextgridBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +newdir = uigetdir(VSData.vars.OT_Textgriddir); +if (ischar(newdir) == 1) + VSData.vars.OT_Textgriddir = newdir; + set(handles.edit_Parameters_Textgriddir, 'String', newdir); + guidata(handles.VSHandle, VSData); +end + + +function edit_Parameters_EGGdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_Parameters_EGGdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Parameters_EGGdir as text +% str2double(get(hObject,'String')) returns contents of edit_Parameters_EGGdir as a double +VSData = guidata(handles.VSHandle); +newdir = get(hObject, 'String'); +if (exist(newdir, 'dir') == 7) % new dir exists + VSData.vars.OT_EGGdir = newdir; +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.OT_EGGdir); +end +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Parameters_EGGdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Parameters_EGGdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_Parameters_EGGBrowse. +function pushbutton_Parameters_EGGBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Parameters_EGGBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +newdir = uigetdir(VSData.vars.OT_EGGdir); +if (ischar(newdir) == 1) + set(handles.edit_Parameters_EGGdir, 'String', newdir); + VSData.vars.OT_EGGdir = newdir; + guidata(handles.VSHandle, VSData); +end + + +function edit_numSegments_Callback(hObject, eventdata, handles) +% hObject handle to edit_numSegments (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_numSegments as text +% str2double(get(hObject,'String')) returns contents of edit_numSegments as a double + +VSData = guidata(handles.VSHandle); +num = str2double(get(hObject, 'String')); + +if (~isnan(num)) + num = round(num); + if (num < 1) + num = 1; + elseif (num > 999) + num = 999; + end + + VSData.vars.OT_numSegments = num; + + set(hObject, 'String', num2str(VSData.vars.OT_numSegments)); + guidata(handles.VSHandle, VSData); +else + set(hObject, 'String', num2str(VSData.vars.OT_numSegments)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_numSegments_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_numSegments (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_OutputOptions_SingleFile_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_SingleFile (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_singleFilename = [filename ext]; + VSData.vars.OT_Single = [pathname VSData.vars.dirdelimiter VSData.vars.OT_singleFilename]; +end + +set(hObject, 'String', VSData.vars.OT_Single); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_SingleFile_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_SingleFile (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OutputOptions_SingleBrowse. +function pushbutton_OutputOptions_SingleBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OutputOptions_SingleBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_singleFilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_SingleFile, 'String', [newpath newfile]); + VSData.vars.OT_Single = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +function edit_OutputOptions_F0CPPE_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_F0CPPE (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_F0CPPEfilename = [filename ext]; + VSData.vars.OT_F0CPPE = [pathname VSData.vars.dirdelimiter VSData.vars.OT_F0CPPEfilename]; +end + +set(hObject, 'String', VSData.vars.OT_F0CPPE); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_F0CPPE_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_F0CPPE (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_OutputOptions_Formants_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_Formants (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_Formantsfilename = [filename ext]; + VSData.vars.OT_Formants = [pathname VSData.vars.dirdelimiter VSData.vars.OT_Formantsfilename]; +end + +set(hObject, 'String', VSData.vars.OT_Formants); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_Formants_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_Formants (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +function edit_OutputOptions_Hx_Ax_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_Hx_Ax (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_Hx_Axfilename = [filename ext]; + VSData.vars.OT_HA = [pathname VSData.vars.dirdelimiter VSData.vars.OT_Hx_Axfilename]; +end + +set(hObject, 'String', VSData.vars.OT_HA); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_Hx_Ax_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_Hx_Ax (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_OutputOptions_HxHx_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_HxHx (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_HxHxfilename = [filename ext]; + VSData.vars.OT_HxHx = [pathname VSData.vars.dirdelimiter VSData.vars.OT_HxHxfilename]; +end + +set(hObject, 'String', VSData.vars.OT_HxHx); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_HxHx_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_HxHx (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_OutputOptions_HxAx_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_HxAx (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_HxAxfilename = [filename ext]; + VSData.vars.OT_HxAx = [pathname VSData.vars.dirdelimiter VSData.vars.OT_HxAxfilename]; +end + +set(hObject, 'String', VSData.vars.OT_HxAx); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_HxAx_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_HxAx (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OO_F0CPPEBrowse. +function pushbutton_OO_F0CPPEBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_F0CPPEBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_F0CPPEfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_F0CPPE, 'String', [newpath newfile]); + VSData.vars.OT_F0CPPE = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +% --- Executes on button press in pushbutton_OO_FormantsBrowse. +function pushbutton_OO_FormantsBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_FormantsBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_Formantsfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_Formants, 'String', [newpath newfile]); + VSData.vars.OT_Formants = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +% --- Executes on button press in pushbutton_OO_Hx_AxBrowse. +function pushbutton_OO_Hx_AxBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_Hx_AxBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_Hx_Axfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_Hx_Ax, 'String', [newpath newfile]); + VSData.vars.OT_HA = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +% --- Executes on button press in pushbutton_OO_HxHxBrowse. +function pushbutton_OO_HxHxBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_HxHxBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_HxHxfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_HxHx, 'String', [newpath newfile]); + VSData.vars.OT_HxHx = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +% --- Executes on button press in pushbutton_OO_HxAxBrowse. +function pushbutton_OO_HxAxBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_HxAxBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_HxAxfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_HxAx, 'String', [newpath newfile]); + VSData.vars.OT_HxAx = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + + +function edit_OutputOptions_EGG_Callback(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_EGG (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); + +str = get(hObject, 'String'); +[pathname, filename, ext] = fileparts(str); + +if (exist(pathname, 'dir') == 7) + VSData.vars.OT_EGGfilename = [filename ext]; + VSData.vars.OT_EGG = [pathname VSData.vars.dirdelimiter VSData.vars.OT_EGGfilename]; +end + +set(hObject, 'String', VSData.vars.OT_EGG); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_OutputOptions_EGG_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_OutputOptions_EGG (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OO_EGGBrowse. +function pushbutton_OO_EGGBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OO_EGGBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +[newfile newpath] = uiputfile({'*.txt', '*.txt'}, 'Select Output File', VSData.vars.OT_EGGfilename); +if (ischar(newfile) == 1) + set(handles.edit_OutputOptions_EGG, 'String', [newpath newfile]); + VSData.vars.OT_EGG = [newpath newfile]; + guidata(handles.VSHandle, VSData); +end + +% --- Executes on button press in togglebutton_Start. +function togglebutton_Start_Callback(hObject, eventdata, handles) +% hObject handle to togglebutton_Start (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of togglebutton_Start +if (get(hObject, 'Value') == 1) % start writing output + set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red'); + + OutputToText(handles); + set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0); + +end + + + + +% --- Executes on button press in checkbox_Parameters_includeTextgrids. +function checkbox_Parameters_includeTextgrids_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Parameters_includeTextgrids (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +VSData.vars.OT_includeTextgridLabels = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + + +function segments_buttongroup_SelectionChangeFcn(hObject, eventdata) +handles = guidata(hObject); +VSData = guidata(handles.VSHandle); + +switch (get(eventdata.NewValue, 'Tag')) + case 'radiobutton_noSegments' + VSData.vars.OT_noSegments = 1; + VSData.vars.OT_useSegments = 0; + set(handles.edit_numSegments, 'Enable', 'Off'); + case 'radiobutton_useSegments' + VSData.vars.OT_noSegments = 0; + VSData.vars.OT_useSegments = 1; + set(handles.edit_numSegments, 'Enable', 'On'); +end +guidata(handles.VSHandle, VSData); + + +% +function outputoptions_buttongroup_SelectionChangeFcn(hObject, eventdata) +handles = guidata(hObject); +VSData = guidata(handles.VSHandle); + +switch (get(eventdata.NewValue, 'Tag')) + case 'radiobutton_Singlefile' + VSData.vars.OT_singleFile = 1; + VSData.vars.OT_multipleFiles = 0; + + set(handles.edit_OutputOptions_SingleFile, 'Enable', 'On'); + set(handles.pushbutton_OutputOptions_SingleBrowse, 'Enable', 'On'); + + set(handles.edit_OutputOptions_F0CPPE, 'Enable', 'Off'); + set(handles.edit_OutputOptions_Formants, 'Enable', 'Off'); + set(handles.edit_OutputOptions_Hx_Ax, 'Enable', 'Off'); + set(handles.edit_OutputOptions_HxHx, 'Enable', 'Off'); + set(handles.edit_OutputOptions_HxAx, 'Enable', 'Off'); + set(handles.edit_OutputOptions_EGG, 'Enable', 'Off'); + + set(handles.pushbutton_OO_F0CPPEBrowse, 'Enable', 'Off'); + set(handles.pushbutton_OO_FormantsBrowse, 'Enable', 'Off'); + set(handles.pushbutton_OO_Hx_AxBrowse, 'Enable', 'Off'); + set(handles.pushbutton_OO_HxHxBrowse, 'Enable', 'Off'); + set(handles.pushbutton_OO_HxAxBrowse, 'Enable', 'Off'); + set(handles.pushbutton_OO_EGGBrowse, 'Enable', 'Off'); + + case 'radiobutton_Multiplefiles' + VSData.vars.OT_singleFile = 0; + VSData.vars.OT_multipleFiles = 1; + + set(handles.edit_OutputOptions_SingleFile, 'Enable', 'Off'); + set(handles.pushbutton_OutputOptions_SingleBrowse, 'Enable', 'Off'); + + set(handles.edit_OutputOptions_F0CPPE, 'Enable', 'On'); + set(handles.edit_OutputOptions_Formants, 'Enable', 'On'); + set(handles.edit_OutputOptions_Hx_Ax, 'Enable', 'On'); + set(handles.edit_OutputOptions_HxHx, 'Enable', 'On'); + set(handles.edit_OutputOptions_HxAx, 'Enable', 'On'); + set(handles.edit_OutputOptions_EGG, 'Enable', 'On'); + + set(handles.pushbutton_OO_F0CPPEBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_FormantsBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_Hx_AxBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_HxHxBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_HxAxBrowse, 'Enable', 'On'); + set(handles.pushbutton_OO_EGGBrowse, 'Enable', 'On'); +end +guidata(handles.VSHandle, VSData); + + +% --- Executes on selection change in listbox_Parameters_matfilelist. +function listbox_Parameters_matfilelist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_Parameters_matfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_Parameters_matfilelist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_Parameters_matfilelist + + +% --- Executes during object creation, after setting all properties. +function listbox_Parameters_matfilelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_Parameters_matfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_Parameters_includesubdir. +function checkbox_Parameters_includesubdir_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Parameters_includesubdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +VSData.vars.OT_includesubdir = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); +if (VSData.vars.OT_includesubdir == 1) + func_setlistbox(handles.listbox_Parameters_matfilelist, VSData.vars.OT_matdir, 'recurse', VSData.vars, '*.mat'); +else + func_setlistbox(handles.listbox_Parameters_matfilelist, VSData.vars.OT_matdir, 'none', VSData.vars, '*.mat'); +end + + + +% executes on key press +function matfiles_listbox_KeyPressFcn(hObject, eventdata) +handles = guidata(hObject); + +key = double(get(gcbf, 'CurrentCharacter')); +if (gcbo == handles.listbox_Parameters_matfilelist) + if (key == 127) % delete key + + inx = get(handles.listbox_Parameters_matfilelist, 'Value'); + contents = get(handles.listbox_Parameters_matfilelist, 'String'); + + %nothing to do + if (isempty(contents)) + return; + end + + newinx = setxor(inx, [1:length(contents)]); + + newcontents = contents(newinx); + set(handles.listbox_Parameters_matfilelist, 'String', newcontents); + + if (inx(end) > length(newcontents)) + set(handles.listbox_Parameters_matfilelist, 'Value', length(newcontents)); + else + set(handles.listbox_Parameters_matfilelist, 'Value', inx(end)); + end + end +end + + +% this is the function that does the actual outputting of text +function OutputToText(handles) + +% check if there are any parameters and files selected +if (isempty(get(handles.listbox_Parameters_paramlist, 'Value')) && get(handles.checkbox_Parameters_includeEGG, 'Value') == 0) + msgbox('Error: No parameters selected.', 'Error', 'warn', 'modal'); + return; +end + +if (isempty(get(handles.listbox_Parameters_matfilelist, 'String'))) + msgbox('Error: No mat files to process.', 'Error', 'warn', 'modal'); + return; +end + +% get variables from the main VS window +VSData = guidata(handles.VSHandle); +matfilelist = get(handles.listbox_Parameters_matfilelist, 'String'); +contents = get(handles.listbox_Parameters_paramlist, 'String'); +paramlist = contents(get(handles.listbox_Parameters_paramlist, 'Value')); + +% get the output delimiter +contents = get(handles.popupmenu_Parameters_delimiter, 'String'); +delim = contents{VSData.vars.OT_columndelimiter}; +delimiter = 9; % ascii code for tab +switch(delim) + case {'tab'} + delimiter = 9; + case {'comma'} + delimiter = 44; %ascii for comma + case {'space'} + delimiter = ' '; +end + +% check output files +fids = zeros(6, 1); % these store the fids of the open files +if (get(handles.radiobutton_Singlefile, 'Value') == 1) % single file + fid = fopen(VSData.vars.OT_Single, 'wt'); + + if (fid == -1) + msgbox('Error: Unable to open file for output.', 'Error', 'error', 'modal'); + return; + end + + writeFileHeaders(fid, paramlist, handles, delimiter); + fids = [fid fid fid fid fid fid]; + +else % multiple files + fid1 = fopen(VSData.vars.OT_F0CPPE, 'wt'); + fid2 = fopen(VSData.vars.OT_Formants, 'wt'); + fid3 = fopen(VSData.vars.OT_HA, 'wt'); + fid4 = fopen(VSData.vars.OT_HxHx, 'wt'); + fid5 = fopen(VSData.vars.OT_HxAx, 'wt'); + + if (fid1 == -1) + msgbox('Error: Unable to open F0/CPP/E file for output.', 'Error', 'error', 'modal'); + return; + end + + if (fid2 == -1) + msgbox('Error: Unable to open Formants file for output.', 'Error', 'error', 'modal'); + return; + end + + if (fid3 == -1) + msgbox('Error: Unable to open Hx/Ax file for output.', 'Error', 'error', 'modal'); + return; + end + + if (fid4 == -1) + msgbox('Error: Unable to open Hx-Hx file for output.', 'Error', 'error', 'modal'); + return; + end + + if (fid5 == -1) + msgbox('Error: Unable to open Hx-Ax file for output.', 'Error', 'error', 'modal'); + return; + end + + fidEGG = -1; + if (VSData.vars.OT_includeEGG == 1) + fidEGG = fopen(VSData.vars.OT_EGG, 'wt'); + if (fidEGG == -1) + msgbox('Error: Unable to open EGG file for output.', 'Error', 'error', 'modal'); + return; + end + end + + fids = [fid1 fid2 fid3 fid4 fid5 fidEGG]; + writeFileHeaders(fids, paramlist, handles, delimiter); +end + +MBox = MessageBox; +MBoxHandles = guidata(MBox); +messages = cell(length(matfilelist) + 1, 1); % allocate some memory for messages +errorcnt = 0; +uniquefids = unique(fids); % store the number of unique fids + +% process every file in matfilelist +for k=1:length(matfilelist) + matfile = [VSData.vars.OT_matdir VSData.vars.dirdelimiter matfilelist{k}]; + TGfile = [VSData.vars.OT_Textgriddir VSData.vars.dirdelimiter matfilelist{k}(1:end-3) 'Textgrid']; + messages{k} = sprintf('%d/%d. %s: ', k, length(matfilelist), matfilelist{k}); + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize); + + frameshift = VSData.vars.frameshift; % this could be wrong if the mat file has it's own frameshift + if (isfield(mdata, 'frameshift')) + frameshift = mdata.frameshift; + end + + % find the max length of the data + if (isfield(mdata, 'strF0')) + maxlen = length(mdata.strF0) * frameshift; + elseif (isfield(mdata, 'sF0')) + maxlen = length(mdata.sF0) * frameshift; + elseif (isfield(mdata, 'pF0')) + maxlen = length(mdata.pF0) * frameshift; + elseif (isfield(mdata, 'oF0')) + maxlen = length(mdata.oF0) * frameshift; + end + + % load up the textgrid data, or if it doesn't exist, use the whole file + if (exist(TGfile, 'file') == 0) % file not found, use start and end + messages{k} = [messages{k} 'Textgrid not found - using all data points: ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + start = 1; + stop = maxlen; + labels = {matfilelist{k}}; + + else % use textgrid start points + ignorelabels = textscan(VSData.vars.TextgridIgnoreList, '%s', 'delimiter', ','); + ignorelabels = ignorelabels{1}; + + [labels, start, stop] = func_readTextgrid(TGfile); + labels_tmp = []; + start_tmp = []; + stop_tmp = []; + + for m=1:length(VSData.vars.TextgridTierNumber) + inx = VSData.vars.TextgridTierNumber(m); + if (inx <= length(labels)) + labels_tmp = [labels_tmp; labels{inx}]; + start_tmp = [start_tmp; start{inx}]; + stop_tmp = [stop_tmp; stop{inx}]; + end + end + + labels = labels_tmp; + start = start_tmp * 1000; % milliseconds + stop = stop_tmp * 1000; % milliseconds + + % just pull out the start/stop of the labels that aren't + % ignored + inx = 1:length(labels); + for n=1:length(labels) + switch(labels{n}) + case ignorelabels + inx(n) = 0; + end + end + inx = unique(inx); + inx(inx == 0) = []; + labels = labels(inx); + start = start(inx); + stop = stop(inx); + end + + % get the EGG file if requested + [proceedEGG, EGGfile] = checkEGGfilename(matfilelist{k}, handles); + + if (VSData.vars.OT_includeEGG == 1 && proceedEGG == 0) + messages{k} = [messages{k} 'EGG file not found, ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + errorcnt = errorcnt + 1; + end + + if (proceedEGG) + [EGGData, EGGTime] = func_readEGGfile(EGGfile, VSData.vars.EGGheaders, VSData.vars.EGGtimelabel); + end + + % assume each file has the parameters in the mat file + paramlist_valid = ones(length(paramlist), 1); + + + % no segments - complete dump + if (VSData.vars.OT_noSegments == 1) + + % for each label, loop through and write out the selected + % parameters + for n=1:length(start) + sstart = round(start(n) / frameshift); % get the correct sample + sstop = round(stop(n) / frameshift); + + sstart(sstart == 0) = 1; % special case for t = 0 + sstop(sstop > maxlen) = maxlen; % special case for t=maxlen + + for s=sstart:sstop + + for m=1:length(uniquefids) + if (uniquefids(m) == -1) + continue; + end + + fprintf(uniquefids(m), '%s%c', matfilelist{k}, delimiter); + + if (VSData.vars.OT_includeTextgridLabels == 1) + fprintf(uniquefids(m), '%s%c', labels{n}, delimiter); + fprintf(uniquefids(m), '%.3f%c', start(n), delimiter); + fprintf(uniquefids(m), '%.3f%c', stop(n), delimiter); + end + + fprintf(uniquefids(m), '%.3f%c', s * frameshift, delimiter); + end + + % print out the selected params + for m=1:length(paramlist) + val = VSData.vars.NotANumber; % default is the NaN label + + C = textscan(paramlist{m}, '%s %s', 'delimiter', '('); + fidinx = func_getfileinx(paramlist{m}); + param = C{2}{1}(1:end-1); + if (isfield(mdata, param)) + data = mdata.(param); + if (length(data)==1 && isnan(data)) % guard against empty vectors + paramlist_valid(m) = 0; + else + if (~isnan(data(s)) && ~isinf(data(s))) + val = sprintf('%.3f', data(s)); + end + end + else + if (paramlist_valid(m) == 1) + messages{k} = [messages{k} param ' not found, ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + errorcnt = errorcnt + 1; + paramlist_valid(m) = 0; + end + end + + fprintf(fids(fidinx), '%s%c', val, delimiter); + end + + % for the case where EGG was requested, but no EGG file was found + if (VSData.vars.OT_includeEGG == 1 && proceedEGG == 0) + fidinx = 6; + EGGheaders = textscan(VSData.vars.EGGheaders, '%s', 'delimiter', ','); + EGGheaders = EGGheaders{1}; + + for m=1:length(EGGheaders) + fprintf(fids(fidinx), '%s%c', VSData.vars.NotANumber, delimiter); + end + end + + + % process EGG stuff + if (proceedEGG) + fidinx = 6; + + % find the time segment from EGGTime, use that to index + % EGGData + t = s * frameshift; % this is the time in ms. Get the closest EGGTime to t + [val, s_EGG] = min(abs(EGGTime - t)); + + if (abs(t - EGGTime(s_EGG)) / t > 0.05) % if t_EGG is more than 5% away from t, it is not correct + for m=1:length(EGGData) + fprintf(fids(fidinx), '%s%c', VSData.vars.NotANumber, delimiter); + end + else + for m=1:length(EGGData) + fprintf(fids(fidinx), '%.3f%c', EGGData{m}(s_EGG), delimiter); + end + end + end + + % finally, write out new line + for m=1:length(uniquefids) + if (uniquefids(m) == -1) + continue; + end + fprintf(uniquefids(m), '\n'); + end + + end + + end + + + % outputting with segments + else + Nseg = str2double(get(handles.edit_numSegments, 'String')); + + % for each segment, print out overall mean, then parts mean + for n=1:length(start) + + % print out the header stuff + for m=1:length(uniquefids) + if (uniquefids(m) == -1) + continue; + end + + fprintf(uniquefids(m), '%s%c', matfilelist{k}, delimiter); + + if (VSData.vars.OT_includeTextgridLabels == 1) + fprintf(uniquefids(m), '%s%c', labels{n}, delimiter); + fprintf(uniquefids(m), '%.3f%c', start(n), delimiter); + fprintf(uniquefids(m), '%.3f%c', stop(n), delimiter); + end + + end + + % get array of start and stop times for the segments. First one + % is the total mean + tsegs = linspace(start(n), stop(n), Nseg+1); + tstart = zeros(Nseg+1, 1); + tstop = zeros(Nseg+1, 1); + + tstart(1) = start(n); + tstop(1) = stop(n); + tstart(2:end) = tsegs(1:Nseg); + tstop(2:end) = tsegs(2:Nseg+1); + + % get the sample equivalents + sstart = round(tstart ./ frameshift); + sstop = round(tstop ./ frameshift); + + % don't output segments if Nseg == 1 + if (Nseg == 1) + sstart = sstart(1); + sstop = sstop(1); + end + + % guard against 0 and maxlen + sstart(sstart == 0) = 1; + sstop(sstop > maxlen) = maxlen; + + for m=1:length(paramlist) + val = VSData.vars.NotANumber; % default value is no value + + fidinx = func_getfileinx(paramlist{m}); + C = textscan(paramlist{m}, '%s %s', 'delimiter', '('); + param = C{2}{1}(1:end-1); + if (isfield(mdata, param)) + data = mdata.(param); + + for p=1:length(sstart) + if (length(data)==1 && isnan(data)) + paramlist_valid(m) = 0; + else + dataseg = data(sstart(p):sstop(p)); + mdataseg = mean(dataseg(~isnan(dataseg) & ~isinf(dataseg))); + if (~isempty(mdataseg) && ~isnan(mdataseg) && ~isinf(mdataseg)) + val = sprintf('%.3f', mdataseg); + end + end + fprintf(fids(fidinx), '%s%c', val, delimiter); + end + else + if (paramlist_valid(m) == 1) + messages{k} = [messages{k} param ' not found, ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + errorcnt = errorcnt + 1; + paramlist_valid(m) = 0; + end + + for p=1:length(sstart) + fprintf(fids(fidinx), '%s%c', val, delimiter); + end + end + + end + + + % this case if for when the EGG was requested, but no egg file + % was found + if (VSData.vars.OT_includeEGG == 1 && proceedEGG == 0) + fidinx = 6; + EGGheaders = textscan(VSData.vars.EGGheaders, '%s', 'delimiter', ','); + EGGheaders = EGGheaders{1}; + for m=1:length(EGGheaders) + for p=1:length(tstart) + fprintf(fids(fidinx), '%s%c', VSData.vars.NotANumber, delimiter); + end + end + end + + % process EGG stuff + if (proceedEGG) + fidinx = 6; + + for m=1:length(EGGData) + for p=1:length(tstart) + EGGInx = (EGGTime >= tstart(p)) & (EGGTime <= tstop(p)); + meanval = mean(EGGData{m}(EGGInx)); + if (~isempty(meanval) && ~isnan(meanval) && ~isinf(meanval)) + val = sprintf('%.3f', meanval); + else + val = VSData.vars.NotANumber; + end + fprintf(fids(fidinx), '%s%c', val, delimiter); + end + end + end + + % finally, write out new line + for m=1:length(uniquefids) + if (uniquefids(m) == -1) + continue; + end + fprintf(uniquefids(m), '\n'); + end + + end + end +end + +for k=1:length(uniquefids) + if (uniquefids(k) == -1) + continue; + end + fclose(uniquefids(k)); +end + +if (errorcnt > 0) + messages{length(matfilelist)+1} = sprintf('Completed: %d parameters not found.', errorcnt); +else + messages{length(matfilelist)+1} = sprintf('Completed.'); +end +set(MBoxHandles.listbox_messages, 'String', messages, 'Value', length(matfilelist)+1); + +% allow the MBox to close +set(MBoxHandles.pushbutton_close, 'Enable', 'on'); +set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + + +% write headers to files +function writeFileHeaders(fids, paramlist, handles, delimiter) +VSData = guidata(handles.VSHandle); + +% write out the filename and textgrid labels if required +for k=1:length(fids) + if (fids(k) == -1) + continue; + end + + fprintf(fids(k), 'Filename%c', delimiter); + + if (VSData.vars.OT_includeTextgridLabels == 1) + fprintf(fids(k), 'Label%c', delimiter); + fprintf(fids(k), 'seg_Start%c', delimiter); + fprintf(fids(k), 'seg_End%c', delimiter); + end + + % only print a time stamp when doing complete dumps + if (VSData.vars.OT_noSegments == 1) + fprintf(fids(k), 't_ms%c', delimiter); + end +end + +% make the file ids the same length as using multiple files +if (length(fids)==1) + if (VSData.vars.OT_includeEGG) + fids = [fids fids fids fids fids fids]; + else + fids = [fids fids fids fids fids -1]; + end +end + +% separate case for complete data dump +if (VSData.vars.OT_noSegments == 1) + for k=1:length(paramlist) + fidinx = func_getfileinx(paramlist{k}); + C = textscan(paramlist{k}, '%s %s', 'delimiter', '('); + fprintf(fids(fidinx), '%s%c', C{2}{1}(1:end-1), delimiter); + end + + if (VSData.vars.OT_includeEGG) + fidinx = 6; + C = textscan(VSData.vars.EGGheaders, '%s', 'delimiter', ','); + for n=1:length(C{1}) + fprintf(fids(fidinx), '%s%c', C{1}{n}, delimiter); + end + end + + % finally, write out new line + fids = unique(fids); + for k=1:length(fids) + if (fids(k) == -1) + continue; + end + fprintf(fids(k), '\n'); + end + +% using segments +else + Nseg = str2double(get(handles.edit_numSegments, 'String')); + + % for each parameter, print the mean, followed by the means of each + % segment + for k=1:length(paramlist) + fidinx = func_getfileinx(paramlist{k}); + C = textscan(paramlist{k}, '%s %s', 'delimiter', '('); + label = C{2}{1}(1:end-1); + fprintf(fids(fidinx), '%s_mean%c', label, delimiter); + if (Nseg > 1) + for n=1:Nseg + segno = sprintf('%3d', n); + segno = strrep(segno, ' ', '0'); + fprintf(fids(fidinx), '%s_means%s%c', label, segno, delimiter); + end + end + end + + if (VSData.vars.OT_includeEGG) + fidinx = 6; + C = textscan(VSData.vars.EGGheaders, '%s', 'delimiter', ','); + for n=1:length(C{1}) + fprintf(fids(fidinx), '%s_mean%c', C{1}{n}, delimiter); + + if (Nseg > 1) + for m=1:Nseg + segno = sprintf('%3d', m); + segno = strrep(segno, ' ', '0'); + fprintf(fids(fidinx), '%s_means%s%c', C{1}{n}, segno, delimiter); + end + end + end + end + + % finally, write out a new line + fids = unique(fids); + for k=1:length(fids) + if (fids(k) == -1) + continue; + end + fprintf(fids(k), '\n'); + end + + +end + + + +function [proceedEGG, EGGfile] = checkEGGfilename(matfile, handles) +VSData = guidata(handles.VSHandle); + +if (VSData.vars.OT_includeEGG == 0) + proceedEGG = 0; + EGGfile = ''; + return; +end + +% deal with the filename stupidity that is PCQuirer +VSData = guidata(handles.VSHandle); + +EGGfile = [VSData.vars.OT_EGGdir VSData.vars.dirdelimiter matfile(1:end-3) 'egg']; % attempt to open .egg +if (exist(EGGfile, 'file') == 0) + proceedEGG = 0; + + if (length(matfile) > 10) + if (strcmpi(matfile(end-9:end-4), '_Audio')) % case insensitive + EGGfile = [VSData.vars.OT_EGGdir VSData.vars.dirdelimiter matfile(1:end-9), 'ch1.egg']; % try with ch1 first + + if (exist(EGGfile, 'file') == 0) + EGGfile = [VSData.vars.OT_EGGdir VSData.vars.dirdelimiter matfile(1:end-10) '.egg']; % next try with .egg w/o _Audio + if (exist(EGGfile, 'file') == 0) + proceedEGG = 0; + else + proceedEGG = 1; + end + else + proceedEGG = 1; + end + + end + end +else + proceedEGG = 1; +end + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ParameterDisplay.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,405 @@ +function varargout = vs_ParameterDisplay(varargin) +% VS_PARAMETERDISPLAY M-file for vs_ParameterDisplay.fig +% VS_PARAMETERDISPLAY, by itself, creates a new VS_PARAMETERDISPLAY or raises the existing +% singleton*. +% +% H = VS_PARAMETERDISPLAY returns the handle to a new VS_PARAMETERDISPLAY or the handle to +% the existing singleton*. +% +% VS_PARAMETERDISPLAY('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_PARAMETERDISPLAY.M with the given input arguments. +% +% VS_PARAMETERDISPLAY('Property','Value',...) creates a new VS_PARAMETERDISPLAY or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_ParameterDisplay_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_ParameterDisplay_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_ParameterDisplay + +% Last Modified by GUIDE v2.5 13-Oct-2009 22:52:31 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_ParameterDisplay_OpeningFcn, ... + 'gui_OutputFcn', @vs_ParameterDisplay_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_ParameterDisplay is made visible. +function vs_ParameterDisplay_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_ParameterDisplay (see VARARGIN) + +% Choose default command line output for vs_ParameterDisplay +handles.output = hObject; + +% YS: get the settings from the main figure +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +VSData = guidata(handles.VSHandle); +set(handles.edit_wavdir, 'String', VSData.vars.PD_wavdir); +set(handles.edit_matdir, 'String', VSData.vars.PD_matdir); + +if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.PD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring); +else + func_setlistbox(handles.listbox_wavfilelist, VSData.vars.PD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring); +end + +set(handles.listbox_wavfilelist, 'Value', 1); + +% Update handles structure +guidata(hObject, handles); + +checkParameters(handles); +plotData(handles); + +% UIWAIT makes vs_ParameterDisplay wait for user response (see UIRESUME) +% uiwait(handles.figure_ParameterDisplay); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_ParameterDisplay_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +% displays the waveform based on the selected parameters +function plotData(handles) +VSData = guidata(handles.VSHandle); +contents = get(handles.listbox_wavfilelist, 'String'); +paramlist = get(handles.listbox_paramlist, 'String'); + +if (isempty(contents)) + return; +end + +shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')}; +wavfile = [VSData.vars.PD_wavdir VSData.vars.dirdelimiter, shortwavfile]; +figdata = guidata(handles.figure_ParameterDisplay); +mdata = figdata.mdata; + +[y,Fs] = wavread(wavfile); + +if (isempty(VSData.vars.PD_paramselection) || isempty(paramlist)) + position = [0.05 0.05 0.9 0.9]; +else + position = [0.05 0.7 0.9 0.295]; +end + +% top plot is always the wav +subp = subplot('Position', position, 'Parent', handles.uipanel_figure); +t = linspace(0, length(y) / Fs * 1000, length(y)); +plot(subp, t, y); +axis(subp, 'tight'); + +if (isempty(VSData.vars.PD_paramselection) || isempty(paramlist)) % nothing else to do + return; +end + +%set(subp, 'XTick', []); +set(subp, 'XTickLabel', []); + +subp2 = subplot('Position', [0.05 0.1 0.9 0.595], 'Parent', handles.uipanel_figure); +cla(subp2); + +hold(subp2, 'on'); +labels = cell(length(VSData.vars.PD_paramselection), 1); +for k=1:length(VSData.vars.PD_paramselection) + C = textscan(paramlist{VSData.vars.PD_paramselection(k)}, '%s %s', 'delimiter', '('); + param = C{2}{1}(1:end-1); + labels{k} = param; + t = [1:length(mdata.(param))] * mdata.frameshift; + plot(subp2, t, mdata.(param), VSData.vars.PD_plottype{mod(k-1, VSData.vars.PD_maxplots)+1}); +end + +axis(subp2, 'tight'); +legend(subp2, labels); +xlabel(subp2, 'Time (ms)'); + + +% fill in the parameter listbox +function checkParameters(handles) +VSData = guidata(handles.VSHandle); +contents = get(handles.listbox_wavfilelist, 'String'); + +if (isempty(contents)) + return; +end + +shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')}; +matfile = [VSData.vars.PD_matdir VSData.vars.dirdelimiter, shortwavfile(1:end-3) 'mat']; + +figdata = guidata(handles.figure_ParameterDisplay); % store it so we don't have to recreate the mat data + +if (exist(matfile, 'file') == 0) + set(handles.listbox_paramlist, 'String', []); + mdata = []; + paramlist = []; +else + + %load it up and check available parameters + mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize); + + paramlist = func_getoutputparameterlist(); + paraminx = 1:length(paramlist); + + for k=1:length(paramlist) + C = textscan(paramlist{k}, '%s %s', 'delimiter', '('); + param = C{2}{1}(1:end-1); + if (~isfield(mdata, param)) + paraminx(k) = 0; + end + end + + paraminx(paraminx == 0) = []; + paramlist = paramlist(paraminx); + +end + +figdata.mdata = mdata; +guidata(handles.figure_ParameterDisplay, figdata); + +set(handles.listbox_paramlist, 'String', paramlist, 'Value', VSData.vars.PD_paramselection); + + + +function edit_wavdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_wavdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_wavdir as text +% str2double(get(hObject,'String')) returns contents of edit_wavdir as a double +new_dir = get(hObject, 'String'); + +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData = func_setwavdir('PD_wavdir', new_dir, VSData); + + if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_wavfilelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + else + func_setlistbox(handles.listbox_wavfilelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring); + end + + if (VSData.vars.PE_savematwithwav) + set(handles.edit_matdir, 'String', new_dir); + VSData = func_setmatdir('PD_matdir', new_dir, VSData); + end + + guidata(handles.VSHandle, VSData); + checkParameters(handles); + plotData(handles); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.PD_wavdir); +end + +% --- Executes during object creation, after setting all properties. +function edit_wavdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_wavdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_wavdir_browse. +function pushbutton_wavdir_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_wavdir_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_wavdir, 'String'); +new_dir = uigetdir(current_dir); + +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + + set(handles.edit_wavdir, 'String', new_dir); + func_setlistbox(handles.listbox_wavfilelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + VSData = func_setwavdir('PD_wavdir', new_dir, VSData); + + if (VSData.vars.PE_savematwithwav) + set(handles.edit_matdir, 'String', new_dir); + VSData = func_setmatdir('PD_matdir', new_dir, VSData); + end + + guidata(handles.VSHandle, VSData); + + checkParameters(handles); + plotData(handles); +end + + + +% --- Executes on selection change in listbox_wavfilelist. +function listbox_wavfilelist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_wavfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = get(hObject,'String') returns listbox_wavfilelist contents as cell array +% contents{get(hObject,'Value')} returns selected item from listbox_wavfilelist +checkParameters(handles); +plotData(handles); + + +% --- Executes during object creation, after setting all properties. +function listbox_wavfilelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_wavfilelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_matdir_Callback(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +new_dir = get(hObject, 'String'); + +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) + VSData = func_setmatdir('PD_matdir', newdir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + guidata(handles.VSHandle, VSData); + + checkParameters(handles); + plotData(handles); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.PD_matdir); +end + + +% --- Executes during object creation, after setting all properties. +function edit_matdir_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_matdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_matdir_browse. +function pushbutton_matdir_browse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_matdir_browse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_matdir, 'String'); +new_dir = uigetdir(current_dir); + +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) + VSData = func_setmatdir('PD_matdir', new_dir, VSData); + set(handles.edit_matdir, 'String', new_dir); + + guidata(handles.VSHandle, VSData); + + checkParameters(handles); + plotData(handles); + +end + + + + +% --- Executes on selection change in listbox_paramlist. +function listbox_paramlist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +contents = get(hObject, 'String'); + +if (isempty(contents)) + return; +end + +VSData = guidata(handles.VSHandle); +inx = get(hObject, 'Value'); +VSData.vars.PD_paramselection = setxor(VSData.vars.PD_paramselection, inx); +VSData.vars.PD_paramselection(VSData.vars.PD_paramselection > length(contents)) = []; + +set(hObject, 'Value', VSData.vars.PD_paramselection); +guidata(handles.VSHandle, VSData); + +figdata = guidata(handles.figure_ParameterDisplay); +if (~isfield(figdata, 'mdata')) + checkParameters(handles); +end + +plotData(handles); + + +% --- Executes during object creation, after setting all properties. +function listbox_paramlist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OK. +function pushbutton_OK_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OK (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +delete(gcf);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ParameterEstimation.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,1144 @@ +function varargout = vs_ParameterEstimation(varargin) +% VS_PARAMETERESTIMATION M-file for vs_ParameterEstimation.fig +% VS_PARAMETERESTIMATION, by itself, creates a new VS_PARAMETERESTIMATION or raises the existing +% singleton*. +% +% H = VS_PARAMETERESTIMATION returns the handle to a new VS_PARAMETERESTIMATION or the handle to +% the existing singleton*. +% +% VS_PARAMETERESTIMATION('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_PARAMETERESTIMATION.M with the given input arguments. +% +% VS_PARAMETERESTIMATION('Property','Value',...) creates a new VS_PARAMETERESTIMATION or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_ParameterEstimation_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_ParameterEstimation_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_ParameterEstimation + +% Last Modified by GUIDE v2.5 19-Oct-2009 11:55:41 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_ParameterEstimation_OpeningFcn, ... + 'gui_OutputFcn', @vs_ParameterEstimation_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_ParameterEstimation is made visible. +function vs_ParameterEstimation_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_ParameterEstimation (see VARARGIN) + +% Choose default command line output for vs_ParameterEstimation +handles.output = hObject; + +% YS: get the settings from the main figure +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +% set up the text fields with default values +setGUIVariables(handles); + +set(handles.listbox_filelist, 'KeyPressFcn', @filelist_listbox_KeyPressFcn); + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_ParameterEstimation wait for user response (see UIRESUME) +% uiwait(handles.figure_ParameterEstimation); + + +function setGUIVariables(handles) +VSData = guidata(handles.VSHandle); + +set(handles.edit_inputdirectory, 'String', VSData.vars.wavdir); +set(handles.edit_outputdirectory, 'String', VSData.vars.matdir); + +set(handles.checkbox_savematwithwav, 'Value', VSData.vars.PE_savematwithwav); +set(handles.checkbox_process16khz, 'Value', VSData.vars.PE_processwith16k); +set(handles.checkbox_useTextgrid, 'Value', VSData.vars.PE_useTextgrid); +set(handles.checkbox_showwaveform, 'Value', VSData.vars.PE_showwaveforms); % turn this off at startup + + +if (VSData.vars.recursedir) + func_setlistbox(handles.listbox_filelist, VSData.vars.wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring); +else + func_setlistbox(handles.listbox_filelist, VSData.vars.wavdir, 'none', VSData.vars, VSData.vars.I_searchstring); +end + +if (VSData.vars.PE_savematwithwav == 1) + set(handles.edit_outputdirectory, 'Enable', 'Off'); + set(handles.pushbutton_outputBrowse, 'Enable', 'Off'); +else + set(handles.edit_outputdirectory, 'Enable', 'On'); + set(handles.pushbutton_outputBrowse, 'Enable', 'On'); +end + +if (length(VSData.vars.PE_params) == 0) + set(handles.edit_parameterselection, 'String', 'None'); +elseif (length(VSData.vars.PE_params) == length(func_getparameterlist())) + set(handles.edit_parameterselection, 'String', 'All'); +else + set(handles.edit_parameterselection, 'String', 'Custom'); +end + + + +function filelist_listbox_KeyPressFcn(hObject, eventdata) +handles = guidata(hObject); + +key = double(get(gcbf, 'CurrentCharacter')); +if (gcbo == handles.listbox_filelist) + if (key == 127) % delete key + + inx = get(handles.listbox_filelist, 'Value'); + contents = get(handles.listbox_filelist, 'String'); + + %nothing to do + if (isempty(contents)) + return; + end + + newinx = setxor(inx, [1:length(contents)]); + + newcontents = contents(newinx); + set(handles.listbox_filelist, 'String', newcontents); + + if (inx(end) > length(newcontents)) + set(handles.listbox_filelist, 'Value', length(newcontents)); + else + set(handles.listbox_filelist, 'Value', inx(end)); + end + end +end + + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_ParameterEstimation_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on selection change in listbox_filelist. +function listbox_filelist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_filelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if (get(handles.checkbox_showwaveform, 'Value') == 1) + plotCurrentWav(handles); +end + + +% --- Executes during object creation, after setting all properties. +function listbox_filelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_filelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_inputdirectory_Callback(hObject, eventdata, handles) +% hObject handle to edit_inputdirectory (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +new_dir = get(handles.edit_inputdirectory, 'String'); + +VSData = guidata(handles.VSHandle); + +if (exist(new_dir, 'dir') == 7) % check if new_dir exists + VSData.vars.wavdir = new_dir; + set(handles.edit_inputdirectory, 'String', new_dir); + + if (get(handles.checkbox_savematwithwav, 'Value') == 1) % change output dir too + set(handles.edit_outputdirectory, 'String', new_dir); + + VSData = func_setmatdir('matdir', new_dir, VSData); + end + + % update the listbox + if (VSData.vars.recursedir == 1) + func_setlistbox(handles.listbox_filelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + else + func_setlistbox(handles.listbox_filelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring); + end + + VSData = func_setwavdir('wavdir', new_dir, VSData); + + % update the variables + guidata(handles.VSHandle, VSData); +else + msgbox('Error: directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.wavdir); +end + + +% --- Executes during object creation, after setting all properties. +function edit_inputdirectory_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_inputdirectory (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_inputBrowse. +function pushbutton_inputBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_inputBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +current_dir = get(handles.edit_inputdirectory, 'String'); +new_dir = uigetdir(current_dir); + +VSData = guidata(handles.VSHandle); + +if (ischar(new_dir)) % check if a new dir was returned + VSData.vars.wavdir = new_dir; + set(handles.edit_inputdirectory, 'String', new_dir); + + if (get(handles.checkbox_savematwithwav, 'Value') == 1) % change output dir too + set(handles.edit_outputdirectory, 'String', new_dir); + + VSData = func_setmatdir('matdir', new_dir, VSData); + end + + % update the listbox + if (VSData.vars.recursedir == 1) + func_setlistbox(handles.listbox_filelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring); + else + func_setlistbox(handles.listbox_filelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring); + end + + VSData = func_setwavdir('wavdir', new_dir, VSData); + + % update the variables + guidata(handles.VSHandle, VSData); +end + + + +function edit_outputdirectory_Callback(hObject, eventdata, handles) +% hObject handle to edit_outputdirectory (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); + +if (strcmp(get(hObject, 'Enable'), 'on')) + new_dir = get(handles.edit_outputdirectory, 'String'); + + if (exist(new_dir, 'dir') == 7) + set(handles.edit_outputdirectory, 'String', new_dir); + + VSData = func_setmatdir('matdir', new_dir, VSData); + + guidata(handles.VSHandle, VSData); + else + msgbox('Error: Directory not found.', 'Error', 'error', 'modal'); + set(hObject, 'String', VSData.vars.matdir); + end +end + +% --- Executes during object creation, after setting all properties. +function edit_outputdirectory_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_outputdirectory (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_outputBrowse. +function pushbutton_outputBrowse_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_outputBrowse (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); + +if (strcmp(get(hObject, 'Enable'), 'on')) + curr_dir = get(handles.edit_outputdirectory, 'String'); + new_dir = uigetdir(curr_dir); + + if (ischar(new_dir)) + set(handles.edit_outputdirectory, 'String', new_dir); + + VSData = func_setmatdir('matdir', new_dir, VSData); + + guidata(handles.VSHandle, VSData); + end +end + + +% --- Executes on button press in checkbox_savematwithwav. +function checkbox_savematwithwav_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_savematwithwav (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +VSData.vars.PE_savematwithwav = get(hObject, 'Value'); + +if (get(hObject, 'Value') == 1) % link input with output directory + VSData = func_setmatdir('matdir', VSData.vars.wavdir, VSData); + + set(handles.edit_outputdirectory, 'String', VSData.vars.matdir); + set(handles.edit_outputdirectory, 'Enable', 'off'); + set(handles.pushbutton_outputBrowse, 'Enable', 'off'); +else + %enable user to pick output directory + set(handles.edit_outputdirectory, 'Enable', 'on'); + set(handles.pushbutton_outputBrowse, 'Enable', 'on'); +end + +guidata(handles.VSHandle, VSData); + + + + + +% --- Executes on button press in pushbutton_ParameterSelection. +function pushbutton_ParameterSelection_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_ParameterSelection (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% save the old file list +filelist = get(handles.listbox_filelist, 'String'); +fileinx = get(handles.listbox_filelist, 'Value'); +vs_SelectParameters(); +set(handles.listbox_filelist, 'String', filelist, 'Value', fileinx); + + + +function edit_parameterselection_Callback(hObject, eventdata, handles) +% hObject handle to edit_parameterselection (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_parameterselection as text +% str2double(get(hObject,'String')) returns contents of edit_parameterselection as a double + + +% --- Executes during object creation, after setting all properties. +function edit_parameterselection_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_parameterselection (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_process16khz. +function checkbox_process16khz_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_process16khz (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +VSData.vars.PE_processwith16k = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_useTextgrid. +function checkbox_useTextgrid_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_useTextgrid (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +VSData.vars.PE_useTextgrid = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_showwaveform. +function checkbox_showwaveform_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_showwaveform (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +VSData.vars.PE_showwaveforms = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + +if (get(hObject, 'Value') == 1) + SWfig = vs_ShowWaveform; + SWhandle = guidata(SWfig); + + handles.SWfig = SWfig; + handles.SWhandle = SWhandle; + guidata(hObject, handles); + + plotCurrentWav(handles); +else + if (isfield(handles, 'SWfig')) + delete(handles.SWfig); + handles = rmfield(handles, 'SWfig'); + guidata(hObject, handles); + end +end + + +% --- plots the current wavfile into handles.SWhandle.axes_main +function plotCurrentWav(handles) +% get the present file selected +VSData = guidata(handles.VSHandle); + +contents = get(handles.listbox_filelist, 'String'); +if (isempty(contents)) + return; % do nothing +end +inx = get(handles.listbox_filelist, 'Value'); +filename = contents{inx}; +directory = get(handles.edit_inputdirectory, 'String'); +wavfile = [directory VSData.vars.dirdelimiter filename]; + +[y,Fs] = wavread(wavfile); +t = linspace(0,length(y)/Fs*1000, length(y)); +plot(handles.SWhandle.axes_main, t, y); +ylabel(handles.SWhandle.axes_main, 'Amplitude'); +xlabel(handles.SWhandle.axes_main, 'Time (ms)'); +axis(handles.SWhandle.axes_main, 'tight'); +set(handles.SWhandle.figure_ShowWaveform, 'Name', filename); + + +% --- Executes on button press in togglebutton_start. +function togglebutton_start_Callback(hObject, eventdata, handles) +% hObject handle to togglebutton_start (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if (get(hObject, 'Value') == 1) % start the process + set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red'); + + BatchProcess(handles); + set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0); + +end + + + +% this is the main parameter estimation function +function BatchProcess(handles) +VSData = guidata(handles.VSHandle); +filelist = get(handles.listbox_filelist, 'String'); +paramlist = VSData.vars.PE_params; + +if (isempty(filelist)) + msgbox('No input files.', 'Error', 'warn', 'modal'); + return; +end + +if (isempty(paramlist)) + msgbox('No parameters selected.', 'Error', 'warn', 'modal'); + return; +end + +MBox = MessageBox; +MBoxHandles = guidata(MBox); + +messages = cell(length(filelist)+1, 1); % allocate some memory for messages + +% get the variables from settings +windowsize = VSData.vars.windowsize; +frameshift = VSData.vars.frameshift; +preemphasis = VSData.vars.preemphasis; +F0algorithm = VSData.vars.F0algorithm; +FMTalgorithm = VSData.vars.FMTalgorithm; +maxF0 = VSData.vars.maxF0; +minF0 = VSData.vars.minF0; +frame_precision = VSData.vars.frame_precision; % used for Praat f0/formant + % estimation, SHR algorithm + % to set precision for time + % alignment of data + % vectors, in terms of frames + +inputdir = get(handles.edit_inputdirectory, 'String'); +outputdir = get(handles.edit_outputdirectory, 'String'); + +% start the processing of each file +for k=1:length(filelist) + % check if 'stop' button has been pressed + if (~ishandle(MBoxHandles.figure_MessageBox) || get(MBoxHandles.figure_MessageBox, 'UserData') == 1) + messages{k} = 'Stop button pressed by user.'; + if (ishandle(MBoxHandles.figure_MessageBox)) + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + end + return; + end + + messages{k} = sprintf('%d/%d. %s: ', k, length(filelist), filelist{k}); + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + set(handles.listbox_filelist, 'Value', k); + drawnow; + + wavfile = [inputdir VSData.vars.dirdelimiter filelist{k}]; + matfile = [outputdir VSData.vars.dirdelimiter filelist{k}(1:end-3) 'mat']; + textgridfile = [wavfile(1:end-3) 'Textgrid']; + + % strip down the matfile and check if the directory exists + mdir = fileparts(matfile); + if (exist(mdir, 'dir') ~= 7) + mkdir(mdir); + end + + % check if we are showing the waveforms + if (get(handles.checkbox_showwaveform, 'Value') == 1) + plotCurrentWav(handles); + end + + % check to see if we're using textgrids + useTextgrid = get(handles.checkbox_useTextgrid, 'Value'); + if (useTextgrid == 1) + if (exist(textgridfile, 'file') == 0) + useTextgrid = 0; + end + end + + % read in the wav file + [y, Fs, nbits] = wavread(wavfile); + + if (size(y, 2) > 1) + messages{k} = [messages{k} ' Multi-channel wav file - using first channel only: ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + y = y(:,1); + end + + % see if we need to resample to 16 kHz (faster for Straight) + resampled = 0; + if (get(handles.checkbox_process16khz, 'Value') == 1) + if (Fs ~= 16000) + y = resample(y, 16000, Fs); + wavfile = generateRandomFile(wavfile, handles); + wavfile = [wavfile(1:end-4) '_16kHz.wav']; + warning off; % stop clipping messages + wavwrite(y, 16000, nbits, wavfile); + warning on; + resampled = 1; + end + [y, Fs] = wavread(wavfile); % reread the resampled file + end + + % calculate the length of data vectors - all measures will have this + % length - important!! + data_len = floor(length(y) / Fs * 1000 / frameshift); + + % parse the parameter list to get proper ordering + paramlist = func_parseParameters(paramlist, handles, matfile, data_len); + + for n=1:length(paramlist) + + % check if 'stop' button has been pressed + if (~ishandle(MBoxHandles.figure_MessageBox) || get(MBoxHandles.figure_MessageBox, 'UserData') == 1) + break; + end + + + % F0 straight + if (strcmp(paramlist{n}, 'F0 (Straight)')) + messages{k} = [messages{k} 'strF0 ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + err = 0; + + if (useTextgrid) + try + [strF0, V] = func_StraightPitch(y, Fs, VSData.vars, textgridfile); + catch + err = 1; + end + else + try + [strF0, V] = func_StraightPitch(y, Fs, VSData.vars); + catch + err = 1; + end + end + + if (strcmp(VSData.vars.F0algorithm, 'F0 (Straight)') && err == 1) + messages{k+1} = 'Error: Problem with STRAIGHT - please check settings'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with STRAIGHT - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + return; + end + + strF0 = strF0(1:frameshift:end); % drop samples if necessary + + if (length(strF0) > data_len) + strF0 = strF0(1:data_len); + elseif (length(strF0) < data_len) + strF0 = [strF0; ones(data_len - length(strF0), 1) * NaN]; + end + + if (exist(matfile, 'file')) + save(matfile, 'strF0', 'Fs', '-append'); + else + save(matfile, 'strF0', 'Fs'); + end + + + % F0 (Snack) + elseif (strcmp(paramlist{n}, 'F0 (Snack)')) + messages{k} = [messages{k} 'sF0 ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + % guard case for 32-bit precision files - some version of snack + % on a 64-bit machine causes pitch estimation to fail + use_alt_file = 0; + if (nbits ~= 16) + snackwavfile = [wavfile(1:end-4) '_16b.wav']; + use_alt_file = 1; + wavwrite(y, Fs, 16, snackwavfile); + else + snackwavfile = wavfile; + end + + err = 0; + try + [sF0, sV, err] = func_SnackPitch(snackwavfile, windowsize/1000, frameshift/1000, maxF0, minF0); + catch + err = 1; + end + + % check for fatal errors + if (strcmp(VSData.vars.F0algorithm, 'F0 (Snack)') && err == 1) + messages{k+1} = 'Error: Problem with snack - please check settings'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with snack - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + if (use_alt_file) + delete(snackwavfile); + end + return; + end + + sF0 = [zeros(floor(windowsize/frameshift/2),1)*NaN; sF0]; sF0 = [sF0; ones(data_len-length(sF0), 1)*NaN]; + sV = [zeros(floor(windowsize/frameshift/2),1)*NaN; sV]; sV = [sV; ones(data_len-length(sV), 1)* NaN]; + + if (exist(matfile, 'file')) + save(matfile, 'sF0', 'sV', 'Fs', '-append'); + else + save(matfile, 'sF0', 'sV', 'Fs'); + end + + if (use_alt_file) + delete(snackwavfile); + end + + % F0 (Praat) + elseif (strcmp(paramlist{n}, 'F0 (Praat)')) + messages{k} = [messages{k} 'pF0 ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + % guard case for 32-bit precision files - some version of snack + % on a 64-bit machine causes pitch estimation to fail + err = 0; + try + [pF0, err] = func_PraatPitch(wavfile, frameshift/1000, frame_precision, ... + VSData.vars.F0Praatmin, ... + VSData.vars.F0Praatmax, ... + VSData.vars.F0PraatSilenceThreshold, ... + VSData.vars.F0PraatVoiceThreshold, ... + VSData.vars.F0PraatOctaveCost, ... + VSData.vars.F0PraatOctaveJumpCost, ... + VSData.vars.F0PraatVoicedUnvoicedCost, ... + VSData.vars.F0PraatKillOctaveJumps, ... + VSData.vars.F0PraatSmooth, ... + VSData.vars.F0PraatSmoothingBandwidth, ... + VSData.vars.F0PraatInterpolate, ... + VSData.vars.F0Praatmethod, ... + data_len); + catch + err = 1; + end + + % check for fatal errors + if (strcmp(VSData.vars.F0algorithm, 'F0 (Praat)') && err ~= 0) + messages{k+1} = 'Error: Problem with Praat - please check settings'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with Praat - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + + return; + elseif (err ~= 0) + messages{k} = [messages{k} '(error) ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + end + + if (exist(matfile, 'file')) + save(matfile, 'pF0', 'Fs', '-append'); + else + save(matfile, 'pF0', 'Fs'); + end + + % F0 (Other) + elseif (strcmp(paramlist{n}, 'F0 (Other)')) + messages{k} = [messages{k} 'oF0 ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + oF0 = zeros(data_len, 1) * NaN; % allocate some memory + + err = 0; + try + [F0, errmsg] = func_OtherPitch(wavfile, handles); + catch + err = 1; + end + + if ((length(F0)==1 && isnan(F0)) || isempty(F0)) + err = 1; + end + + % check for fatal errors + if (err == 1) + messages{k} = [messages{k} '- error: ' errmsg ' ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + + if (strcmp(VSData.vars.F0algorithm, 'F0 (Other)')) + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + msgbox({['Error: ' errmsg], 'Problem with F0 estimation - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + return; + end + elseif (err ~= 0) + messages{k} = [messages{k} '(error) ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + end + + + if (VSData.vars.F0OtherOffset + length(F0) <= data_len) + oF0(VSData.vars.F0OtherOffset+1:VSData.vars.F0OtherOffset + length(F0)) = F0; + else % need to trim F0 + oF0(VSData.vars.F0OtherOffset+1:end) = F0(1:data_len - VSData.vars.F0OtherOffset); + end + + if (exist(matfile, 'file')) + save(matfile, 'oF0', 'Fs', '-append'); + else + save(matfile, 'oF0', 'Fs'); + end + + + % F1, F2, F3, F4 (Snack) + elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Snack)')) + messages{k} = [messages{k} 'FMTs ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + % guard case for 32-bit files - some version of snack on a + % 64-bit machine causes formant estimation to fail + use_alt_file = 0; + if (nbits ~= 16) + snackwavfile = [wavfile(1:end-4) '_16b.wav']; + wavwrite(y, Fs, 16, snackwavfile); + use_alt_file = 1; + else + snackwavfile = wavfile; + end + + [sF1, sF2, sF3, sF4, sB1, sB2, sB3, sB4, err] = func_SnackFormants(snackwavfile, windowsize/1000, frameshift/1000, preemphasis); + + if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Snack)') && err == 1) + messages{k+1} = 'Error: Problem with snack - please check settings'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with snack - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + if (use_alt_file) + delete(snackwavfile); + end + + return; + end + + sF1 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF1]; sF1 = [sF1; ones(data_len-length(sF1), 1)*NaN]; + sF2 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF2]; sF2 = [sF2; ones(data_len-length(sF2), 1)*NaN]; + sF3 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF3]; sF3 = [sF3; ones(data_len-length(sF3), 1)*NaN]; + sF4 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF4]; sF4 = [sF4; ones(data_len-length(sF4), 1)*NaN]; + sB1 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB1]; sB1 = [sB1; ones(data_len-length(sB1), 1)*NaN]; + sB2 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB2]; sB2 = [sB2; ones(data_len-length(sB2), 1)*NaN]; + sB3 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB3]; sB3 = [sB3; ones(data_len-length(sB3), 1)*NaN]; + sB4 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB4]; sB4 = [sB4; ones(data_len-length(sB4), 1)*NaN]; + + if (exist(matfile, 'file')) + save(matfile, 'sF1', 'sF2', 'sF3', 'sF4', 'sB1', 'sB2', 'sB3', 'sB4', '-append'); + save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append'); + else + save(matfile, 'sF1', 'sF2', 'sF3', 'sF4', 'sB1', 'sB2', 'sB3', 'sB4'); + save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append'); + end + + if (use_alt_file) + delete(snackwavfile); + end + + % F1, F2, F3, F4 (Praat) + elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Praat)')) + messages{k} = [messages{k} 'FMTp ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + [pF1, pF2, pF3, pF4, pB1, pB2, pB3, pB4, err] = ... + func_PraatFormants(wavfile, windowsize/1000, frameshift/1000, frame_precision, data_len); + + if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Praat)') && err ~= 0) + messages{k+1} = 'Error: Problem with Praat - please check settings'; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with Praat - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + + return; + end + + if (exist(matfile, 'file')) + save(matfile, 'pF1', 'pF2', 'pF3', 'pF4', 'pB1', 'pB2', 'pB3', 'pB4', '-append'); + save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append'); + else + save(matfile, 'pF1', 'pF2', 'pF3', 'pF4', 'pB1', 'pB2', 'pB3', 'pB4'); + save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append'); + end + + % F1, F2, F3, F4 (Other) + elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Other)')) + messages{k} = [messages{k} 'oFMTs ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + oF1 = zeros(data_len, 1) * NaN; % allocate some memory + oF2 = zeros(data_len, 1) * NaN; + oF3 = zeros(data_len, 1) * NaN; + oF4 = zeros(data_len, 1) * NaN; + oB1 = zeros(data_len, 1) * NaN; + oB2 = zeros(data_len, 1) * NaN; + oB3 = zeros(data_len, 1) * NaN; + oB4 = zeros(data_len, 1) * NaN; + + err = 0; + try + [F1, F2, F3, F4, B1, B2, B3, B4, errmsg] = func_OtherFormants(wavfile, handles); + catch + err = 1; + end + + if ((length(F1) == 1 && isnan(F1)) || isempty(F1)) + err = 1; + end + + if (err == 1) + messages{k} = [messages{k} '-error: ' errmsg]; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + + if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Other)')) + set(MBoxHandles.pushbutton_close, 'Enable', 'on'); + set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + msgbox({'Error: Unable to proceed.', 'Problem with formant tracker - please check settings'}, 'Error', 'error', 'modal'); + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + + return; + end + end + + % build up the actual vector + if (VSData.vars.FormantsOtherOffset + length(F1) <= data_len) + oF1(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F1)) = F1; + oF2(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F2)) = F2; + oF3(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F3)) = F3; + oF4(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F4)) = F4; + oB1(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B1)) = B1; + oB2(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B2)) = B2; + oB3(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B3)) = B3; + oB4(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B4)) = B4; + else % need to trim + oF1(VSData.vars.FormantsOtherOffset+1:end) = F1(1:data_len - VSData.vars.FormantsOtherOffset); + oF2(VSData.vars.FormantsOtherOffset+1:end) = F2(1:data_len - VSData.vars.FormantsOtherOffset); + oF3(VSData.vars.FormantsOtherOffset+1:end) = F3(1:data_len - VSData.vars.FormantsOtherOffset); + oF4(VSData.vars.FormantsOtherOffset+1:end) = F4(1:data_len - VSData.vars.FormantsOtherOffset); + oB1(VSData.vars.FormantsOtherOffset+1:end) = B1(1:data_len - VSData.vars.FormantsOtherOffset); + oB2(VSData.vars.FormantsOtherOffset+1:end) = B2(1:data_len - VSData.vars.FormantsOtherOffset); + oB3(VSData.vars.FormantsOtherOffset+1:end) = B3(1:data_len - VSData.vars.FormantsOtherOffset); + oB4(VSData.vars.FormantsOtherOffset+1:end) = B4(1:data_len - VSData.vars.FormantsOtherOffset); + end + + if (exist(matfile, 'file')) + save(matfile, 'oF1', 'oF2', 'oF3', 'oF4', 'oB1', 'oB2', 'oB3', 'oB4', '-append'); + else + save(matfile, 'oF1', 'oF2', 'oF3', 'oF4', 'oB1', 'oB2', 'oB3', 'oB4'); + end + + + + % H1, H2, H4 + elseif (strcmp(paramlist{n}, 'H1, H2, H4')) + messages{k} = [messages{k} 'Hx ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + + F0 = func_parseF0(matdata, F0algorithm); + + if (useTextgrid) + [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, MBoxHandles, VSData.vars, textgridfile); + else + [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, MBoxHandles, VSData.vars); + end + + HF0algorithm = F0algorithm; + + % check if the process was completed + if (isComplete==0) + messages{k+1} = 'Stop button pressed by user.'; + if (ishandle(MBoxHandles.figure_MessageBox)) + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1); + end + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + + return; + end + + if (exist(matfile, 'file')) + save(matfile, 'H1', 'H2', 'H4', 'HF0algorithm', '-append'); + else + save(matfile, 'H1', 'H2', 'H4', 'HF0algorithm'); + end + + + + % A1, A2, A3 + elseif (strcmp(paramlist{n}, 'A1, A2, A3')) + messages{k} = [messages{k} 'Ax ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); % file has to exist at this point - dependency checking should make sure of this + + F0 = func_parseF0(matdata, F0algorithm); + [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm); + + if (useTextgrid) + [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, VSData.vars, textgridfile); + else + [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, VSData.vars); + end + + AFMTalgorithm = FMTalgorithm; + + save(matfile, 'A1', 'A2', 'A3', 'AFMTalgorithm', '-append'); + + + % H1*-H2* and H2*-H4* + elseif (strcmp(paramlist{n}, 'H1*-H2*, H2*-H4*')) + messages{k} = [messages{k} 'H1H2c H2H4c ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + F0 = func_parseF0(matdata, F0algorithm); + [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm); + + [H1H2c, H2H4c] = func_GetH1H2_H2H4(matdata.H1, matdata.H2, matdata.H4, Fs, F0, F1, F2); + save(matfile, 'H1H2c', 'H2H4c', '-append'); + + + % H1*-A1*, H1*-A2*, and H1*-A3* + elseif (strcmp(paramlist{n}, 'H1*-A1*, H1*-A2*, H1*-A3*')) + messages{k} = [messages{k} 'H1A1c H1A2c H1A3c ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + F0 = func_parseF0(matdata, F0algorithm); + [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm); + + [H1A1c, H1A2c, H1A3c] = func_GetH1A1_H1A2_H1A3(matdata.H1, matdata.A1, matdata.A2, matdata.A3, Fs, F0, F1, F2, F3); + save(matfile, 'H1A1c', 'H1A2c', 'H1A3c', '-append'); + + + % Energy + elseif (strcmp(paramlist{n}, 'Energy')) + messages{k} = [messages{k} 'E ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + F0 = func_parseF0(matdata, F0algorithm); + + Energy = func_GetEnergy(y, F0, Fs, VSData.vars); + save(matfile, 'Energy', '-append'); + + + % CPP + elseif (strcmp(paramlist{n}, 'CPP')) + messages{k} = [messages{k} 'CPP ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + F0 = func_parseF0(matdata, F0algorithm); + + CPP = func_GetCPP(y, Fs, F0, VSData.vars); + save(matfile, 'CPP', '-append'); + + + % HNR + elseif (strcmp(paramlist{n}, 'Harmonic to Noise Ratios - HNR')) + messages{k} = [messages{k} 'HNR ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + F0 = func_parseF0(matdata, F0algorithm); + + [HNR05, HNR15, HNR25, HNR35] = func_GetHNR(y, Fs, F0, VSData.vars); + save(matfile, 'HNR05', 'HNR15', 'HNR25', 'HNR35', '-append'); + + + % SHR + elseif (strcmp(paramlist{n}, 'Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0')) + messages{k} = [messages{k} 'SHR, shrF0 ']; + set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k); + drawnow; + + matdata = load(matfile); + + [SHR, shrF0] = func_GetSHRP(y, Fs, VSData.vars, data_len); + save(matfile, 'SHR', 'shrF0', '-append'); + end + + end + + if (resampled) % delete the temporary file if it exists + delete(wavfile); + end + +end + +messages{length(filelist)+1} = 'Processing complete.'; +set(MBoxHandles.listbox_messages, 'String', messages, 'Value', length(filelist)+1); +set(MBoxHandles.pushbutton_close, 'Enable', 'on'); +set(MBoxHandles.pushbutton_stop, 'Enable', 'off'); + + +% Function to generate random file names +function filename = generateRandomFile(fname, handles) +VSData = guidata(handles.VSHandle); +N = 8; % this many random digits/characters +[pathstr, name, ext] = fileparts(fname); +randstr = '00000000'; + +isok = 0; + +while(isok == 0) + for k=1:N + randstr(k) = floor(rand() * 25) + 65; + end + filename = [pathstr VSData.vars.dirdelimiter 'tmp_' name randstr ext]; + + if (exist(filename, 'file') == 0) + isok = 1; + end +end + + +% --- Executes when user attempts to close figure_ParameterEstimation. +function figure_ParameterEstimation_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure_ParameterEstimation (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: delete(hObject) closes the figure +if (isfield(handles, 'SWfig')) + delete(handles.SWfig); +end + +VSData = guidata(handles.VSHandle); +VSData.vars.PE_showwaveforms = 0; +guidata(handles.VSHandle, VSData); + +delete(hObject); + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_SelectParameters.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,176 @@ +function varargout = vs_SelectParameters(varargin) +% VS_SELECTPARAMETERS M-file for vs_SelectParameters.fig +% VS_SELECTPARAMETERS, by itself, creates a new VS_SELECTPARAMETERS or raises the existing +% singleton*. +% +% H = VS_SELECTPARAMETERS returns the handle to a new VS_SELECTPARAMETERS or the handle to +% the existing singleton*. +% +% VS_SELECTPARAMETERS('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_SELECTPARAMETERS.M with the given input arguments. +% +% VS_SELECTPARAMETERS('Property','Value',...) creates a new VS_SELECTPARAMETERS or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_SelectParameters_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_SelectParameters_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_SelectParameters + +% Last Modified by GUIDE v2.5 16-Oct-2009 14:30:10 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_SelectParameters_OpeningFcn, ... + 'gui_OutputFcn', @vs_SelectParameters_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_SelectParameters is made visible. +function vs_SelectParameters_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_SelectParameters (see VARARGIN) + +% Choose default command line output for vs_SelectParameters +handles.output = hObject; + +PEfig = vs_ParameterEstimation; +PEhandle = guidata(PEfig); +handles.PEfig = PEfig; +handles.PEhandle = PEhandle; +handles.VSHandle = PEhandle.VSHandle; + +% get the list of parameters: +paramlist = func_getparameterlist(); +paraminx = 1:length(paramlist); + +% check to see if "Other" F0/FMT have been enabled +VSData = guidata(handles.VSHandle); +if (VSData.vars.F0OtherEnable == 0) + paraminx(func_getparameterlist('F0 (Other)')) = 0; +end + +% check to see which formant algorithm to use +if (VSData.vars.FormantsOtherEnable == 0) + paraminx(func_getparameterlist('F1, F2, F3, F4 (Other)')) = 0; +end + +paraminx(paraminx == 0) = []; +paramlist = paramlist(paraminx); + +set(handles.listbox_paramlist, 'String', paramlist); + +selectedparamlist = VSData.vars.PE_params; + +% work out which ones to select +paraminx = zeros(length(paramlist), 1); +cnt = 1; +for k=1:length(paramlist) + for n=1:length(selectedparamlist) + if (strcmp(paramlist(k), selectedparamlist(n))) + paraminx(cnt) = k; + cnt = cnt + 1; + break; + end + end +end +paraminx(paraminx==0) = []; +handles.paraminx = paraminx; + +set(handles.listbox_paramlist, 'Value', handles.paraminx); + +if (isempty(handles.paraminx)) + set(handles.PEhandle.edit_parameterselection, 'String', 'None'); +elseif (length(handles.paraminx) == length(paramlist)) + set(handles.PEhandle.edit_parameterselection, 'String', 'All'); +else + set(handles.PEhandle.edit_parameterselection, 'String', 'Custom'); +end + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_SelectParameters wait for user response (see UIRESUME) +% uiwait(handles.figure_SelectParameters); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_SelectParameters_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on selection change in listbox_paramlist. +function listbox_paramlist_Callback(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +newinx = get(hObject, 'Value'); +handles.paraminx = setxor(handles.paraminx, newinx); + +paramlist = get(hObject, 'String'); +VSData.vars.PE_params = paramlist(handles.paraminx); + +set(handles.listbox_paramlist, 'Value', handles.paraminx); + +guidata(hObject, handles); +guidata(handles.VSHandle, VSData); + +if (isempty(handles.paraminx)) + set(handles.PEhandle.edit_parameterselection, 'String', 'None'); +elseif (length(handles.paraminx) == length(paramlist)) + set(handles.PEhandle.edit_parameterselection, 'String', 'All'); +else + set(handles.PEhandle.edit_parameterselection, 'String', 'Custom'); +end + + + +% --- Executes during object creation, after setting all properties. +function listbox_paramlist_CreateFcn(hObject, eventdata, handles) +% hObject handle to listbox_paramlist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: listbox controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OK. +function pushbutton_OK_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OK (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +delete(gcf);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_Settings.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,1208 @@ +function varargout = vs_Settings(varargin) +% VS_SETTINGS M-file for vs_Settings.fig +% VS_SETTINGS, by itself, creates a new VS_SETTINGS or raises the existing +% singleton*. +% +% H = VS_SETTINGS returns the handle to a new VS_SETTINGS or the handle to +% the existing singleton*. +% +% VS_SETTINGS('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_SETTINGS.M with the given input arguments. +% +% VS_SETTINGS('Property','Value',...) creates a new VS_SETTINGS or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_Settings_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_Settings_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_Settings + +% Last Modified by GUIDE v2.5 09-Mar-2011 22:29:50 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_Settings_OpeningFcn, ... + 'gui_OutputFcn', @vs_Settings_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_Settings is made visible. +function vs_Settings_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_Settings (see VARARGIN) + +% Choose default command line output for vs_Settings +handles.output = hObject; + +% YS: get the settings from the main figure +if (~isfield(handles, 'VSHandle')) + VSHandle = VoiceSauce; + handles.VSHandle = VSHandle; +end + +% restore the variables from initialization +setGUIVariables(handles); + + +% +set(handles.uipanel_Formants,'SelectionChangeFcn',@formants_buttongroup_SelectionChangeFcn); +set(handles.uipanel_F0,'SelectionChangeFcn',@F0_buttongroup_SelectionChangeFcn); + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_Settings wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_Settings_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +% aligns the variables with those in VS.vars +function setGUIVariables(handles) +VSData = guidata(handles.VSHandle); +vars = VSData.vars; + +%F0 +switch(vars.F0algorithm) + case {'F0 (Straight)'} + set(handles.radiobutton_F0_Straight, 'Value', 1); + case {'F0 (Snack)'} + set(handles.radiobutton_F0_Snack, 'Value', 1); + case {'F0 (Praat)'} + set(handles.radiobutton_F0_Praat, 'Value', 1); + case {'F0 (Other)'} + set(handles.radiobutton_F0_Other, 'Value', 1); +end + +set(handles.edit_F0_Straight_maxF0, 'String', num2str(vars.maxstrF0)); +set(handles.edit_F0_Straight_minF0, 'String', num2str(vars.minstrF0)); +set(handles.edit_F0_Straight_maxduration, 'String', num2str(vars.maxstrdur)); + +set(handles.edit_F0_Snack_maxF0, 'String', num2str(vars.maxF0)); +set(handles.edit_F0_Snack_minF0, 'String', num2str(vars.minF0)); + +set(handles.checkbox_F0_Other_Enable, 'Value', vars.F0OtherEnable); +set(handles.edit_F0_Other_Command, 'String', vars.F0OtherCommand); +set(handles.edit_F0_Other_Offset, 'String', num2str(vars.F0OtherOffset)); +if (vars.F0OtherEnable == 1) + set(handles.edit_F0_Other_Command, 'Enable', 'On'); + set(handles.edit_F0_Other_Offset, 'Enable', 'On'); + set(handles.radiobutton_F0_Other, 'Enable', 'On'); +end + + +% Formants +switch(vars.FMTalgorithm) + case {'F1, F2, F3, F4 (Snack)'} + set(handles.radiobutton_Formants_Snack, 'Value', 1); + case {'F1, F2, F3, F4 (Praat)'} + set(handles.radiobutton_Formants_Praat, 'Value', 1); + case {'F1, F2, F3, F4 (Other)'} + set(handles.radiobutton_Formants_Other, 'Value', 1); +end + +set(handles.edit_Formants_Snack_preemphasis, 'String', num2str(vars.preemphasis)); +set(handles.checkbox_Formants_Other_Enable, 'Value', vars.FormantsOtherEnable); +set(handles.edit_Formants_Other_Command, 'String', vars.FormantsOtherCommand); +set(handles.edit_Formants_Other_Offset, 'String', num2str(vars.FormantsOtherOffset)); + +if (vars.FormantsOtherEnable) + set(handles.edit_Formants_Other_Command, 'Enable', 'On'); + set(handles.edit_Formants_Other_Offset, 'Enable', 'On'); + set(handles.radiobutton_Formants_Other, 'Enable', 'On'); +end + +% SHR +set(handles.edit_SHR_max_F0, 'String', num2str(vars.SHRmax)); +set(handles.edit_SHR_min_F0, 'String', num2str(vars.SHRmin)); +set(handles.edit_SHR_threshold, 'String', num2str(vars.SHRThreshold)); + +% Common +set(handles.edit_Common_windowsize, 'String', num2str(vars.windowsize)); +set(handles.edit_Common_frameshift, 'String', num2str(vars.frameshift)); +set(handles.edit_Common_NaN, 'String', vars.NotANumber); +set(handles.checkbox_Common_linkmatdir, 'Value', vars.linkmatdir); +set(handles.checkbox_Common_linkwavdir, 'Value', vars.linkwavdir); +set(handles.checkbox_Common_recursedir, 'Value', vars.recursedir); +set(handles.edit_Common_Nperiods, 'String', num2str(vars.Nperiods)); +set(handles.edit_Common_Nperiods_EC, 'String', num2str(vars.Nperiods_EC)); + +% Textgrid +set(handles.edit_Textgrid_ignorelist, 'String', vars.TextgridIgnoreList); +set(handles.edit_Textgrid_tiernumber, 'String', num2str(vars.TextgridTierNumber)); + +% EGG +set(handles.edit_EGGData_headers, 'String', vars.EGGheaders); +set(handles.edit_EGGData_timelabel, 'String' ,vars.EGGtimelabel); + +% Outputs +set(handles.edit_Outputs_smoothwinsize, 'String', num2str(vars.O_smoothwinsize)); + +% Input (wav) files +set(handles.edit_Input_searchstring, 'String', vars.I_searchstring); + + +function edit_Common_windowsize_Callback(hObject, eventdata, handles) +% hObject handle to edit_Common_windowsize (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Common_windowsize as text +% str2double(get(hObject,'String')) returns contents of edit_Common_windowsize as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isnan(num)) + set(hObject, 'String', num2str(vars.windowsize)); +else + num = round(num); + if (num > 0) + VSData.vars.windowsize = num; + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); + else + set(hObject, 'String', num2str(num)); + end +end + + + +% --- Executes during object creation, after setting all properties. +function edit_Common_windowsize_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Common_windowsize (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Common_frameshift_Callback(hObject, eventdata, handles) +% hObject handle to edit_Common_frameshift (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Common_frameshift as text +% str2double(get(hObject,'String')) returns contents of edit_Common_frameshift as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isnan(num)) + set(hObject, 'String', num2str(vars.frameshift)); +else + num = round(num); + if (num > 0) + VSData.vars.frameshift = num(1); + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); + else + set(hObject, 'String', num2str(vars.frameshift)); + end +end + + +% --- Executes during object creation, after setting all properties. +function edit_Common_frameshift_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Common_frameshift (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Formants_Snack_preemphasis_Callback(hObject, eventdata, handles) +% hObject handle to edit_Formants_Snack_preemphasis (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Formants_Snack_preemphasis as text +% str2double(get(hObject,'String')) returns contents of edit_Formants_Snack_preemphasis as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.preemphasis)); +else + num = num(1); + VSData.vars.preemphasis = num; + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); +end + + + +% --- Executes during object creation, after setting all properties. +function edit_Formants_Snack_preemphasis_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Formants_Snack_preemphasis (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_F0_Straight_maxF0_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_maxF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Straight_maxF0 as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Straight_maxF0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.maxstrF0)); +else + num = num(1); + VSData.vars.maxstrF0 = num; + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Straight_maxF0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_maxF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_F0_Straight_minF0_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_minF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Straight_minF0 as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Straight_minF0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.minstrF0)); +else + num = num(1); + VSData.vars.minstrF0 = num; + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Straight_minF0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_minF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in radiobutton_F0_Straight. +function radiobutton_F0_Straight_Callback(hObject, eventdata, handles) +% hObject handle to radiobutton_F0_Straight (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radiobutton_F0_Straight + + +% --- Executes on button press in radiobutton_F0_Snack. +function radiobutton_F0_Snack_Callback(hObject, eventdata, handles) +% hObject handle to radiobutton_F0_Snack (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radiobutton_F0_Snack + + +% --- Executes on button press in radiobutton_F0_Other. +function radiobutton_F0_Other_Callback(hObject, eventdata, handles) +% hObject handle to radiobutton_F0_Other (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radiobutton_F0_Other + + + +function edit_F0_Straight_maxduration_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_maxduration (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Straight_maxduration as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Straight_maxduration as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.maxstrdur)); +else + num = num(1); + VSData.vars.maxstrdur = num; + set(hObject, 'String', num2str(num)) + guidata(handles.VSHandle, VSData); +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Straight_maxduration_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Straight_maxduration (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_F0_Snack_maxF0_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Snack_maxF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Snack_maxF0 as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Snack_maxF0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.maxF0)); +else + num = num(1); + VSData.vars.maxF0 = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Snack_maxF0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Snack_maxF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_F0_Snack_minF0_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Snack_minF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Snack_minF0 as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Snack_minF0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.minF0)); +else + num = num(1); + VSData.vars.minF0 = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Snack_minF0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Snack_minF0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_F0_Other_Enable. +function checkbox_F0_Other_Enable_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_F0_Other_Enable (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); + +if (get(hObject, 'Value') == 1) + set(handles.edit_F0_Other_Command, 'Enable', 'on'); + set(handles.edit_F0_Other_Offset, 'Enable', 'on'); + set(handles.radiobutton_F0_Other, 'Enable', 'on'); + VSData.vars.F0OtherEnable = 1; +else + set(handles.edit_F0_Other_Command, 'Enable', 'off'); + set(handles.edit_F0_Other_Offset, 'Enable', 'off'); + set(handles.radiobutton_F0_Other, 'Enable', 'off'); + VSData.vars.F0OtherEnable = 0; + + if (get(handles.radiobutton_F0_Other, 'Value') == 1) % switch back to Straight + set(handles.radiobutton_F0_Straight, 'Value', 1); + VSData.vars.F0algorithm = 'F0 (Straight)'; + end +end + +guidata(handles.VSHandle, VSData); +function edit_F0_Other_Command_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Other_Command (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Other_Command as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Other_Command as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +VSData.vars.F0OtherCommand = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Other_Command_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Other_Command (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_F0_Other_Offset_Callback(hObject, eventdata, handles) +% hObject handle to edit_F0_Other_Offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_F0_Other_Offset as text +% str2double(get(hObject,'String')) returns contents of edit_F0_Other_Offset as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.F0OtherOffset)); +else + num = num(1); + VSData.vars.F0OtherOffset = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_F0_Other_Offset_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_F0_Other_Offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in radiobutton_Formants_Snack. +function radiobutton_Formants_Snack_Callback(hObject, eventdata, handles) +% hObject handle to radiobutton_Formants_Snack (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radiobutton_Formants_Snack + + +% --- Executes on button press in radiobutton_Formants_Other. +function radiobutton_Formants_Other_Callback(hObject, eventdata, handles) +% hObject handle to radiobutton_Formants_Other (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radiobutton_Formants_Other + + + +function edit_Formants_Other_Offset_Callback(hObject, eventdata, handles) +% hObject handle to edit_Formants_Other_Offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Formants_Other_Offset as text +% str2double(get(hObject,'String')) returns contents of edit_Formants_Other_Offset as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.FormantsOtherOffset)); +else + num = num(1); + VSData.vars.FormantsOtherOffset = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_Formants_Other_Offset_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Formants_Other_Offset (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Formants_Other_Command_Callback(hObject, eventdata, handles) +% hObject handle to edit_Formants_Other_Command (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Formants_Other_Command as text +% str2double(get(hObject,'String')) returns contents of edit_Formants_Other_Command as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +VSData.vars.FormantsOtherCommand = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Formants_Other_Command_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Formants_Other_Command (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_Formants_Other_Enable. +function checkbox_Formants_Other_Enable_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Formants_Other_Enable (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); + +if (get(hObject, 'Value') == 1) + set(handles.edit_Formants_Other_Command, 'Enable', 'on'); + set(handles.edit_Formants_Other_Offset, 'Enable', 'on'); + set(handles.radiobutton_Formants_Other, 'Enable', 'on'); + VSData.vars.FormantsOtherEnable = 1; +else + set(handles.edit_Formants_Other_Command, 'Enable', 'off'); + set(handles.edit_Formants_Other_Offset, 'Enable', 'off'); + set(handles.radiobutton_Formants_Other, 'Enable', 'off'); + VSData.vars.FormantsOtherEnable = 0; + + if (get(handles.radiobutton_Formants_Other, 'Value') == 1) % set back to Snack + set(handles.radiobutton_Formants_Snack, 'Value', 1); + VSData.vars.FMTalgorithm = 'F1, F2, F3, F4 (Snack)'; + end +end + +guidata(handles.VSHandle, VSData); + + +function edit_Textgrid_ignorelist_Callback(hObject, eventdata, handles) +% hObject handle to edit_Textgrid_ignorelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Textgrid_ignorelist as text +% str2double(get(hObject,'String')) returns contents of edit_Textgrid_ignorelist as a double +VSData = guidata(handles.VSHandle); + +if (isempty(get(hObject, 'String'))) + set(hObject, 'String', '"", " ", "SIL"'); % this is the default, edit box cannot be empty +end + +VSData.vars.TextgridIgnoreList = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_Textgrid_ignorelist_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Textgrid_ignorelist (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Textgrid_tiernumber_Callback(hObject, eventdata, handles) +% hObject handle to edit_Textgrid_tiernumber (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Textgrid_tiernumber as text +% str2double(get(hObject,'String')) returns contents of edit_Textgrid_tiernumber as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2num(get(hObject, 'String')); +if (isempty(num)) + set(hObject, 'String', num2str(vars.TextgridTierNumber)); +else + VSData.vars.TextgridTierNumber = unique(num); + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(VSData.vars.TextgridTierNumber)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_Textgrid_tiernumber_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Textgrid_tiernumber (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% YS: executes on the press of a radio button in formants panel +function formants_buttongroup_SelectionChangeFcn(hObject, eventdata) +handles = guidata(hObject); +VSData = guidata(handles.VSHandle); + +switch get(eventdata.NewValue, 'Tag') + case 'radiobutton_Formants_Snack' + VSData.vars.FMTalgorithm = 'F1, F2, F3, F4 (Snack)'; + case 'radiobutton_Formants_Praat' + VSData.vars.FMTalgorithm = 'F1, F2, F3, F4 (Praat)'; + case 'radiobutton_Formants_Other' + VSData.vars.FMTalgorithm = 'F1, F2, F3, F4 (Other)'; + otherwise +end +guidata(handles.VSHandle, VSData); + + + +% YS: executes on the press of a radio button in F0 panel +function F0_buttongroup_SelectionChangeFcn(hObject, eventdata) +handles = guidata(hObject); +VSData = guidata(handles.VSHandle); + +switch get(eventdata.NewValue, 'Tag') + case 'radiobutton_F0_Straight' + VSData.vars.F0algorithm = 'F0 (Straight)'; + case 'radiobutton_F0_Snack' + VSData.vars.F0algorithm = 'F0 (Snack)'; + case 'radiobutton_F0_Praat' + VSData.vars.F0algorithm = 'F0 (Praat)'; + case 'radiobutton_F0_Other' + VSData.vars.F0algorithm = 'F0 (Other)'; + otherwise +end +guidata(handles.VSHandle, VSData); + + + +% --- Executes on button press in pushbutton_Exit. +function pushbutton_Exit_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Exit (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +delete(gcf); + + +% -------------------------------------------------------------------- +function menu_Settings_Callback(hObject, eventdata, handles) +% hObject handle to menu_Settings (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +% -------------------------------------------------------------------- +function menu_Settings_Load_Callback(hObject, eventdata, handles) +% hObject handle to menu_Settings_Load (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +filename = uigetfile('*.mat', 'Select File to Load'); + +if (~ischar(filename)) + return; +end + +matdata = load(filename); +VSData.vars = matdata.settings; + +% set the machine specific variables +if (ispc) + VSData.vars.dirdelimiter = '\'; +else + VSData.vars.dirdelimiter = '/'; +end + +if (exist(VSData.vars.wavdir, 'dir') ~= 7) + VSData.vars.wavdir = ['.' vars.dirdelimiter]; +end + +if (exist(VSData.vars.matdir, 'dir') ~= 7) + VSData.vars.matdir = ['.' vars.dirdelimiter]; +end + +guidata(handles.VSHandle, VSData); +setGUIVariables(handles); + + +% -------------------------------------------------------------------- +function menu_Settings_Save_Callback(hObject, eventdata, handles) +% hObject handle to menu_Settings_Save (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +VSData = guidata(handles.VSHandle); +VSData.vars.PE_showwaveformst = 0; % this is a special case +settings = VSData.vars; +[filename, pathname] = uiputfile('*.mat', 'Select File to Save'); + +if (~ischar(filename)) + return; +end + +save([pathname filename], 'settings'); + +helpdlg('Save complete.', 'Save'); + + + +function edit_EGGData_headers_Callback(hObject, eventdata, handles) +% hObject handle to edit_EGGData_headers (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_EGGData_headers as text +% str2double(get(hObject,'String')) returns contents of edit_EGGData_headers as a double +VSData = guidata(handles.VSHandle); + +if (isempty(get(hObject, 'String'))) + set(hObject, 'String', VSData.vars.EGGheaders); % this is the default, edit box cannot be empty +end + +VSData.vars.EGGheaders = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_EGGData_headers_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_EGGData_headers (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_EGGData_timelabel_Callback(hObject, eventdata, handles) +% hObject handle to edit_EGGData_timelabel (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_EGGData_timelabel as text +% str2double(get(hObject,'String')) returns contents of edit_EGGData_timelabel as a double +VSData = guidata(handles.VSHandle); + +if (isempty(get(hObject, 'String'))) + set(hObject, 'String', VSData.vars.EGGtimelabel); % this is the default, edit box cannot be empty +end + +VSData.vars.EGGtimelabel = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + + +% --- Executes during object creation, after setting all properties. +function edit_EGGData_timelabel_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_EGGData_timelabel (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Common_NaN_Callback(hObject, eventdata, handles) +% hObject handle to edit_Common_NaN (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Common_NaN as text +% str2double(get(hObject,'String')) returns contents of edit_Common_NaN as a double +VSData = guidata(handles.VSHandle); +VSData.vars.NotANumber = get(hObject, 'String'); +guidata(handles.VSHandle, VSData); + +% --- Executes during object creation, after setting all properties. +function edit_Common_NaN_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Common_NaN (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in checkbox_Common_linkmatdir. +function checkbox_Common_linkmatdir_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Common_linkmatdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_Common_linkmatdir +VSData = guidata(handles.VSHandle); +VSData.vars.linkmatdir = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_Common_linkwavdir. +function checkbox_Common_linkwavdir_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Common_linkwavdir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_Common_linkwavdir +VSData = guidata(handles.VSHandle); +VSData.vars.linkwavdir = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_Common_recursedir. +function checkbox_Common_recursedir_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_Common_recursedir (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_Common_recursedir +VSData = guidata(handles.VSHandle); +VSData.vars.recursedir = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + + +function edit_Outputs_smoothwinsize_Callback(hObject, eventdata, handles) +% hObject handle to edit_Outputs_smoothwinsize (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +num = str2double(get(hObject, 'String')); + +if (~isnan(num)) + num = round(num); + if (num >= 0) % 0 denotes no output smoothing + set(hObject, 'String', num2str(num)); + VSData.vars.O_smoothwinsize = num; + guidata(handles.VSHandle, VSData); + else + set(hObject, 'String', num2str(vars.O_smoothwinsize)); + end +else + set(hObject, 'String', num2str(vars.O_smoothwinsize)); +end + + + +% --- Executes during object creation, after setting all properties. +function edit_Outputs_smoothwinsize_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Outputs_smoothwinsize (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Input_searchstring_Callback(hObject, eventdata, handles) +% hObject handle to edit_Input_searchstring (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +VSData = guidata(handles.VSHandle); +str = get(hObject, 'String'); +if (isempty(str)) + set(hObject, 'String', VSData.vars.I_searchstring); +else + VSData.vars.I_searchstring = str; + guidata(handles.VSHandle, VSData); +end + + + +% --- Executes during object creation, after setting all properties. +function edit_Input_searchstring_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Input_searchstring (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +% --- Executes on button press in pushbutton_Settings_Praat. +function pushbutton_Settings_Praat_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_Settings_Praat (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +vs_Settings_Praat(); + + + +function edit_SHR_min_F0_Callback(hObject, eventdata, handles) +% hObject handle to edit_SHR_min_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_SHR_min_F0 as text +% str2double(get(hObject,'String')) returns contents of edit_SHR_min_F0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isempty(num) || num < 0) + set(hObject, 'String', num2str(vars.SHRmin)); +else + VSData.vars.SHRmin = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_SHR_min_F0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_SHR_min_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_SHR_max_F0_Callback(hObject, eventdata, handles) +% hObject handle to edit_SHR_max_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_SHR_max_F0 as text +% str2double(get(hObject,'String')) returns contents of edit_SHR_max_F0 as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isempty(num) || num < 0) + set(hObject, 'String', num2str(vars.SHRmax)); +else + VSData.vars.SHRmax = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_SHR_max_F0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_SHR_max_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_SHR_threshold_Callback(hObject, eventdata, handles) +% hObject handle to edit_SHR_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_SHR_threshold as text +% str2double(get(hObject,'String')) returns contents of edit_SHR_threshold as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isempty(num) || num < 0) + set(hObject, 'String', num2str(vars.SHRThreshold)); +else + VSData.vars.SHRThreshold = num; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(num)) +end + + +% --- Executes during object creation, after setting all properties. +function edit_SHR_threshold_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_SHR_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Common_Nperiods_Callback(hObject, eventdata, handles) +% hObject handle to edit_Common_Nperiods (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Common_Nperiods as text +% str2double(get(hObject,'String')) returns contents of edit_Common_Nperiods as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isempty(num) || round(num) < 0) + set(hObject, 'String', num2str(vars.Nperiods)); +else + VSData.vars.Nperiods = round(num); + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(round(num))) +end + + +% --- Executes during object creation, after setting all properties. +function edit_Common_Nperiods_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Common_Nperiods (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_Common_Nperiods_EC_Callback(hObject, eventdata, handles) +% hObject handle to edit_Common_Nperiods_EC (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Common_Nperiods_EC as text +% str2double(get(hObject,'String')) returns contents of edit_Common_Nperiods_EC as a double +VSData = guidata(handles.VSHandle); +vars = VSData.vars; +num = str2double(get(hObject, 'String')); +if (isempty(num) || round(num) < 0) + set(hObject, 'String', num2str(vars.Nperiods_EC)); +else + VSData.vars.Nperiods_EC = round(num); + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(round(num))) +end + + +% --- Executes during object creation, after setting all properties. +function edit_Common_Nperiods_EC_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Common_Nperiods_EC (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_Settings_Praat.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,413 @@ +function varargout = vs_Settings_Praat(varargin) +% VS_SETTINGS_PRAAT M-file for vs_Settings_Praat.fig +% VS_SETTINGS_PRAAT, by itself, creates a new VS_SETTINGS_PRAAT or raises the existing +% singleton*. +% +% H = VS_SETTINGS_PRAAT returns the handle to a new VS_SETTINGS_PRAAT or the handle to +% the existing singleton*. +% +% VS_SETTINGS_PRAAT('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_SETTINGS_PRAAT.M with the given input arguments. +% +% VS_SETTINGS_PRAAT('Property','Value',...) creates a new VS_SETTINGS_PRAAT or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_Settings_Praat_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_Settings_Praat_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_Settings_Praat + +% Last Modified by GUIDE v2.5 08-Mar-2011 23:30:28 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_Settings_Praat_OpeningFcn, ... + 'gui_OutputFcn', @vs_Settings_Praat_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_Settings_Praat is made visible. +function vs_Settings_Praat_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_Settings_Praat (see VARARGIN) + +% Choose default command line output for vs_Settings_Praat +handles.output = hObject; + +Setfig = vs_Settings; +Sethandle = guidata(Setfig); +handles.Setfig = Setfig; +handles.Sethandle = Sethandle; +handles.VSHandle = Sethandle.VSHandle; + +setGUIVariables(handles); + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_Settings_Praat wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% align the variables with those in VS.vars +function setGUIVariables(handles) +VSData = guidata(handles.VSHandle); +vars = VSData.vars; + +set(handles.edit_max_F0, 'String', num2str(vars.F0Praatmax)); +set(handles.edit_min_F0, 'String', num2str(vars.F0Praatmin)); + +set(handles.edit_voice_threshold, 'String', num2str(vars.F0PraatVoiceThreshold)); +set(handles.edit_silence_threshold, 'String', num2str(vars.F0PraatSilenceThreshold)); +set(handles.edit_octave_cost, 'String', num2str(vars.F0PraatOctaveCost)); +set(handles.edit_oct_j_cost, 'String', num2str(vars.F0PraatOctiveJumpCost)); +set(handles.edit_voiced_unvoiced_cost, 'String', num2str(vars.F0PraatVoicedUnvoicedCost)); +set(handles.edit_smoothing_bandwidth, 'String', num2str(vars.F0PraatSmoothingBandwidth)); + +set(handles.checkbox_kill_octave_jumps, 'Value', vars.F0PraatKillOctaveJumps); +set(handles.checkbox_smooth, 'Value', vars.F0PraatSmooth); +set(handles.checkbox_interpolate, 'Value', vars.F0PraatInterpolate); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_Settings_Praat_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +function edit_min_F0_Callback(hObject, eventdata, handles) +% hObject handle to edit_min_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_min_F0 as text +% str2double(get(hObject,'String')) returns contents of edit_min_F0 as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0Praatmin = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0Praatmin)); +end + + + +% --- Executes during object creation, after setting all properties. +function edit_min_F0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_min_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_max_F0_Callback(hObject, eventdata, handles) +% hObject handle to edit_max_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_max_F0 as text +% str2double(get(hObject,'String')) returns contents of edit_max_F0 as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0Praatmax = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0Praatmax)); +end + + + + +% --- Executes during object creation, after setting all properties. +function edit_max_F0_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_max_F0 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_voice_threshold_Callback(hObject, eventdata, handles) +% hObject handle to edit_voice_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_voice_threshold as text +% str2double(get(hObject,'String')) returns contents of edit_voice_threshold as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatVoiceThreshold = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatVoiceThreshold)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_voice_threshold_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_voice_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_oct_j_cost_Callback(hObject, eventdata, handles) +% hObject handle to edit_oct_j_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_oct_j_cost as text +% str2double(get(hObject,'String')) returns contents of edit_oct_j_cost as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatOctiveJumpCost = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatOctiveJumpCost)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_oct_j_cost_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_oct_j_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton_OK. +function pushbutton_OK_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton_OK (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +delete(gcf); + + +% --- Executes on button press in checkbox_kill_octave_jumps. +function checkbox_kill_octave_jumps_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_kill_octave_jumps (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_kill_octave_jumps +VSData = guidata(handles.VSHandle); +VSData.vars.F0PraatKillOctaveJumps = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_smooth. +function checkbox_smooth_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_smooth (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_smooth +VSData = guidata(handles.VSHandle); +VSData.vars.F0PraatSmooth = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + +% --- Executes on button press in checkbox_interpolate. +function checkbox_interpolate_Callback(hObject, eventdata, handles) +% hObject handle to checkbox_interpolate (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox_interpolate +VSData = guidata(handles.VSHandle); +VSData.vars.F0PraatInterpolate = get(hObject, 'Value'); +guidata(handles.VSHandle, VSData); + + + +function edit_silence_threshold_Callback(hObject, eventdata, handles) +% hObject handle to edit_silence_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_silence_threshold as text +% str2double(get(hObject,'String')) returns contents of edit_silence_threshold as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatSilenceThreshold = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatSilenceThreshold)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_silence_threshold_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_silence_threshold (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_octave_cost_Callback(hObject, eventdata, handles) +% hObject handle to edit_octave_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_octave_cost as text +% str2double(get(hObject,'String')) returns contents of edit_octave_cost as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatOctaveCost = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatOctaveCost)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_octave_cost_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_octave_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_voiced_unvoiced_cost_Callback(hObject, eventdata, handles) +% hObject handle to edit_voiced_unvoiced_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_voiced_unvoiced_cost as text +% str2double(get(hObject,'String')) returns contents of edit_voiced_unvoiced_cost as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatVoicedUnvoicedCost = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatVoicedUnvoicedCost)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_voiced_unvoiced_cost_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_voiced_unvoiced_cost (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_smoothing_bandwidth_Callback(hObject, eventdata, handles) +% hObject handle to edit_smoothing_bandwidth (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_smoothing_bandwidth as text +% str2double(get(hObject,'String')) returns contents of edit_smoothing_bandwidth as a double +VSData = guidata(handles.VSHandle); +val = str2double(get(hObject, 'String')); + +if (~isnan(val) && val >= 0) + VSData.vars.F0PraatSmoothingBandwidth = val; + guidata(handles.VSHandle, VSData); + set(hObject, 'String', num2str(val)); +else + set(hObject, 'String', num2str(VSData.vars.F0PraatSmoothingBandwidth)); +end + + +% --- Executes during object creation, after setting all properties. +function edit_smoothing_bandwidth_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_smoothing_bandwidth (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ShowWaveform.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,105 @@ +function varargout = vs_ShowWaveform(varargin) +% VS_SHOWWAVEFORM M-file for vs_ShowWaveform.fig +% VS_SHOWWAVEFORM, by itself, creates a new VS_SHOWWAVEFORM or raises the existing +% singleton*. +% +% H = VS_SHOWWAVEFORM returns the handle to a new VS_SHOWWAVEFORM or the handle to +% the existing singleton*. +% +% VS_SHOWWAVEFORM('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in VS_SHOWWAVEFORM.M with the given input arguments. +% +% VS_SHOWWAVEFORM('Property','Value',...) creates a new VS_SHOWWAVEFORM or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before vs_ShowWaveform_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to vs_ShowWaveform_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help vs_ShowWaveform + +% Last Modified by GUIDE v2.5 24-Jul-2009 14:54:12 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @vs_ShowWaveform_OpeningFcn, ... + 'gui_OutputFcn', @vs_ShowWaveform_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before vs_ShowWaveform is made visible. +function vs_ShowWaveform_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to vs_ShowWaveform (see VARARGIN) + +% Choose default command line output for vs_ShowWaveform +handles.output = hObject; + +PEfig = vs_ParameterEstimation; +PEhandle = guidata(PEfig); +handles.PEfig = PEfig; +handles.PEhandle = PEhandle; + +if (~isfield(PEhandle, 'SWfig')) + VSData = guidata(PEhandle.VSHandle); + VSData.vars.PE_showwaveform = 1; + guidata(PEhandle.VSHandle, VSData); +end + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes vs_ShowWaveform wait for user response (see UIRESUME) +% uiwait(handles.figure_ShowWaveform); + + +% --- Outputs from this function are returned to the command line. +function varargout = vs_ShowWaveform_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes when user attempts to close figure_ShowWaveform. +function figure_ShowWaveform_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure_ShowWaveform (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +set(handles.PEhandle.checkbox_showwaveform, 'Value', 0); +PEData = guidata(handles.PEfig); +if (isfield(PEData, 'SWfig')) + PEData = rmfield(PEData, 'SWfig'); + guidata(handles.PEfig, PEData); + VSData = guidata(PEData.VSHandle); + VSData.vars.PE_showwaveform = 0; + guidata(PEData.VSHandle, VSData); +end + +delete(hObject); + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/h_specgram2.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,163 @@ +function [yo,fo,to] = h_specgram2(varargin) +%SPECGRAM Calculate spectrogram from signal. +% B = SPECGRAM(A,NFFT,Fs,WINDOW,SHIFT) calculates the spectrogram for +% the signal in vector A. SPECGRAM splits the signal into overlapping +% segments, windows each with the WINDOW vector and forms the columns of +% B with their zero-padded, length NFFT discrete Fourier transforms. Thus +% each column of B contains an estimate of the short-term, time-localized +% frequency content of the signal A. Time increases linearly across the +% columns of B, from left to right. Frequency increases linearly down +% the rows, starting at 0. If A is a length NX complex signal, B is a +% complex matrix with NFFT rows and +% k = fix((NX-NOVERLAP)/(length(WINDOW)-NOVERLAP)) +% columns, where NOVERLAP = length(WINDOW)-mean(SHIFT) +% If A is real, B still has k columns but the higher frequency +% components are truncated (because they are redundant); in that case, +% SPECGRAM returns B with NFFT/2+1 rows for NFFT even and (NFFT+1)/2 rows +% for NFFT odd. If you specify a scalar for WINDOW, SPECGRAM uses a +% Hanning window of that length. WINDOW must have length smaller than +% or equal to NFFT and greater than NOVERLAP. NOVERLAP is the number of +% samples the sections of A overlap. Fs is the sampling frequency +% which does not effect the spectrogram but is used for scaling plots. +% +% [B,F,T] = SPECGRAM(A,NFFT,Fs,WINDOW,NOVERLAP) returns a column of +% frequencies F and one of times T at which the spectrogram is computed. +% F has length equal to the number of rows of B, T has length k. If you +% leave Fs unspecified, SPECGRAM assumes a default of 2 Hz. +% +% B = SPECGRAM(A) produces the spectrogram of the signal A using default +% settings; the defaults are NFFT = minimum of 256 and the length of A, a +% Hanning window of length NFFT, and NOVERLAP = length(WINDOW)/2. You +% can tell SPECGRAM to use the default for any parameter by leaving it +% off or using [] for that parameter, e.g. SPECGRAM(A,[],1000) +% +% See also PWELCH, CSD, COHERE and TFE. + +% Author(s): L. Shure, 1-1-91 +% T. Krauss, 4-2-93, updated +% Copyright 1988-2000 The MathWorks, Inc. +% $Revision: 1.6 $ $Date: 2000/06/09 22:07:35 $ + +error(nargchk(1,5,nargin)) +[msg,x,nfft,Fs,window,shift]=specgramchk(varargin); +error(msg) + +nx = length(x); +nwind = length(window); +if nx < nwind % zero-pad x if it has length less than the window length + x(nwind)=0; nx=nwind; +end +x = x(:); % make a column vector for ease later +window = window(:); % be consistent with data set +noverlap = nwind - mean(shift); +ncol = fix((nx-noverlap)/(nwind-noverlap)); + +totalshift = sum(shift); +numshift = length(shift); +progshift = (cumsum(shift)-shift(1))'; +overshift = 1:totalshift:nx; +shifts = progshift(:,ones(1,length(overshift)))+overshift(ones(length(progshift),1),:); +colindex = reshape(shifts,1,prod(size(shifts))); +colindex = colindex(1:ncol); +%colindex = 1 + (0:(ncol-1))*(nwind-noverlap); +rowindex = (1:nwind)'; +if length(x)<(nwind+colindex(ncol)-1) + x(nwind+colindex(ncol)-1) = 0; % zero-pad x +end + +y = zeros(nwind,ncol); + +% put x into columns of y with the proper offset +% should be able to do this with fancy indexing! +y(:) = x(rowindex(:,ones(1,ncol))+colindex(ones(nwind,1),:)-1); + +% Apply the window to the array of offset signal segments. +y = window(:,ones(1,ncol)).*y; + +% now fft y which does the columns +y = fft(y,nfft); +if ~any(any(imag(x))) % x purely real + if rem(nfft,2), % nfft odd + select = [1:(nfft+1)/2]; + else + select = [1:nfft/2+1]; + end + y = y(select,:); +else + select = 1:nfft; +end +f = (select - 1)'*Fs/nfft; + +t = (colindex-1)'/Fs; + +% take abs, and use image to display results +if nargout == 0 +% newplot; +% if length(t)==1 +% imagesc([0 1/f(2)],f,20*log10(abs(y)+eps));axis xy; colormap(jet) +% else +% imagesc(t,f,20*log10(abs(y)+eps));axis xy; colormap(jet) +% end +% xlabel('Time') +% ylabel('Frequency') +elseif nargout == 1, + yo = y; +elseif nargout == 2, + yo = y; + fo = f; +elseif nargout == 3, + yo = y; + fo = f; + to = t; +end + +function [msg,x,nfft,Fs,window,shift] = specgramchk(P) +%SPECGRAMCHK Helper function for SPECGRAM. +% SPECGRAMCHK(P) takes the cell array P and uses each cell as +% an input argument. Assumes P has between 1 and 5 elements. + +msg = []; + +x = P{1}; +if (length(P) > 1) & ~isempty(P{2}) + nfft = P{2}; +else + nfft = min(length(x),256); +end +if (length(P) > 2) & ~isempty(P{3}) + Fs = P{3}; +else + Fs = 2; +end +if length(P) > 3 & ~isempty(P{4}) + window = P{4}; +else + if length(nfft) == 1 + window = hanning(nfft); + else + msg = 'You must specify a window function.'; + end +end +if length(window) == 1, window = hanning(window); end +if (length(P) > 4) & ~isempty(P{5}) + shift = P{5}; +else + shift = ceil(length(window)/2); +end + +% NOW do error checking +if (length(nfft)==1) & (nfft<length(window)), + msg = 'Requires window''s length to be no greater than the FFT length.'; +end +if (min(shift) <= 0), + msg = 'Requires SHIFT to be strictly positive.'; +end +if (length(nfft)==1) & (nfft ~= abs(round(nfft))) + msg = 'Requires positive integer values for NFFT.'; +end +if sum(shift ~= abs(round(shift))), + msg = 'Requires positive integer value for NOVERLAP.'; +end +if min(size(x))~=1, + msg = 'Requires vector (either row or column) input.'; +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/mpeg7getspec.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,27 @@ +% Modified 30/04/2002 by Thorsten Kastner - zero pad (length overlap) at start and end for overlap removed; +% because: there's no overlap in ASF +function [fftout,phase] = mpeg7getspec( data, fs, hopsize, windowsize, window, FFTsize) +% data = data(1:5004); +if size(data,1)==1 + data = data'; +end + +hs = mean(hopsize); +hops = length(hopsize); +num_f = ceil(length(data)/hs); +rem_f = mod(num_f,hops); +pad = sum(hopsize(1:rem_f)) - (length(data)-(num_f-rem_f)*hs); +data = [data; zeros(pad,1)]; +num_samples = length(data); +fstart = 1; +fftout = []; +NormWindow = sum(window.*window); +spec = (h_specgram2(data,FFTsize,fs,window,hopsize))/sqrt(FFTsize*NormWindow); +fftout = abs(spec); +phase = angle(spec); +% figure(30); imagesc([1 size(fftout(2))],[0 v.fs/2],fftout) +% Need to compensate first and last frames for the zero padding + +if pad + fftout(:,end) = fftout(:,end)*sqrt(windowsize/(windowsize-pad)); +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/FromWeb/mpeg7init.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,74 @@ +function standvar = mpeg7init(fs,hopsize,windowsize,window,FFTsize) + +% This function creates a structure of the default values +% to be used throughout the descriptors + +% Written by Melanie Jackson + +% Version 1 15th March 2001 +% Modified 30/04/2002 by Thorsten Kastner - changed standard hopsize to 30ms +% - set hopsize = windowsize (no overlap for ASF) + +if nargin == 0 + Error = 'need to specify the sampling frequency: standvar = mpeg7init(fs)' + standvar = []; + return +end + +try % variable defined + if isempty(hopsize) % variable defined but no value + hopsize = [fs*30 1000]; % Changed hopsize: 30ms recommend + else + hopsize = [fs*hopsize(1) hopsize(2)]; + end +catch + hopsize = [fs*30 1000] ; +end +[q, n, d] = h_fraction(hopsize(1),hopsize(2)); +% This next section of code is to ensure minimal stray from the sampling period +% This is done by interleaving minor hopsize with major +% e.g if 10 10 10 10 10 11 11 are the hops then the pattern should be +% 10 10 10 11 10 10 11 +if n==0 + hopsize = q; +elseif d-n>=n + k = ceil((d-n)/n); % ratio of q to q+1 occurence + fr = floor((d-n)/(k)); % number of sub sequences required + frr = [q*ones(1,k) q+1]; % subsequence - length k+1 + hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr); % append subsequences to each other + hopsize = [hopsize q*ones(1,d-n-k*fr) (q+1)*ones(1,n-fr)]; % attach extra values +else + k = ceil(n/(d-n)); + fr = floor(n/k); + frr = [(q+1)*ones(1,k) q]; + hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr); + hopsize = [hopsize (q+1)*ones(1,n-k*fr) q*ones(1,d-n-fr)]; +end + + +try + if isempty(windowsize) % variable defined but no value + windowsize = ceil(fs*30/1000); % Changed:Windowsize fixed at 30ms + end +catch + windowsize = ceil(fs*30/1000); % Changed: Windowsize fixed at 30ms +end + +try + if isempty(FFTsize) % variable defined but no value + FFTsize = 2^nextpow2(windowsize); + end +catch + FFTsize = 2^nextpow2(windowsize); +end + +try + if isempty(window) % variable defined but no value + window = [hamming(windowsize)]; + end +catch + window = [hamming(windowsize)]; +end + +standvar = struct('fs',fs,'hopsize',hopsize,'windowsize',windowsize,'window',window,'FFTsize',FFTsize); +return \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/calculate_HNR.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,70 @@ +function [HNR] = calculate_HNR( y, fs, noOfFrames, silenceFrames, pitch ) + + %find the maximum lag M + DEBUG=0; + + maxPeriod = ceil(fs/getVariables('getMinFreq')); %get the default minimum fundatmental frequency + minPeriod = floor(fs/getVariables('getMaxFreq')); %get the default maximum fundamental frequency + + for i = 1:(noOfFrames - 1) + if( silenceFrames(i) == 1 ) + + % frame is not silent + NA = xcorr(y(:,i), y(:,i), 'coeff'); + NA = NA( ceil(length(NA)/2) : end ); + + if(DEBUG) + subplot(211); plot(y(:,i)); title(i); + subplot(212); plot(NA); hold on; + end + + % find the maximum nearset to the predicted pitch + f0 = pitch(i); + if( (f0 < minPeriod) || (isnan(f0)) ) + f0 = minPeriod; + end + % perform a search outwards from that point + startSearch = floor(f0-(f0*0.1)); + endSearch = ceil(f0+(f0*0.1)); + if( startSearch > length(NA) ) + startSearch = length(NA) - 20; + end + if( endSearch > length(NA) ) + endSearch = length(NA); + end + [max_value max_position] = max( NA( startSearch : endSearch )); + + if(DEBUG) + plot( max_position + startSearch - 1, max_value, 'gx' ); + plot( startSearch : endSearch, NA(startSearch : endSearch), 'r'); + hold off; + end + + HR(i) = max_value; + + if( HR(i) < 0) + % if the sample is negative it probably means the frame is + % silent so just set to 'most noisy so far' +% if(i>1) +% HNR(i) = min( HNR ); +% else + HNR(i) = NaN; +% end + else + HNR(i)= 10*log10(HR(i)/(1-HR(i))); + end + if(DEBUG) title(HNR(i)); end + else + HNR(i) = NaN; + end + + end + + + + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/calculate_audioPower.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,17 @@ +function AP = audioPower(s,fs,framelength,noOfFrame) +totalTime = size(s) / fs; +frameTime = totalTime/noOfFrame; +y=buffer(s,framelength); %the frame length is 10ms + +for i = 1:noOfFrame + + totalPower(i) = 0; + ap(i) = 0; + for j = 1: (framelength) + totalPower(i) = totalPower(i) + s(j + framelength*(i-1)) * s(j + framelength*(i-1)); + end; +end; + +ap= totalPower / framelength; +b = 0:frameTime:(totalTime-frameTime); +AP = [ap' b']; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/detect_AudioPower.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,28 @@ +function [ audioPower ] = detect_AudioPower( sampleWavFileName, OVERWRITE ) +% find the audio power + +% open original power calculation +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +fileName = [ sampleFileName '_AP.txt']; +fileID = fopen( fileName ); + +if( (fileID <= 0) || (OVERWRITE) ) %does the file exist? + % no + disp('WARNING: MISSING AUDIO POWER FILE'); + %calculate it + [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); + + audioPower = calculate_audioPower(x, fs, frameLength, noOfFrames); +% frameIndex = 1:1:length(AP); + fileID = fopen( fileName, 'w'); + for i = 1 : noOfFrames + fprintf( fileID, '%d %s \n' , i, num2str( audioPower(i,1)) ); + end + + fclose( fileID ); + fileID = fopen( fileName ); +end + +audioPower = fscanf( fileID, '%f', inf ); +audioPower = audioPower(2:2:end); +fclose( fileID ); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/MPEG7/detect_HNR.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,46 @@ +function [HNR] = detect_HNR( sampleWavFileName, OVERWRITE ) + +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +[x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); + +%---------------- GET THE SILENT FRAME VALUES ------------------- + +% only wish to consider pitch values from voiced frames. +% silent and unvoiced frames will produce pitch values that +% are random and therefore will bias our results + +segmentFrames = detect_Silence( sampleWavFileName, 0 ); +[ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); + + +%---------------- GET THE PITCH VALUES -------------------------- + +[ pitch ] = detect_pitch( sampleWavFileName, 0 ); + +% calculate the HNR + +% open original calculation +fileName = [ sampleFileName '_HNR.txt']; +% read pitch metrics from file +fileID = fopen( fileName ); + +if(( fileID <= 0 ) || ( OVERWRITE )) %does the file exist? + % no + disp('WARNING: MISSING HNR FILE'); + %calculate it +% [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); + y = buffer(x,frameLength); + harmonicToNoiseRatio = calculate_HNR( y, fs, noOfFrames, silentFrames, pitch ); + + fileID = fopen( fileName, 'w'); + for i = 1 : (noOfFrames-1) + fprintf(fileID, '%d %s \n' , i, num2str( harmonicToNoiseRatio(i) )); + end + fclose( fileID ); + fileID = fopen( fileName ); +end + + +HNR = fscanf( fileID, '%f', inf ); +HNR = HNR(2:2:end); +fclose(fileID);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Speech/calculate_MFCC.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,22 @@ +function [ceps] = calculate_MFCC( x, fs, frameLength, noOfFrames ) + +% sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +% fileName = [ sampleFileName '_MFCC.txt']; +% fileID = fopen( fileName, 'w'); +% +% raw = x(:,1); + +[ceps,freqresp,fb,fbrecon,freqrecon] = mfcc( x, fs, fs/frameLength ); + + +% noOfValidFrames = length(ceps); + +% for i = 1 : noOfValidFrames +% fprintf(fileID,'%d ',i); +% for j = 1: 13 % get's the first 13 MFCC's +% fprintf(fileID, '%f ', ceps(j,i)); +% end +% fprintf(fileID, '\n'); +% end +% +% fclose( fileID ); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Speech/detect_MFCC.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,44 @@ +function [HNR] = detect_MFCC( sampleWavFileName, OVERWRITE ) + +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +[x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); + +%---------------- GET THE SILENT FRAME VALUES ------------------- + +% only wish to consider pitch values from voiced frames. +% silent and unvoiced frames will produce pitch values that +% are random and therefore will bias our results + +segmentFrames = detect_Silence( sampleWavFileName, 0 ); +[ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); + +% open original calculation +fileName = [ sampleFileName '_MFCC.txt']; +fileID = fopen( fileName ); + +if(( fileID <= 0 ) || ( OVERWRITE )) %does the file exist? + % no + disp('WARNING: MISSING MFCC FILE'); + %calculate it + mfcc = calculate_MFCC( x, fs, frameLength, noOfFrames ); + + fileID = fopen( fileName, 'w'); + for i = 1 : (noOfFrames-1) + if( silentFrames(i) == 1 ) + % frame is not silent + fprintf(fileID, '%d %s \n' , i, num2str( mfcc(:,i)' )); + else + % set to zero + mfcc(:,i) = 0; + end + end + fclose( fileID ); + fileID = fopen( fileName ); +end + + +mfcc = fscanf( fileID, '%f', inf ); +mfcc = buffer(mfcc,14); % 13 MFCC values and one frame number +mfcc = mfcc(2:14,:)'; + +fclose(fileID);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Speech/mfcc.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,181 @@ +% mfcc - Mel frequency cepstrum coefficient analysis. +% [ceps,freqresp,fb,fbrecon,freqrecon] = ... +% mfcc(input, samplingRate, [frameRate]) +% Find the cepstral coefficients (ceps) corresponding to the +% input. Four other quantities are optionally returned that +% represent: +% the detailed fft magnitude (freqresp) used in MFCC calculation, +% the mel-scale filter bank output (fb) +% the filter bank output by inverting the cepstrals with a cosine +% transform (fbrecon), +% the smooth frequency response by interpolating the fb reconstruction +% (freqrecon) +% -- Malcolm Slaney, August 1993 +% Modified a bit to make testing an algorithm easier... 4/15/94 +% Fixed Cosine Transform (indices of cos() were swapped) - 5/26/95 +% Added optional frameRate argument - 6/8/95 +% Added proper filterbank reconstruction using inverse DCT - 10/27/95 +% Added filterbank inversion to reconstruct spectrum - 11/1/95 + +% (c) 1998 Interval Research Corporation + +function [ceps,freqresp,fb,fbrecon,freqrecon] = ... + mfcc(input, samplingRate, frameRate) +global mfccDCTMatrix mfccFilterWeights + +[r c] = size(input); +if (r > c) + input=input'; +end + +% Filter bank parameters +lowestFrequency = 133.3333; +linearFilters = 13; +linearSpacing = 66.66666666; +logFilters = 27; +logSpacing = 1.0711703; +fftSize = 512; +cepstralCoefficients = 13; +windowSize = 400; +windowSize = 256; % Standard says 400, but 256 makes more sense + % Really should be a function of the sample + % rate (and the lowestFrequency) and the + % frame rate. +if (nargin < 2) samplingRate = 16000; end; +if (nargin < 3) frameRate = 100; end; + +% Keep this around for later.... +totalFilters = linearFilters + logFilters; + +% Now figure the band edges. Interesting frequencies are spaced +% by linearSpacing for a while, then go logarithmic. First figure +% all the interesting frequencies. Lower, center, and upper band +% edges are all consequtive interesting frequencies. + +freqs = lowestFrequency + (0:linearFilters-1)*linearSpacing; +freqs(linearFilters+1:totalFilters+2) = ... + freqs(linearFilters) * logSpacing.^(1:logFilters+2); + +lower = freqs(1:totalFilters); +center = freqs(2:totalFilters+1); +upper = freqs(3:totalFilters+2); + +% We now want to combine FFT bins so that each filter has unit +% weight, assuming a triangular weighting function. First figure +% out the height of the triangle, then we can figure out each +% frequencies contribution +mfccFilterWeights = zeros(totalFilters,fftSize); +triangleHeight = 2./(upper-lower); +fftFreqs = (0:fftSize-1)/fftSize*samplingRate; + +for chan=1:totalFilters + mfccFilterWeights(chan,:) = ... + (fftFreqs > lower(chan) & fftFreqs <= center(chan)).* ... + triangleHeight(chan).*(fftFreqs-lower(chan))/(center(chan)-lower(chan)) + ... + (fftFreqs > center(chan) & fftFreqs < upper(chan)).* ... + triangleHeight(chan).*(upper(chan)-fftFreqs)/(upper(chan)-center(chan)); +end +%semilogx(fftFreqs,mfccFilterWeights') +%axis([lower(1) upper(totalFilters) 0 max(max(mfccFilterWeights))]) + +hamWindow = 0.54 - 0.46*cos(2*pi*(0:windowSize-1)/windowSize); + +if 0 % Window it like ComplexSpectrum + windowStep = samplingRate/frameRate; + a = .54; + b = -.46; + wr = sqrt(windowStep/windowSize); + phi = pi/windowSize; + hamWindow = 2*wr/sqrt(4*a*a+2*b*b)* ... + (a + b*cos(2*pi*(0:windowSize-1)/windowSize + phi)); +end + +% Figure out Discrete Cosine Transform. We want a matrix +% dct(i,j) which is totalFilters x cepstralCoefficients in size. +% The i,j component is given by +% cos( i * (j+0.5)/totalFilters pi ) +% where we have assumed that i and j start at 0. +mfccDCTMatrix = 1/sqrt(totalFilters/2)*cos((0:(cepstralCoefficients-1))' * ... + (2*(0:(totalFilters-1))+1) * pi/2/totalFilters); +mfccDCTMatrix(1,:) = mfccDCTMatrix(1,:) * sqrt(2)/2; + +%imagesc(mfccDCTMatrix); + +% Filter the input with the preemphasis filter. Also figure how +% many columns of data we will end up with. +if 1 + preEmphasized = filter([1 -.97], 1, input); +else + preEmphasized = input; +end +windowStep = samplingRate/frameRate; +cols = fix((length(input)-windowSize)/windowStep); + +% Allocate all the space we need for the output arrays. +ceps = zeros(cepstralCoefficients, cols); +if (nargout > 1) freqresp = zeros(fftSize/2, cols); end; +if (nargout > 2) fb = zeros(totalFilters, cols); end; + +% Invert the filter bank center frequencies. For each FFT bin +% we want to know the exact position in the filter bank to find +% the original frequency response. The next block of code finds the +% integer and fractional sampling positions. +if (nargout > 4) + fr = (0:(fftSize/2-1))'/(fftSize/2)*samplingRate/2; + j = 1; + for i=1:(fftSize/2) + if fr(i) > center(j+1) + j = j + 1; + end + if j > totalFilters-1 + j = totalFilters-1; + end + fr(i) = min(totalFilters-.0001, ... + max(1,j + (fr(i)-center(j))/(center(j+1)-center(j)))); + end + fri = fix(fr); + frac = fr - fri; + + freqrecon = zeros(fftSize/2, cols); +end + +% Ok, now let's do the processing. For each chunk of data: +% * Window the data with a hamming window, +% * Shift it into FFT order, +% * Find the magnitude of the fft, +% * Convert the fft data into filter bank outputs, +% * Find the log base 10, +% * Find the cosine transform to reduce dimensionality. +for start=0:cols-1 + first = start*windowStep + 1; + last = first + windowSize-1; + fftData = zeros(1,fftSize); + fftData(1:windowSize) = preEmphasized(first:last).*hamWindow; + fftMag = abs(fft(fftData)); + earMag = log10(mfccFilterWeights * fftMag'); + + ceps(:,start+1) = mfccDCTMatrix * earMag; + if (nargout > 1) freqresp(:,start+1) = fftMag(1:fftSize/2)'; end; + if (nargout > 2) fb(:,start+1) = earMag; end + if (nargout > 3) + fbrecon(:,start+1) = ... + mfccDCTMatrix(1:cepstralCoefficients,:)' * ... + ceps(:,start+1); + end + if (nargout > 4) + f10 = 10.^fbrecon(:,start+1); + freqrecon(:,start+1) = samplingRate/fftSize * ... + (f10(fri).*(1-frac) + f10(fri+1).*frac); + end +end + +% OK, just to check things, let's also reconstruct the original FB +% output. We do this by multiplying the cepstral data by the transpose +% of the original DCT matrix. This all works because we were careful to +% scale the DCT matrix so it was orthonormal. +if 1 & (nargout > 3) + fbrecon = mfccDCTMatrix(1:cepstralCoefficients,:)' * ceps; +% imagesc(mt(:,1:cepstralCoefficients)*mfccDCTMatrix); +end; + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/PRAAT/formant-singing Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,65 @@ +#This file is used to extract all the jitter value of the singing database +#All formant results would be saved into a txt file for each sample + + +for folder from 1 to 4 + + if ( folder = 1 ) + folderName$ = "WangXinnong\pos\" + elsif ( folder = 2 ) + folderName$ = "WangXinnong\neg\" + elsif ( folder = 3 ) + folderName$ = "ZhangShuo\pos\" + elsif ( folder = 4 ) + folderName$ = "ZhangShuo\neg\" + endif + + for method from 1 to 3 + + if ( method = 1 ) + theMethod$ = "robust" + elsif ( method = 2 ) + theMethod$ = "Burg" + elsif ( method = 3 ) + theMethod$ = "all" + endif + + dirPath$ = "C:\Users\Dawn\Dropbox\BUPTResearch2011\Data\Opera\PaperDatabase\" + folderName$ + Create Strings as file list... list 'dirPath$'\*.wav + fileNum = Get number of strings + for ifile to fileNum + select Strings list + fileName$ = Get string... ifile + newFileName$ = fileName$ + Read from file... 'dirPath$''fileName$' + newfilePath$ = dirPath$ + + newFileName$ = newFileName$-".wav" + #To PointProcess (extrema)... 1 yes no Sinc70 + + if ( method = 1 ) + To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 + elsif ( method = 2 ) + To Formant (burg)... 0.01162 3 20000 0.001 50 + elsif ( method = 3 ) + To Formant (keep all)... 0.01162 3 20000 0.001 50 + endif + + Down to FormantTier + newfolder$ = newFileName$ + "_metrics" + metricFilename$ = newFileName$ + "_Formant_" + theMethod$ + #c$ > 'dirPath$''newfolder$'\'metricFilename$'.txt + Write to text file... 'dirPath$''newfolder$'\'metricFilename$'.txt + + select Sound 'newFileName$' + Remove + select Formant 'newFileName$' + Remove + select FormantTier 'newFileName$' + Remove + + endfor + select Strings list + Remove + endfor +endfor \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/PRAAT/jitter-singing Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,66 @@ +#This file is used to extract all the jitter value of the singing database +#All jitter results would be saved into a txt file for each sample + + +for folder from 2 to 4 + + if ( folder = 1 ) + folderName$ = "WangXinnong\pos\" + elsif ( folder = 2 ) + folderName$ = "WangXinnong\neg\" + elsif ( folder = 3 ) + folderName$ = "ZhangShuo\pos\" + elsif ( folder = 4 ) + folderName$ = "ZhangShuo\neg\" + endif + + for method from 1 to 4 + + if ( method = 1 ) + theMethod$ = "rap" + elsif ( method = 2 ) + theMethod$ = "ddp" + elsif ( method = 3 ) + theMethod$ = "local" + elsif ( method = 4 ) + theMethod$ = "ppq5" + endif + + dirPath$ = "C:\Users\Dawn\Dropbox\BUPTResearch2011\Data\Opera\PaperDatabase\" + folderName$ + Create Strings as file list... list 'dirPath$'\*.wav + fileNum = Get number of strings + for ifile to fileNum + select Strings list + fileName$ = Get string... ifile + newFileName$ = fileName$ + Read from file... 'dirPath$''fileName$' + newfilePath$ = dirPath$ + + newFileName$ = newFileName$-".wav" + To PointProcess (extrema)... 1 yes no Sinc70 + + + if ( method = 1 ) + c$ = Get jitter (rap)... 0.0 0 0.0001 0.02 1.3 + elsif ( method = 2 ) + c$ = Get jitter (ddp)... 0.0 0 0.0001 0.02 1.3 + elsif ( method = 3 ) + c$ = Get jitter (local)... 0.0 0 0.0001 0.02 1.3 + elsif ( method = 4 ) + c$ = Get jitter (ppq5)... 0.0 0 0.0001 0.02 1.3 + endif + + newfolder$ = newFileName$ + "_metrics" + metricFilename$ = newFileName$ + "_FullJitter_" + theMethod$ + #c$ > 'dirPath$''newfolder$'\'metricFilename$'.txt + Write to text file... 'dirPath$''newfolder$'\'metricFilename$'.txt + + select PointProcess 'newFileName$' + Remove + select Sound 'newFileName$' + Remove + endfor + select Strings list + Remove + endfor +endfor \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/PRAAT/old_formant-singing.txt Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,190 @@ +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\neg\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\neg\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\neg\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove + + +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\pos\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\pos\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\fem01\pos\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove + + + + + +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove + + + + + +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove + + + + + +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove + + + + + +dirPath$ = "C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +#To Formant (robust)... 0.01162 3 20000 0.001 50 1.5 5 0.000001 +#To Formant (burg)... 0.01162 3 20000 0.001 50 +To Formant (keep all)... 0.01162 3 20000 0.001 50 +Down to FormantTier +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_Formant_all" +Write to text file... C:\Users\dawn\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\'newfolder$'\'metricFilename$'.txt + +select Sound 'newFileName$' +Remove +select Formant 'newFileName$' +Remove +select FormantTier 'newFileName$' +Remove +endfor +select Strings list +Remove
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/PRAAT/shimmer-singing Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,71 @@ +#This file is used to extract all the shimmer value of the singing database +#All jitter results would be saved into a txt file for each sample + + +for folder from 1 to 4 + + if ( folder = 1 ) + folderName$ = "WangXinnong\pos\" + elsif ( folder = 2 ) + folderName$ = "WangXinnong\neg\" + elsif ( folder = 3 ) + folderName$ = "ZhangShuo\pos\" + elsif ( folder = 4 ) + folderName$ = "ZhangShuo\neg\" + endif + + for method from 1 to 5 + + if ( method = 1 ) + theMethod$ = "apq3" + elsif ( method = 2 ) + theMethod$ = "apq5" + elsif ( method = 3 ) + theMethod$ = "apq11" + elsif ( method = 4 ) + theMethod$ = "dda" + elsif ( method = 5 ) + theMethod$ = "local" + endif + + dirPath$ = "C:\Users\Dawn\Dropbox\BUPTResearch2011\Data\Opera\PaperDatabase\" + folderName$ + Create Strings as file list... list 'dirPath$'\*.wav + fileNum = Get number of strings + for ifile to fileNum + select Strings list + fileName$ = Get string... ifile + newFileName$ = fileName$ + Read from file... 'dirPath$''fileName$' + newfilePath$ = dirPath$ + + newFileName$ = newFileName$-".wav" + To PointProcess (extrema)... 1 yes no Sinc70 + plus Sound 'newFileName$' + + + if ( method = 1 ) + c$ = Get shimmer (local)... 0.0 0 0.0001 0.02 1.3 1.6 + elsif ( method = 2 ) + c$ = Get shimmer (apq5)... 0.0 0 0.0001 0.02 1.3 1.6 + elsif ( method = 3 ) + c$ = Get shimmer (apq11)... 0.0 0 0.0001 0.02 1.3 1.6 + elsif ( method = 4 ) + c$ = Get shimmer (dda)... 0.0 0 0.0001 0.02 1.3 1.6 + elsif ( method = 5 ) + c$ = Get shimmer (apq3)... 0.0 0 0.0001 0.02 1.3 1.6 + endif + + newfolder$ = newFileName$ + "_metrics" + metricFilename$ = newFileName$ + "_FullShimmer_" + theMethod$ + #c$ > 'dirPath$''newfolder$'\'metricFilename$'.txt + Write to text file... 'dirPath$''newfolder$'\'metricFilename$'.txt + + select PointProcess 'newFileName$' + Remove + select Sound 'newFileName$' + Remove + endfor + select Strings list + Remove + endfor +endfor \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/PRAAT/temp Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,108 @@ +dirPath$ = "D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +To PointProcess (extrema)... 1 yes no Sinc70 +c$ = Get jitter (local)... 0 0 0.0001 0.02 1.3 +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_jitter_local" +Write to text file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\'newfolder$'\'metricFilename$'.txt +c$ > D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\neg\'newfolder$'\'metricFilename$'.txt + +select PointProcess 'newFileName$' +Remove +select Sound 'newFileName$' +Remove +endfor +select Strings list +Remove + + +dirPath$ = "D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +To PointProcess (extrema)... 1 yes no Sinc70 +c$ = Get jitter (local)... 0 0 0.0001 0.02 1.3 +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_jitter_local" +Write to text file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\'newfolder$'\'metricFilename$'.txt +c$ > D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\male01\pos\'newfolder$'\'metricFilename$'.txt + +select PointProcess 'newFileName$' +Remove +select Sound 'newFileName$' +Remove +endfor +select Strings list +Remove + + +dirPath$ = "D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +To PointProcess (extrema)... 1 yes no Sinc70 +c$ = Get jitter (local)... 0 0 0.0001 0.02 1.3 +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_jitter_local" +Write to text file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\'newfolder$'\'metricFilename$'.txt +c$ > D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\neg\'newfolder$'\'metricFilename$'.txt + +select PointProcess 'newFileName$' +Remove +select Sound 'newFileName$' +Remove +endfor +select Strings list +Remove + +dirPath$ = "D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\" +Create Strings as file list... list 'dirPath$'\*.wav +fileNum = Get number of strings +for ifile to fileNum +select Strings list +fileName$ = Get string... ifile +newFileName$ = fileName$ +Read from file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\'fileName$' +newfilePath$ = dirPath$ + +newFileName$ = newFileName$-".wav" +To PointProcess (extrema)... 1 yes no Sinc70 +c$ = Get jitter (local)... 0 0 0.0001 0.02 1.3 +newfolder$ = newFileName$ + "_metrics" +metricFilename$ = newFileName$ + "_jitter_local" +Write to text file... D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\'newfolder$'\'metricFilename$'.txt +c$ > D:\Dropbox\BUPTResearch2011\Data\Opera\TestDatabase\Trans01\pos\'newfolder$'\'metricFilename$'.txt + +select PointProcess 'newFileName$' +Remove +select Sound 'newFileName$' +Remove +endfor +select Strings list +Remove + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/private/dftoperiod copy.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,14 @@ +% prd=dftoperiod(d,b,t) - estimate period from difference function +% +% prd: row matrix of period estimates +% +% d: column vector or matrix of difference functions +% b: bounds matrix ([lo, hi]) +% t: threshold +% +% Difference functions are supposed to be cumulative-mean-normalized. +% For each column of d, search for the first minimum between lo and hi that +% falls below threshold. The index of this minimum (re 0) +% is the period estimate. +% +% Mex function.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/private/src/sf_info.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,438 @@ +function i = sf_info(i) +% i=sf_info(i) - extract useful info from file + +% Alain de Cheveigné, CNRS/Ircam, 2002. +% Copyright (c) 2002 Centre National de la Recherche Scientifique. +% +% Permission to use, copy, modify, and distribute this software without +% fee is hereby granted FOR RESEARCH PURPOSES only, provided that this +% copyright notice appears in all copies and in all supporting +% documentation, and that the software is not redistributed for any +% fee (except for a nominal shipping charge). +% +% For any other uses of this software, in original or modified form, +% including but not limited to consulting, production or distribution +% in whole or in part, specific prior permission must be obtained from CNRS. +% Algorithms implemented by this software may be claimed by patents owned +% by CNRS, France Telecom, Ircam or others. +% +% The CNRS makes no representations about the suitability of this +% software for any purpose. It is provided "as is" without express +% or implied warranty. Beware of the bugs. + +if ~nargin ; error('sf_info: no input arguement'); end +if ~isa(i, 'struct') + j.fname=i; + i=j; + i=sf_info(i); + return +end +if ~isfield(i, 'fname'); error('sf_info: no fname field'); end + +% guess format only if unknown +if ~isfield(i, 'format') | isempty(i.format); + i = sf_format(i); + if ~strcmp(i.format, 'matrix') disp(i.format); end +end + +% handle workspace matrices as if they were files +if strcmp(i.format, 'matrix') + [nrows, ncols] = size(i.fname); + i.nchans=ncols; + i.nsamples=nrows; + i.totalsamples = i.nsamples*i.nchans; + i.sr=[]; + return; +end + +% close file if open +if exist('i.fd') & fopen(i.fd) + fclose(i.fd); +end + +% use standard matlab functions for AU and WAV and MACSND +if strcmp(i.format, 'AU') + if isempty(findstr('.', i.fname)) + disp(['WARNING: matlab function AUREAD requires '... + '.au or .snd suffix on file name: ' i.fname]); + end + sz = auread(i.fname, 'size'); + i.nsamples=sz(1); + i.nchans=sz(2); + i.totalsamples = i.nsamples*i.nchans; + [dummy, i.sr, i.samplebits] = auread(i.fname, 1); + return; +end +if strcmp(i.format, 'WAV') + if isempty(findstr('.wav', i.fname)) & isempty(findstr('.WAV', i.fname)) + disp(['WARNING: matlab function WAVREAD requires '... + '.wav suffix on file name: ' i.fname]); + end + sz = wavread(i.fname, 'size'); + i.nsamples=sz(1); + i.nchans=sz(2); + i.totalsamples = i.nsamples*i.nchans; + [dummy, i.sr, i.samplebits] = wavread(i.fname, 1); + return; +end +if strcmp(i.format, 'MACSND') + % must load the data to get info - this is stupid + if ~isempty(findstr(':', i.fname)) + disp(['matlab function READSND cannot handle an '... + 'indirect path: ' i.fname]); + end + if 3==exist('readsnd') + [data, i.sr] = eval('readsnd(i.fname)'); + else + error('cannot read MACSND on this platform'); + end + i.nsamples = size(data,2); + i.nchans = size(data,1); + i.totalsamples = i.nsamples*i.nchans; + return +end + +% reopen file +if strcmp(i.format, 'ascii') ... + | strcmp(i.format, 'csv') | strcmp(i.format, '|WAVE') + [i.fd, msg] = fopen(i.fname, 'rt'); +else + [i.fd, msg] = fopen(i.fname, 'r', 'ieee-be.l64'); +end +if i.fd == -1 + if isempty(msg) + error(['could not open: ', i.fname]); + else + error(msg) + end +end +fd = i.fd; +if ~isfield(i, 'nbytes') + if (-1 == fseek(i.fd, 0, 1)) ; error ('fseek failed'); end; + i.nbytes = ftell(i.fd); +end +fseek(fd, 0, -1); % rewind + + +switch i.format +%%%%%%%%%%%%%%%%%%% AIFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case {'AIFF','AIFC'} + fseek(fd, 12, 0); % skip container chunk + % skip over spurious chunks + idx=ftell(fd); + while 1 + magic=char(fread(fd,4,'uchar'))'; + if strcmp(magic,'COMM'); break; end; + idx = idx+1; + status = fseek(fd,idx,-1); + if status == -1 + error('expected COMM magic word, found eof'); + end; + end; + + %ckSize=fread(fd,1,'int32'); + %status = fseek(fd, ckSize, 0); % skip to end of chunk + %if status == -1 + % error('unexpected eof'); + %end + + %while (1) + % magic = char(fread(fd, 4, 'char'))'; + % if ~strcmp(magic, 'SSND') + % fseek(fd, -4, 0); % skip back + % break; + % end + % ckSize = fread(fd, 1, 'long'); + % fseek(fd, ckSize, 0); % skip to end of sound chunk + %end + %magic = char(fread (fd, 4, 'char'))'; + %if ~strcmp(magic, 'COMM'); error(['expected COMM, found ', magic]) ; end + commsz = fread(fd, 1, 'int32'); + i.nchans = fread(fd, 1, 'int16'); + i.nsamples = fread(fd, 1, 'uint32'); + i.totalsamples = i.nsamples*i.nchans; + i.samplebits = fread(fd, 1, 'int16'); + switch i.samplebits + case 16 + i.sample_bytes = 2; + i.sample_type = 'int16'; + case 32 + i.sample_bytes = 4; + i.sample_type = 'int32'; % or float? + otherwise + error(['unexpected samplebits: ' num2str(i.samplebits) ]); + end + % read sampling rate using Hideki Kawahara's code: + srex1=fread(fd,1,'uint16'); + srex2=fread(fd,1,'uint64'); + if strcmp(char(i.format),'AIFC') + compress=fread(fd,4,'uchar'); + if ~strcmp(char(compress),'NONE') + error('Compression is not supported.'); + end; + fseek(fd, commsz-22, 0); + end; + i.sr = 2^(srex1-16383)*srex2/hex2dec('8000000000000000'); + %fseek(fd, 12, -1); % skip back to end of container chunk + % skip over eventual common chunk + %while(1) + % magic = char(fread(fd, 4, 'char'))'; + % if ~strcmp(magic, 'COMM') + % fseek(fd, -4, 0); % skip back + % break; + % end + % ckSize = fread(fd, 1, 'long'); + % fseek(fd, ckSize, 0); % skip over chunk + %end + magic=char(fread(fd,4,'uchar'))'; + while ~strcmp(char(magic),'SSND') + [ckSize, count]=fread(fd,1,'int32'); + if ~count; + error('expected chunk size field, found eof'); + return + end + status = fseek(fd, ckSize, 0); % skip to end of chunk + if status == -1 + error('expected SSND magic word, found eof'); + return + end; + magic=char(fread(fd,4,'uchar'))'; + end; + + %magic = char(fread(fd, 4, 'char'))'; + %if ~strcmp(magic, 'SSND') + % error (['expected SSND, found' magic]); + %end + fseek(fd, 12, 0); % skip over ckSize, offset and blocksize fields + i.bytes_to_data = ftell(fd); + if i.totalsamples*i.sample_bytes ~= i.nbytes-i.bytes_to_data + disp(['WARNING: header fields sample_bytes: ' ... + num2str(i.sample_bytes)]); + disp (['and sample and channel count: ' num2str(i.nsamples) ... + ', ' num2str(i.nchans)]); + disp(['are inconsistent with offset to data: ' ... + num2str(i.bytes_to_data) ' and file size: ' ... + num2str(i.nbytes)]); + disp (['(' num2str(i.totalsamples*i.sample_bytes) ... + ' ~= ' num2str(i.nbytes-i.bytes_to_data) ')']); + end + + return +%%%%%%%%%%%%%%%%%%% NIST %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case 'NIST' +% fseek(fd, 0, -1); +% line = fscanf(fd, '%s' , 1); +% if ~strcmp(line, 'NIST_1A'); error(['expected NIST_1A, found ', magic]); end + fseek(fd, 8, 0); % skip over magic string + i.bytes_to_data = fscanf(fd, '%d', 1); + while (1) + key = fscanf(fd, '%s', 1); + if strcmp(key, 'end_head'); break; end; + % read third field according to spec in second field (type) + % this may need refining... + type = fscanf(fd, '%s', 1); + if strcmp(type(1:2), '-s') + bytes_to_read = sscanf(type(3:end), '%d', 1); + fseek(fd, 1, 0); % skip blank + value = char(fread(fd, bytes_to_read, 'char'))'; + else + value = fscanf(fd, '%f', 1); + end + i = setfield(i, key, value); + end + % give standard names to useful fields + if isfield(i, 'channel_count'); i.nchans = i.channel_count; end + if isfield(i, 'sample_count'); i.nsamples = i.sample_count; end + i.totalsamples = i.nsamples*i.nchans; + if isfield(i, 'sample_rate'); + i.sr = i.sample_rate; + i.xunits = 's'; + end + if ~isfield(i, 'sample_coding'); i.sample_coding = 'pcm'; end + i.bytes_to_data = 1024; % needs checking + i.sample_bytes=2; + i.sample_type='int16'; + return +%%%%%%%%%%%%%%%%%%% |WAVE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case '|WAV' + line = fscanf(fd, '%s' , 1); % skip first line + i.nsamples = fscanf(fd, '%d', 1); + i.nchans = fscanf(fd, '%d', 1); + i.totalsamples = i.nsamples*i.nchans; + i.bytes_to_data = ftell(fd); + % channel info handled during data read + i.totalsamples = i.nsamples * i.nchans; + return +%%%%%%%%%%%%%%%%%%% WFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case 'wff' + fseek(fd, 4, 0); % skip magic number + i.version = fread(fd, 1, 'long'); + i.type_code = fread(fd, 1, 'long'); + i.nchans = fread(fd, 1, 'long'); + i.info.channel_flags = fread(fd, 1, 'long'); + i.bytes_to_data = fread(fd, 1, 'long'); + fseek(fd, 40, 0); + i.gen_prog_name = fread(fd, 32, 'char'); + i.comment = fread(fd, 32, 'char'); + i.sample_bytes = 2; + i.sample_type = 'int16'; + return; +% channel info handled later during channel read +%%%%%%%%%%%%%%%%%%% ESPS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case 'ESPS' +% Based on Peter Kabal's afsp package. +% This handles at least one kind of ESPS waveform file. Others? + i.machine_code = fread(fd, 1, 'uint'); + i.version_check_code = fread(fd, 1, 'uint'); + i.bytes_to_data = fread(fd, 1, 'uint'); + i.record_size = fread(fd, 1, 'uint'); + fseek(fd, 20, -1); + i.EDR_ESPS_flag = fread(fd, 1, 'uint'); + i.align_pad_size = fread(fd, 1, 'uint'); + fseek(fd, 32, -1); + i.file_type = fread(fd, 1, 'uint16'); + fseek(fd, 40, -1); + i.file_creation_date_time = char(fread(fd, 26, 'char'))'; + i.header_version = char(fread(fd, 8, 'char'))'; + i.program_name = char(fread(fd, 16, 'char'))'; + i.program_version = char(fread(fd, 8, 'char'))'; + i.compile_date = char(fread(fd, 26, 'char'))'; + i.tag = fread(fd, 1, 'uint'); + fseek(fd, 132, -1); + i.ndoubles = fread(fd, 1, 'uint'); + i.nfloats = fread(fd, 1, 'uint'); + i.nlongs = fread(fd, 1, 'uint'); + i.nshorts = fread(fd, 1, 'uint'); + i.nchars = fread(fd, 1, 'uint'); + i.fixed_header_size = fread(fd, 1, 'uint'); + i.var_header_size = fread(fd, 1, 'uint'); + %w.dunno_what = fread(fd, 1, 'uint'); + fseek(fd, 160, -1); + i.user = char(fread(fd, 8, 'char'))'; + % scan the rest of the header to find sampling rate + a = ftell(fd); + bytes_left_in_header = i.bytes_to_data - ftell(fd); + hunk = char(fread(fd, bytes_left_in_header, 'uchar'))'; + b = findstr(hunk, 'record_freq'); + %fseek(fd, a+b-1, -1); + %w.xxxx = char(fread(fd, 12, 'char'))'; + %w.count = fread(fd, 1, 'uint'); + %w.data_code = fread(fd, 1, 'ushort'); + fseek(fd, a+b-1+12+2+4, -1); + i.sr = fread(fd, 1, 'double'); + i.nchans = i.ndoubles+i.nfloats+i.nlongs ... + +i.nshorts+i.nchars; + recordsize = i.ndoubles*8 + i.nfloats*4 + i.nlongs*4 ... + +i.nshorts*2+i.nchars; + i.nsamples = (i.nbytes - i.bytes_to_data) / recordsize; + i.totalsamples = i.nsamples * i.nchans; + i.sample_bytes = 2; % bug + i.sample_type = 'int16'; % bug + return; +%%%%%%%%%%%%% PLAIN ASCII %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case 'ascii' + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + line = fgetl(fd); + i.nchans = size(sscanf(line, '%f'), 1); + nlines = 1; + while (1) + line = fgets(i.fd); + if isa(line, 'double') & -1 == line; break; end + nlines = nlines+1; + end + i.nsamples = nlines; + i.totalsamples = i.nsamples*i.nchans; + i.sr=1; + return +%%%%%%%%%%%%% COMMA-SEPARATED VALUES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case 'csv'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + % todo + return +%%%%%%%%%%%%% Binary %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +case {'uchar'}; % should take care of signed/unsigned + i.sample_bytes = 1; + i.sample_type = 'uchar'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + if ~isfield(i, 'nchans') + i.nchans = 1; + end + i.nsamples = (i.nbytes-i.bytes_to_data)/i.sample_bytes; + i.totalsamples = i.nsamples * i.nchans; + i.sr=1; + return +case {'short', 'int16'}; + i.sample_bytes = 2; + i.sample_type = 'int16'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + if ~isfield(i, 'nchans') + i.nchans = 1; + end + i.nsamples = (i.nbytes-i.bytes_to_data)/i.sample_bytes; + i.totalsamples = i.nsamples * i.nchans; + i.sr=1; + return +case {'long', 'int32'}; + i.sample_bytes = 4; + i.sample_type = 'int32'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + if ~isfield(i, 'nchans') + i.nchans = 1; + end + i.nsamples = (i.nbytes-i.bytes_to_data)/i.sample_bytes; + i.totalsamples = i.nsamples * i.nchans; + i.sr=1; + return +case {'float', 'float32'}; + i.sample_bytes = 4; + i.sample_type = 'float32'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + if ~isfield(i, 'nchans') + i.nchans = 1; + end + i.nsamples = (i.nbytes-i.bytes_to_data)/i.sample_bytes; + i.totalsamples = i.nsamples * i.nchans; + i.sr=1; + return +case {'double', 'float64'}; + i.sample_bytes = 8; + i.sample_type = 'float64'; + if isfield(i, 'bytes_to_data') + fseek(fd, i.bytes_to_data, 0); + else + i.bytes_to_data = 0; + end + if ~isfield(i, 'nchans') + i.nchans = 1; + end + i.nsamples = (i.nbytes-i.bytes_to_data)/i.sample_bytes; + i.totalsamples = i.nsamples * i.nchans; + i.sr=1; + return +otherwise + error(['unknown format: >' i.format '<']); +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/private/src/sf_wave.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,193 @@ +function y = sf_wave(i, samples, chans) +% y=sf_wave(i,samples,chans) - read data from file +% +% y: data read from file (column vector or matrix) +% +% i: structure containing information about file +% samples: range of samples to read ([start stop]) - default ([]) means entire file +% chans: range of channels to read ([lo hi]) - default ([]) means all channels\ +% + +% Alain de Cheveigné, CNRS/Ircam, 2002. +% Copyright (c) 2002 Centre National de la Recherche Scientifique. +% +% Permission to use, copy, modify, and distribute this software without +% fee is hereby granted FOR RESEARCH PURPOSES only, provided that this +% copyright notice appears in all copies and in all supporting +% documentation, and that the software is not redistributed for any +% fee (except for a nominal shipping charge). +% +% For any other uses of this software, in original or modified form, +% including but not limited to consulting, production or distribution +% in whole or in part, specific prior permission must be obtained from CNRS. +% Algorithms implemented by this software may be claimed by patents owned +% by CNRS, France Telecom, Ircam or others. +% +% The CNRS makes no representations about the suitability of this +% software for any purpose. It is provided "as is" without express +% or implied warranty. Beware of the bugs. + +if ~nargin | ~isfield(i, 'fname') + error('usage: i.fname = "file name", then call y=sf_wave(i)'); +end +if ~isfield(i, 'format') + i = sf_info(i); +end +% defaults +if nargin<2 | isempty(samples); + if (i.nsamples) samples=[1 i.nsamples]; end; +end +if nargin<3 | isempty(chans) + if (i.nchans) chans=[1 i.nchans]; end; +end + +% clip +if samples(1) < 1 + samples(1) = 1; +end +if samples(2) > i.nsamples + samples(2) = i.nsamples; +end +if samples(2) < samples(1) + y=[];return + error(['start sample after stop sample: ' num2str(samples(1)) '-' num2str(samples(2))]); +end +if chans(1) < 1 | chans(2) > i.nchans + error(['requested inexistent channels: ' num2str(chans(1)) '-' num2str(chans(2))]); +end + + +% workspace matrix +if strcmp(i.format, 'matrix') + y = i.fname(samples(1):samples(2), chans(1):chans(2)); + return +end + +% use matlab functions for AU and WAV and MACSND +if strcmp(i.format, 'AU') + y=auread(i.fname, [samples(1) samples(2)]); + y=y(:,chans(1):chans(2)); + return; +end +if strcmp(i.format, 'WAV') + y=wavread(i.fname, [samples(1) samples(2)]); + y=y(:,chans(1):chans(2)); + return; +end +if strcmp(i.format, 'MACSND') + if 3==exist('readsnd') + y = eval('readsnd(i.fname)'); + else + error('cannot read MACSND on this platform'); + end + y = y(samples(1):samples(2),chans(1):chans(2)); + return; +end + +% close if open +% if fopen(i.fd) +% fclose(i.fd); +% end + +if ~isfield(i, 'bytes_to_data') + i.bytes_to_data=0; +end + +% ascii formats +if strcmp(i.format, 'ascii') | strcmp(i.format, 'csv') | strcmp(i.format, 'IWAVE') + i.fd = fopen(i.fname, 'rt'); + fseek(i.fd, i.bytes_to_data, -1); + + switch i.format + case 'ascii' + nsamples = samples(2) - samples(1) + 1; + nchans = chans(2) - chans(1) + 1; + y = zeros(nsamples, nchans); + % skip to start + for j=1:samples(1)-1 + line = fgetl(i.fd); + if isempty(line) | line == -1; error('unexpected eof'); end + end + k=1; + % read + for j=samples(1) : samples(2) + line = fgetl(i.fd); + if isempty(line) | line == -1; error('unexpected eof'); end + a = sscanf(line, '%f'); + y(k,:) = a(chans(1):chans(2))'; + k = k+1; + end + case 'cvs' + error('not implemented'); + case 'IWAVE' + error('not implemented'); + end + fclose(i.fd); + return +end + +% binary formats +fr = samples(2) - samples(1) + 1; +skip_samples = i.nchans * (samples(1) - 1); +switch i.format +case 'uchar' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 1, 0); + y = fread(i.fd, [fr, i.nchans], 'uchar'); + fclose(i.fd); +case 'short' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 2, 0); + y = fread(i.fd, [fr, i.nchans], 'short'); + fclose(i.fd); +case 'long' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 4, 0); + y = fread(i.fd, [fr, i.nchans], 'long'); + fclose(i.fd); +case 'float' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 4, 0); + y = fread(i.fd, [fr, i.nchans], 'float'); + fclose(i.fd); +case 'double' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 8, 0); + y = fread(i.fd, [fr, i.nchans], 'double'); + fclose(i.fd); +case 'NIST' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + y = zeros(i.nsamples, i.nchans); + switch i.sample_coding + case 'pcm' + fseek(i.fd, skip_samples * 2, 0); + y = fread(i.fd, [fr, i.nchans], 'short'); + otherwise + error(['cannot handle NIST sample_coding = ', i.sample_coding]); + end + fclose(i.fd); +case 'ESPS' + i.fd = fopen(i.fname, 'r'); + fseek(i.fd, i.bytes_to_data, -1); + fseek(i.fd, skip_samples * 2, 0); + y = fread(i.fd, [fr, i.nchans], 'short'); + +case 'AIFF' + i.fd = fopen(i.fname, 'r', 's'); + fseek(i.fd, i.bytes_to_data, -1); + % should check sample size + fseek(i.fd, skip_samples * 2, 0); + y = fread(i.fd, [fr, i.nchans], 'short'); + fclose(i.fd); + +otherwise + error(['don''t know how to load format = ', i.format]); +end + +y = y(:,chans(1):chans(2));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/private/src/yink.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,147 @@ +function r=yink(p,fileinfo) +% YINK - fundamental frequency estimator +% new version (feb 2003) +% +% + +%global jj; +%jj=0; +% process signal a chunk at a time +idx=p.range(1)-1; +totalhops=round((p.range(2)-p.range(1)+1) / p.hop); +r1=nan*zeros(1,totalhops);r2=nan*zeros(1,totalhops); +r3=nan*zeros(1,totalhops);r4=nan*zeros(1,totalhops); +idx2=0+round(p.wsize/2/p.hop); +while (1) + start = idx+1; + stop = idx+p.bufsize; + stop=min(stop, p.range(2)); + xx=sf_wave(fileinfo, [start, stop], []); +% if size(xx,1) == 1; xx=xx'; end + xx=xx(:,1); % first channel if multichannel + [prd,ap0,ap,pwr]=yin_helper(xx,p); + n=size(prd ,2); + if (~n) break; end; + idx=idx+n*p.hop; + + r1(idx2+1:idx2+n)= prd; + r2(idx2+1:idx2+n)= ap0; + r3(idx2+1:idx2+n)= ap; + r4(idx2+1:idx2+n)= pwr; + idx2=idx2+n; +end +r.r1=r1; % period estimate +r.r2=r2; % gross aperiodicity measure +r.r3=r3; % fine aperiodicity measure +r.r4=r4; % power +sf_cleanup(fileinfo); +% end of program + + + +% Estimate F0 of a chunk of signal +function [prd,ap0,ap,pwr]=yin_helper(x,p,dd) +smooth=ceil(p.sr/p.lpf); +x=rsmooth(x,smooth); % light low-pass smoothing +x=x(smooth:end-smooth+1); +[m,n]=size(x); +maxlag = ceil(p.sr/p.minf0); +minlag = floor(p.sr/p.maxf0); +mxlg = maxlag+2; % +2 to improve interp near maxlag + + +hops=floor((m-mxlg-p.wsize)/p.hop); +prd=zeros(1,hops); +ap0=zeros(1,hops); +ap=zeros(1,hops); +pwr=zeros(1,hops); +if hops<1; return; end + +% difference function matrix +dd=zeros(floor((m-mxlg-p.hop)/p.hop),mxlg); +if p.shift == 0 % windows shift both ways + lags1=round(mxlg/2) + round((0:mxlg-1)/2); + lags2=round(mxlg/2) - round((1:mxlg)/2); + lags=[lags1; lags2]; +elseif p.shift == 1 % one window fixed, other shifts right + lags=[zeros(1,mxlg); 1:mxlg]; +elseif p.shift == -1 % one window fixed, other shifts right + lags=[mxlg-1:-1:0; mxlg*ones(1,mxlg)]; +else + error (['unexpected shift flag: ', num2str(p.shift)]); +end +rdiff_inplace(x,x,dd,lags,p.hop); +rsum_inplace(dd,round(p.wsize/p.hop)); +dd=dd'; +[dd,ddx]=minparabolic(dd); % parabolic interpolation near min +cumnorm_inplace(dd);; % cumulative mean-normalize + +% first period estimate +%global jj; +for j=1:hops + d=dd(:,j); + if p.relflag + pd=dftoperiod2(d,[minlag,maxlag],p.thresh); + else + pd=dftoperiod(d,[minlag,maxlag],p.thresh); + end + ap0(j)=d(pd+1); + prd(j)=pd; +end + +% replace each estimate by best estimate in range +range = 2*round(maxlag/p.hop); +if hops>1; prd=prd(mininrange(ap0,range*ones(1,hops))); end +%prd=prd(mininrange(ap0,prd)); + + +% refine estimate by constraining search to vicinity of best local estimate +margin1=0.6; +margin2=1.8; +for j=1:hops + d=dd(:,j); + dx=ddx(:,j); + pd=prd(j); + lo=floor(pd*margin1); lo=max(minlag,lo); + hi=ceil(pd*margin2); hi=min(maxlag,hi); + pd=dftoperiod(d,[lo,hi],0); + ap0(j)=d(pd+1); + pd=pd+dx(pd+1)+1; % fine tune based on parabolic interpolation + prd(j)=pd; + + % power estimates + idx=(j-1)*p.hop; + k=(1:ceil(pd))'; + x1=x(k+idx); + x2=k+idx+pd-1; + interp_inplace(x,x2); + x3=x2-x1; + x4=x2+x1; + x1=x1.^2; rsum_inplace(x1,pd); + x3=x3.^2; rsum_inplace(x3,pd); + x4=x4.^2; rsum_inplace(x4,pd); + + x1=x1(1)/pd; + x2=x2(1)/pd; + x3=x3(1)/pd; + x4=x4(1)/pd; + % total power + pwr(j)=x1; + + % fine aperiodicity + ap(j)=(eps+x3)/(eps+(x3+x4)); % accurate, only for valid min + + %ap(j) + %plot(min(1, d)); pause + + prd(j)=pd; +end + + + +%cumulative mean-normalize +function y=cumnorm(x) +[m,n]=size(x); +y = cumsum(x); +y = (y)./ (eps+repmat((1:m)',1,n)); % cumulative mean +y = (eps+x) ./ (eps+y);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/private/yink.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,147 @@ +function r=yink(p,fileinfo) +% YINK - fundamental frequency estimator +% new version (feb 2003) +% +% + +%global jj; +%jj=0; +% process signal a chunk at a time +idx=p.range(1)-1; +totalhops=round((p.range(2)-p.range(1)+1) / p.hop); +r1=nan*zeros(1,totalhops);r2=nan*zeros(1,totalhops); +r3=nan*zeros(1,totalhops);r4=nan*zeros(1,totalhops); +idx2=0+round(p.wsize/2/p.hop); +while (1) + start = idx+1; + stop = idx+p.bufsize; + stop=min(stop, p.range(2)); + xx=sf_wave(fileinfo, [start, stop], []); +% if size(xx,1) == 1; xx=xx'; end + xx=xx(:,1); % first channel if multichannel + [prd,ap0,ap,pwr]=yin_helper(xx,p); + n=size(prd ,2); + if (~n) break; end; + idx=idx+n*p.hop; + + r1(idx2+1:idx2+n)= prd; + r2(idx2+1:idx2+n)= ap0; + r3(idx2+1:idx2+n)= ap; + r4(idx2+1:idx2+n)= pwr; + idx2=idx2+n; +end +r.r1=r1; % period estimate +r.r2=r2; % gross aperiodicity measure +r.r3=r3; % fine aperiodicity measure +r.r4=r4; % power +sf_cleanup(fileinfo); +% end of program + + + +% Estimate F0 of a chunk of signal +function [prd,ap0,ap,pwr]=yin_helper(x,p,dd) +smooth=ceil(p.sr/p.lpf); +x=rsmooth(x,smooth); % light low-pass smoothing +x=x(smooth:end-smooth+1); +[m,n]=size(x); +maxlag = ceil(p.sr/p.minf0); +minlag = floor(p.sr/p.maxf0); +mxlg = maxlag+2; % +2 to improve interp near maxlag + + +hops=floor((m-mxlg-p.wsize)/p.hop); +prd=zeros(1,hops); +ap0=zeros(1,hops); +ap=zeros(1,hops); +pwr=zeros(1,hops); +if hops<1; return; end + +% difference function matrix +dd=zeros(floor((m-mxlg-p.hop)/p.hop),mxlg); +if p.shift == 0 % windows shift both ways + lags1=round(mxlg/2) + round((0:mxlg-1)/2); + lags2=round(mxlg/2) - round((1:mxlg)/2); + lags=[lags1; lags2]; +elseif p.shift == 1 % one window fixed, other shifts right + lags=[zeros(1,mxlg); 1:mxlg]; +elseif p.shift == -1 % one window fixed, other shifts right + lags=[mxlg-1:-1:0; mxlg*ones(1,mxlg)]; +else + error (['unexpected shift flag: ', num2str(p.shift)]); +end +rdiff_inplace(x,x,dd,lags,p.hop); +rsum_inplace(dd,round(p.wsize/p.hop)); +dd=dd'; +[dd,ddx]=minparabolic(dd); % parabolic interpolation near min +cumnorm_inplace(dd);; % cumulative mean-normalize + +% first period estimate +%global jj; +for j=1:hops + d=dd(:,j); + if p.relflag + pd=dftoperiod2(d,[minlag,maxlag],p.thresh); + else + pd=dftoperiod(d,[minlag,maxlag],p.thresh); + end + ap0(j)=d(pd+1); + prd(j)=pd; +end + +% replace each estimate by best estimate in range +range = 2*round(maxlag/p.hop); +if hops>1; prd=prd(mininrange(ap0,range*ones(1,hops))); end +%prd=prd(mininrange(ap0,prd)); + + +% refine estimate by constraining search to vicinity of best local estimate +margin1=0.6; +margin2=1.8; +for j=1:hops + d=dd(:,j); + dx=ddx(:,j); + pd=prd(j); + lo=floor(pd*margin1); lo=max(minlag,lo); + hi=ceil(pd*margin2); hi=min(maxlag,hi); + pd=dftoperiod(d,[lo,hi],0); + ap0(j)=d(pd+1); + pd=pd+dx(pd+1)+1; % fine tune based on parabolic interpolation + prd(j)=pd; + + % power estimates + idx=(j-1)*p.hop; + k=(1:ceil(pd))'; + x1=x(k+idx); + x2=k+idx+pd-1; + interp_inplace(x,x2); + x3=x2-x1; + x4=x2+x1; + x1=x1.^2; rsum_inplace(x1,pd); + x3=x3.^2; rsum_inplace(x3,pd); + x4=x4.^2; rsum_inplace(x4,pd); + + x1=x1(1)/pd; + x2=x2(1)/pd; + x3=x3(1)/pd; + x4=x4(1)/pd; + % total power + pwr(j)=x1; + + % fine aperiodicity + ap(j)=(eps+x3)/(eps+(x3+x4)); % accurate, only for valid min + + %ap(j) + %plot(min(1, d)); pause + + prd(j)=pd; +end + + + +%cumulative mean-normalize +function y=cumnorm(x) +[m,n]=size(x); +y = cumsum(x); +y = (y)./ (eps+repmat((1:m)',1,n)); % cumulative mean +y = (eps+x) ./ (eps+y);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin.html Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,84 @@ +<html> +<head> +<title> YIN </title> +</head> + +<body> + +See README for copyright information. + +<hr> +<h2> YIN: fundamental frequency estimator </h2> +<hr> + +YIN estimates the fundamental frequency (F0) of an audio signal. +Features are: +<ul> +<li> Reliability (based on tests, see reference below). +<li> Accuracy (subsample resolution). +<li> Wide search range (default is 30 Hz - sr/4). +<li> Good temporal resolution. +<li> Ease of use. +</ul> + +YIN operates on vectors or files. YIN outputs a structure containing a set +of four vectors: F0 vs time, two estimates of aperiodic/total power +(one gross estimate, one fine estimate), and a period-smoothed estimate +of instantaneous power. +<p> +If no output argment is specified, YIN +plots F0 as a function of time (in octaves re: 440 Hz), aperiodicity, and power. +<p> +In the F0 plot, samples in blue are reckoned reliable (aperiodicity<threshold), +green are intermediate (aperiodicity<2*threshold), and +yellow unreliable (aperiodicity>2*threshold). + +<p> +Type 'help yin' for a description of the parameters. Read the reference below and +the code to understand their meaning. In brief: +<ul> +<li> To increase speed: increase 'hop' or 'minf0'. +<li> To reduce memory needs: reduce 'bufsize', or increase 'hop' or 'minf0'. +<li> To slightly increase reliability: reduce 'hop'. +<li> To slightly increase precision: upsample before processing. +<li> To improve temporal resolution: increase 'minf0', decrease 'hop'. +<li> To process lower F0s: reduce 'minf0'. Higher F0s: upsample and increase 'maxf0'. +<li> To avoid subharmonic errors: increase 'thresh'. +<li> To avoid harmonic/formant errors: reduce 'thresh'. +<li> Make sure that the range [minf0 maxf0] includes the expected f0. +</ul> +Parameter 'thresh' sets the proportion of aperiodic power that is +tolerated within a "periodic" signal. This may vary according to the application. +<p> +For speech or musical instruments a value of 0.1 is usually adequate. Singing voice +may require a smaller value (as low as 0.001) if a harmonic is reinforced by a +sharp formant. +<p> +Some signals are inherently ambiguous. For example +the response of a high-Q resonator excited by a pulse train may be seen either as a complex +tone with an F0 equal to that of the pulse train, or as an +amplitude modulated pure tone with an F0 equal to the resonant frequency. +Neither is more "correct" than the other. To obtain the result +that you expect, you must set the threshold to an appropriate value: small for the +fundamental periodicity, large for the resonance periodicity. + +<p> +YIN is described in: +<br></tt> +de Cheveigné, A., and Kawahara, H. (2002). "YIN, a fundamental frequency estimator +for speech and music," J. Acoust. Soc. Am., 111, 1917-1930. (<a href= + "http://www.ircam.fr/pcm/cheveign/ps/yin.pdf">pdf</a>) + </tt> + + <hr> +[Code is <a href="http://www.ircam.fr/pcm/cheveign/sw/yin.zip">here</a>] +[<a href="http://www.ircam.fr/pcm/cheveign">Alain de Cheveigné</a>] + + + + + + </body> + </html> + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/CHANGES Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,39 @@ +15 May 2002: changed value of dipwidth in period_11.m (1.9 --> 1.85) to +avoid error condition. + +20 June 2002: plot square root of aperiodicity ratio, rather than ratio +itself + +1 June 2003: new version of YIN. The implementation is improved (faster, +more robust, bugs corrected). YIN now processes files a chunk at a +time, so it can handle larger files. + +28 July 2003: bug fixes. + +1 Sept 2003: put sf routines in yin/private/. + +16 Sept 2003: bug fix. + +17 Sept 2003: bug fix. + +22 Sept 2003: bug fix (rdiff_inplace.c). Mex functions must be +recompiled for Windows. Added option 'shift' to allow windows to +shift left, right, or symmetrically. + +30 Sept 2003: changed definition of 'thresh' parameter to match +the value actually used in algorithm (threshold for min of difference +function). Old and new definitions differ by a factor of two. Old +default was 0.1, new is 0.2 (behavior is the same). + +3 Oct 2003: +- Fixed a bug that increased error probability at buffer edge. +- Fixed a weakness in the search for minimum that increased the + likelihood of a 'too low' error. +- New parameter 'relflag'. If 0 the threshold is absolute, if + ~0 the threshold is relative to the global minimum of the difference + function. Default is 1. This changes the semantics of 'thresh'. +- Default of 'thresh' is now 0.1. +- Windows: mex files must be recompiled! + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/INSTALL Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,13 @@ +To get yin to work on your system, put yin/ on your matlab path. + +Yin uses mex files for its private routines. Precompiled mex files are +for several platforms. If there aren't any for yours, you must compile +them yourself. Go to + yin/private/src +In matlab, for each filename.c, type + mex filename.c +then move the mex files produced to + /yin/private/ + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/README Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,24 @@ +% Alain de Cheveigné, CNRS/Ircam, 2002. +% Copyright (c) 2002 Centre National de la Recherche Scientifique. +% + +% Alain de Cheveigné, CNRS/Ircam, 2002, 2003. +% Copyright (c) 2002, 2003 Centre National de la Recherche Scientifique. +% +% Permission to use, copy, modify, and distribute this software without +% fee is hereby granted FOR RESEARCH PURPOSES only, provided that this +% copyright notice appears in all copies and in all supporting +% documentation, and that the software is not redistributed for any +% fee (except for a nominal shipping charge). +% +% For any other uses of this software, in original or modified form, +% including but not limited to consulting, production or distribution +% in whole or in part, specific prior permission must be obtained from CNRS. +% Algorithms implemented by this software may be claimed by patents owned +% by CNRS, France Telecom, Ircam or others. +% +% The CNRS makes no representations about the suitability of this +% software for any purpose. It is provided "as is" without express +% or implied warranty. Beware of the bugs. + +% See yin.html for more information.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/female04_16K_PitchDetection_Fixed_Correct.txt Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,1167 @@ +2 0 0 0 +3 0 0 0 +4 0 0 0 +5 0 0 0 +6 0 0 0 +7 0 0 0 +8 0 0 0 +9 0 0 0 +10 0 0 0 +11 2 0 7 +12 2 0 7 +13 3 60 7 +14 6 58 0 +15 6 55 0 +16 6 53 0 +17 6 52 0 +18 6 51 0 +19 6 50 0 +20 6 50 0 +21 6 50 0 +22 6 50 0 +23 6 51 0 +24 3 50 0 +25 3 52 0 +26 3 52 0 +27 3 54 0 +28 3 56 0 +29 3 57 0 +30 3 57 0 +31 3 60 0 +32 3 60 0 +33 3 61 0 +34 3 61 0 +35 3 70 0 +36 3 70 0 +37 3 73 0 +38 3 77 0 +39 3 73 0 +40 3 75 7 +41 2 0 7 +42 2 0 7 +43 0 0 0 +44 0 0 0 +45 0 0 0 +46 6 54 0 +47 6 64 0 +48 4 70 0 +49 4 72 0 +50 4 71 0 +51 4 70 0 +52 4 70 0 +53 4 73 0 +54 4 74 0 +55 4 80 0 +56 4 81 0 +57 4 84 0 +58 4 90 0 +59 4 90 0 +60 4 91 0 +61 4 90 0 +62 4 80 0 +63 4 90 0 +64 1 94 0 +65 1 102 0 +66 1 100 0 +67 1 101 0 +68 4 100 0 +69 4 93 0 +70 4 90 0 +71 4 90 0 +72 6 82 0 +73 4 80 0 +74 4 76 0 +75 4 70 0 +76 6 70 0 +77 6 70 0 +78 6 70 0 +79 4 71 0 +80 4 73 0 +81 4 74 0 +82 4 80 0 +83 4 80 0 +84 4 80 0 +85 4 90 0 +86 4 100 0 +87 1 110 0 +88 1 110 0 +89 1 113 0 +90 1 120 0 +91 1 128 0 +92 1 130 0 +93 1 130 0 +94 1 130 0 +95 1 133 0 +96 1 131 0 +97 1 143 0 +98 1 140 0 +99 1 150 0 +100 1 113 7 +101 2 0 0 +102 0 0 0 +103 0 0 0 +104 0 0 0 +105 0 0 0 +106 0 0 0 +107 0 0 0 +108 0 0 0 +109 0 0 0 +110 0 0 0 +111 0 0 0 +112 0 0 0 +113 0 0 0 +114 0 0 0 +115 0 0 0 +116 0 0 0 +117 0 0 0 +118 6 56 7 +119 4 54 0 +120 4 55 0 +121 4 56 0 +122 3 62 7 +123 3 55 0 +124 2 0 7 +125 6 54 0 +126 4 53 0 +127 4 52 0 +128 4 50 0 +129 4 50 0 +130 3 52 7 +131 2 0 7 +132 2 0 0 +133 3 50 7 +134 3 53 7 +135 0 0 0 +136 2 0 0 +137 2 0 0 +138 2 0 0 +139 2 0 7 +140 4 52 0 +141 6 50 0 +142 1 53 7 +143 1 52 0 +144 1 51 0 +145 1 52 0 +146 1 51 0 +147 1 50 0 +148 4 46 0 +149 6 41 0 +150 6 38 0 +151 6 35 0 +152 6 33 0 +153 6 31 0 +154 3 30 0 +155 3 30 0 +156 1 36 7 +157 3 34 7 +158 3 33 7 +159 3 32 7 +160 2 0 7 +161 2 0 0 +162 1 51 7 +163 4 56 0 +164 6 58 0 +165 6 60 0 +166 6 60 0 +167 3 61 7 +168 3 56 0 +169 3 60 0 +170 1 58 0 +171 3 60 7 +172 6 70 0 +173 6 70 0 +174 4 80 0 +175 4 80 0 +176 4 80 0 +177 4 80 0 +178 6 74 0 +179 6 70 0 +180 4 70 0 +181 1 83 0 +182 3 74 0 +183 1 72 0 +184 3 75 0 +185 2 0 7 +186 2 0 0 +187 4 74 0 +188 6 83 0 +189 4 84 0 +190 6 86 0 +191 4 90 0 +192 6 90 0 +193 3 100 7 +194 2 0 0 +195 2 0 0 +196 2 0 0 +197 2 0 0 +198 2 0 0 +199 2 0 0 +200 2 0 0 +201 2 0 0 +202 2 0 0 +203 2 0 0 +204 2 0 0 +205 6 60 7 +206 6 64 0 +207 6 63 0 +208 6 61 0 +209 4 60 0 +210 6 55 0 +211 4 52 0 +212 1 50 0 +213 3 50 0 +214 4 50 0 +215 4 47 0 +216 1 50 0 +217 4 50 0 +218 4 51 0 +219 4 52 0 +220 4 54 0 +221 4 54 0 +222 6 58 0 +223 4 62 0 +224 4 64 0 +225 4 66 0 +226 4 70 0 +227 4 67 0 +228 4 66 0 +229 4 65 0 +230 4 63 0 +231 4 62 0 +232 4 60 0 +233 6 60 0 +234 4 60 0 +235 4 60 0 +236 4 60 0 +237 4 61 0 +238 6 61 0 +239 4 61 0 +240 4 60 0 +241 4 64 0 +242 1 70 0 +243 1 72 0 +244 1 71 0 +245 2 0 0 +246 2 0 0 +247 2 0 0 +248 2 0 0 +249 6 80 7 +250 4 90 0 +251 1 103 0 +252 1 104 0 +253 1 113 0 +254 1 124 0 +255 1 120 0 +256 1 100 0 +257 1 100 0 +258 1 92 0 +259 1 96 0 +260 1 109 0 +261 4 100 0 +262 4 100 0 +263 1 105 0 +264 1 102 0 +265 1 100 0 +266 1 90 0 +267 4 76 0 +268 4 73 0 +269 4 70 0 +270 4 70 0 +271 4 70 0 +272 4 70 0 +273 4 70 0 +274 1 86 0 +275 2 0 0 +276 0 0 0 +277 2 0 0 +278 0 0 0 +279 2 0 0 +280 4 90 0 +281 1 90 0 +282 3 90 0 +283 3 100 7 +284 2 0 7 +285 2 0 7 +286 2 0 7 +287 2 0 7 +288 2 0 7 +289 2 0 7 +290 2 0 7 +291 2 0 7 +292 2 0 7 +293 2 0 7 +294 2 0 7 +295 2 0 7 +296 2 0 7 +297 2 0 0 +298 2 0 0 +299 0 0 0 +300 0 0 0 +301 0 0 0 +302 0 0 0 +303 2 0 7 +304 2 0 7 +305 2 0 7 +306 0 0 0 +307 0 0 0 +308 0 0 0 +309 0 0 0 +310 0 0 0 +311 0 0 0 +312 0 0 0 +313 0 0 0 +314 2 0 0 +315 2 0 0 +316 2 0 0 +317 5 0 0 +318 5 0 0 +319 5 0 0 +320 5 0 0 +321 5 0 0 +322 5 0 0 +323 5 0 0 +324 5 0 7 +325 4 43 0 +326 6 40 0 +327 6 40 0 +328 6 37 0 +329 3 40 0 +330 3 33 7 +331 3 30 0 +332 3 30 0 +333 3 29 0 +334 3 29 0 +335 3 30 0 +336 3 30 0 +337 3 35 0 +338 0 0 0 +339 0 0 0 +340 0 0 0 +341 6 30 0 +342 6 30 0 +343 6 31 0 +344 6 31 0 +345 6 33 0 +346 6 32 0 +347 6 33 0 +348 6 34 0 +349 3 34 0 +350 3 32 0 +351 3 32 0 +352 2 0 0 +353 2 0 0 +354 6 34 0 +355 6 35 0 +356 6 37 0 +357 6 40 0 +358 3 44 7 +359 2 0 0 +360 2 0 0 +361 2 0 0 +362 2 0 0 +363 2 0 0 +364 2 0 0 +365 2 0 0 +366 2 0 0 +367 6 40 7 +368 4 44 0 +369 4 46 0 +370 4 47 0 +371 4 50 0 +372 4 48 0 +373 4 47 0 +374 4 46 0 +375 6 45 0 +376 6 44 0 +377 4 44 0 +378 4 46 0 +379 6 50 7 +380 1 46 0 +381 1 45 0 +382 1 45 0 +383 4 45 0 +384 4 46 0 +385 4 47 0 +386 1 50 0 +387 1 50 0 +388 1 52 0 +389 4 55 0 +390 4 54 0 +391 4 60 0 +392 4 60 0 +393 6 60 0 +394 6 61 0 +395 6 64 0 +396 4 67 0 +397 4 70 0 +398 1 73 0 +399 2 0 0 +400 2 0 0 +401 2 0 0 +402 2 0 0 +403 2 0 0 +404 2 0 0 +405 2 0 0 +406 2 0 0 +407 2 0 0 +408 2 0 0 +409 6 54 0 +410 6 58 0 +411 6 62 0 +412 4 60 0 +413 4 60 0 +414 6 56 0 +415 6 54 0 +416 3 54 7 +417 3 56 7 +418 3 60 0 +419 5 0 0 +420 2 0 0 +421 2 0 0 +422 2 0 0 +423 2 0 0 +424 1 70 7 +425 2 0 0 +426 0 0 0 +427 0 0 0 +428 0 0 0 +429 6 67 7 +430 6 73 0 +431 6 73 0 +432 6 72 0 +433 6 73 0 +434 6 74 0 +435 6 74 0 +436 4 75 0 +437 4 74 0 +438 4 73 0 +439 4 80 0 +440 4 76 0 +441 4 76 0 +442 4 80 0 +443 4 80 0 +444 4 80 0 +445 4 81 0 +446 6 82 0 +447 6 81 0 +448 6 82 0 +449 4 82 0 +450 6 82 0 +451 6 83 0 +452 6 85 0 +453 6 86 0 +454 6 90 0 +455 1 83 0 +456 3 83 0 +457 3 82 0 +458 1 82 0 +459 1 82 0 +460 1 82 0 +461 1 83 0 +462 1 83 0 +463 1 90 0 +464 1 86 0 +465 1 83 0 +466 1 80 0 +467 1 80 0 +468 1 74 0 +469 1 73 0 +470 1 70 0 +471 2 0 7 +472 0 0 0 +473 0 0 0 +474 0 0 0 +475 0 0 0 +476 0 0 0 +477 0 0 0 +478 0 0 0 +479 0 0 0 +480 0 0 0 +481 0 0 0 +482 0 0 0 +483 0 0 0 +484 2 0 0 +485 0 0 0 +486 2 0 0 +487 1 60 0 +488 6 60 0 +489 6 60 0 +490 6 61 0 +491 6 64 0 +492 6 64 0 +493 6 62 0 +494 6 62 0 +495 6 61 0 +496 6 61 0 +497 6 61 7 +498 2 0 0 +499 2 0 0 +500 3 62 0 +501 3 62 0 +502 1 60 0 +503 2 0 0 +504 3 54 0 +505 3 52 0 +506 1 55 0 +507 3 54 0 +508 3 53 0 +509 3 50 0 +510 6 45 0 +511 4 44 0 +512 4 43 0 +513 6 40 0 +514 6 40 0 +515 6 39 0 +516 6 39 0 +517 6 37 0 +518 6 36 0 +519 6 36 0 +520 6 35 0 +521 6 35 0 +522 6 35 0 +523 6 35 0 +524 6 35 0 +525 6 36 0 +526 6 37 0 +527 6 36 0 +528 6 36 0 +529 2 0 7 +530 3 36 0 +531 6 38 0 +532 4 43 0 +533 4 50 0 +534 4 50 0 +535 6 54 0 +536 4 55 0 +537 6 56 0 +538 6 57 0 +539 6 54 0 +540 6 54 0 +541 6 54 0 +542 6 53 0 +543 6 50 0 +544 6 45 0 +545 6 47 0 +546 6 46 0 +547 6 46 0 +548 6 46 0 +549 6 46 0 +550 6 45 0 +551 6 45 0 +552 6 44 0 +553 6 43 0 +554 6 41 0 +555 6 41 0 +556 6 41 0 +557 4 41 0 +558 4 41 0 +559 4 42 0 +560 4 41 0 +561 6 41 0 +562 4 42 0 +563 6 44 0 +564 1 44 0 +565 1 42 0 +566 2 0 0 +567 2 0 0 +568 2 0 0 +569 2 0 0 +570 2 0 0 +571 1 40 7 +572 4 43 0 +573 4 44 0 +574 4 44 0 +575 4 43 0 +576 4 45 0 +577 4 45 0 +578 4 44 0 +579 4 44 0 +580 4 45 0 +581 3 42 0 +582 1 41 0 +583 1 43 0 +584 1 44 0 +585 4 46 0 +586 1 50 0 +587 1 50 0 +588 1 51 0 +589 1 52 0 +590 6 50 7 +591 6 50 0 +592 6 51 0 +593 6 54 0 +594 6 55 0 +595 6 60 0 +596 6 60 0 +597 6 60 0 +598 6 65 0 +599 1 60 0 +600 3 70 0 +601 3 70 0 +602 2 0 0 +603 2 0 0 +604 2 0 0 +605 2 0 0 +606 2 0 0 +607 3 60 0 +608 3 62 0 +609 6 60 0 +610 6 57 0 +611 6 57 0 +612 6 57 0 +613 6 60 0 +614 6 60 0 +615 1 68 7 +616 1 66 0 +617 1 65 0 +618 4 60 0 +619 6 57 0 +620 6 57 0 +621 6 60 0 +622 6 59 0 +623 6 58 0 +624 6 57 0 +625 4 56 0 +626 4 60 0 +627 4 61 0 +628 1 60 0 +629 3 60 0 +630 3 60 0 +631 3 60 0 +632 3 60 0 +633 3 64 0 +634 2 0 0 +635 2 0 0 +636 2 0 0 +637 2 0 0 +638 6 65 0 +639 6 61 0 +640 6 60 0 +641 6 62 0 +642 6 69 0 +643 6 70 0 +644 6 80 0 +645 6 80 0 +646 6 83 0 +647 6 90 0 +648 6 92 0 +649 6 97 0 +650 6 100 0 +651 1 100 0 +652 1 100 0 +653 1 100 0 +654 1 95 0 +655 1 100 0 +656 1 100 0 +657 3 100 0 +658 1 105 0 +659 1 110 0 +660 2 0 0 +661 2 0 0 +662 2 0 0 +663 2 0 0 +664 6 64 7 +665 6 67 0 +666 6 73 0 +667 1 73 0 +668 6 76 0 +669 6 80 0 +670 6 80 0 +671 4 81 0 +672 4 84 0 +673 4 90 0 +674 1 94 0 +675 3 100 0 +676 2 0 7 +677 6 71 0 +678 6 74 0 +679 6 77 0 +680 6 80 0 +681 6 80 0 +682 6 87 0 +683 3 111 0 +684 3 81 0 +685 3 78 0 +686 3 80 0 +687 3 82 0 +688 2 0 7 +689 2 0 7 +690 6 65 0 +691 6 65 0 +692 6 66 0 +693 6 70 0 +694 6 70 0 +695 6 70 0 +696 3 75 0 +697 1 83 0 +698 1 73 0 +699 4 71 0 +700 4 70 0 +701 6 70 0 +702 6 73 0 +703 6 75 0 +704 4 71 0 +705 4 80 0 +706 4 80 0 +707 4 80 0 +708 4 80 0 +709 6 76 0 +710 6 80 0 +711 6 80 0 +712 6 80 0 +713 6 80 0 +714 6 83 0 +715 4 85 0 +716 1 90 0 +717 1 85 0 +718 4 90 0 +719 4 90 0 +720 4 86 0 +721 6 85 0 +722 6 85 0 +723 6 86 0 +724 6 86 0 +725 6 90 0 +726 4 90 0 +727 1 90 0 +728 4 86 0 +729 6 86 0 +730 6 86 0 +731 4 90 0 +732 1 85 0 +733 1 98 0 +734 1 94 0 +735 1 90 0 +736 3 90 0 +737 6 80 0 +738 6 80 0 +739 6 80 0 +740 6 81 0 +741 6 81 0 +742 4 83 0 +743 6 82 0 +744 1 90 0 +745 5 0 0 +746 2 0 0 +747 2 0 0 +748 2 0 0 +749 2 0 0 +750 2 0 0 +751 2 0 0 +752 2 0 0 +753 2 0 0 +754 2 0 0 +755 2 0 0 +756 6 58 0 +757 6 58 0 +758 6 60 0 +759 6 62 0 +760 6 64 0 +761 6 68 0 +762 6 69 0 +763 6 73 0 +764 6 77 0 +765 6 81 0 +766 3 80 0 +767 6 81 0 +768 6 81 0 +769 6 83 0 +770 6 80 0 +771 6 82 0 +772 6 86 0 +773 6 86 0 +774 6 90 0 +775 1 91 0 +776 1 90 0 +777 1 93 0 +778 1 93 0 +779 1 95 0 +780 1 90 0 +781 1 90 0 +782 1 80 0 +783 6 70 0 +784 6 63 0 +785 6 62 0 +786 6 61 0 +787 6 61 0 +788 6 64 0 +789 6 70 0 +790 3 70 7 +791 3 77 0 +792 6 78 0 +793 6 81 0 +794 6 81 0 +795 4 80 0 +796 3 77 0 +797 1 82 0 +798 1 83 0 +799 3 80 0 +800 3 76 0 +801 3 77 0 +802 2 0 7 +803 2 0 0 +804 6 56 0 +805 6 56 0 +806 6 55 0 +807 6 56 0 +808 4 60 0 +809 6 60 0 +810 6 61 0 +811 4 63 0 +812 6 64 0 +813 6 64 0 +814 4 65 7 +815 2 0 0 +816 2 0 0 +817 2 0 0 +818 2 0 0 +819 2 0 0 +820 2 0 0 +821 2 0 0 +822 2 0 0 +823 1 60 7 +824 4 70 0 +825 6 70 0 +826 3 66 0 +827 2 0 0 +828 3 70 0 +829 2 0 7 +830 2 0 0 +831 6 73 0 +832 6 75 0 +833 6 76 0 +834 6 76 0 +835 6 76 0 +836 6 70 0 +837 4 65 0 +838 4 70 0 +839 1 70 0 +840 2 0 0 +841 2 0 0 +842 2 0 0 +843 2 0 0 +844 2 0 0 +845 2 0 0 +846 2 0 0 +847 0 0 0 +848 0 0 0 +849 0 0 0 +850 2 0 0 +851 6 43 0 +852 6 46 0 +853 4 52 0 +854 4 55 0 +855 4 54 0 +856 6 56 0 +857 3 60 0 +858 3 60 0 +859 3 51 7 +860 3 57 0 +861 0 0 0 +862 2 0 0 +863 2 0 0 +864 2 0 0 +865 2 0 0 +866 2 0 0 +867 2 0 0 +868 2 0 0 +869 2 0 0 +870 0 0 0 +871 0 0 0 +872 0 0 0 +873 0 0 0 +874 2 0 0 +875 6 33 0 +876 6 35 0 +877 6 42 0 +878 6 48 0 +879 6 51 0 +880 6 53 0 +881 6 54 0 +882 6 53 0 +883 6 51 0 +884 4 50 0 +885 3 48 0 +886 3 51 0 +887 3 48 0 +888 3 51 0 +889 3 51 0 +890 3 50 0 +891 3 50 7 +892 3 52 0 +893 2 0 0 +894 2 0 0 +895 2 0 0 +896 2 0 0 +897 6 49 0 +898 4 51 0 +899 4 54 0 +900 4 58 0 +901 6 63 0 +902 4 67 0 +903 6 71 0 +904 6 76 0 +905 6 76 0 +906 6 77 0 +907 3 81 0 +908 3 90 0 +909 3 90 0 +910 1 84 0 +911 3 80 0 +912 6 70 0 +913 4 68 0 +914 6 70 0 +915 1 80 0 +916 3 80 0 +917 3 80 0 +918 3 74 0 +919 3 67 0 +920 2 0 0 +921 6 61 7 +922 6 64 0 +923 6 70 0 +924 4 75 0 +925 4 70 0 +926 4 70 0 +927 6 71 0 +928 6 72 0 +929 4 79 0 +930 4 74 0 +931 4 74 0 +932 4 72 0 +933 4 70 0 +934 4 70 0 +935 4 66 0 +936 6 61 7 +937 1 63 0 +938 6 61 0 +939 6 60 0 +940 6 60 0 +941 6 60 0 +942 6 65 0 +943 1 121 7 +944 3 120 7 +945 1 115 7 +946 2 0 0 +947 6 60 7 +948 6 62 0 +949 6 64 0 +950 6 64 0 +951 6 63 0 +952 6 61 0 +953 4 61 0 +954 3 68 0 +955 3 71 0 +956 2 0 0 +957 2 0 0 +958 2 0 0 +959 2 0 0 +960 2 0 0 +961 2 0 0 +962 6 64 0 +963 6 67 0 +964 6 70 0 +965 6 74 0 +966 6 75 0 +967 1 81 0 +968 1 90 0 +969 1 80 0 +970 4 80 0 +971 6 71 0 +972 6 70 0 +973 6 67 0 +974 6 65 0 +975 4 62 0 +976 4 62 0 +977 4 60 0 +978 4 56 0 +979 4 55 0 +980 6 53 0 +981 6 51 0 +982 6 51 0 +983 6 56 0 +984 4 55 0 +985 4 54 0 +986 6 54 0 +987 6 54 0 +988 6 55 0 +989 6 60 0 +990 6 60 0 +991 4 62 0 +992 4 70 0 +993 4 70 0 +994 4 73 0 +995 4 74 0 +996 4 75 0 +997 6 71 0 +998 6 75 0 +999 1 80 0 +1000 6 78 0 +1001 1 80 0 +1002 6 80 0 +1003 6 83 0 +1004 6 83 0 +1005 6 80 0 +1006 6 81 0 +1007 6 83 0 +1008 6 82 0 +1009 6 82 0 +1010 6 81 0 +1011 3 80 0 +1012 3 80 0 +1013 6 81 0 +1014 6 74 0 +1015 6 80 0 +1016 6 78 0 +1017 6 75 0 +1018 6 70 0 +1019 6 63 0 +1020 6 60 0 +1021 6 54 0 +1022 6 52 0 +1023 6 47 0 +1024 6 43 0 +1025 6 41 0 +1026 6 38 0 +1027 6 32 0 +1028 2 0 7 +1029 2 0 0 +1030 2 0 0 +1031 2 0 0 +1032 2 0 0 +1033 2 0 0 +1034 2 0 0 +1035 3 53 7 +1036 3 61 0 +1037 1 70 0 +1038 6 70 0 +1039 6 74 0 +1040 6 78 0 +1041 6 87 0 +1042 6 90 0 +1043 6 91 0 +1044 6 92 0 +1045 6 90 0 +1046 6 90 0 +1047 6 85 0 +1048 6 85 0 +1049 6 91 0 +1050 2 0 0 +1051 2 0 0 +1052 2 0 0 +1053 2 0 0 +1054 2 0 0 +1055 2 0 0 +1056 2 0 0 +1057 2 0 0 +1058 2 0 0 +1059 2 0 0 +1060 2 0 0 +1061 2 0 0 +1062 2 0 0 +1063 2 0 0 +1064 2 0 0 +1065 6 36 7 +1066 6 38 0 +1067 6 40 0 +1068 1 38 0 +1069 6 39 0 +1070 6 39 0 +1071 6 37 0 +1072 6 35 0 +1073 6 34 0 +1074 6 34 0 +1075 6 34 0 +1076 6 35 0 +1077 3 45 0 +1078 3 51 0 +1079 3 53 0 +1080 1 54 0 +1081 1 68 0 +1082 3 71 0 +1083 3 75 0 +1084 3 74 0 +1085 6 75 0 +1086 6 80 0 +1087 6 77 0 +1088 3 77 0 +1089 3 80 0 +1090 3 74 0 +1091 3 73 0 +1092 3 80 0 +1093 3 76 0 +1094 3 70 0 +1095 1 71 0 +1096 1 65 0 +1097 1 65 0 +1098 1 62 0 +1099 6 60 0 +1100 6 50 0 +1101 6 44 0 +1102 6 44 0 +1103 1 46 0 +1104 2 0 0 +1105 2 0 0 +1106 2 0 0 +1107 2 0 0 +1108 2 0 0 +1109 2 0 0 +1110 2 0 0 +1111 2 0 0 +1112 2 0 0 +1113 2 0 0 +1114 2 0 0 +1115 0 0 0 +1116 0 0 0 +1117 2 0 0 +1118 5 0 0 +1119 1 46 0 +1120 1 47 0 +1121 1 48 0 +1122 1 46 0 +1123 6 50 0 +1124 6 51 0 +1125 6 50 0 +1126 1 46 0 +1127 1 50 0 +1128 3 55 0 +1129 3 53 0 +1130 3 51 0 +1131 3 50 0 +1132 3 51 0 +1133 2 0 0 +1134 6 34 7 +1135 6 35 0 +1136 6 40 0 +1137 1 56 0 +1138 1 65 0 +1139 1 74 0 +1140 6 53 0 +1141 6 53 0 +1142 6 60 0 +1143 3 86 0 +1144 3 92 0 +1145 3 96 0 +1146 3 93 0 +1147 3 100 0 +1148 1 101 0 +1149 1 110 0 +1150 1 102 0 +1151 1 104 0 +1152 2 0 0 +1153 2 0 0 +1154 0 0 0 +1155 0 0 0 +1156 0 0 0 +1157 2 0 0 +1158 0 0 0 +1159 0 0 0 +1160 0 0 0 +1161 0 0 0 +1162 0 0 0 +1163 0 0 0 +1164 0 0 0 +1165 0 0 0 +1166 0 0 0 +1167 0 0 0 +1168 0 0 0 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/pitch.txt Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,9352 @@ +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +135.8 +135.88 +135.87 +135.91 +135.77 +136.51 +252.25 +207.3 +207.28 +207.2 +207.14 +207.17 +207.22 +207.31 +207.04 +207.06 +184.59 +157.76 +207.3 +157.68 +157.51 +157.53 +157.39 +242.26 +157.67 +242.44 +242.22 +242.41 +150.83 +157.6 +112.73 +112.89 +98.983 +98.779 +98.537 +98 +290.53 +398.51 +164.67 +233 +185.4 +176.02 +164 +164.09 +164.86 +164 +164.85 +277 +282.96 +265 +17 +6 +6 +18 +6 +6 +6 +6 +9 +17 +10 +10 +10 +10.208 +10.293 +10.218 +10.194 +10.258 +10.346 +10.84 +10.5 +49.877 +41.105 +53.193 +54.83 +54.398 +54.036 +64.37 +64.459 +64.159 +63.778 +63.659 +62.711 +62.625 +60 +60 +58.791 +58.719 +58 +57.488 +57.257 +57.364 +57.363 +56.825 +56.685 +56.421 +56.096 +55.83 +55.562 +55.314 +55.065 +54.83 +54.675 +54.527 +54.48 +54.22 +54.099 +54.002 +53.764 +53.644 +53.464 +53.321 +53.131 +52.914 +52.736 +52.439 +52.344 +52.278 +52.005 +51.805 +51.65 +51.432 +51.408 +51.325 +51.193 +51.073 +50.977 +50.84 +50.733 +50.683 +50.585 +50.531 +50.502 +50.332 +50.284 +50.328 +50.314 +50.141 +50.186 +50.145 +50.064 +49.99 +49.919 +49.95 +49.949 +50.003 +49.927 +49.825 +49.729 +49.687 +49.666 +49.625 +49.635 +49.629 +49.67 +49.647 +49.695 +49.77 +49.763 +49.809 +49.738 +49.757 +49.708 +49.717 +49.786 +50.048 +50.043 +50.095 +50.2 +50.259 +50.46 +50.663 +50.721 +50.749 +50.71 +50.995 +51.089 +51.137 +51.245 +51.293 +51.378 +51.38 +51.329 +51.497 +51.638 +51.852 +51.982 +52.117 +52.461 +52.468 +52.654 +52.857 +53.085 +53.318 +53.464 +53.584 +53.778 +53.839 +54.024 +54.258 +54.384 +54.533 +54.597 +54.875 +55.089 +55.337 +55.473 +55.473 +55.73 +55.696 +55.937 +56.136 +56.304 +56.404 +56.377 +56.67 +56.845 +56.975 +57.264 +57.442 +57.658 +57.806 +57.71 +57.882 +58.232 +58.442 +58.827 +59.103 +59.15 +59.271 +59.384 +59.641 +59.731 +59.881 +60.17 +60.262 +60.629 +60.717 +61.032 +61.085 +61.702 +61.827 +62.455 +62.57 +62.714 +62.927 +63.274 +63.564 +63.812 +64.03 +64.171 +64.285 +64.425 +64.702 +64.848 +65.712 +65.915 +66.507 +66.525 +67.282 +67.354 +68.626 +68.927 +69.374 +69.554 +69.664 +70.049 +70.187 +70.698 +70.841 +71.283 +71.596 +71.958 +72.132 +72.426 +72.921 +73.542 +73.798 +74.547 +74.642 +74.74 +75.036 +75.267 +75.507 +75.548 +75.782 +75.811 +75.877 +75.782 +75.83 +76.148 +76.113 +75.939 +75.803 +75.669 +75.314 +75.244 +76.034 +76.047 +75.722 +75.441 +75.097 +75.338 +75.446 +74.989 +75.191 +74.782 +73.555 +73.435 +73 +73.976 +75.753 +74.264 +74.763 +74.741 +73.957 +73.601 +73.846 +74.298 +73.105 +73.834 +73.711 +74.52 +74 +43 +42 +35 +32 +34 +43 +30 +34 +37 +33 +35 +32 +43 +84.536 +93 +82 +82 +82 +82 +82 +82 +135.99 +80.623 +106.83 +105.2 +106.01 +105.21 +72 +71.463 +70 +69 +69 +69.107 +68 +68.434 +68.489 +68.169 +67.833 +68.204 +68.567 +68.527 +68.519 +68.573 +68.772 +68.906 +69.125 +69.271 +69.702 +69.993 +70.342 +70.562 +70.811 +70.954 +71.463 +71.502 +71.853 +71.612 +71.516 +71.286 +71.092 +70.951 +70.896 +70.778 +70.584 +70.311 +70.211 +70.15 +70.05 +70.071 +70.045 +70.023 +70.12 +70.146 +70.266 +70.454 +70.701 +70.981 +71.084 +71.325 +71.531 +72.012 +72.26 +72.623 +73.042 +73.532 +73.743 +74.405 +74.651 +75.237 +75.558 +76.058 +76.529 +76.831 +77.389 +77.6 +77.948 +78.096 +78.384 +78.777 +78.981 +79.26 +79.378 +79.605 +79.775 +80.027 +80.377 +80.633 +80.91 +81.101 +81.32 +81.58 +81.831 +82.093 +82.356 +82.677 +83.037 +83.328 +83.55 +83.9 +84.386 +84.795 +84.98 +85.231 +85.492 +85.856 +86.135 +86.482 +86.95 +87.226 +87.716 +88.037 +88.307 +88.803 +89.311 +89.437 +89.89 +90.338 +90.487 +90.664 +90.829 +90.676 +90.639 +90.418 +89.829 +89.049 +88.609 +87.642 +86.893 +86.37 +85.593 +85.174 +85.108 +84.803 +84.76 +84.647 +84.594 +84.971 +85.217 +85.425 +86.259 +87.12 +88.02 +89.248 +90.2 +91.162 +92.584 +93.663 +94.344 +95.24 +96.244 +97.397 +97.97 +98.711 +99.514 +99.974 +100.33 +100.96 +101.25 +101.41 +101.73 +101.89 +102.07 +102.26 +102.45 +102.62 +102.75 +102.9 +102.99 +102.32 +101.9 +101.72 +100.6 +99.744 +99.254 +97.719 +96.842 +96.565 +95.995 +95.36 +95.134 +94.714 +94.506 +94.275 +93.91 +93.779 +93.602 +93.257 +93.214 +92.874 +92.413 +92.398 +92.037 +91.611 +91.565 +91.056 +90.65 +90.505 +90.001 +89.603 +89.367 +88.811 +88.618 +88.171 +87.602 +87.311 +86.713 +86.168 +85.926 +85.452 +84.911 +84.602 +84.035 +83.464 +83.151 +82.595 +82.157 +81.86 +81.263 +81.012 +80.616 +80.057 +79.818 +79.412 +79.012 +78.624 +78.231 +77.966 +77.53 +77.193 +76.818 +76.544 +76.208 +75.79 +75.39 +74.916 +74.539 +73.992 +73.412 +72.882 +72.028 +71.397 +70.999 +70.615 +70.293 +69.973 +69.876 +69.733 +69.787 +69.847 +69.831 +69.831 +69.853 +69.853 +69.834 +69.883 +69.973 +70.032 +70.11 +70.154 +70.188 +70.275 +70.312 +70.397 +70.51 +70.594 +70.64 +70.786 +70.929 +71.059 +71.107 +71.206 +71.367 +71.443 +71.59 +71.663 +71.816 +71.964 +72.138 +72.275 +72.416 +72.57 +72.758 +72.967 +73.251 +73.507 +73.935 +74.23 +74.453 +74.883 +75.08 +75.478 +75.716 +76.034 +76.435 +76.685 +77.134 +77.191 +77.499 +77.935 +78.191 +78.614 +78.769 +79.154 +79.476 +79.842 +80.237 +80.618 +81.05 +81.451 +81.717 +82.309 +83.064 +83.693 +83.944 +84.786 +85.52 +86.244 +87.438 +87 +88.622 +90.133 +90 +91.759 +93.298 +94.333 +96 +97.402 +98.904 +100.89 +101.58 +102.81 +104.41 +104.86 +105.67 +107.06 +107.11 +108.06 +109.39 +109.39 +110.1 +111.16 +111.68 +111.96 +112.44 +113.45 +113.61 +114.04 +115.19 +115.58 +115.85 +116.62 +117.51 +117.88 +118.32 +119.93 +120.2 +120.68 +121.13 +122.02 +122.1 +122.53 +123.03 +123.43 +123.53 +123.9 +124.16 +124.34 +124.65 +124.91 +125.11 +125.33 +125.58 +125.81 +125.94 +126.35 +126.79 +126.83 +127.06 +127.41 +127.72 +127.71 +127.88 +128.15 +128.72 +128.52 +128.71 +128.91 +129.04 +128.82 +128.75 +129.06 +129.25 +129.27 +129.51 +129.61 +129.83 +129.88 +130.03 +130.1 +130.24 +130.38 +130.76 +130.8 +131.36 +131.88 +132.19 +132.22 +133.31 +134.96 +135.36 +135.37 +135.8 +137.78 +139.07 +139.12 +139.47 +141.52 +142.31 +142.39 +142.49 +143.69 +145.55 +145.81 +145.82 +145.85 +146.16 +146.26 +145.94 +145.92 +146 +145.26 +145.08 +144.95 +146.2 +148 +100 +254.23 +252 +106.44 +110.08 +109.13 +109 +110 +121 +121.91 +121 +121.79 +134 +133.8 +144.47 +144.93 +166.49 +155.68 +133.26 +134.22 +134.1 +134.28 +136.14 +131.83 +137.75 +175.57 +125.79 +171.85 +221.51 +107.74 +163.79 +79.593 +9.0437 +9 +9 +9.3263 +9.0893 +8.9942 +8.769 +8.7111 +8.7443 +8.7435 +8.749 +8.7224 +8.6753 +8.7041 +8.6908 +8.6883 +8.7056 +8.6723 +8.6152 +8.5308 +8.5062 +8.5531 +8.5659 +8.5491 +8.5065 +8.4554 +8.454 +8.449 +8.4391 +8.4569 +8.3891 +8.3268 +8.2636 +8.194 +8.1508 +8.1377 +8.1441 +8.1425 +8.1021 +8.0865 +8.0779 +8.0871 +8.0728 +7.9885 +7.9775 +7.9889 +7.9607 +7.9676 +7.9357 +7.9446 +7.9022 +7.8812 +7.884 +7.7227 +7.6775 +7.751 +7.7287 +7.6922 +7.7135 +7.6253 +7.755 +6.8506 +6.95 +7.3011 +7.5155 +7.3424 +7.3984 +7.724 +85.819 +86.038 +86.309 +86.167 +86.265 +87.444 +89.953 +89.737 +70.668 +70.844 +41.376 +41.657 +41.448 +41.581 +41.374 +41.303 +41.391 +41.28 +41.231 +41.216 +41.283 +90.108 +90.115 +90.204 +43.55 +43.77 +43.739 +43.699 +40.843 +35 +35 +75 +34 +40.215 +74.724 +99 +72.54 +76 +62.831 +52.067 +52.087 +53.433 +55 +56.087 +56.331 +56.373 +56.349 +56.142 +56.125 +56.171 +56.143 +56.132 +56.113 +56.066 +55.978 +55.962 +55.945 +56.024 +55.981 +55.938 +55.872 +55.782 +55.738 +55.716 +55.744 +55.705 +55.627 +55.655 +55.653 +55.667 +55.688 +55.771 +55.803 +55.839 +55.838 +55.891 +55.918 +55.931 +56.008 +56.006 +55.954 +56.136 +56.896 +57 +58.415 +62 +64.327 +60.385 +59.427 +60 +55.372 +56 +54 +54.964 +55.009 +54.923 +54.794 +54.54 +54.384 +54.361 +54.386 +54.306 +54.113 +53.818 +53.762 +53.708 +53.656 +53.614 +53.43 +53.37 +53.199 +53.096 +52.948 +52.744 +52.644 +52.471 +52.389 +52.265 +52.111 +52.047 +52.039 +51.951 +51.876 +51.864 +51.81 +51.798 +51.861 +51.872 +51.91 +51.972 +52.085 +52.153 +52.258 +52.308 +52.374 +52.616 +52.666 +52.777 +53.153 +53.308 +53.745 +54.247 +54.745 +55.795 +56.208 +57.622 +57.116 +55.709 +54.658 +54.14 +53.684 +52 +51.68 +51.81 +51.976 +52.005 +51.849 +51.718 +51.709 +51.512 +51.401 +51.345 +51.279 +45.329 +51.171 +51.199 +51.182 +51.167 +51.185 +51.319 +51.116 +50.463 +51 +51.289 +51 +51 +51 +52.178 +52.143 +51.626 +50.971 +72.996 +46.374 +41.076 +71.998 +53.785 +59.264 +71.878 +59.194 +59.22 +71.924 +71.966 +71.959 +71.96 +71.968 +71.963 +71.95 +71.943 +71.939 +71.962 +71.949 +72.004 +87.733 +87.747 +87.586 +87.553 +87.613 +87.789 +53.08 +53.098 +53.044 +53.089 +53.112 +53.038 +52.925 +52.668 +52.433 +52.244 +51.936 +51.72 +51.516 +51.35 +51.295 +51.141 +51.019 +51 +50.875 +50.765 +50.653 +50.571 +50.52 +50.483 +50.433 +50.366 +50.359 +50.356 +50.375 +50.41 +50.431 +50.459 +50.57 +50.73 +50.768 +51.046 +51.404 +51.561 +51.75 +51.625 +51.539 +51.385 +51.349 +51.368 +51.32 +51.294 +51.309 +51.322 +51.313 +51.311 +51.294 +51.318 +51.307 +51.274 +51.278 +51.292 +51.257 +51.242 +51.182 +51.158 +51.042 +50.908 +50.774 +50.617 +50.388 +50.148 +49.942 +49.641 +49.362 +49.128 +48.765 +48.442 +48.122 +47.781 +47.43 +46.957 +46.472 +45.336 +44.693 +43.991 +43.484 +43.037 +42.599 +42.306 +41.88 +41.538 +41.188 +40.723 +40.411 +40.078 +39.68 +39.329 +38.988 +38.691 +38.381 +37.995 +37.599 +37.274 +36.911 +36.567 +36.277 +35.996 +35.76 +35.516 +35.258 +34.986 +34.735 +34.461 +34.241 +34.052 +33.84 +33.604 +33.397 +33.216 +33.022 +32.821 +32.617 +32.427 +32.234 +31.993 +31.752 +31.535 +31.343 +31.129 +30.858 +30.592 +30.379 +30.292 +30.242 +30.161 +30.099 +30.111 +30.132 +30.054 +29.917 +29.686 +29.618 +29.62 +29.349 +29.155 +29.425 +29.583 +29.685 +29.644 +29.801 +30.233 +30.602 +30.839 +31.35 +31.492 +31.909 +31.782 +31.641 +31.567 +31.558 +31.835 +31.723 +31.698 +31.728 +31.64 +31.525 +31.396 +31.158 +30.754 +30.949 +31.325 +31.437 +31.399 +31 +28.714 +22.432 +21.881 +21.844 +21.924 +21.883 +84.298 +84.315 +84.206 +84.131 +84.123 +31.877 +84.103 +31.877 +31.907 +48.127 +48.122 +48.398 +48.967 +49.382 +50.87 +51.193 +51.802 +52.027 +52.721 +53.226 +53.371 +54 +54.179 +54.599 +54.798 +55.09 +55.34 +55.787 +56.225 +56.493 +57.052 +57.36 +57.554 +57.825 +57.917 +58.047 +58.27 +58.39 +58.56 +58.635 +58.837 +58.903 +59.104 +59.186 +59.337 +59.522 +59.649 +59.467 +59.408 +59.363 +59.485 +59.424 +59.356 +59.292 +59.314 +59.4 +59.431 +59.572 +59.883 +60.161 +60.384 +60.663 +59.397 +58.178 +58.26 +58.885 +58.404 +56.901 +56.366 +55.866 +56.755 +57.296 +57.922 +59.011 +59.152 +59.442 +59.704 +59.691 +59.454 +59.304 +58.865 +58.789 +58.496 +58.38 +58.243 +58.218 +34.551 +44.558 +35 +35 +66.918 +68.969 +69.891 +70.179 +70.497 +70.413 +70.667 +70.792 +71.325 +71.656 +71.876 +72.354 +72 +72.997 +73.135 +73.653 +74.225 +74.766 +75.398 +75.427 +75.812 +76.345 +76.812 +77.558 +77.821 +78.104 +78.136 +78.264 +78.449 +78.584 +78.694 +78.738 +78.874 +78.929 +78.974 +78.884 +78.892 +78.816 +78.629 +78.514 +78.133 +78.068 +77.478 +77.393 +77.173 +76.631 +76.425 +75.853 +75.755 +75.276 +74.991 +74.691 +74.268 +74.161 +73.772 +73.544 +73.216 +72.922 +72.702 +72.353 +72.146 +71.913 +71.592 +71.395 +71.115 +71.001 +70.664 +70.563 +70.382 +70.146 +70.005 +69.664 +69.565 +69.505 +69.412 +69.279 +69.234 +69.647 +69.977 +70 +72.218 +72 +79.958 +78.075 +76 +79 +76.007 +74.353 +73.895 +73.981 +73.388 +74.002 +73.382 +73.781 +74.038 +74.036 +73.772 +73.497 +73.274 +72.921 +71.65 +71.902 +71.826 +67.055 +78.803 +110.2 +111.39 +110.89 +106.75 +106.9 +106.91 +106.47 +73.713 +73.174 +54.89 +56 +60.459 +59.215 +71 +72.447 +73.801 +74.733 +75.4 +76.126 +76.408 +77.008 +77.666 +78.01 +78.423 +78.605 +78.799 +79.241 +79.514 +79.809 +79.928 +80.452 +80.97 +81.447 +82.059 +82.739 +83.211 +83.582 +83.79 +83.945 +84.269 +84.474 +84.644 +84.919 +85.087 +85.287 +85.525 +85.754 +86.02 +86.366 +86.566 +86.837 +87.309 +87.58 +88.089 +88.355 +88.603 +89.276 +89.497 +89.843 +90.452 +90.902 +91.275 +91.407 +91.489 +91.995 +92.288 +92.664 +93.017 +93.617 +94.362 +94.767 +95.503 +96.214 +96.429 +97.671 +98.363 +98 +101.9 +103.85 +103.93 +104.06 +104.19 +104.16 +104.12 +103.96 +104.05 +96.134 +88.095 +88.133 +88.096 +95.224 +95.026 +124.28 +116.51 +123.95 +115.22 +95.199 +95.081 +95.013 +94.892 +94.859 +94.787 +94.743 +7 +7 +7 +7 +7.7998 +7.7734 +7.7637 +7.7692 +7 +7 +7.4798 +7.3919 +7.3718 +7.3544 +7.3568 +7.3521 +7.3114 +7.3161 +7.2068 +8.942 +8.9544 +9.0158 +9.0591 +9.0717 +9.0714 +9.0153 +8.9975 +9.0006 +8.989 +8.9105 +7.1173 +6.9846 +6.9979 +6.8948 +7.0293 +7.0963 +7.1386 +7.1252 +7.1951 +7.2144 +84.395 +83.561 +82.38 +89.161 +89.212 +89.295 +89.286 +44.884 +99.123 +38 +60.071 +67.756 +98.561 +38 +75.498 +54 +54 +61.091 +60.794 +62.986 +63.074 +63.312 +63.295 +63.813 +63.876 +63.876 +63.87 +64.012 +64.041 +63.914 +63.881 +63.863 +63.899 +63.699 +63.672 +63.609 +63.531 +63.309 +63.221 +63.035 +62.795 +62.583 +62.382 +62.174 +61.896 +61.753 +61.568 +61.444 +61.139 +61.037 +60.934 +60.858 +60.541 +60.388 +60.192 +60.073 +59.788 +59.543 +59.178 +58.959 +58.617 +58.284 +57.456 +57.031 +56.398 +55.541 +55.118 +53.918 +53.737 +52.908 +52.542 +52.222 +51.919 +51.647 +51.406 +51.321 +51.125 +51.006 +50.862 +50.539 +50.427 +50.255 +50.073 +50.024 +49.807 +49.616 +49.482 +49.38 +49.281 +49.159 +48.883 +48.741 +48.585 +48.428 +48.303 +48.124 +48.061 +47.974 +47.89 +47.932 +47.894 +47.835 +47.933 +47.926 +47.849 +47.978 +48.048 +48.082 +48.242 +48.341 +48.447 +48.634 +48.81 +49.038 +49.246 +49.426 +49.558 +49.646 +49.714 +49.737 +49.853 +49.898 +49.945 +50.083 +50.142 +50.223 +50.389 +50.546 +50.754 +50.943 +51.123 +51.316 +51.469 +51.699 +51.912 +52.15 +52.45 +52.695 +52.989 +53.17 +53.398 +53.576 +53.888 +54.007 +54.18 +54.425 +54.629 +54.928 +55.167 +55.577 +55.805 +56.1 +56.344 +56.607 +56.877 +57.183 +57.439 +57.762 +58.086 +58.439 +58.87 +59.183 +59.674 +59.977 +60.545 +60.845 +61.467 +61.69 +62.216 +62.437 +62.882 +63.133 +63.468 +63.673 +63.987 +64.204 +64.485 +64.729 +64.974 +65.298 +65.445 +65.81 +65.932 +66.281 +66.422 +66.87 +67.049 +67.561 +67.759 +68.24 +68.469 +68.617 +68.668 +68.633 +68.313 +68.107 +67.585 +67.356 +66.812 +66.733 +66.326 +66.261 +65.945 +65.876 +65.695 +65.629 +65.468 +65.433 +65.327 +65.326 +65.195 +65.161 +65.018 +64.886 +64.749 +64.631 +64.432 +64.207 +63.946 +63.617 +63.439 +63.118 +63.153 +62.844 +62.798 +62.489 +62.396 +62.024 +61.739 +61.412 +61.342 +61.169 +61.093 +60.971 +60.909 +60.884 +60.865 +60.823 +60.721 +60.5 +60.405 +60.244 +60.192 +60.117 +60.151 +60.209 +60.213 +60.125 +60.089 +60.068 +60.054 +60.049 +60.068 +60.068 +60.057 +60.058 +60.051 +60.052 +60.08 +60.088 +60.099 +60.11 +60.127 +60.15 +60.205 +60.213 +60.22 +60.234 +60.259 +60.278 +60.296 +60.296 +60.293 +60.311 +60.323 +60.362 +60.385 +60.415 +60.437 +60.501 +60.531 +60.557 +60.587 +60.616 +60.664 +60.693 +60.738 +60.762 +60.818 +60.853 +60.883 +60.924 +60.966 +60.98 +61.046 +61.102 +61.156 +61.204 +61.32 +61.405 +61.546 +61.657 +61.811 +61.916 +62.047 +62.192 +62.35 +62.549 +62.743 +62.973 +63.291 +63.685 +64.005 +64.645 +65.066 +65.841 +66.362 +67.425 +67.726 +68.558 +68.956 +69.64 +69.89 +70.009 +70.194 +70.178 +70.265 +70.313 +70.352 +70.461 +71.564 +71.653 +72.238 +72.402 +73.222 +74.88 +75.063 +75.175 +75.05 +75.009 +75.273 +75.46 +75.299 +75.234 +75.312 +75.581 +75.456 +75.468 +75.297 +67.595 +67.296 +75.47 +75.373 +75.174 +72.723 +72.669 +66.889 +66.825 +66.456 +57.113 +48.078 +58.874 +48.611 +48.958 +60.254 +69.002 +69.189 +73.105 +75 +78.075 +79.748 +80.062 +80.81 +81.838 +82.16 +82.934 +83.791 +84.041 +84.885 +85 +85 +86.365 +86 +87.014 +87.974 +89 +90.064 +92.351 +93.308 +94.195 +95.903 +96.722 +97.927 +100.16 +101.05 +103.65 +105 +106.36 +107.65 +108.56 +108.86 +109.16 +109.92 +110.2 +110.55 +111.94 +112.66 +112.95 +113.24 +114.34 +115.02 +115.43 +117.63 +118.13 +118.24 +118 +121.47 +121 +121.28 +121.32 +121.11 +120 +119.14 +116.1 +112 +112.1 +110.37 +105.97 +104.35 +104.03 +102.85 +101.29 +100.79 +100.41 +99.926 +99.216 +98.507 +98.393 +98.152 +97.563 +97.475 +96.734 +95.272 +94.848 +94.285 +93.911 +94.007 +93.92 +94.585 +94.621 +95.499 +97.186 +97.292 +98.815 +101 +102.13 +102.94 +102.15 +102.08 +102.21 +100.35 +99.84 +99.639 +99.036 +98.901 +98.776 +98.422 +98.09 +97.958 +97.96 +97.86 +97.655 +97.719 +97.757 +97.51 +97.553 +97.701 +98.018 +98.174 +98.38 +98.663 +98.905 +99.14 +99.674 +100.29 +100.49 +100.93 +101.53 +101.69 +102.12 +102.55 +102.69 +102.68 +102.5 +101.92 +100.94 +100.31 +99.051 +97.725 +96.951 +95.984 +95.347 +94.441 +92.83 +92.24 +90.867 +89.551 +89.371 +88.3 +86.904 +86.268 +84.559 +83.787 +82.908 +81.408 +80.424 +79.3 +78.576 +77.386 +77.079 +76.255 +75.453 +74.94 +74.051 +73.726 +73.054 +72.655 +72.151 +71.817 +71.513 +71.196 +70.957 +70.644 +70.388 +70.205 +69.945 +69.756 +69.575 +69.292 +69.182 +68.926 +68.855 +68.67 +68.55 +68.413 +68.294 +68.227 +68.119 +68.089 +68.003 +68.001 +67.951 +67.937 +67.983 +68.05 +68.17 +68.235 +68.362 +68.424 +68.54 +68.69 +68.78 +69.011 +69.089 +69.296 +69.365 +69.626 +69.704 +69.974 +70.111 +70.273 +70.385 +70 +70.797 +71.114 +72.056 +72 +80 +80.219 +88.039 +89.375 +86.292 +84 +84.321 +84.376 +86 +80.085 +72.262 +71 +70.301 +69.817 +70.261 +70.386 +69.799 +69.362 +69.185 +69 +69.926 +69 +69.822 +70.115 +70.427 +144.6 +72.092 +63.036 +68 +67.435 +145.15 +120.41 +78.56 +84.224 +67.121 +79.281 +81 +83 +83.981 +84.242 +85 +86.129 +86.16 +86 +86.803 +86 +86 +87.323 +87.21 +87 +87 +88.31 +89 +89 +90.316 +91 +91 +93 +95.305 +95.461 +98 +101 +101.96 +101 +101 +100 +100.13 +98 +99.492 +88 +107.99 +106.43 +109 +109 +109 +109.76 +110.68 +111.14 +111.09 +111 +111.74 +111 +113 +113 +112.43 +112.44 +113 +117 +118.36 +118.34 +118 +117.85 +117.8 +118.12 +117 +118.4 +117.96 +139.98 +140.31 +78.494 +78.657 +77.864 +77 +75.382 +77.388 +78.372 +77.748 +76.431 +77.299 +245.57 +245.94 +245.8 +245.62 +245.66 +245.37 +245.16 +245.16 +245.48 +244.35 +128.13 +104 +128 +245.34 +245.14 +245.81 +244.24 +246.1 +373.23 +373.98 +491.72 +491.7 +374.47 +373.59 +512.44 +368.38 +368.7 +368.14 +368.25 +509.82 +510.6 +510.35 +511.27 +511.17 +511.22 +510.69 +509.96 +509.93 +391.55 +392.36 +392.68 +392.88 +392.48 +392.82 +393.36 +394.44 +394.04 +396.62 +503 +502.34 +502.95 +503.53 +503.64 +503.85 +413.48 +252.38 +321.66 +231.35 +231.06 +251.84 +251.77 +342.67 +342.91 +433.17 +181.76 +181.63 +181.55 +181.28 +245.89 +245.82 +245.98 +246.1 +245.82 +247.13 +247.24 +182.73 +183.32 +225.93 +189.29 +234.19 +230.06 +231.44 +252.72 +249.96 +234.23 +252.89 +239.78 +250.94 +251.81 +226.05 +252.22 +253.09 +266.92 +266.02 +268.04 +268.04 +268.06 +268 +266.46 +267.41 +266 +267 +269.34 +272.91 +273.31 +272.28 +269 +270.17 +269.12 +240.53 +176.5 +292.68 +235 +182.71 +262.84 +263.04 +263.3 +269.27 +350 +379.19 +476 +370.99 +371.09 +470.05 +435.43 +371.04 +29.439 +29.44 +29.442 +29.44 +29.447 +28.834 +28.771 +35.575 +28.942 +35.58 +35.465 +35.404 +35 +35.155 +34.993 +33 +34.131 +29.282 +29.011 +28.647 +30 +30 +29.611 +27.8 +31.778 +35 +35 +35 +32.195 +40.223 +43.976 +42.484 +36.114 +179.83 +147.53 +196 +179.74 +147.66 +148 +200 +285.65 +148 +37.939 +37.787 +44.487 +44.556 +44.291 +44.043 +44.135 +209.9 +200.19 +198.41 +198.28 +198.01 +180.5 +526 +526 +526 +192.5 +176 +203.34 +265.29 +271.13 +295.87 +293 +293.12 +293.08 +295.39 +295.18 +499.89 +301.03 +276.96 +278.76 +302.96 +194.77 +194.44 +195.28 +187.56 +184.87 +188.08 +187.15 +186.86 +186.92 +186.89 +186.89 +188.83 +186.96 +186.56 +186.31 +186.35 +5 +5 +5.1718 +4.93 +4.9691 +5.005 +5.0969 +5.1969 +5.1914 +5.1608 +5.1297 +5.1171 +5.111 +5.091 +4.9676 +4.9436 +4.9275 +4.9361 +4.9281 +4.906 +4.9458 +4.9512 +4.9757 +4.9584 +4.928 +4.8966 +4.927 +4.9267 +4.903 +4.9026 +4.9147 +4.9631 +4.9697 +4.9726 +4.9652 +4.9732 +4.989 +4.9718 +4.9697 +4.9398 +4.9351 +4.9385 +4.9665 +4.9739 +4.9708 +4.9886 +4.996 +4.9866 +4.9765 +4.9855 +4.994 +4.9949 +32.433 +57.167 +57.086 +32.823 +32.827 +32.83 +32.875 +32.83 +32.845 +32.777 +32.821 +32.788 +32.863 +47.502 +42.881 +42.733 +42.695 +42.823 +43.118 +43.275 +43.391 +43.329 +43.235 +43.104 +42.976 +42.894 +42.733 +42.594 +42.421 +42.331 +42.177 +42.02 +41.88 +41.657 +41.484 +41.2 +40.902 +40.535 +40.135 +39.614 +39.152 +38.759 +38.417 +38.088 +37.851 +37.663 +37.564 +37.441 +37.336 +37.263 +37.169 +37.09 +36.979 +36.83 +36.728 +36.667 +36.617 +36.597 +36.572 +36.557 +36.568 +36.571 +36.507 +36.123 +35.153 +33.966 +32.429 +31.733 +31.584 +31.393 +31.194 +31.086 +31.126 +31.139 +30.953 +30.72 +30.618 +30.615 +30.593 +30.468 +30.309 +30.181 +30.152 +30.18 +30.067 +29.804 +29.736 +29.873 +29.883 +29.609 +29.44 +29.552 +29.497 +29.202 +29.106 +29.272 +29.267 +29.108 +29.165 +29.319 +29.26 +29.149 +29.23 +29.343 +29.265 +29.171 +29.225 +29.271 +29.323 +29.374 +29.452 +29.499 +29.276 +29.4 +29.676 +29.43 +29.133 +29.321 +29.411 +29.211 +28.927 +29.905 +31.181 +32.019 +33 +34 +35 +35.782 +37 +36.246 +34.171 +35.72 +35.913 +32.375 +33.937 +34 +34 +35.032 +34.404 +34.694 +34 +34 +35.368 +35.005 +32.861 +29.108 +28.98 +29.438 +30.339 +30.636 +30.541 +30.233 +29.93 +29.812 +29.855 +29.925 +29.983 +30.053 +30.141 +30.236 +30.324 +30.4 +30.466 +30.526 +30.579 +30.626 +30.655 +30.696 +30.761 +30.838 +30.905 +30.952 +30.996 +31.048 +31.101 +31.153 +31.196 +31.229 +31.252 +31.273 +31.291 +31.303 +31.308 +31.315 +31.32 +31.329 +31.343 +31.362 +31.4 +31.441 +31.488 +31.537 +31.587 +31.649 +31.723 +31.821 +31.922 +32.02 +32.121 +32.23 +32.351 +32.456 +32.559 +32.661 +32.754 +32.849 +32.964 +33.083 +33.182 +33.285 +33.362 +33.433 +33.498 +33.541 +33.56 +33.59 +33.625 +33.642 +33.684 +33.798 +34.009 +34.378 +34.591 +34.257 +33.609 +33.508 +33.091 +32.691 +32.488 +32.331 +32.269 +32.196 +32.074 +32.038 +31.972 +31.995 +31.972 +31.881 +31.936 +32.041 +32.07 +32.228 +32.577 +32.985 +33.465 +33.386 +34.037 +36.011 +36.202 +36.198 +36.001 +35.365 +34.871 +34.873 +35.02 +35.085 +34.994 +34.905 +35.002 +35.105 +35.144 +35.14 +35.149 +35.228 +35.302 +35.357 +35.409 +35.475 +35.62 +35.787 +35.924 +36.035 +36.153 +36.344 +36.596 +36.753 +36.886 +37.034 +37.196 +37.4 +37.545 +37.668 +37.776 +37.902 +38.033 +38.139 +38.26 +38.438 +38.652 +38.83 +39.033 +39.178 +39.334 +39.626 +40.308 +40.968 +41.713 +43.082 +43.846 +44.314 +44.322 +44.459 +39.833 +38.959 +38.788 +38.845 +38.685 +38.451 +38.734 +38.919 +38.996 +38.86 +38.737 +38.711 +39.025 +39.11 +39.028 +39.034 +39.095 +38.082 +37 +37.106 +36.755 +37.021 +39.472 +36.811 +37.149 +37.262 +37.495 +36.761 +37.488 +30.45 +30.71 +39.561 +40.623 +38.366 +37.876 +38 +39.065 +39.769 +40.267 +34.104 +40.599 +40.611 +35.958 +33 +33.948 +34.004 +33.994 +34.069 +34.168 +33.906 +33.817 +33.295 +40.93 +39 +39 +40.379 +40.636 +41.036 +41.394 +41.683 +41.946 +42.156 +42.347 +42.48 +42.655 +42.776 +42.942 +43.031 +43.178 +43.329 +43.427 +43.72 +43.966 +44.31 +44.621 +44.856 +45.051 +45.188 +45.337 +45.532 +45.639 +45.81 +45.963 +46.119 +46.264 +46.424 +46.575 +46.742 +46.936 +47.107 +47.316 +47.482 +47.679 +47.849 +47.951 +48.131 +48.201 +48.227 +48.3 +48.384 +48.368 +48.361 +48.313 +48.274 +48.157 +48.033 +47.907 +47.807 +47.683 +47.53 +47.419 +47.229 +47.023 +46.868 +46.669 +46.434 +46.216 +46.082 +45.905 +45.671 +45.511 +45.361 +45.18 +45.014 +44.937 +44.8 +44.676 +44.618 +44.524 +44.438 +44.378 +44.322 +44.265 +44.233 +44.219 +44.188 +44.202 +44.243 +44.269 +44.331 +44.409 +44.476 +44.547 +44.643 +44.749 +44.826 +44.957 +45.092 +45.16 +45.267 +45.366 +45.464 +45.55 +45.689 +45.801 +45.883 +45.997 +46.115 +46.244 +46.299 +46.392 +46.457 +46.482 +46.428 +46.322 +46.262 +46.161 +45.875 +45.867 +45.65 +45.332 +45.33 +45.247 +45.133 +45.049 +44.979 +44.982 +44.928 +44.923 +44.89 +44.895 +44.891 +44.887 +44.91 +44.93 +44.946 +44.961 +44.985 +45.021 +45.062 +45.1 +45.162 +45.229 +45.276 +45.345 +45.405 +45.502 +45.552 +45.665 +45.779 +45.845 +45.952 +46.088 +46.2 +46.31 +46.464 +46.593 +46.722 +46.894 +47.047 +47.212 +47.431 +47.465 +47.596 +47.765 +47.957 +48.233 +48.445 +48.739 +48.946 +49.166 +49.519 +49.772 +49.994 +50.246 +50.595 +50.927 +51.231 +51.687 +52.058 +52.539 +52.913 +53.126 +53.621 +53.817 +53.958 +54.093 +54.277 +54.495 +54.681 +54.919 +55.052 +55.266 +55.497 +55.803 +56.018 +56.276 +56.547 +56.764 +57.054 +57.14 +57.342 +57.533 +57.678 +57.833 +58.014 +58.14 +58.257 +58.379 +58.471 +58.572 +58.627 +58.757 +58.82 +58.965 +59.047 +59.23 +59.333 +59.471 +59.642 +59.758 +60.019 +60.115 +60.395 +60.471 +60.775 +60.827 +61.118 +61.173 +61.448 +61.513 +61.804 +61.873 +62.15 +62.239 +62.553 +62.708 +63.017 +63.249 +63.441 +63.774 +63.912 +64.358 +64.524 +64.998 +65.161 +65.725 +65.907 +66.489 +66.741 +67.709 +68.052 +69.267 +69.629 +70.516 +70.783 +71.463 +71.932 +72.139 +73.202 +73 +76.027 +76 +78.179 +78 +77.869 +76.468 +76.023 +76 +76.824 +84.859 +84.254 +76.087 +75.93 +76.128 +76.368 +76.187 +122.31 +122.15 +122.14 +121.81 +121.22 +121.11 +121.03 +120.91 +120.84 +7.3108 +7.2776 +7.2794 +7.3193 +7.3561 +125.74 +126.04 +126.07 +126.29 +126.16 +126.31 +126.2 +126.02 +126.01 +126.03 +80.968 +80.868 +127.08 +127.17 +81.03 +81.198 +80.657 +80.849 +80.978 +81.15 +81.482 +81.334 +80.996 +80.772 +83.622 +81.952 +81.924 +82.335 +82.936 +83.415 +83.595 +84.263 +84.389 +84.756 +85.252 +84.983 +85.526 +86.13 +86.372 +43.811 +83.827 +83.811 +32.868 +32.819 +49 +47 +48.338 +51.261 +53.159 +53.684 +53.786 +54.419 +54.53 +54.72 +54.831 +55.099 +55.312 +55.472 +55.645 +55.734 +55.854 +55.937 +56.031 +56.205 +56.326 +56.594 +56.956 +57.267 +57.541 +57.775 +58.235 +58.467 +58.776 +58.944 +59.38 +59.756 +60.175 +60.714 +60.901 +60.83 +60.767 +60.521 +60.421 +60.159 +60.072 +59.995 +59.716 +59.562 +59.305 +59.162 +58.908 +58.778 +58.388 +58.192 +57.881 +57.668 +57.49 +57.304 +57.142 +56.991 +56.77 +56.674 +56.523 +56.322 +56.229 +56.015 +55.867 +55.727 +55.626 +55.464 +55.442 +55.399 +55.461 +55.481 +55.551 +55.55 +55.659 +56.057 +54 +53.734 +53.344 +53.826 +54.234 +55.246 +56.363 +56.777 +56.836 +46.696 +53.125 +61.034 +69.124 +69.193 +38.591 +7.9291 +7.9379 +7.9441 +7.9565 +8.0067 +8.0089 +8.0085 +8.0083 +8.0116 +8.0123 +8.0127 +8.0156 +8.0446 +8.0762 +8.0942 +8.3648 +8.3896 +8.4719 +8.6116 +8.6211 +8.5204 +8.7989 +8.8552 +8.8728 +8.8858 +8.8113 +8.8412 +8.846 +8.7732 +8.4579 +8 +8.4501 +8.4063 +8.3586 +8.248 +8.3307 +7.8568 +7.6921 +7.5549 +7.4383 +7.4745 +7.439 +7.4584 +7.2708 +7.2423 +7.0511 +6.7911 +6.6554 +7 +7 +5 +5 +83 +84.435 +54.042 +90.25 +86.016 +92.254 +133.38 +135.25 +50 +39 +38.811 +38 +38 +38 +38 +97.761 +97.665 +107 +100.51 +50.542 +79 +66 +61.001 +51.103 +59.457 +62.63 +62.593 +65.347 +65.398 +66.443 +66.585 +67.271 +67.439 +67 +67.76 +67.852 +68.064 +68.197 +68.478 +68 +69.335 +69 +70.493 +70.717 +71.847 +72.02 +72.5 +72.803 +73.474 +73.536 +73.103 +72.998 +73.314 +73.186 +72.994 +73.004 +73.011 +73.294 +73.053 +73.045 +73.044 +73.369 +73.443 +73.448 +73.471 +73.501 +73.691 +73.795 +73.821 +73.764 +73.828 +73.948 +73.975 +74.095 +74.147 +74.233 +74.329 +74.338 +74.288 +74.341 +74.603 +74.653 +74.697 +74.721 +74.815 +74.971 +75.007 +75.017 +74.999 +75.133 +75.193 +75.234 +75.278 +75.336 +75.49 +75.444 +75.397 +75.377 +75.368 +75.433 +75.444 +75.458 +75.501 +75.645 +75.794 +75.87 +75.886 +75.935 +75.934 +75.97 +76.017 +76.035 +76.205 +76.331 +76.416 +76.726 +76.87 +77.239 +77.634 +77.701 +77.581 +77.496 +77.543 +77.606 +77.704 +77.791 +77.893 +78.117 +78.288 +78.584 +78.796 +78.915 +79.1 +79.211 +79.363 +79.477 +79.59 +79.533 +79.276 +78.996 +79 +78.896 +79.277 +79.424 +79.404 +79.611 +79.659 +80.001 +80.299 +80.292 +80.576 +80.659 +80.882 +81.133 +81.341 +81.658 +82.021 +82.305 +82.697 +83.239 +83.483 +83.841 +84.126 +84.39 +84.44 +84.538 +84.788 +84.863 +85.011 +84.772 +84.531 +84.47 +84.509 +84.617 +84.548 +84.303 +84.051 +84.123 +84.279 +84.262 +84.154 +84.061 +84.295 +84.375 +84.427 +84.401 +84.482 +84.541 +84.502 +84.516 +84.46 +84.488 +84.441 +84.439 +84.396 +84.191 +84.287 +84.247 +84.302 +84.174 +84.112 +84.071 +83.939 +83.958 +83.856 +84.041 +84.206 +84.169 +84.135 +84.136 +84.296 +84.476 +84.661 +84.556 +84.48 +84.563 +84.724 +84.932 +84.893 +84.898 +84.983 +85.319 +85.356 +85.109 +85.238 +85.56 +85.93 +85.89 +86.08 +85 +86.208 +86.814 +86.902 +86 +86.043 +86.153 +86 +87.245 +87.607 +87.341 +87 +87 +88 +88.494 +87.344 +86 +86 +87.135 +86.921 +86.853 +86.622 +86.796 +86.891 +87.008 +86.737 +86.285 +86.312 +86.163 +86.514 +86.301 +86.413 +86.128 +86.253 +86.182 +86.01 +85.943 +85.772 +85.684 +85.436 +85.116 +85.236 +85.472 +85.618 +85.486 +85.417 +85.648 +85.596 +85.366 +85.361 +85.338 +85.553 +85.55 +85.649 +85.74 +85.817 +85.786 +85.761 +85.674 +85.72 +85.873 +85.999 +86.159 +86.283 +86.377 +86.53 +86.406 +86.472 +86.562 +86.839 +86.807 +86.74 +86.7 +86.691 +86.744 +86.748 +86.717 +86.823 +86.794 +86.468 +86.267 +86.103 +86.051 +86.067 +85.717 +85.199 +84.81 +84.724 +84.502 +84.374 +84.227 +83.806 +83.591 +83.185 +82.596 +82.361 +81.65 +81.245 +80.761 +80.464 +80.315 +79.713 +79.499 +79.13 +78.607 +78.37 +78.049 +77.998 +77.721 +77.328 +76.966 +76.7 +76.501 +76.239 +76.006 +75.693 +75.362 +75.128 +74.862 +74.659 +74.394 +74.157 +73.831 +73.746 +73.534 +73.339 +73.22 +73.234 +73.106 +72.941 +73.01 +73.031 +73.063 +73.01 +72.978 +72.735 +72.981 +72.407 +71.786 +72.026 +71.821 +72 +72.424 +76.203 +76 +83 +84.277 +87 +101.12 +44 +52.112 +44.389 +87.631 +129.59 +127.64 +44 +96.107 +96.222 +95.695 +95.804 +96.539 +97.01 +97.163 +72.209 +39 +42.427 +63.439 +64.446 +63.911 +64.115 +64.024 +64.133 +64.382 +64.836 +64 +64.441 +64.689 +65.154 +65.142 +65.05 +64.942 +64.924 +64.904 +64.996 +64.917 +64.958 +65.24 +65.339 +65.324 +65.105 +64.694 +65.043 +65.431 +65.175 +63.331 +63.402 +63.211 +62.851 +62.536 +61.958 +59.028 +58.929 +58.09 +55.442 +55.83 +55.316 +55.836 +83.324 +83.172 +108.43 +55.653 +55.493 +55.614 +55.74 +101.71 +55.348 +90.924 +56.292 +56.474 +34.12 +170.71 +114.12 +114.05 +114.68 +113.74 +89.033 +88.819 +319 +308.52 +534 +534 +532.57 +458 +441 +214.73 +153.11 +153 +213.32 +275.15 +345.4 +409.49 +457.39 +217.39 +217 +458.42 +447 +400.93 +270.18 +107 +107 +77.851 +71 +36 +57 +38.704 +38.599 +72.947 +72.875 +68.158 +67.918 +64.323 +64 +63.332 +63.27 +60.438 +60.188 +59.847 +59.61 +59.412 +59.347 +59.344 +59.288 +59.261 +59.27 +59.194 +59.208 +59.177 +59.245 +59.278 +59.6 +59.715 +60.004 +60.168 +60.539 +60.826 +61.167 +61.4 +61.734 +61.974 +62.196 +62.432 +62.602 +62.84 +62.97 +63.208 +63.321 +63.524 +63.647 +63.778 +63.918 +63.995 +64.072 +64.134 +64.17 +64.182 +64.227 +64.29 +64.341 +64.395 +64.381 +64.364 +64.274 +64.241 +64.132 +64.045 +63.904 +63.833 +63.767 +63.626 +63.524 +63.267 +63.14 +62.9 +62.811 +62.544 +62.435 +62.191 +62.104 +61.925 +61.854 +61.732 +61.66 +61.54 +61.449 +61.377 +61.334 +61.309 +61.276 +61.278 +61.216 +61.205 +61.175 +61.179 +61.162 +61.171 +61.179 +61.192 +61.232 +61.299 +61.639 +61.758 +62.099 +62.085 +62.385 +62.264 +61.889 +62.236 +61.133 +61.686 +59.914 +59.8 +59.858 +59.737 +60.074 +60.406 +60.808 +61.017 +61.057 +61.186 +61.159 +61.156 +61.224 +61.366 +61.388 +61.296 +61.299 +61.418 +61.524 +61.586 +61.531 +61.576 +61.613 +61.579 +61.461 +61.433 +61.338 +61.332 +61.472 +61.392 +61.024 +60.17 +59.01 +58.285 +51 +51 +52 +53.268 +53 +53.852 +53.861 +53.934 +53.938 +53.927 +53.934 +54.001 +54.039 +54.106 +54.13 +54.166 +54.24 +54.294 +54.427 +54.428 +54.441 +54.483 +54.442 +54.491 +54.509 +54.545 +54.569 +54.612 +54.623 +54.603 +54.569 +54.516 +54.491 +54.355 +54.282 +54.15 +53.968 +53.855 +53.59 +53.335 +53.06 +52.652 +52.28 +51.904 +51.447 +50.906 +50.389 +49.79 +49.18 +48.7 +48.189 +47.546 +47.184 +46.696 +46.371 +46.095 +45.75 +45.598 +45.319 +45.144 +44.931 +44.777 +44.584 +44.393 +44.189 +44.01 +43.834 +43.679 +43.497 +43.364 +43.172 +43.059 +42.881 +42.751 +42.589 +42.424 +42.289 +42.089 +41.934 +41.699 +41.505 +41.3 +41.069 +40.818 +40.592 +40.35 +40.149 +39.936 +39.785 +39.646 +39.573 +39.497 +39.443 +39.377 +39.305 +39.223 +39.143 +39.074 +39.014 +38.939 +38.876 +38.815 +38.752 +38.706 +38.617 +38.532 +38.423 +38.296 +38.176 +38.058 +37.975 +37.849 +37.718 +37.568 +37.448 +37.335 +37.2 +37.065 +36.952 +36.796 +36.674 +36.55 +36.421 +36.313 +36.221 +36.121 +36.016 +35.934 +35.852 +35.766 +35.701 +35.632 +35.561 +35.483 +35.41 +35.345 +35.285 +35.219 +35.152 +35.097 +35.057 +35.014 +34.975 +34.933 +34.903 +34.883 +34.866 +34.848 +34.834 +34.825 +34.82 +34.815 +34.81 +34.81 +34.814 +34.83 +34.85 +34.869 +34.894 +34.924 +34.969 +35.019 +35.063 +35.106 +35.147 +35.192 +35.238 +35.285 +35.328 +35.373 +35.419 +35.472 +35.522 +35.573 +35.625 +35.686 +35.744 +35.795 +35.854 +35.918 +35.977 +36.034 +36.082 +36.134 +36.187 +36.215 +36.226 +36.224 +36.217 +36.218 +36.211 +36.196 +36.19 +36.193 +36.207 +36.226 +36.254 +36.286 +36.298 +36.327 +36.329 +36.327 +36.339 +36.351 +36.369 +36.394 +36.414 +36.439 +36.481 +36.533 +36.582 +36.634 +36.665 +36.679 +36.571 +36 +35.877 +35.911 +36.278 +36.517 +36.823 +37.356 +37.796 +38.456 +39.029 +39.78 +40.331 +41.143 +41.735 +42.447 +43.113 +43.589 +44.107 +44.569 +44.945 +45.364 +45.72 +46.061 +46.475 +46.85 +47.307 +47.732 +48.118 +48.375 +48.743 +49.071 +49.464 +49.974 +50.465 +51.141 +51.622 +51.944 +52.271 +52.682 +52.89 +53.011 +53.279 +53.523 +53.76 +53.937 +54.319 +54.497 +54.568 +54.716 +54.818 +54.928 +55.002 +55.11 +55.254 +55.41 +55.58 +55.712 +55.847 +55.953 +56.034 +56.096 +56.136 +56.19 +56.259 +56.321 +56.362 +56.362 +56.371 +56.375 +56.319 +56.227 +56.12 +56.05 +55.961 +55.869 +55.76 +55.641 +55.543 +55.453 +55.332 +55.245 +55.149 +55.052 +54.951 +54.864 +54.757 +54.675 +54.599 +54.517 +54.459 +54.32 +54.234 +54.173 +54.066 +53.944 +53.792 +53.607 +53.352 +53.018 +52.612 +52.171 +51.504 +50.328 +49.724 +48.642 +47.231 +46.521 +45.795 +45.774 +45.895 +45.948 +45.999 +46.062 +46.11 +46.153 +46.236 +46.262 +46.285 +46.341 +46.375 +46.417 +46.479 +46.521 +46.527 +46.626 +46.657 +46.625 +46.581 +46.566 +46.53 +46.471 +46.428 +46.37 +46.319 +46.285 +46.193 +46.116 +46.021 +45.888 +45.844 +45.824 +45.723 +45.7 +45.73 +45.735 +45.731 +45.761 +45.758 +45.824 +45.823 +45.838 +45.792 +45.805 +45.861 +45.771 +45.721 +45.741 +45.697 +45.668 +45.654 +45.636 +45.575 +45.467 +45.39 +45.493 +45.367 +45.297 +45.288 +45.163 +45.111 +45.064 +45.036 +44.909 +44.805 +44.706 +44.553 +44.44 +44.346 +44.212 +43.978 +43.896 +43.724 +43.524 +43.355 +43.134 +43.036 +42.922 +42.825 +42.663 +42.553 +42.449 +42.31 +42.104 +41.962 +41.866 +41.71 +41.601 +41.466 +41.378 +41.273 +41.127 +41.111 +41.059 +40.946 +40.887 +40.937 +40.904 +40.909 +40.911 +40.98 +41.04 +41.067 +41.076 +41.116 +41.173 +41.212 +41.243 +41.283 +41.349 +41.391 +41.468 +41.512 +41.546 +41.622 +41.704 +41.745 +41.811 +41.839 +41.892 +41.933 +41.993 +42.013 +42.056 +42.105 +42.119 +42.118 +42.138 +42.112 +42.084 +42.06 +42.005 +41.958 +41.917 +41.841 +41.81 +41.75 +41.716 +41.657 +41.623 +41.59 +41.574 +41.568 +41.581 +41.607 +41.67 +41.734 +41.818 +41.903 +42.007 +42.103 +42.214 +42.308 +42.396 +42.491 +42.584 +42.688 +42.777 +42.896 +42.999 +43.113 +43.232 +43.345 +43.449 +43.593 +43.792 +43.997 +44.183 +44.367 +44.342 +44.397 +44.242 +44.114 +44.018 +43.852 +43.789 +43.79 +43.717 +42.291 +43.846 +43.739 +41.757 +41 +41.627 +41.358 +41.138 +39.331 +39 +39 +44.578 +44.714 +44.847 +44.92 +45.133 +39.492 +39.211 +39.33 +39.304 +39.319 +39.345 +39.403 +39.397 +39.433 +39.493 +39.509 +39.471 +39.542 +39.509 +39.46 +39.41 +39.385 +39.463 +39.997 +46.897 +39.976 +40 +40.01 +40.344 +40.509 +41.068 +41.239 +41.589 +41.845 +42.121 +42.301 +42.481 +42.585 +42.677 +42.767 +42.821 +42.872 +42.913 +42.977 +43.041 +43.112 +43.211 +43.321 +43.437 +43.556 +43.613 +43.668 +43.72 +43.767 +43.809 +43.86 +43.929 +43.993 +44.063 +44.128 +44.195 +44.266 +44.346 +44.431 +44.511 +44.576 +44.645 +44.714 +44.804 +44.874 +44.952 +45.045 +45.099 +45.167 +45.221 +45.296 +45.327 +45.357 +45.369 +45.378 +45.371 +45.363 +45.341 +45.31 +45.267 +45.206 +45.158 +45.082 +45.023 +44.958 +44.9 +44.845 +44.762 +44.712 +44.645 +44.594 +44.538 +44.507 +44.496 +44.524 +44.513 +44.496 +44.48 +44.466 +44.453 +44.452 +44.43 +44.417 +44.4 +44.415 +44.426 +44.483 +44.549 +44.805 +45.039 +44.946 +43.445 +42.867 +42.294 +41.845 +41.521 +41.245 +41.001 +41.501 +41.798 +42.089 +42.253 +42.516 +42.77 +43.05 +43.259 +43.466 +43.705 +43.865 +44.055 +44.203 +44.387 +44.501 +44.671 +44.859 +45.005 +45.173 +45.387 +45.531 +45.741 +45.905 +46.06 +46.218 +46.385 +46.564 +46.743 +47.022 +47.206 +47.519 +47.81 +48.094 +48.388 +48.615 +48.896 +49.096 +49.226 +49.435 +49.644 +49.767 +49.942 +50.164 +50.274 +50.442 +50.587 +50.707 +50.874 +51.071 +51.22 +51.402 +51.624 +51.752 +51.805 +51.433 +50.28 +49.987 +49.905 +49.561 +49.437 +49.31 +49.378 +49.393 +49.501 +49.586 +49.638 +49.743 +49.788 +49.882 +49.983 +50.065 +50.172 +50.323 +50.385 +50.557 +50.715 +50.862 +51.115 +51.231 +51.462 +51.693 +51.929 +52.252 +52.435 +52.806 +53.084 +53.394 +53.664 +53.983 +54.299 +54.46 +54.766 +54.914 +55.109 +55.263 +55.384 +55.529 +55.653 +55.857 +56.039 +56.26 +56.573 +56.94 +57.297 +57.681 +58.041 +58.403 +58.641 +58.994 +59.197 +59.403 +59.502 +59.54 +59.56 +59.54 +59.608 +59.613 +59.728 +59.783 +59.923 +59.965 +60.089 +60.177 +60.391 +60.65 +60.917 +61.166 +61.277 +61.803 +62.021 +62.638 +62.866 +63.022 +63.228 +63.964 +64.136 +64.238 +64.916 +64 +65.367 +65 +66 +69 +70 +71 +74.344 +74.063 +75 +74 +74 +73 +72 +66.34 +66.309 +64.338 +64.459 +63.962 +63.388 +61.273 +58 +59.179 +57.934 +57.986 +59.851 +59.871 +59.91 +59.884 +58.038 +56.21 +58.105 +56.079 +58.021 +56.118 +58.019 +57.99 +56.272 +58.014 +57.983 +58.075 +58.129 +58.154 +58.239 +58.362 +59.835 +59.817 +59.699 +59.693 +59.435 +59.449 +59.72 +62.579 +62.713 +62.68 +62.651 +62.723 +62.773 +62.731 +62.488 +62.376 +62.083 +61.927 +61.681 +61.343 +61.057 +60.77 +60.27 +59.783 +59.313 +58.696 +58.39 +58.026 +57.891 +57.556 +57.483 +57.291 +57.209 +57.125 +57.109 +57.075 +57.001 +56.948 +56.913 +56.87 +56.863 +56.837 +56.833 +56.862 +56.866 +56.909 +56.947 +56.989 +57.048 +57.097 +57.153 +57.182 +57.23 +57.295 +57.371 +57.439 +57.549 +57.611 +57.748 +57.843 +57.97 +58.083 +58.22 +58.357 +58.523 +58.785 +58.927 +59.23 +59.396 +59.713 +59.866 +60.119 +60.208 +60.327 +60.383 +60.535 +60.598 +60.832 +60.884 +61.258 +61 +62.138 +62.122 +62.467 +62 +62.311 +63 +62.467 +63.476 +62.849 +63.359 +63.028 +62 +62.291 +60.797 +60.087 +59.063 +58.929 +58.44 +58.204 +57.701 +57.641 +57.383 +57.252 +57.18 +57.102 +57.044 +56.994 +56.984 +56.96 +56.948 +56.935 +56.972 +56.955 +56.981 +56.971 +57.016 +57.043 +57.082 +57.17 +57.22 +57.312 +57.374 +57.501 +57.622 +57.752 +57.883 +58.047 +58.136 +58.258 +58.324 +58.421 +58.448 +58.499 +58.483 +58.496 +58.477 +58.459 +58.421 +58.392 +58.367 +58.322 +58.298 +58.259 +58.22 +58.173 +58.124 +58.045 +57.981 +57.886 +57.819 +57.728 +57.655 +57.539 +57.487 +57.46 +57.487 +57.452 +57.533 +57.545 +57.649 +57.705 +57.805 +57.919 +58.037 +58.264 +58.368 +58.676 +58.79 +59.077 +59.219 +59.513 +59.681 +59.963 +60.099 +60.359 +60.503 +60.806 +61.058 +61.374 +61.629 +62.054 +62.666 +63.088 +64.321 +64.604 +65.711 +65.291 +64.384 +64.142 +62.468 +61.961 +60.33 +59.338 +57.914 +57.597 +57.916 +58.07 +58.012 +58.013 +57.933 +57.927 +57.99 +58.118 +58.144 +58.11 +58.102 +58.189 +58.186 +58.195 +58.267 +58.195 +58.293 +58.302 +58.234 +58.14 +58.084 +58.077 +57.98 +57.076 +55.058 +60.747 +60.838 +61.131 +84.02 +83.988 +84.004 +83.946 +83.921 +83.938 +50.272 +50.134 +50.228 +50.122 +50.124 +50.139 +50.111 +50.228 +50.088 +100.56 +50.109 +50.02 +99.529 +99.727 +99.552 +99.534 +99.392 +99.303 +72.156 +72.053 +72.135 +60.357 +65.731 +60.642 +61.212 +61.441 +62.835 +62.946 +62.958 +62.865 +62.402 +62.319 +61.965 +61.824 +61.587 +61.345 +61.189 +61.023 +60.945 +60.795 +60.733 +60.581 +60.505 +60.438 +60.409 +60.341 +60.349 +60.364 +60.42 +60.507 +60.661 +60.814 +61.091 +61.336 +61.775 +62.179 +62.737 +63.338 +63.845 +64.581 +65.099 +65.741 +66.195 +66.674 +67.059 +67.5 +67.833 +68.128 +68.46 +68.683 +69.049 +69.312 +69.63 +69.869 +70.276 +70.559 +71.016 +71.441 +71.99 +72.531 +73.339 +73.903 +74.949 +75.614 +76.562 +77.369 +77.751 +78.851 +79.388 +79.849 +80.819 +81.451 +82.482 +83.129 +83.86 +84.761 +85.439 +85.826 +86.53 +86.978 +87.225 +88.049 +88.489 +88.768 +89.574 +89.897 +90.142 +90.749 +90.908 +91.246 +91.639 +91.78 +92.195 +92.564 +92.729 +93.248 +93.681 +93.913 +94.458 +94.834 +95.198 +95.784 +96.052 +96.365 +96.616 +96.767 +96.87 +96.998 +96.97 +96.992 +97.123 +97.149 +97.268 +97.482 +97.406 +97.417 +97.74 +97.239 +97.757 +98 +97.333 +98.377 +98.267 +97.94 +96 +96.7 +96.488 +96.086 +96.169 +96.058 +95.843 +95.689 +95.692 +95.471 +95.17 +95.013 +94.85 +94.58 +94.595 +94.433 +94.34 +94.436 +94.364 +94.338 +94.344 +94.44 +94.604 +94.66 +94.838 +95.052 +95.287 +95.497 +95.846 +96.146 +96.439 +96.827 +97.161 +97.376 +97.725 +98.102 +98.626 +99.115 +99.23 +100.03 +100.61 +100.81 +101.76 +101.99 +102.24 +102.74 +103.15 +103.61 +103.92 +104.38 +104.26 +104.41 +104 +104.48 +107.9 +104.36 +108.13 +108.35 +108.54 +108.76 +108.48 +108.3 +104 +104.5 +103.77 +103.21 +102.78 +103 +104.23 +104.06 +102 +102 +102.4 +102.49 +191.81 +80.115 +81.806 +83.483 +91.636 +91.826 +92.026 +91.75 +62 +92.907 +93.539 +93.613 +62.964 +40 +55.856 +56 +61 +63.662 +64.349 +65.02 +65.12 +65.269 +65.19 +65.496 +65.704 +66.231 +66.487 +66.798 +66.971 +67.175 +67.361 +67.506 +67.795 +67.887 +68.269 +68.307 +68.729 +69.088 +69.885 +70 +72.059 +72.63 +73.103 +73.166 +73.539 +73.787 +74.084 +74.368 +74.66 +74.876 +75.003 +75.184 +75.292 +75.495 +75.66 +75.749 +75.995 +76.067 +76.314 +76.483 +76.598 +76.83 +76.896 +77.151 +77.237 +77.423 +77.604 +77.667 +78.042 +78.117 +78.533 +78.692 +78.778 +79.058 +79.123 +79.513 +79.725 +79.956 +80.353 +80.457 +80.69 +80.889 +81.037 +81.26 +81.557 +81.843 +82.037 +82.364 +82.644 +83.045 +83.318 +83.5 +83.939 +84.215 +84.492 +84.735 +85.094 +85.444 +86.333 +86 +87.017 +88.128 +88.84 +89.981 +90.914 +91.982 +93 +94 +94 +97.893 +98.96 +95 +79.331 +80.722 +61.263 +59 +65.019 +66.333 +67.365 +68.722 +69.343 +70.042 +70.165 +70.915 +71.032 +71.388 +71.784 +72.057 +72.407 +72.579 +72.82 +72.982 +73.127 +73.369 +73.595 +73.81 +74.185 +74.395 +75.034 +75.573 +76.414 +77.201 +77.635 +78.026 +78.34 +78.456 +78.531 +78.559 +78.688 +78.764 +78.947 +79.072 +79.124 +79.201 +79.272 +79.478 +79.592 +79.819 +80.024 +80.124 +80.37 +80.507 +80.823 +80.976 +81.102 +81.282 +81.353 +81.905 +82.09 +82 +83.938 +85.112 +86 +87.22 +88.176 +90 +89.987 +86.222 +83.143 +83.16 +80.405 +81.459 +82.016 +83 +82.786 +83.224 +83.148 +82.926 +82.13 +82.481 +81.111 +81.296 +79.999 +79.146 +79.407 +79.026 +79.12 +79.325 +79.431 +78.695 +78.557 +78 +77.587 +77.817 +77.145 +76.391 +76.327 +77.814 +77 +77 +77.269 +75.198 +78.34 +75.279 +75.354 +41.819 +41.934 +50.974 +55 +59.196 +65.012 +65 +64.83 +64.774 +64.818 +64.727 +64.392 +64.3 +64.472 +64.487 +64.441 +64.392 +64.583 +64.621 +64.821 +64.886 +64.98 +64.944 +65.048 +65.077 +65.177 +65.194 +65.339 +65.436 +65.589 +65.706 +65.803 +65.989 +66.099 +66.24 +66.33 +66.492 +66.58 +66.767 +66.872 +67.048 +67.147 +67.331 +67.438 +67.597 +67.698 +67.785 +67.862 +67.923 +68.026 +68.095 +68.2 +68.273 +68.369 +68.415 +68.491 +68.528 +68.586 +68.655 +68.777 +68.884 +69.012 +69.095 +69.391 +69.548 +69.876 +70.652 +71.207 +74.329 +74 +77.853 +77 +76.127 +75.026 +74 +73.818 +73.707 +73.441 +73.363 +72.838 +72.443 +71.996 +71.573 +71.241 +70.829 +70.672 +70.253 +70.165 +69.859 +69.796 +69.578 +69.502 +69.402 +69.417 +69.34 +69.348 +69.355 +69.4 +69.422 +69.546 +69.577 +69.685 +69.759 +69.953 +70.042 +70.305 +70.387 +70.634 +70.829 +71.009 +71.254 +71.476 +71.748 +71.982 +72.234 +72.436 +72.795 +72.947 +73.264 +73.422 +73.638 +73.858 +74.037 +74.219 +74.378 +74.56 +74.809 +74.939 +75.082 +75.201 +75.242 +75.324 +75.45 +75.495 +75.656 +75.72 +75.939 +76.071 +76.23 +76.401 +76.426 +76.592 +76.652 +76.764 +76.912 +76.943 +77.165 +77.213 +77.343 +77.437 +77.494 +77.549 +77.551 +77.456 +77.394 +77.179 +77.079 +77.01 +76.69 +76.607 +76.423 +76.202 +76.169 +76.134 +76.171 +76.205 +76.207 +76.216 +76.306 +76.342 +76.475 +76.536 +76.647 +76.751 +76.811 +77.002 +77.048 +77.233 +77.412 +77.539 +77.772 +77.847 +78.088 +78.216 +78.36 +78.591 +78.673 +78.87 +78.973 +79.087 +79.25 +79.328 +79.502 +79.598 +79.771 +79.973 +80.081 +80.303 +80.417 +80.687 +81.023 +81.211 +81.599 +81.689 +81.931 +82.221 +82.335 +82.668 +82.854 +83.018 +83.227 +83.381 +83.728 +83.904 +84.031 +84.433 +84.643 +85.071 +85.264 +85.604 +86.064 +86.202 +87.089 +87.383 +87.747 +88.362 +88.407 +88.739 +89.066 +89.156 +89.214 +89.33 +89.36 +89.421 +89.509 +89.429 +89.384 +89.379 +89.271 +89.128 +89.135 +89.044 +88.964 +88.927 +88.813 +88.735 +88.66 +88.486 +88.396 +87.767 +87.632 +87.567 +86.924 +86.858 +86.649 +86.272 +86.087 +85.664 +85.384 +85.22 +84.918 +84.566 +84.586 +84.432 +84.306 +84.331 +84.257 +84.233 +84.415 +84.443 +84.428 +84.533 +84.493 +84.569 +84.66 +84.7 +84.9 +85.029 +85.145 +85.286 +85.457 +85.59 +85.726 +85.953 +85.985 +85.97 +86.049 +86.104 +86.23 +86.305 +86.41 +86.573 +86.637 +86.57 +86.549 +86.586 +86.512 +86.52 +86.635 +86.766 +86.896 +87.387 +87.595 +87.988 +88.663 +88.849 +88.942 +88.905 +88.967 +88.925 +88.86 +88.781 +88.656 +88.67 +88.33 +87.984 +87.976 +87.183 +87.07 +86.94 +86.745 +86.621 +86.523 +86.377 +86.322 +86.301 +86.202 +86.188 +86.207 +86.272 +86.287 +86.304 +86.338 +86.331 +86.439 +86.428 +86.667 +86.721 +86.76 +86.962 +87.056 +87.133 +87.348 +87.427 +87.566 +87.896 +87.956 +88.15 +88.794 +88.887 +89.542 +90.233 +90.291 +90.533 +90.654 +90.676 +91.176 +91.684 +92.261 +93.35 +93.728 +94 +95.745 +95.786 +97.013 +97.281 +97.043 +97.037 +96.17 +94.884 +94.708 +93.149 +91.662 +91.346 +89.937 +88.856 +88.606 +87.41 +87.266 +86.853 +86.121 +86.009 +85.446 +84.879 +84.74 +84.218 +83.946 +83.72 +83.213 +82.989 +82.54 +82.29 +82.005 +81.661 +81.419 +81.029 +80.865 +80.701 +80.477 +80.345 +80.203 +80.127 +80.033 +79.949 +79.892 +79.88 +79.864 +79.862 +79.954 +79.952 +80.033 +80.066 +80.098 +80.186 +80.186 +80.302 +80.358 +80.428 +80.536 +80.594 +80.796 +80.904 +81.058 +81.249 +81.348 +81.446 +81.618 +81.694 +81.828 +81.911 +82.044 +82.204 +82.368 +82.419 +82.544 +82.803 +82.979 +83.196 +83.304 +83.56 +83.919 +84.067 +84.224 +84.333 +84.683 +85.406 +85.799 +86.089 +86.483 +88.768 +89.146 +89.555 +89.942 +90.26 +90.005 +95.147 +95.367 +95.459 +95.168 +94.994 +94.942 +94.946 +94.968 +94.992 +100.04 +111.97 +112 +112.06 +112.12 +106.93 +126.95 +126.94 +164.82 +74.947 +164.71 +89.889 +89.896 +81.955 +81.9 +5.2981 +5.2715 +5.2426 +5.24 +5.2143 +5.1796 +5.1515 +5.1301 +5.1185 +5.1107 +5.1273 +5.174 +5.1539 +5.1114 +5.0791 +5.0809 +5.0962 +5.0942 +5.0836 +5.1194 +7.0764 +7.0925 +7.0998 +7.1019 +7.0705 +7.104 +7.0995 +7.0735 +7.0981 +7.1135 +7.1146 +7.1227 +7.1315 +7.1149 +7.1074 +7.0597 +7.0365 +7.072 +52.127 +83.676 +98 +98.879 +98.578 +98.617 +98.414 +98.262 +98.164 +90.907 +98.047 +53.974 +53.994 +53.166 +46.748 +53.121 +55.084 +54.082 +55.475 +55.817 +56.717 +57.021 +57.41 +57.496 +57.423 +57.587 +57.506 +57.639 +57.6 +57.739 +57.737 +57.94 +58.024 +58.213 +58.32 +58.476 +58.547 +58.643 +58.785 +58.882 +59.017 +59.171 +59.363 +59.52 +59.805 +59.983 +60.278 +60.429 +60.601 +60.678 +60.798 +60.873 +61.079 +61.195 +61.464 +61.635 +61.855 +62.059 +62.374 +62.578 +63.004 +63.226 +63.626 +63.881 +64.288 +64.809 +65.16 +65.822 +66.093 +66.625 +66.919 +67.385 +67.732 +68.222 +68.514 +69.133 +69.401 +69.72 +70.068 +70.521 +70.962 +71.412 +71.619 +72.044 +72.436 +72.849 +73.45 +73.917 +74.405 +74.543 +74.872 +75.009 +75.934 +76 +77 +79.508 +79.751 +80.003 +80.258 +80.481 +80.673 +80.728 +80.91 +80.938 +81.031 +81.132 +81.23 +81.409 +81.524 +81.642 +81.86 +81.853 +82.03 +82.288 +82.41 +82.219 +82.203 +82.218 +82.332 +82.412 +82.576 +82.603 +82.633 +82.663 +82.653 +82.687 +82.729 +82.8 +82.756 +82.681 +82.584 +82.213 +82.248 +82.153 +82.079 +82.019 +81.911 +81.841 +81.81 +81.814 +81.769 +81.863 +81.936 +81.957 +82.215 +82.281 +82.57 +82.949 +83.264 +83.676 +84.137 +84.423 +84.95 +85.457 +85.62 +85.98 +86.278 +86.422 +86.716 +86.941 +87.241 +87.606 +87.693 +88.017 +88.129 +88.147 +88.367 +88.445 +88.487 +88.684 +88.554 +89.141 +89.376 +89.315 +90.221 +90.197 +90.381 +91.299 +90.732 +90.911 +89.951 +90.608 +91.18 +91.56 +91.75 +92.054 +92.239 +92.291 +92.402 +92.397 +92.477 +92.593 +92.607 +92.724 +92.823 +92.858 +92.944 +92.973 +92.969 +93.061 +93.263 +93.374 +93.458 +93.569 +93.713 +93.796 +93.886 +93.927 +93.965 +93.931 +93.963 +93.909 +93.804 +93.686 +93.66 +93.43 +93.059 +92.498 +92.355 +91.94 +91.199 +91.181 +90.373 +89.391 +89.178 +88.554 +87.854 +87.561 +86.676 +86.064 +85.571 +84.714 +83.235 +81 +77.438 +71.071 +69.82 +68.306 +67.991 +66.824 +66.095 +65.181 +64.86 +64.452 +64.326 +64.133 +64.039 +63.81 +63.689 +63.427 +63.32 +63.124 +63.019 +62.829 +62.643 +62.415 +62.253 +62.08 +61.954 +61.826 +61.729 +61.629 +61.546 +61.485 +61.449 +61.447 +61.433 +61.443 +61.455 +61.493 +61.562 +61.624 +61.749 +61.828 +61.992 +62.085 +62.289 +62.417 +62.674 +62.816 +63.041 +63.219 +63.394 +63.602 +63.775 +63.984 +64.151 +64.344 +64.547 +64.867 +65.061 +65.416 +65.687 +66.134 +66.462 +67.074 +67.506 +68.087 +69.129 +70.376 +73.675 +74.433 +75.729 +76.149 +76.22 +76.098 +76.154 +76.679 +76.776 +76.818 +76.83 +76.88 +77.336 +77.536 +77.701 +77.858 +77.944 +78.331 +78.553 +78.716 +78.932 +79.114 +79.399 +79.549 +79.737 +79.93 +80.148 +80.319 +80.387 +80.439 +80.545 +80.604 +80.716 +80.782 +80.761 +80.781 +80.814 +80.806 +80.787 +80.803 +80.808 +80.804 +80.764 +80.76 +80.856 +80.896 +81.03 +81.042 +81.064 +81.209 +81.167 +81.08 +80.652 +80.517 +80.536 +80.819 +81.015 +81.405 +81.391 +81.381 +81.234 +81.22 +81.319 +81.248 +81.199 +81.315 +81.223 +81.157 +81.022 +80.783 +81.042 +80.634 +79.881 +79.871 +78.259 +78.913 +77.912 +78.323 +79.495 +79.345 +78 +78.923 +78.917 +79.303 +78.86 +78.983 +77.039 +78.919 +79.656 +76.995 +134.56 +58.87 +58.457 +57.326 +57.423 +57.78 +55.722 +56.242 +55.101 +53 +53.901 +54.086 +55.159 +55.056 +54.969 +55.423 +55.408 +55.525 +55.564 +55.677 +55.68 +55.707 +55.775 +55.823 +55.663 +55.648 +55.625 +55.623 +55.611 +55.554 +55.6 +55.61 +55.579 +55.623 +55.722 +55.749 +55.841 +55.871 +55.97 +55.997 +56.111 +56.233 +56.343 +56.558 +56.658 +56.875 +57.039 +57.244 +57.521 +57.726 +58.07 +58.369 +58.511 +58.852 +58.96 +59.184 +59.315 +59.36 +59.453 +59.543 +59.653 +59.677 +59.808 +59.852 +60.01 +60.089 +60.304 +60.389 +60.621 +60.741 +60.963 +61.076 +61.293 +61.475 +61.659 +61.854 +62.069 +62.262 +62.502 +62.697 +62.885 +63.162 +63.338 +63.482 +63.616 +63.733 +63.806 +63.934 +63.937 +63.925 +63.934 +63.963 +63.982 +63.985 +64.009 +63.975 +63.972 +63.951 +63.925 +63.923 +63.911 +63.906 +63.869 +63.817 +63.779 +63.803 +63.892 +64.024 +64.076 +64.231 +64.184 +63.748 +63.628 +62.402 +62.926 +62.933 +62.782 +62.495 +61.709 +61.648 +62.09 +65.649 +60.365 +59.932 +65.608 +65.597 +65.03 +64.845 +60.645 +59.715 +59.802 +59.857 +59.95 +59.987 +59.761 +59.579 +8.0731 +8.07 +8.0241 +8.0633 +8.0889 +8.1876 +7.9605 +7.4898 +7.4618 +7.3491 +7.3103 +7.2796 +7.2998 +7.3094 +7.4585 +59.698 +60.061 +60.14 +59.685 +59.196 +116 +116.17 +116.29 +116.41 +116.97 +105.63 +111.61 +60.286 +69.013 +60.455 +59 +58.962 +59.332 +62 +64.322 +64.881 +65.007 +65.611 +65.759 +65.91 +65.989 +66.144 +66.342 +66.399 +66.64 +66.691 +67.044 +67.184 +67.434 +67.521 +67.607 +67.611 +67.703 +67.742 +67.787 +67.921 +68.019 +68.315 +68.443 +68.999 +69.101 +70.032 +70.145 +70.744 +71.39 +70 +94.35 +99.741 +92.056 +93.968 +92.926 +93 +92.379 +70.086 +93 +68.314 +67.708 +68.009 +68.115 +69.072 +66.886 +67.803 +72.433 +72.159 +72.94 +72.916 +62.258 +124.24 +91.953 +61.867 +61.671 +62.058 +62.404 +62.399 +71.006 +70.987 +71.591 +71.776 +72.392 +72.478 +72.798 +72.976 +73.12 +73.526 +73.68 +73.98 +74.121 +74.296 +74.567 +74.759 +75.007 +75.389 +75.624 +75.932 +76.092 +76.394 +76.622 +76.859 +77.066 +77.17 +77.277 +77.305 +77.336 +77.358 +77.302 +77.252 +77.181 +76.945 +76.838 +76.463 +76.277 +75.913 +75.509 +75.213 +74.549 +74.226 +73.686 +73.189 +72.667 +72.214 +71.657 +71.168 +70.566 +70.176 +69.527 +69.198 +68.588 +68.25 +67.852 +67.475 +67.286 +66.844 +66.698 +66.317 +66.104 +65.78 +65.487 +65.332 +65.159 +65.336 +65.416 +65.387 +65.383 +65.567 +65.522 +65.924 +66.275 +66.423 +66.733 +66.693 +66.669 +66.998 +66.944 +66.955 +69.234 +69.162 +70.928 +70.589 +70.813 +70.695 +117 +71.161 +70 +70.997 +70.439 +70.263 +69.925 +69.631 +70.045 +70.414 +68.22 +67.651 +67.99 +68.1 +67.832 +34.216 +34.314 +34.449 +34.304 +34.376 +34.166 +33.944 +33.737 +33.286 +32.482 +32.153 +32.243 +32.13 +32.104 +32.124 +32.379 +32.33 +32.092 +31.934 +31.842 +446.3 +506.64 +303.88 +303.64 +303.3 +303.34 +302.95 +302.35 +302.23 +301.88 +301.97 +302.38 +303.21 +303.15 +301.93 +345.26 +345.82 +345.62 +32.217 +31.447 +33.102 +34.32 +34.251 +33.93 +35.602 +41.181 +71.044 +58.107 +54.783 +42.018 +44.119 +51.115 +51.077 +39.086 +41.701 +40.849 +42.395 +43.049 +43.661 +44.042 +44.247 +44.505 +44.707 +44.874 +45.016 +45.117 +45.235 +45.307 +45.378 +45.465 +45.535 +45.603 +45.719 +45.848 +46.023 +46.166 +46.439 +46.664 +46.971 +47.229 +47.565 +48.002 +48.438 +49.098 +49.683 +50.352 +51.265 +51.807 +52.325 +52.881 +53.171 +53.464 +53.624 +54.088 +54.57 +54.915 +55.329 +55.486 +55.727 +55.825 +55.942 +55.96 +56.001 +56.055 +56.189 +56.333 +56.433 +56.467 +56.501 +56.512 +56.47 +56.463 +56.424 +56.416 +56.399 +56.377 +56.372 +56.33 +56.328 +56.304 +56.431 +56.735 +57.298 +58.111 +59.316 +59 +59 +59 +57.811 +57 +56.451 +56.714 +57.035 +55.877 +55 +54.269 +51.985 +51.339 +51.18 +50.749 +51.14 +41.008 +41.024 +40.819 +40.813 +40.713 +40.669 +40.726 +40.737 +40.728 +40.732 +40.719 +40.714 +40.745 +40.717 +40.741 +40.758 +9.0163 +9.1442 +9.5974 +9.5365 +9.5731 +9.5295 +9.5752 +9.5748 +9.4859 +9.3801 +9.5205 +9.484 +9.4496 +9.518 +9.5083 +9.4351 +9.5466 +9.6024 +9.5469 +7.2618 +7.2847 +9.1486 +9.1837 +9.0506 +9.0535 +9.1099 +9.1171 +9.1166 +9.1703 +9.1768 +9.247 +9.299 +9.5078 +9.4015 +9.4095 +9.3488 +9.5421 +9.5763 +9.5169 +9.529 +9.5174 +9.5192 +9.5238 +9.5868 +9.5757 +9.5755 +9.6012 +9.6011 +9.5676 +9.5503 +9.5546 +9.5206 +9.5762 +9.6041 +9.5809 +9.648 +9.7292 +9.8599 +9.9512 +9.8769 +9.6238 +9.9422 +9.9325 +11 +11 +11 +6 +6 +6 +5 +5 +5 +5 +5 +5 +45 +20 +20 +20 +20 +20 +36.505 +21.463 +20.804 +51.238 +20 +20 +20 +30.648 +33.249 +34.289 +34 +34.449 +34.087 +33.696 +33.519 +33.488 +33.505 +33.557 +33.638 +33.799 +33.904 +34.003 +34.078 +34.127 +34.176 +34.2 +34.242 +34.294 +34.364 +34.581 +34.997 +35.65 +36.463 +37.267 +38.141 +38.965 +39 +40.833 +42.913 +44.224 +45.145 +45.898 +46.422 +47.567 +48.502 +49.165 +49.695 +49.952 +50.404 +50.726 +50.925 +51.243 +51.589 +51.836 +52.051 +52.334 +52.557 +52.771 +52.89 +53.013 +53.229 +53.429 +53.59 +53.788 +53.839 +53.88 +53.854 +53.867 +53.838 +53.768 +53.718 +53.653 +53.609 +53.467 +53.358 +53.312 +53.164 +52.997 +52.785 +52.624 +52.385 +52.128 +51.866 +51.636 +51.347 +50.981 +50.765 +50.479 +50.223 +50.063 +49.866 +49.758 +49.663 +49.507 +49.478 +49.462 +49.395 +49.378 +49.404 +49.421 +49.459 +49.785 +49.95 +50.091 +50.598 +50.377 +51.074 +50.958 +51.109 +51.406 +51.433 +51.475 +51.017 +50.865 +50.916 +50.714 +50.409 +50.788 +50.828 +50.751 +51.419 +51.542 +51.391 +51.515 +51.306 +51.297 +51.427 +51.565 +51.636 +51.701 +51.879 +51.723 +51.636 +51.704 +51.663 +51.357 +51.381 +51.611 +51.49 +51.729 +51.786 +51.758 +51.865 +51.835 +51.819 +51.799 +51.915 +51.861 +51.819 +51.778 +51.89 +25.921 +25 +25 +25 +25 +28 +23 +23.434 +24.995 +25.198 +25.293 +25.009 +25.1 +25.068 +24.982 +25.118 +25.256 +25.043 +48.084 +48.155 +48.095 +48.075 +48.073 +48.125 +48.098 +48.045 +48.062 +48.098 +48.117 +48.108 +48.078 +48.05 +48.005 +42.501 +42.573 +42.985 +45.133 +45.516 +46.235 +46.874 +47.297 +47.641 +48.022 +48.36 +48.584 +48.802 +49.04 +49.233 +49.372 +49.473 +49.617 +49.832 +49.986 +50.227 +50.483 +50.734 +51.141 +51.507 +51.851 +52.248 +52.644 +52.92 +53.313 +53.703 +54.038 +54.475 +54.858 +55.519 +56.002 +56.598 +57.074 +57.694 +58.209 +58.916 +59.237 +60.166 +60.647 +61.646 +62.154 +63.269 +63.878 +64.608 +64.988 +65.446 +65.952 +66.289 +66.829 +67.232 +67.792 +68.112 +68.902 +69.177 +69.722 +70.065 +70.425 +70.867 +71.309 +71.75 +72.174 +72.667 +73.19 +73.718 +74.263 +75.029 +75.472 +76.162 +76.423 +76.86 +77.015 +77.243 +77.538 +77.631 +77.68 +77.701 +77.845 +77.893 +77.921 +78.036 +78.074 +78.229 +78.238 +78.28 +78.273 +78.268 +78.448 +78.568 +78.533 +78.6 +78.727 +79.431 +79.967 +81.414 +82.598 +83.349 +84.71 +85.266 +86.12 +86.693 +87.139 +87.469 +87.334 +87.076 +87.043 +86.654 +85.821 +85.567 +84.756 +84.682 +83.977 +82.377 +80.769 +77.432 +77.176 +74.718 +73 +72.488 +71.191 +70.894 +69.847 +69.534 +68.95 +68.749 +68.307 +68.116 +67.871 +67.774 +67.701 +67.68 +67.677 +67.685 +67.687 +67.758 +67.75 +67.806 +67.796 +67.816 +67.824 +67.865 +67.88 +68.011 +68.11 +68.328 +68.505 +68.805 +69.078 +69.495 +70.051 +70.375 +71.649 +72.281 +75.089 +75 +78 +80 +83.752 +83.804 +83.843 +83.883 +83.662 +84.052 +83.726 +83.78 +83.217 +82.97 +83.05 +82 +82 +81.463 +81.412 +81.086 +79 +79.361 +78 +78 +78 +77 +75 +74 +72.969 +71 +67.326 +67.916 +67.735 +105.47 +57.11 +57.297 +65.103 +98.61 +49.232 +57.008 +57.077 +58.379 +61.363 +62.448 +62.842 +63.188 +63.34 +63.824 +63.959 +64.389 +64.568 +65.07 +65.262 +65.738 +65.907 +66.374 +66.588 +67.011 +67.222 +67.36 +67.541 +67.652 +67.92 +68 +68.281 +68.358 +68.668 +68.754 +69.005 +69.104 +69.374 +69.586 +69.839 +70.181 +70.887 +71.346 +72.433 +72.518 +71.966 +71.237 +70.818 +70.573 +70.219 +70.119 +69.972 +69.935 +69.985 +70.041 +70.099 +70.236 +70.271 +70.451 +70.521 +70.664 +70.731 +70.871 +70.975 +71.092 +71.204 +71.396 +71.485 +71.702 +71.803 +71.969 +72.127 +72.254 +72.391 +72.481 +72.612 +72.704 +72.819 +72.879 +73.07 +73.232 +73.53 +73.86 +74.069 +74.281 +74.212 +73.863 +73.762 +73.626 +73.508 +73.431 +73.445 +73.421 +73.416 +73.357 +73.307 +73.185 +73.053 +72.962 +72.814 +72.685 +72.545 +72.395 +72.172 +71.932 +71.658 +71.377 +70.988 +70.749 +70.354 +69.959 +69.625 +69.187 +68.916 +68.496 +68.293 +67.883 +67.76 +67.398 +67.251 +66.963 +66.801 +66.465 +66.084 +64.948 +64.554 +62 +62.977 +63.11 +62.977 +62.73 +62.661 +62.744 +62.734 +62.816 +62.809 +62.843 +62.832 +62.837 +62.833 +62.857 +62.876 +62.855 +62.893 +62.835 +62.782 +62.738 +62.76 +62.725 +62.603 +62.538 +62.27 +62.207 +61.871 +61.784 +61.382 +61.21 +60.879 +60.751 +60.409 +60.26 +59.943 +59.763 +59.446 +59.279 +59.029 +58.773 +58.612 +58.428 +58.381 +58.347 +58.361 +58.457 +58.49 +58.739 +58.822 +59.034 +59.216 +59.314 +59.509 +59.686 +60.005 +60.151 +60.427 +60 +64.082 +64.455 +65.826 +66.326 +70 +70 +68.378 +68 +89.951 +92.426 +96.246 +107 +107 +107 +107 +107 +107 +114 +105 +104.86 +105.46 +105 +105 +90.512 +50.25 +57.599 +80.922 +57.397 +57.417 +50.302 +55.323 +55.142 +57.717 +57.996 +58.783 +58.827 +59.389 +59.473 +60.113 +60.229 +60.728 +60.831 +61.23 +61.32 +61.708 +61.804 +62.082 +62.285 +62.469 +62.69 +62.823 +63.095 +63.206 +63.463 +63.509 +63.599 +63.618 +63.636 +63.641 +63.66 +63.648 +63.632 +63.619 +63.549 +63.501 +63.431 +63.378 +63.298 +63.207 +63.112 +63.008 +62.904 +62.814 +62.739 +62.667 +62.6 +62.517 +62.437 +62.347 +62.257 +62.208 +62.147 +62.081 +61.972 +61.974 +61.948 +62.062 +62.129 +62.423 +62.823 +63.238 +63.805 +64.438 +65 +65.086 +65.443 +65 +65 +66.427 +65.465 +65 +65.285 +65.148 +64.988 +64 +64.495 +64.121 +64.07 +63.445 +63.202 +62.819 +62.757 +62.536 +62.502 +62.342 +62.373 +62.399 +62.188 +62.267 +62.341 +62.264 +62.568 +62.506 +62.51 +62.267 +62.278 +62.371 +62.056 +61 +83.406 +82.875 +83.254 +82.887 +83.036 +82.096 +104.58 +104.58 +104.56 +104.63 +53 +53.04 +83.265 +82.664 +61.416 +61.694 +53.427 +54 +57.657 +58.363 +62.962 +63.106 +63.788 +63.92 +64.484 +64.554 +64.98 +65.038 +65.419 +65.58 +65.895 +66.072 +66.342 +66.552 +66.755 +67.007 +67.102 +67.465 +67.582 +68.051 +68.164 +68.754 +68.925 +69.456 +69.651 +70.071 +70.388 +70.786 +71.184 +71.556 +72.003 +72.294 +72.909 +73.132 +73.798 +74.061 +74.558 +74.655 +74.921 +75.037 +75.086 +75.166 +75.156 +75.337 +75.417 +75.766 +75.987 +76.211 +76.815 +77.011 +78.206 +79 +82.448 +82 +83.329 +84 +84 +84.05 +83 +83.089 +83.352 +82.42 +82.104 +80.783 +79.679 +79.241 +77 +76.951 +75.339 +73.744 +73.211 +72.364 +72.136 +71.381 +71.095 +70.612 +70.371 +70.115 +69.91 +69.779 +69.618 +69.512 +69.389 +69.304 +69.188 +69.102 +68.954 +68.883 +68.683 +68.603 +68.392 +68.297 +68.091 +67.995 +67.829 +67.733 +67.578 +67.436 +67.318 +67.096 +66.968 +66.73 +66.589 +66.345 +66.179 +65.923 +65.706 +65.452 +65.219 +65.015 +64.752 +64.502 +64.2 +64.01 +63.632 +63.475 +63.044 +62.956 +62.576 +62.478 +62.2 +62.089 +61.827 +61.663 +61.447 +61.128 +60.962 +60.62 +60.481 +59.987 +59.758 +59.297 +58.96 +58.659 +58.26 +57.971 +57.573 +57.139 +56.812 +56.262 +56.092 +55.754 +55.446 +55.161 +54.777 +54.646 +54.386 +54.215 +53.978 +53.701 +53.547 +53.267 +53.151 +53.024 +52.791 +52.614 +52.311 +52.088 +51.693 +51.37 +51.157 +50.966 +51.02 +50.96 +50.96 +50.939 +50.872 +50.924 +50.921 +50.937 +50.933 +50.94 +50.934 +50.93 +50.949 +51.025 +51.181 +51.354 +51.553 +51.519 +51.548 +51.738 +51.974 +52.472 +53.562 +53.881 +54.27 +54.323 +54.389 +54.652 +54.846 +54.946 +55.103 +55.146 +55.026 +54.945 +54.133 +53.962 +53.878 +53.871 +53.819 +53.915 +53.917 +53.988 +54.021 +54.066 +54.124 +54.129 +54.223 +54.257 +54.342 +54.435 +54.506 +54.744 +54.806 +54.961 +55.061 +55.137 +55.259 +55.368 +55.6 +55.705 +55.886 +56.128 +56.291 +56.667 +57.054 +57.418 +58.167 +58.516 +59.469 +59.73 +60.958 +61.762 +61.832 +62.126 +62.25 +62.429 +62.737 +62.821 +63.101 +63.323 +63.681 +64.042 +64.455 +64.829 +65.222 +65.661 +66.081 +66.549 +66.935 +67.499 +67.696 +68.373 +68.646 +69.296 +69.634 +70.208 +70.53 +70.937 +71.156 +71.339 +71.576 +71.777 +71.986 +72.197 +72.414 +72.574 +72.73 +72.862 +72.963 +73.079 +73.236 +73.366 +73.48 +73.579 +73.725 +73.885 +73.996 +74.214 +73.852 +73.843 +73.591 +73.558 +73.348 +74.029 +74.004 +74.05 +74.148 +74.13 +74.445 +74.541 +74.822 +74.956 +75.001 +75.413 +75.469 +75.796 +75.901 +76.023 +76.246 +76.289 +76.514 +76.614 +76.695 +76.893 +76.904 +77.085 +77.153 +77.276 +77.337 +77.357 +77.515 +77.529 +77.634 +77.686 +77.715 +77.973 +78.002 +78.236 +78.39 +78.456 +78.803 +78.855 +79.167 +79.392 +79.574 +80.068 +80.145 +80.64 +80.852 +81.119 +81.433 +81.501 +81.861 +81.964 +82.139 +82.286 +82.311 +82.473 +82.558 +82.648 +82.767 +82.812 +82.926 +82.976 +83.021 +83.159 +83.239 +83.426 +83.494 +83.613 +83.759 +83.782 +83.903 +83.939 +83.958 +84.057 +84.078 +84.174 +84.242 +84.274 +84.374 +84.463 +84.484 +84.502 +84.486 +84.524 +84.505 +84.51 +84.701 +84.75 +84.933 +85.162 +85.216 +85.546 +85.499 +85.474 +85.782 +85.603 +85.388 +85.114 +84.946 +84.924 +84.815 +84.782 +84.684 +84.454 +84.328 +84.166 +84.088 +83.963 +83.849 +83.855 +83.814 +83.714 +83.745 +83.725 +83.71 +83.72 +83.782 +83.808 +83.772 +83.713 +83.699 +83.7 +83.542 +83.413 +83.137 +82.995 +82.638 +81.861 +81.501 +80.632 +80.191 +79.628 +78.911 +78.447 +77.73 +77.22 +76.358 +75.194 +75.373 +73.172 +72.865 +75 +76.698 +77.003 +77.176 +77.23 +77.385 +77.472 +77.537 +77.536 +77.513 +77.478 +77.45 +77.42 +77.394 +77.37 +77.433 +77.388 +77.189 +77.084 +76.941 +76.74 +76.585 +76.277 +75.905 +75.527 +74.83 +74.847 +74.06 +73.567 +72.99 +72.42 +72.151 +71.267 +71.14 +70.668 +70.205 +69.689 +69.069 +68.32 +67.244 +66.844 +65.095 +59.291 +59.033 +59.059 +58.635 +58.835 +58.198 +58.17 +57.805 +57.51 +57.2 +56.852 +56.483 +56.236 +55.774 +55.523 +55.036 +54.645 +54.272 +53.712 +53.378 +52.886 +52.648 +52.183 +52.015 +51.736 +51.512 +51.151 +50.622 +50.137 +49.417 +48.822 +48.092 +47.34 +46.365 +45.681 +44.949 +44.267 +43.77 +43.11 +42.561 +42.273 +41.873 +41.403 +40.881 +40.551 +40.026 +39.677 +39.366 +39.118 +38.76 +38.5 +38.149 +37.87 +37.511 +37.259 +37.077 +37.008 +36.912 +36.904 +36.749 +36.561 +36.34 +36.036 +35.819 +35.539 +34.941 +34.281 +33.719 +32.815 +32.336 +32.381 +32.944 +33.485 +34 +35.92 +35 +35 +35.997 +35.972 +36.01 +36 +37 +37 +37.483 +37.003 +37.178 +36 +37.056 +37.124 +36 +36.918 +36.359 +36.476 +35.977 +35.922 +36.197 +36.627 +36.272 +71.352 +71.515 +70.843 +70.439 +34 +35.008 +35.169 +34.786 +34.858 +34 +35.398 +35 +37.384 +37 +37.411 +35.491 +37.197 +37.116 +45.01 +47.361 +50 +51.156 +52.394 +53.297 +54.321 +55.249 +56.19 +56.929 +57 +58.371 +59.156 +59.766 +60 +60.985 +61.792 +62.144 +62.914 +63.423 +64.196 +64.783 +65.141 +65.508 +66.509 +66.641 +67.547 +67.767 +68.563 +68.795 +68.84 +68.689 +69.199 +69.823 +70.284 +71.35 +71.942 +72.286 +72.374 +72.578 +72.752 +72.921 +72.99 +73.396 +73.568 +73.996 +74.499 +75.166 +77.111 +77.561 +78.444 +78.999 +79.682 +81.343 +85.75 +86.078 +86.818 +86.963 +87.169 +87.57 +87.735 +87.847 +88.271 +88.484 +88.656 +89.048 +89.272 +89.54 +89.888 +90.019 +90.328 +90.691 +90.787 +91.102 +91.282 +91.353 +91.675 +91.808 +91.944 +92.14 +92.151 +92.295 +92.284 +92.209 +92.158 +91.998 +91.91 +91.642 +91.212 +91.057 +90.434 +89.607 +89.393 +88.245 +87.64 +87.392 +86.719 +86.473 +86.358 +86.013 +85.891 +85.844 +85.778 +85.685 +85.661 +85.629 +85.638 +85.615 +85.488 +85.547 +85.584 +85.585 +85.686 +85.775 +85.884 +86.102 +86.258 +86.386 +86.525 +86.606 +86.946 +87.271 +87.472 +88.071 +88.453 +88.579 +88.843 +89.053 +88.919 +89.01 +90.996 +90.996 +91.062 +91.102 +88.341 +88.441 +88.32 +91.053 +91.097 +88.291 +88.315 +85.928 +85.938 +85.88 +88.21 +88.218 +88.118 +85.832 +85.859 +85.911 +85.876 +85.848 +7.0002 +6.99 +6.983 +6.9728 +6.9739 +9.1447 +9.1375 +9.1292 +7.0035 +9.1534 +9.1141 +9.0892 +9.0831 +9.0578 +9.0524 +9.0397 +9.0107 +9.0359 +9.0353 +9.0357 +9.0212 +9.0248 +9.0294 +9.0378 +9.0399 +8.9953 +9.0188 +9.0207 +9.0464 +9.0545 +9.0811 +6.9803 +6.987 +6.995 +6.9961 +6.9989 +6.9977 +6.9985 +6.9956 +7.0082 +7.0235 +7.0251 +7.0239 +7.0247 +7.0281 +7.0357 +7.0461 +7.0492 +7.0562 +7.0499 +7.0484 +7.0527 +7.0464 +7.0406 +7.0446 +7.0454 +7.0416 +7.036 +7.0357 +4.9907 +7.0366 +7.0384 +7.0438 +7.0332 +7.0208 +7.0017 +7.0007 +6.9952 +6.9955 +6.9927 +9.0535 +9.0477 +57.947 +29.995 +30.022 +30.003 +59.974 +59.969 +59.972 +59.968 +59.962 +46.023 +59.952 +55.037 +59.933 +55.058 +45.946 +33.034 +35.123 +35.858 +35.933 +35.739 +36.032 +36.236 +36.402 +36.611 +36.785 +36.831 +36.983 +37.101 +37.167 +37.221 +37.385 +37.481 +37.594 +37.675 +37.764 +37.858 +37.949 +38.04 +38.077 +38.143 +38.199 +38.236 +38.303 +38.349 +38.376 +38.459 +38.49 +38.501 +38.554 +38.554 +38.579 +38.588 +38.596 +38.655 +38.674 +38.717 +38.724 +38.74 +38.761 +38.746 +38.75 +38.735 +38.707 +38.661 +38.598 +38.492 +38.383 +38.196 +38.019 +37.823 +37.574 +37.316 +37.076 +36.806 +36.593 +36.374 +36.081 +35.844 +35.695 +35.573 +35.441 +35.311 +35.225 +35.075 +35.001 +34.844 +34.706 +34.605 +34.481 +34.377 +34.286 +34.212 +34.148 +34.137 +34.107 +34.086 +34.066 +34.086 +34.147 +34.153 +34.202 +34.23 +34.294 +34.359 +34.458 +34.584 +34.66 +34.731 +34.815 +34.908 +34.973 +35.066 +35.177 +35.314 +35.447 +35.574 +35.706 +35.803 +35.92 +36.044 +36.131 +36.209 +36.297 +36.793 +37.063 +37 +38.372 +38 +38 +38.217 +51.638 +51.858 +51 +51.89 +52.428 +52.482 +52.466 +52.94 +53.056 +53 +53.998 +54 +55.243 +56.181 +56.821 +58.442 +58.943 +61.026 +61.48 +61.953 +61.99 +63.019 +64 +65.381 +66.299 +66.686 +67 +67.904 +68.6 +68.9 +69.327 +69.914 +70.203 +70.659 +70.847 +71.419 +72.042 +72.602 +73.019 +73.425 +73.898 +74.391 +74.823 +75.137 +75.361 +75.743 +75.767 +75.598 +75.387 +75.522 +75.361 +75.356 +75.403 +75.439 +75.598 +75.662 +75.776 +75.863 +75.907 +75.99 +76.02 +76.024 +76.044 +76.049 +76.106 +76.168 +76.241 +76.432 +76.589 +76.893 +77.082 +77.239 +77.38 +77.354 +77.466 +77.407 +77.334 +77.333 +77.439 +77.515 +77.575 +77.586 +77.578 +77.348 +77.244 +77.085 +76.931 +76.89 +76.657 +76.597 +76.4 +76.281 +76.189 +76.077 +76.02 +75.907 +75.806 +75.76 +75.667 +75.669 +75.537 +75.484 +75.422 +75.333 +75.373 +75.372 +75.428 +75.762 +75.854 +76.183 +76.396 +76.514 +76.888 +76.984 +76.679 +76.629 +76.117 +75.812 +75.439 +75.078 +74.795 +74.37 +74.157 +73.573 +73.278 +72.934 +72.463 +72.231 +71.937 +71.639 +71.518 +71.125 +70.992 +70.864 +70.646 +70.541 +70.214 +69.902 +68.784 +68.168 +67.209 +66.781 +66.276 +65.996 +65.713 +65.406 +65.176 +64.984 +64.89 +64.779 +64.688 +64.525 +64.387 +64.187 +64.029 +63.806 +63.536 +63.392 +63.007 +62.687 +62.288 +61.961 +61.533 +61.229 +61.021 +60.896 +60.782 +60.561 +60.332 +60.099 +59.904 +59.656 +59.282 +58.776 +53 +52.192 +51.793 +50.207 +48 +43 +43 +43.415 +43.724 +43.918 +43.866 +43.829 +43.841 +43.873 +43.706 +43.7 +43.607 +43.576 +43.29 +43.27 +43.183 +42.989 +42.953 +43.129 +43.518 +43.485 +43.893 +43.433 +43.44 +43.267 +43.259 +43.153 +43.155 +43.063 +43.031 +43.006 +42.933 +42.934 +35.302 +35.11 +35.113 +35.136 +35.206 +33.014 +33.002 +32.992 +32.964 +32.951 +32.955 +32.997 +33.016 +33.001 +33.003 +33.015 +32.956 +32.999 +33.014 +33.005 +33.015 +28.075 +48.057 +27.987 +5.0617 +5.0702 +7.1001 +5.0743 +7.0926 +7.1009 +7.0825 +7.1051 +7.1084 +7.1228 +7.1524 +7.1406 +7.1494 +7.1286 +7.1159 +7.0996 +7.0967 +7.0968 +7.0834 +7.074 +7.0567 +7.0514 +7.0531 +7.0508 +7.0276 +7.0259 +7.0235 +7.0213 +7.0218 +7.0226 +7.0221 +7.0271 +7.0334 +7.034 +7.0338 +7.0327 +7.0339 +7.0338 +7.0331 +7.0337 +7.0364 +7.0377 +7.042 +7.0415 +7.0407 +7.0399 +7.0385 +7.0501 +7.0544 +7.0309 +7.0029 +7.007 +7.0529 +7.0576 +7.0618 +97.121 +97.821 +99.629 +16.548 +20.665 +29 +29 +30 +28.739 +29 +17 +17 +16 +15 +16.635 +38.845 +38.829 +38.966 +38.75 +20.057 +20.408 +21.043 +21.691 +21.983 +22.541 +23.008 +23.246 +23.393 +23.454 +23.383 +23.291 +23.186 +23.092 +23.065 +23.088 +23.154 +23.239 +23.324 +23.417 +23.502 +23.571 +23.624 +23.652 +23.671 +23.681 +23.688 +23.715 +23.76 +23.844 +23.958 +24.052 +24.176 +24.291 +24.248 +24.076 +23.92 +23.748 +23.572 +23.462 +23.361 +23.294 +23.282 +23.345 +23.509 +23.704 +23.957 +24.159 +24.382 +24.555 +24.72 +24.857 +24.966 +25.042 +25.119 +25.211 +25.306 +25.372 +25.435 +25.464 +25.496 +25.537 +25.573 +25.601 +25.574 +25.436 +25.242 +24.83 +24.308 +23.919 +23.907 +24.117 +24.191 +24.193 +24.19 +24.199 +24.349 +24.486 +24.468 +24.835 +25.042 +25.096 +25.158 +25.176 +25.239 +25.413 +25.372 +25.24 +25.2 +25.29 +25.405 +25.735 +25.825 +25.86 +25.891 +25.957 +25.966 +26.008 +26.016 +25.877 +25.8 +25.717 +25.55 +25.35 +25.145 +25.211 +25.304 +25.312 +25.298 +25.38 +25.438 +25.382 +25.278 +25.185 +25.171 +25.047 +24.955 +24.675 +24.814 +24.889 +24.922 +24.927 +24.963 +25.051 +25.051 +25.132 +30.475 +34.947 +34.538 +34.022 +34.478 +35.062 +35.526 +35.991 +36.188 +36.152 +36.049 +35.925 +35.853 +35.795 +35.759 +35.764 +35.775 +35.815 +35.868 +35.917 +35.979 +36.043 +36.069 +36.069 +36.042 +36.023 +36.008 +36.038 +36.019 +36.047 +35.992 +36.023 +36.168 +36.277 +36.067 +30.411 +29.973 +58.906 +59.272 +59.361 +59.862 +59.962 +29.872 +29.889 +23.651 +23.832 +23.981 +23.959 +24.08 +24.082 +24.275 +24.334 +24.445 +24.478 +24.626 +24.79 +24.957 +25.006 +76.062 +77.173 +77 +79.752 +54 +54 +81.936 +82.574 +57.205 +84.288 +84.987 +85.912 +86.293 +87.308 +87.826 +88.225 +89.319 +89.555 +89.825 +89.985 +89.969 +90.242 +90.369 +89.882 +88.127 +87.588 +88.294 +87.999 +87.993 +87.834 +87 +87.552 +88.159 +88.118 +88.407 +89.98 +90.071 +91 +92.691 +92.75 +94.432 +95.278 +95.317 +94.822 +95.235 +95.134 +95.771 +95.883 +96.211 +96.536 +97.146 +97.37 +97.539 +97.805 +97.897 +98.611 +98.897 +99.241 +99.937 +100.37 +100.65 +101.23 +101.32 +101.73 +102.85 +102.95 +103.21 +103.84 +104.05 +104.07 +104.84 +105.46 +105.64 +105.23 +105.41 +105.69 +104.79 +104.25 +104.12 +104.08 +103.72 +103.33 +103.44 +103.02 +102.89 +102.66 +102.53 +101.87 +101.76 +101.76 +102.24 +102.27 +102.27 +103.4 +104.06 +104.37 +105.02 +103.3 +103 +101 +102.27 +98.058 +98.102 +98 +100.28 +106 +104.17 +104.21 +103.29 +104.18 +103 +105 +105.44 +106.27 +107.18 +107.08 +106 +107 +108 +134.26 +134.93 +134.94 +135.7 +135.87 +136.65 +136.46 +135.58 +108.22 +107.68 +107.81 +107.68 +100.38 +99.984 +99.725 +289.58 +517 +532.06 +532.24 +532.51 +524.58 +525 +533.03 +297.16 +297.09 +288.35 +288.63 +288.21 +296.84 +306.77 +315.17 +316.14 +346.18 +372.45 +373.05 +403 +402 +403.21 +402.04 +402.48 +402.63 +393.82 +393.93 +394.08 +402.09 +393.32 +402.44 +393.52 +392.92 +391 +393.14 +393.05 +391.23 +256.24 +265 +266.98 +268 +272.44 +270 +272.33 +272 +273.44 +273 +273 +274.45 +273.47 +272.24 +275.39 +269.15 +268 +269 +270 +269.94 +299.95 +178.33 +178.28 +178 +209 +210.37 +211.93 +207.97 +219.9 +318 +179.74 +195.58 +259.52 +323.6 +375 +125.88 +150.26 +128.12 +128.12 +128.05 +206.53 +127.36 +206.6 +40.254 +40.902 +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN +NaN
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/yin/yin/yin.html Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,84 @@ +<html> +<head> +<title> YIN </title> +</head> + +<body> + +See README for copyright information. + +<hr> +<h2> YIN: fundamental frequency estimator </h2> +<hr> + +YIN estimates the fundamental frequency (F0) of an audio signal. +Features are: +<ul> +<li> Reliability (based on tests, see reference below). +<li> Accuracy (subsample resolution). +<li> Wide search range (default is 30 Hz - sr/4). +<li> Good temporal resolution. +<li> Ease of use. +</ul> + +YIN operates on vectors or files. YIN outputs a structure containing a set +of four vectors: F0 vs time, two estimates of aperiodic/total power +(one gross estimate, one fine estimate), and a period-smoothed estimate +of instantaneous power. +<p> +If no output argment is specified, YIN +plots F0 as a function of time (in octaves re: 440 Hz), aperiodicity, and power. +<p> +In the F0 plot, samples in blue are reckoned reliable (aperiodicity<threshold), +green are intermediate (aperiodicity<2*threshold), and +yellow unreliable (aperiodicity>2*threshold). + +<p> +Type 'help yin' for a description of the parameters. Read the reference below and +the code to understand their meaning. In brief: +<ul> +<li> To increase speed: increase 'hop' or 'minf0'. +<li> To reduce memory needs: reduce 'bufsize', or increase 'hop' or 'minf0'. +<li> To slightly increase reliability: reduce 'hop'. +<li> To slightly increase precision: upsample before processing. +<li> To improve temporal resolution: increase 'minf0', decrease 'hop'. +<li> To process lower F0s: reduce 'minf0'. Higher F0s: upsample and increase 'maxf0'. +<li> To avoid subharmonic errors: increase 'thresh'. +<li> To avoid harmonic/formant errors: reduce 'thresh'. +<li> Make sure that the range [minf0 maxf0] includes the expected f0. +</ul> +Parameter 'thresh' sets the proportion of aperiodic power that is +tolerated within a "periodic" signal. This may vary according to the application. +<p> +For speech or musical instruments a value of 0.1 is usually adequate. Singing voice +may require a smaller value (as low as 0.001) if a harmonic is reinforced by a +sharp formant. +<p> +Some signals are inherently ambiguous. For example +the response of a high-Q resonator excited by a pulse train may be seen either as a complex +tone with an F0 equal to that of the pulse train, or as an +amplitude modulated pure tone with an F0 equal to the resonant frequency. +Neither is more "correct" than the other. To obtain the result +that you expect, you must set the threshold to an appropriate value: small for the +fundamental periodicity, large for the resonance periodicity. + +<p> +YIN is described in: +<br></tt> +de Cheveigné, A., and Kawahara, H. (2002). "YIN, a fundamental frequency estimator +for speech and music," J. Acoust. Soc. Am., 111, 1917-1930. (<a href= + "http://www.ircam.fr/pcm/cheveign/ps/yin.pdf">pdf</a>) + </tt> + + <hr> +[Code is <a href="http://www.ircam.fr/pcm/cheveign/sw/yin.zip">here</a>] +[<a href="http://www.ircam.fr/pcm/cheveign">Alain de Cheveigné</a>] + + + + + + </body> + </html> + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/General/readFormantValueFromFile.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,165 @@ +function [] = readFormantValueFromFile( statsFileID, metricFileName, metricName, vuv ) + +DEBUG=0; + +FileID = fopen( metricFileName ); + +if( FileID <= 0 ) %does the file exist? + % if not + + message = ['WARNING: MISSING ' metricName ' FILE']; + disp( message ); + fprintf( statsFileID, '\t \s missing', metricName ); + + else + % file format is not straight forward + noOfValues = 0; + formants = []; + while( ~(feof(FileID)) ) + + % search for numberOfFormants + thestr = fgetl(FileID); + + if( strfind( thestr , 'numberOfFormants' ) > 0 ) + noOfValues = noOfValues + 1; + %numberOfFormants found + pos = find( thestr == '=' ); + numberOfFormants = str2num(thestr(pos+2:end)); + formants( noOfValues, 1 ) = numberOfFormants; + % discard the 'formant []' line + thestr = fgetl(FileID); + % now read the formant positions + for (i=0:numberOfFormants-1) + thestr = fgetl(FileID); + pos = find( thestr == '=' ); + formants( noOfValues, i+2 ) = str2num(thestr( pos+2 : end )); + end + + % discard the 'bandwidth []' line + thestr = fgetl(FileID); + % now read the formant bandwidths + for (i=0:numberOfFormants-1) + thestr = fgetl(FileID); + pos = find( thestr == '=' ); + formants( noOfValues, i+2+numberOfFormants ) = str2num(thestr( pos+2 : end )); + end + + end + end + fclose(FileID); + + + if(DEBUG) + timeShift = length(formants) / length(vuv); + subplot(211); hold off; + subplot(212); hold off; + for( idx = 1: length( formants )/10 ) + frameIdx = floor( idx / timeShift ) + 1; + if( frameIdx <= length(vuv) ) + if( vuv( frameIdx ) == 0 ) + % frame is silent + subplot(211); plot( idx, formants( idx,2 ), 'w.' ); hold on; + subplot(211); plot( idx, formants( idx,3 ), 'w.' ); + subplot(211); plot( idx, formants( idx,4 ), 'w.' ); + % plot bandwidths + subplot(212); plot( idx, formants( idx,5 ), 'w.' ); hold on; + subplot(212); plot( idx, formants( idx,6 ), 'w.' ); + subplot(212); plot( idx, formants( idx,7 ), 'w.' ); + elseif( vuv( frameIdx ) == 1 ) + % frame is voiced + subplot(211); plot( idx, formants( idx,2 ), 'y.' ); hold on; + subplot(211); plot( idx, formants( idx,3 ), 'c.' ); + subplot(211); plot( idx, formants( idx,4 ), 'g.' ); + % plot bandwidths + subplot(212); plot( idx, formants( idx,5 ), 'y.' ); hold on; + subplot(212); plot( idx, formants( idx,6 ), 'c.' ); + subplot(212); plot( idx, formants( idx,7 ), 'g.' ); + else + %frame is unvoiced + subplot(211); plot( idx, formants( idx,2 ), 'r.' ); hold on; + subplot(211); plot( idx, formants( idx,3 ), 'r.' ); + subplot(211); plot( idx, formants( idx,4 ), 'r.' ); + % plot bandwidths + subplot(212); plot( idx, formants( idx,5 ), 'r.' ); hold on; + subplot(212); plot( idx, formants( idx,6 ), 'r.' ); + subplot(212); plot( idx, formants( idx,7 ), 'r.' ); + end + else + frameIdx + end + end + end + + [ noOfSamples formantDataSize ] = size( formants ); + maxNoOfFormants = (formantDataSize - 1)/2; % the array contains the number of formants, then the position of each formant, then the bandwidth of each formant. + voicedFormant = []; + voicedBandwidth = []; + % find the basic metric set for the voiced frames only + validSamples = min( noOfSamples, length(vuv) ); + for( idx = 1: validSamples ) + if( vuv( idx ) == 1 ) + % frame is voiced + formantsThisFrame = formants(idx,1); + theFormants = formants( idx, 2 : formantsThisFrame+1 ); + theBandwidths = formants( idx, formantsThisFrame+2 : (formantsThisFrame*2)+1 ); + % we want to ignore any results that contain less than the + % max number of formants as then one of the formants is set to + % zero and the detection is not reliable + % DON'T THINK THIS IS STILL VALID + % DO WE WANT TO DISCARD FORMANT SETS THAT CONTAIN '0' FORMANT + % POSITIONS FOR VOICED SEGMENTS? + if( formantsThisFrame == maxNoOfFormants ) + voicedFormant = [ voicedFormant ; theFormants ]; + voicedBandwidth = [ voicedBandwidth; theBandwidths ]; + else + % pad with zeros + diff = maxNoOfFormants - formantsThisFrame; + theFormants = [ theFormants zeros( 1, diff )]; + voicedFormant = [ voicedFormant ; theFormants ]; + theBandwidths = [ theBandwidths zeros( 1, diff )]; + voicedBandwidth = [ voicedBandwidth; theBandwidths ]; + end + + end + end + + % get the basic formant metrics + formantFrequencyMeans = []; + formantGradientMean = []; + formantBandwidthMean = []; + + fprintf( statsFileID, '\t %s %d ', 'maxNoOfFormants', maxNoOfFormants ); + + for( formantIdx = 1:maxNoOfFormants ) + % formant position + [ metrics ] = basicMetricSet( voicedFormant(:,formantIdx), statsFileID ); + formantFrequencyMeans = [ formantFrequencyMeans metrics(1) ]; + % formant gradient + formantGradient = gradient( voicedFormant(:,formantIdx) ); + [ metrics ] = basicMetricSet( formantGradient, statsFileID ); + formantGradientMean = [formantGradientMean metrics(1)]; + % formant second derivative + formantGradient = gradient( formantGradient ); + [ metrics ] = basicMetricSet( formantGradient, statsFileID ); + % formant bandwidth + [ metrics ] = basicMetricSet( voicedBandwidth(:,formantIdx), statsFileID ); + formantBandwidthMean = [formantBandwidthMean metrics(1)]; + % formant bandwidth gradient + formantGradient = gradient( voicedBandwidth(:,formantIdx)); + [ metrics ] = basicMetricSet( formantGradient, statsFileID ); + % formant bandwidth second derivative + formantGradient = gradient( formantGradient ); + [ metrics ] = basicMetricSet( formantGradient, statsFileID ); + end + + % calculate the basic metrics set for the ... + % ... mean of all formant frequencies + meanMetrics = basicMetricSet( formantFrequencyMeans, statsFileID ); + % ... mean of all formant frequency gradients + meanMetrics = basicMetricSet( formantGradientMean, statsFileID ); + % ... mean of all formant bandwidths + meanMetrics = basicMetricSet( formantBandwidthMean, statsFileID ); +end + + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/General/readManyValuesFromFile.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,16 @@ +function [value] = readManyValuesFromFile( statsFileID, metricFileName, metricName, numberOfValuesPerFrame ) + +FileID = fopen( metricFileName ); + +if( FileID <= 0 ) %does the file exist? + % if not + message = ['WARNING: MISSING ' metricName ' FILE']; + disp( message ); + fprintf( statsFileID, '\t \s missing', metricName ); +else + + value = fscanf( FileID, '%f', inf ); + value = buffer( value, numberOfValuesPerFrame + 1 ); % numberOfValuesPerFrame data values and one frame number + value = value( 2 : numberOfValuesPerFrame+1, : )'; % remove the frame numbers + fclose( FileID ); +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/General/readValueFromFile.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,14 @@ +function [] = readValueFromFile( statsFileID, metricFileName, metricName ) + +FileID = fopen( metricFileName ); + +if( FileID <= 0 ) %does the file exist? + % if not + message = ['WARNING: MISSING ' metricName ' FILE']; + disp( message ); + fprintf( statsFileID, '\t \s missing', metricName ); +else + value = fscanf( FileID, '%f', inf ); + fprintf( statsFileID, '\t %f ', value ); + fclose( FileID ); +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/General/readValuesFromFile.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,21 @@ +function [ metrics, nanValues ] = readValuesFromFile( statsFileID, metricFileName, metricName ) + +FileID = fopen( metricFileName ); + +if( FileID <= 0 ) %does the file exist? + % if not + message = ['WARNING: MISSING ' metricName ' FILE']; + disp( message ); + fprintf( statsFileID, '\t \s missing', metricName ); + metrics=0; + nanValues=0; +else + metrics = fscanf( FileID, '%f', inf ); + % remove the frame numbers + metrics = metrics(2:2:end); + % remove all 'NaN' values + nanValues = isnan(metrics); + metrics = metrics(~(nanValues)); +% fprintf( statsFileID, '\t %f ', value ); + fclose( FileID ); +end \ No newline at end of file
--- a/Code/ProcessDatabase.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/ProcessDatabase.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,6 +1,7 @@ function [] = ProcessDatabase( databaseName, functionName, sampleStartNum, OVERWRITE ) % run from D:\Dropbox\BUPTResearch2011\EmotionDetectionCode\Code machineName = getenv('COMPUTERNAME'); +fclose('all'); switch machineName case 'LAPTOP' @@ -19,13 +20,21 @@ addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Descriptors\Matlab\Common']) addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Descriptors\Matlab\MPEG7\FromWeb']) addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Descriptors\PRAAT']) +addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Descriptors\Matlab\Speech']) +addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Descriptors\yin\']) addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\Collation']) addpath ([root 'BUPTResearch2011\emotionDetectionCode\Code\General']) switch databaseName - case 'ChineseOpera' + case 'ChineseOperaTest' cd([root 'BUPTResearch2011/Data/Opera/TestDatabase']) startEmotion = 4; + case 'ChineseOperaFull' + cd([root 'BUPTResearch2011/Data/Opera/FullDatabase']) + startEmotion = 3; + case 'ChineseOperaPaper' + cd([root 'BUPTResearch2011/Data/Opera/PaperDatabase']) + startEmotion = 3; case 'MandarinSpeech' cd([root 'BUPTResearch2011/Data/Database/EditedRecording']) startEmotion = 3; @@ -51,13 +60,14 @@ % how many emotions for that sample? validEmotionList = dir; noOfEmotions = size( validEmotionList ); - +% figure; for emotionNum = startEmotion : noOfEmotions(1) emotionName = validEmotionList(emotionNum).name; cd( emotionName ); % how many samples for that emotion? sampleNames = dir; noOfSamples = size( sampleNames ); + for sampleNumber = 3 : noOfSamples(1) if( sampleNames(sampleNumber).isdir == 0 ) % skip directories @@ -113,45 +123,65 @@ % oldDirName = newDirName; % % fclose( statsFileID ); - % case 'getPitchStatistics' - % statsHeaderFileName = '../../../../FeatureSets/singingHeaderPitchStats.txt'; - % statsHeaderFileID = fopen( statsHeaderFileName, 'w' ); - % if( firstfileOpen == 1 ) - % fprintf( statsHeaderFileID, 'name \t unvoiced to voiced frame ratio \t mean voiced pitch \t median voiced pitch \t stdev voiced pitch \t variance voiced pitch \t min voiced pitch \t max voiced pitch \t range voiced pitch \t mean voiced pitch grad \t median voiced pitch grad \t stdev pitch grad \t variance voiced pitch grad \t min voiced pitch grad \t max voiced pitch grad \t range voiced pitch grad \n'); - % firstfileOpen = 0; - % end - % fclose(statsHeaderFileID); - % - % statsFileName = '../../../../FeatureSets/singingPitchStats.txt'; - % statsFileID = fopen( statsFileName, 'a' ); - % - % [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); - % getPitchStatistics( newDirName, x, fs, statsFileID, frameLength, noOfFrames ); - % fclose( statsFileID ); - % - % - % - % - % - % %%%%%%%%%%%%%%% careful %%%%%%%%%%%%%%% - % case 'getHNRStatistics' - % statsHeaderFileName = '../../../../FeatureSets/singingHeaderHNRStats.txt'; - % statsHeaderFileID = fopen( statsHeaderFileName, 'w' ); - % if( firstfileOpen == 1 ) - % fprintf( statsHeaderFileID, 'name \t \t \t \t \t \n'); - % firstfileOpen = 0; - % end - % fclose(statsHeaderFileID); - % - % statsFileName = '../../../../FeatureSets/singingHNRStats.txt'; - % statsFileID = fopen( statsFileName, 'a' ); - % - % [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); - % getHNRStatistics( newDirName, x, fs, statsFileID, frameLength, noOfFrames ); - % fclose( statsFileID ); - % - % - % + case 'getPitchStatistics' + + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingPitchStats_Voiced.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingPitchStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingPitchStats_Voiced.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinPitchStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechPitchStats.txt'; + end + + statsFileID = fopen( statsFileName, 'a' ); + get_Pitch( newDirName, statsFileID ); + fclose( statsFileID ); + + case 'getHNRStatistics' + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingHNRStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingHNRStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingHNRStats.txt' + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinHNRStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechHNRStats.txt'; + end + + statsFileID = fopen( statsFileName, 'a' ); + get_HNR( newDirName, statsFileID ); + fclose( statsFileID ); + + case 'getEnergyStatistics' + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingEnergyStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingEnergyStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingEnergyStats.txt' + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinEnergyStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechEnergyStats.txt'; + end + statsFileID = fopen( statsFileName, 'a' ); + if( firstfileOpen == 1 ) + fprintf( statsFileID, 'name \t mean energy \t energy variance \t min \t max \t mean voiced energy \t mean unvoiced energy \n'); + firstfileOpen = 0; + end + + get_AudioPower( newDirName, statsFileID ); + fclose( statsFileID ); + % % case 'getEnergyStatistics' % statsFileName = '../../../../FeatureSets/singingEnergyStats.txt'; @@ -235,26 +265,46 @@ % % getSpectralTimbralDescriptors( newDirName, statsFileID ); % fclose( statsFileID ); - % case 'getMFCCs' - % if( firstfileOpen ) - % statsFileName = '../../../../FeatureSets/singingMFCCDescriptorsHeader.txt'; - % statsFileID = fopen( statsFileName, 'w' ); - % - % % Add a header file - % % putMFCCHeader( statsFileID ); - % fclose( statsFileID ); - % end - % - % statsFileName = '../../../../FeatureSets/singingMFCCDescriptors.txt'; - % statsFileID = fopen( statsFileName, 'a' ); - % - % getMFCCStatistics( newDirName, statsFileID ); - % fclose( statsFileID ); - % - % %lin + case 'getMFCCs' + + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingMFCCStats_VoicedAndUnvoiced_Unsmoothed.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingMFCCStats_VoicedAndUnvoiced_Unsmoothed.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingMFCCStats.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinMFCCStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechMFCCStats.txt'; + end + + if( firstfileOpen == 1 ) + statsFileID = fopen( statsFileName, 'w' ); + firstfileOpen = 0; + else + statsFileID = fopen( statsFileName, 'a' ); + end + + get_MFCCS( newDirName, statsFileID ); + fclose( statsFileID ); + + case 'getPRAAT' - % collate all Shimmer values - statsFileName = '../../../../../../../TestResults/singingPRAATStats.txt'; + % collate all PRAAT values + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingPRAATStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingPRAATStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingPRAATStats.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinPRAATStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechPRAATStats.txt'; + end % Add a header row if( firstfileOpen == 1 ) @@ -278,15 +328,99 @@ get_PRAAT( newDirName, statsFileID ); fclose( statsFileID ); - % case 'getJitter' - % % collate Jitter - % statsFileName = '../../../../FeatureSets/singingJitterStats.txt'; - % statsFileID = fopen( statsFileName, 'a' ); - % - % getJitter( newDirName, statsFileID ); - % fclose( statsFileID ); - % - % + case 'getJitter' + % collate all Jitter values + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingJitterStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingJitterStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingJitterStats.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinJitterStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechJitterStats.txt'; + end + + % Add a header row + if( firstfileOpen == 1 ) + statsFileID = fopen( statsFileName, 'w' ); + fprintf( statsFileID, 'Metrics calculated using the PRAAT software. \n' ); + fprintf( statsFileID, ' name \t JITTER: ddp \t local \t ppq5 \t rap \n'); + firstfileOpen = 0; + else + statsFileID = fopen( statsFileName, 'a' ); + end + + get_Jitter( newDirName, statsFileID ); + fclose( statsFileID ); + + case 'getShimmer' + % collate all Shimmer values + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingShimmerStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingShimmerStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingShimmerStats.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinShimmerStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechShimmerStats.txt'; + end + + % Add a header row + if( firstfileOpen == 1 ) + statsFileID = fopen( statsFileName, 'w' ); + fprintf( statsFileID, 'Metrics calculated using the PRAAT software. \n' ); + fprintf( statsFileID, ' name \t SHIMMER: local \t dda \t apq3 \t apq5 \t apq11 \n'); + firstfileOpen = 0; + else + statsFileID = fopen( statsFileName, 'a' ); + end + + get_Shimmer( newDirName, statsFileID ); + fclose( statsFileID ); + + case 'getFormants' + % collate all Formants values + switch databaseName + case 'ChineseOperaTest' + statsFileName = '../../../../../../../TestResults/test_singingFormantsStats.txt'; + case 'ChineseOperaFull' + statsFileName = '../../../../../../../TestResults/full_singingFormantsStats.txt'; + case 'ChineseOperaPaper' + statsFileName = '../../../../../../../TestResults/paper_singingFormantsStats.txt'; + case 'MandarinSpeech' + statsFileName = '../../../../../../../TestResults/mandarinFormantsStats.txt'; + case 'SpeechTestFiles' + statsFileName = '../../../../../../../TestResults/speechFormantsStats.txt'; + end + + % Add a header row + if( firstfileOpen == 1 ) + statsFileID = fopen( statsFileName, 'w' ); + fprintf( statsFileID, 'Metrics calculated using the PRAAT software. \n' ); + fprintf( statsFileID, 'For each of the BURG FORMANTS: numberOfFormants \t meanFrequency \t varFrequency \t minFrequency \t maxFrequency \n'); + fprintf( statsFileID, 'meanFrequencyDerivative \t varienceFrequencyDerivative \t minFrequencyDerivative \t max FrequencyDerivative \n'); + fprintf( statsFileID, 'meanFrequency2ndDerivative \t varienceFrequency2ndDerivative \t minFrequency2ndDerivative \t max Frequency2ndDerivative \n'); + fprintf( statsFileID, 'meanBandwidth \t varBandwidth \t minBandwidth \t maxBandwidth \n'); + fprintf( statsFileID, 'meanBandwidthDerivative \t varBandwidthDerivative \t minBandwidthDerivative \t maxBandwidthDerivative \n'); + fprintf( statsFileID, 'meanBandwidth2ndDerivative \t varBandwidth2ndDerivative \t minBandwidth2ndDerivative \t maxBandwidth2ndDerivative \n'); + fprintf( statsFileID, 'For the mean of all three formants: meanFrequency \t varFrequency \t minFrequency \t maxFrequency \n'); + fprintf( statsFileID, 'meanFrequencyDerivative \t varienceFrequencyDerivative \t minFrequencyDerivative \t max FrequencyDerivative \n'); + fprintf( statsFileID, 'meanFrequency2ndDerivative \t varienceFrequency2ndDerivative \t minFrequency2ndDerivative \t max Frequency2ndDerivative \n'); + firstfileOpen = 0; + else + statsFileID = fopen( statsFileName, 'a' ); + end + + get_Formants( newDirName, statsFileID ); + fclose( statsFileID ) + + % % %%%%% get all the pitch and energy related features @@ -322,7 +456,7 @@ detect_pitch( currentSampleName, OVERWRITE ); case 'calculateSilence' - detect_silence( currentSampleName, OVERWRITE ); + detect_Silence( currentSampleName, OVERWRITE ); case 'calculateVUV' % find the voiced and unvoiced frames using @@ -350,9 +484,7 @@ % ASB_ASP_Detection( currentSampleName, x, fs, frameLength, noOfFrames ); % case 'calculateAudioPower' - -% [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); - detect_AudioPower( currentSampleName, x, fs, frameLength, noOfFrames ); + detect_AudioPower( currentSampleName, OVERWRITE ); % % case 'calculateLogAttackTIme' % [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); @@ -378,15 +510,13 @@ % [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); % spectralTimbralDescriptors( currentSampleName, x, fs, frameLength, noOfFrames ); - case 'calculateAudioSpectrumFlatness' +% case 'calculateAudioSpectrumFlatness' +% +% [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); +% AudioSpectralFlatness_Detection( currentSampleName, x, fs, frameLength, noOfFrames ); - [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); - AudioSpectralFlatness_Detection( currentSampleName, x, fs, frameLength, noOfFrames ); - - % case 'calculateMFCCs' - % - % [x, fs, frameLength, noOfFrames] = openFile( currentSampleName ); - % MFCC_Detection( currentSampleName, x, fs, frameLength, noOfFrames ); + case 'calculateMFCCs' + detect_MFCC( currentSampleName, OVERWRITE ); % % case 'calculatesampleDependantThresholds' %
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Test/formantPlotter.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,22 @@ + +timeShift = length(formants) / length(vuv); + +for( idx = 1: length( formants ) ) + frameIdx = floor( idx / timeShift ) + 1; + if( vuv( frameIdx ) == 0 ) + % frame is silent + plot( formants( idx,2 ), 'w.' ); + plot( formants( idx,3 ), 'w.' ); + plot( formants( idx,4 ), 'w.' ); + elseif( vuv( frameIdx ) == 1 ) + % frame is voiced + plot( formants( idx,2 ), 'y.' ); + plot( formants( idx,3 ), 'c.' ); + plot( formants( idx,4 ), 'g.' ); + else + %frame is unvoiced + plot( formants( idx,2 ), 'r.' ); + plot( formants( idx,3 ), 'r.' ); + plot( formants( idx,4 ), 'r.' ); + end +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Test/formant_tracker.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,116 @@ +function[formant]=formant_tracker(input,dimension,step,window_size,p,threshold) +% %Formant_tracker based on LPC Analysis +% format:[formants]=formant_tracker(input,dimension,step,window_size,p,threshold) +% where, +% input:input speech waveform; +% dimension:input size, in number of samples. +% step:step size , in number of samples; +% window_size: frame/window size, in number of samples; +% p: number of LP coeffcients; +% threshold: the threshold value for pole magnitude.Poles having higher magnitude are candidates for being formant +% frequencies. +% +% Author:Narsimh Kamath. +% NITK, India.Thanks! +num=1; +dimension-window_size; + +for i=1:step:(dimension/50)-window_size + + frame=input(num*step-window_size/2:num*step+window_size/2); + + + +for k=1:p+1 + autocorrelation(k)=0; + for l=1:window_size-k + autocorrelation(k)=autocorrelation(k)+frame(l)*frame(l+k-1); + end + autocorrelation(k)=autocorrelation(k)/window_size; +end + +t=window_size/2; +for k=20:t + acf(k)=0; + for l=1:window_size-k + acf(k)=acf(k)+frame(l)*frame(l+k-1); + end + acf(k)=acf(k)/window_size; +end +[rr,ii]=max(acf(10:t)); +tp=10000/ii; + +alpha=zeros(p,p); +a=zeros(p,1); +E=zeros(p,1); +E(1)=autocorrelation(1); +for i=1:p + sum=0; + for j=1:i-1 + if(i)>1 + sum=sum+alpha(j,(i-1))*autocorrelation(abs(i-j)+1); + end + end + + k(i)=(autocorrelation(i+1)-sum)/E(i); + alpha(i,i)=k(i); + if i>1 + for j=1:i-1 + alpha(j,i)=alpha(j,i-1)-k(i)*alpha(i-j,i-1); + end + end + E(i+1)=(1-k(i)^2)*E(i); + var=E(i+1); + end + for j=1:p + a(j)=alpha(j,p); + end + f=[1 -a']; + gain=0; + p; + for i =1:p+1 + gain=gain+f(i)*autocorrelation(i); + end + gain; + gain=gain^0.5; + + +root1=roots([1,-a']); + + mag_root=abs(root1); + arg_root=angle(root1); + my_roots(:,num) = mag_root(:); +% if( max(frame) > 0.001 ) +% subplot(311); plot(frame); +% subplot(312); plot(abs(fft(frame))); +% subplot(313); plot(mag_root); +% end + k=1; + for j=1:p + if mag_root(j)>threshold + if arg_root(j)>0 &arg_root(j)<pi + formant(num,k)=arg_root(j)/pi*5000; + + num; + k; + k=k+1; + end + end + end + + + num=num+1; +end + s=size(formant); + for i=1:length(formant) + for j=1:s(2) + if formant(i,j)==0 + formant(i,j)=NaN; + end + end + end + + plot(formant,'.b'); + return; +end + \ No newline at end of file
--- a/Code/Test/plotAudioFrameByType.m Mon Sep 10 09:20:12 2012 +0100 +++ b/Code/Test/plotAudioFrameByType.m Wed Feb 13 11:02:39 2013 +0000 @@ -1,17 +1,40 @@ function plotAudioFrameByType( x, noOfValidFrames, vuv, frameLength ); +values = unique( vuv ); -hold on + +figure(1); hold off; + for frameIdx = 1:noOfValidFrames startPoint = ((frameIdx-1) * frameLength)+1; endPoint = frameIdx * frameLength; -% if( vuv( frameIdx ) == 0 ) %silent -% plot( startPoint : endPoint , x( startPoint : endPoint ), 'w' ); - if( vuv( frameIdx ) == 1 ) % voiced - plot( startPoint : endPoint , x( startPoint : endPoint ), 'y' ); - elseif( vuv( frameIdx ) == 2 ) %unvoiced - plot( startPoint : endPoint , x( startPoint : endPoint ) , 'r' ); + xTicks = frameIdx : 1/frameLength : (frameIdx+1)-(1/frameLength); + + if( length( values) == 2 ) + type1 = values(1); + type2 = values(2); + if( vuv( frameIdx ) == type1 ) % voiced + % plot( startPoint : endPoint , x( startPoint : endPoint ), 'y' ); + plot( xTicks , x( startPoint : endPoint ), 'y' );hold on + elseif( vuv( frameIdx ) == type2 ) %unvoiced + % plot( startPoint : endPoint , x( startPoint : endPoint ) , 'r' ); + plot( xTicks , x( startPoint : endPoint ) , 'r' );hold on + end + elseif( length( values) == 3 ) + type1 = values(1); + type2 = values(2); + type3 = values(3); + if( vuv( frameIdx ) == type1 ) % voiced + % plot( startPoint : endPoint , x( startPoint : endPoint ), 'y' ); + plot( xTicks , x( startPoint : endPoint ), 'y' );hold on + elseif( vuv( frameIdx ) == type2 ) %unvoiced + % plot( startPoint : endPoint , x( startPoint : endPoint ) , 'r' ); + plot( xTicks , x( startPoint : endPoint ) , 'g' );hold on + elseif( vuv( frameIdx ) == type3 ) %unvoiced + % plot( startPoint : endPoint , x( startPoint : endPoint ) , 'r' ); + plot( xTicks , x( startPoint : endPoint ) , 'r' );hold on + end end end hold off \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Test/plotColourSignal.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,12 @@ +function [] = plotColourSignal( x, frameLength, noOfFrames, values ) + +figure(1); +hold off; +j=1; +for( i=1: frameLength+1 : noOfFrames * frameLength ) + if( values(j) == 0 ) + plot( [i i+frameLength], x(i:i+frameLength), 'r' ); + elseif( values(j) == 1 ) + plot( [i i+frameLength], x(i:i+frameLength), 'g' ); + end +end \ No newline at end of file