#this scripts gives the statistical mode F0-value in Hertz or Semitones #You will get a histogramlike scatterplot showing a frequency-based #distribution of all measured F0-values ######Version 0.2.2##########04/01/2008####################################### ######For comments please contact me : grawunder_AT_eva.mpg.de############## ############################################################################ form F0 histogram comment Clean Viewport? Title? Grid? Mode value? boolean erase_all 1 boolean title 1 boolean frame 1 boolean mode_value 1 comment Oriantation of the plot choice Ordinate: 2 button count&semit button semit&count choice F0_unit: 2 button Hertz button Semitones comment You may set: "x" or "+" or "o" or "." word mark o comment What steps shall be on the axes? integer vertical_increment 2 integer horizontal_increment 2 endform select all name$ = selected$("Sound") select Sound 'name$' tmin = Get start time tmax = Get end time To Pitch... 0.01 75 300 #To Pitch (ac)... 0 75 15 no 0.03 0.45 0.01 0.35 0.14 600 Rename... pitch rounds=round ((tmax-tmin)/0.01) Create Table with column names... table rounds time semit count #echo Results: a=0 for i to (tmax-tmin)/0.01 time = tmin + i * 0.01 select Pitch pitch if f0_unit=1 pitch = Get value at time... time Hertz Linear elif f0_unit=2 pitch = Get value at time... time "semitones re 100 Hz" Linear endif if not pitch = undefined a=a+1 select Table table Set numeric value... a time time Set numeric value... a semit 'pitch:1' Set numeric value... a count 1 endif endfor ##these lines are necessary because Table table containes also ? ? values select Table table Extract rows where column (number)... count "equal to" 1 ##calculate mode select Table table__count__1 Collapse rows... semit count "" "" "" select Table table__count__1_pooled nrrows = Get number of rows mod=Get quantile... count 0.75 for y from 1 to nrrows co=Get value... y count if 'co' > 'mod' mod='co' else endif endfor rmodal=Search column... count 'mod' modal=Get value... 'rmodal' semit if erase_all=1 Erase all else endif #the scripts plots on the selected viewport, otherwise activate the following line #Select outer viewport... 0 6 0 6 if frame=1 frame$="yes" else frame$="no" endif if f0_unit=1 pitch_title$="F0 (in Hz)" elif f0_unit=2 pitch_title$="F0 (in semitones re 100Hz)" endif if ordinate=1 Scatter plot (mark)... count 0 0 semit 0 0 1 frame$ 'mark$' Text left... yes 'pitch_title$' Text bottom... yes frequency (counts) else Scatter plot (mark)... semit 0 0 count 0 0 1 frame$ 'mark$' Text bottom... yes 'pitch_title$' Text left... yes frequency (counts) endif if title=1 Text top... yes 'name$' else endif if mode_value=1 if f0_unit=2 Text top... no mode='modal'st elif f0_unit=1 Text top... no mode='modal'Hz endif else endif if frame=1 Draw inner box else endif # Marks bottom every... 1 horizontal_increment yes yes yes Marks left every... 1 vertical_increment yes yes yes ############################MPI EVA Leipzig, Sven Grawunder#########################