F0Statistics

form F0 statistics
        sentence Path /home/user/
        word Extension *.wav
        natural Pitch_floor_(Hz) 75
        natural Pitch_ceiling_(Hz) 600
endform

clearinfo
if right$(path$,1) != "/"
        path$=path$+"/"
endif

searchPattern$=path$+extension$

fl=Create Strings as file list: "fileList", searchPattern$
nStr=Get number of strings

clearinfo
writeInfoLine: "Path: ", path$
appendInfoLine: "Extension: ", extension$

writeInfoLine: newline$,"-----------------------------"
appendInfoLine: "file,f0min,f0max,f0mean,f0std"

for i from 1 to nStr
        select 'fl'
        current$=Get string: i
        filename$=path$+current$
        s1=Read from file... 'filename$'
        #tmp1 = i mod 100
        #tmp2 = tmp1+10
        #if tmp2=10
        #       p1=To Pitch: 0, pitch_floor, pitch_ceiling
        #else
                p1=noprogress To Pitch: 0, pitch_floor, pitch_ceiling
        #endif

        minp=Get minimum: 0, 0, "Hertz", "Parabolic"
        maxp=Get maximum: 0, 0, "Hertz", "Parabolic"
        mean=Get mean: 0, 0, "Hertz"
        std=Get standard deviation: 0, 0, "Hertz"

        appendInfoLine: current$,",",'minp:0',",",'maxp:0',",",'mean:3',",",'std:3'

        plus 's1'
        Remove
endfor

select 'fl'
Remove