#! Praat script p2/listeners/analyse_and_draw.praat # # Paul Boersma, April 29, 2001 # form Analyse and draw listeners choice Which: 1 button Scottish button Southern English (Edinburgh) button Southern English (Reading) button Southern English (all) button Spanish button selected endform page = 0 if which$ = "selected" name1$ = selected$ ("Matrix") subjects = 1 call drawOne 1 'name1$' exit endif abbreviation$ = if which = 1 then "scot" else if which = 2 then "seng" else if which = 3 then "seng2" ... else if which = 4 then "seng3" else "span" fi fi fi fi Read from file... data_'abbreviation$'.txt subjects = numberOfSelected ("Matrix") for subject to subjects name'subject'$ = selected$ ("Matrix", subject) endfor Create TableOfReal... table subjects 2 Set column label (index)... 1 F1 Set column label (index)... 2 duration for subject to subjects name$ = name'subject'$ call drawOne subject 'name$' select TableOfReal table Set row label (index)... subject 'name$' endfor select Matrix 'name1$' Copy... average for subject from 2 to subjects name$ = name'subject'$ Formula... self + Matrix_'name$' [] endfor Formula... self / 'subjects' call drawOne subject average if which$ = "Spanish" Rename... average26 Formula... (30 * self - Matrix_dmc [] - Matrix_ir [] - Matrix_jr [] - Matrix_mw []) / 26 subjects = 26 call drawOne 32 average26 Rename... average21 Formula... (26 * self - Matrix_cc [] - Matrix_ct [] - Matrix_lchr [] - Matrix_lg [] ... - Matrix_mc []) / 21 subjects = 21 call drawOne 33 average21 endif ;Remove Viewport... 0 6 0 8 Write to fontless EPS file... 'abbreviation$''page'.eps select TableOfReal table if which$ = "Spanish" row = Get row index... dmc Remove row (index)... row row = Get row index... ir Remove row (index)... row row = Get row index... jr Remove row (index)... row row = Get row index... mw Remove row (index)... row subjects = Get number of rows endif Write to text file... reliances_'abbreviation$'.TableOfReal procedure drawOne number name$ if number mod 12 = 1 if page > 0 Viewport... 0 6 0 8 Write to fontless EPS file... 'abbreviation$''page'.eps endif Erase all page = page + 1 endif Times 10 select Matrix 'name$' if 1; subjects >= 2 position = (number - 1) mod 12 + 1 x = (position - 1) mod 3 y = (position - 1) div 3 Viewport... x*2 x*2+2 y*2 y*2+1.65 endif Axes... 1 7 1 7 for row to 7 for col to 7 m'row''col' = Get value in cell... row col endfor endfor # For drawing, the unmeasured cells are filled with interpolated values # There are four cells that are interpolated from their four neigbours. call interpolate4 2 3 call interpolate4 3 2 call interpolate4 5 6 call interpolate4 6 5 # There are eight cells that are interpolated from 12 neighbours. call interpolate12 3 5 call interpolate12 6 2 Paint contours... 0 0 0 0 0 10 Draw one contour... 0 0 0 0 5 Draw inner box if subjects <> 1 Text top... yes ##'number' 'name$' endif # Compute cue reliances. durationReliance = 0 for row to 7 short = Get value in cell... row 1 long = Get value in cell... row 7 durationReliance = durationReliance + (long - short) / 10 endfor durationReliance = durationReliance / 7 durationReliance$ = fixed$ (durationReliance * 100, 1) spectralReliance = 0 for col to 7 lax = Get value in cell... 1 col tense = Get value in cell... 7 col spectralReliance = spectralReliance + (tense - lax) / 10 endfor spectralReliance = spectralReliance / 7 spectralReliance$ = fixed$ (spectralReliance * 100, 1) Text bottom... no Dur. (ms) Text top... no dur.rel. 'durationReliance$'\% Text left... no %F_1 (Hz) Text right... no spec.rel. 'spectralReliance$'\% One mark bottom... 1 no yes no 83 One mark bottom... 7 no yes no 177 One mark left... 1 no yes no 480 One mark left... 7 no yes no 344 if subjects = 1 Viewport... 0 1.75 0.2 1.65 else Viewport... 0 1.7 0 1.65 endif if number <= subjects select TableOfReal table Set value... number 1 spectralReliance Set value... number 2 durationReliance endif endproc procedure interpolate4 row col Formula... arcsin (sqrt (self/10)) top = Get value in cell... row+1 col bottom = Get value in cell... row-1 col left = Get value in cell... row col-1 right = Get value in cell... row col+1 Set value... row col (top+bottom+left+right)/4 Formula... 10 * sin (self) ^ 2 endproc procedure interpolate12 row col Formula... arcsin (sqrt (self/10)) topleft = Get value in cell... row+1 col-1 topright = Get value in cell... row+1 col+2 bottomleft = Get value in cell... row-2 col-1 bottomright = Get value in cell... row-2 col+2 top1 = Get value in cell... row+1 col top2 = Get value in cell... row+1 col+1 left1 = Get value in cell... row-1 col-1 left2 = Get value in cell... row col-1 right1 = Get value in cell... row-1 col+2 right2 = Get value in cell... row col+2 bottom1 = Get value in cell... row-2 col bottom2 = Get value in cell... row-2 col+1 if 1 Set value... row col (4*topleft+6*top1+4*top2+2*topright ...+6*left2+3*right2+4*left1+2*right1 ...+2*bottomleft+3*bottom1+2*bottom2+1*bottomright)/39 Set value... row col+1 (2*topleft+4*top1+6*top2+4*topright ...+3*left2+6*right2+2*left1+4*right1 ...+1*bottomleft+2*bottom1+3*bottom2+2*bottomright)/39 Set value... row-1 col (2*topleft+3*top1+2*top2+1*topright ...+4*left2+2*right2+6*left1+3*right1 ...+4*bottomleft+6*bottom1+4*bottom2+2*bottomright)/39 Set value... row-1 col+1 (1*topleft+2*top1+3*top2+2*topright ...+2*left2+4*right2+3*left1+6*right1 ...+2*bottomleft+4*bottom1+6*bottom2+4*bottomright)/39 else Set value... row col (2*top1+2*left2+right2+bottom1)/6 Set value... row col+1 (2*top2+left2+2*right2+bottom2)/6 Set value... row-1 col (top1+2*left1+right1+2*bottom1)/6 Set value... row-1 col+1 (top2+left1+2*right1+2*bottom2)/6 endif Formula... 10 * sin (self) ^ 2 endproc