#This script was used to analyze defensive calls in Common ravens as referred to #in Szipl G., Ringler E., Spreafico M. & T. Bugnyar (2017): "Calls during agonistic #interactions vary with arousal and raise audience attention in ravens" #in "Frontier in Zoology" directory$ = "/Users/…" outputdirectory$ = "/Users/…" resultfile$ = directory$ + "output.txt" if fileReadable (resultfile$) pause The result file already exists! Do you want to overwrite it? deleteFile (resultfile$) endif titleline$ = "Filename duration (s) tonality mean_fo (Hz) max_fo (Hz) min_fo (Hz) max_fo_T (%) min_fo_T (%) range_fo (Hz) jitter inflex fosumvar start_fo (Hz) end_fo (Hz) harmonicity (dB) mean_AMP (dB) min_AMP (dB) min_AMP_T (%) max_AMP (dB) max_AMP_T (%) varAMP (dB/s)" appendFileLine: "'resultfile$'", "'titleline$'" Create Strings as file list: "fileList", directory$ + "*.wav" numberOfFiles = Get number of strings for ifile to numberOfFiles selectObject: "Strings fileList" filename$ = Get string: ifile Read from file: directory$ + filename$ soundname$ = selected$ ("Sound", 1) duration = Get total duration Filter (stop Hann band): 0, 80, 1 Rename: "Sound" To Pitch (cc): 0.01, 75, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14, 700 Rename: "Pitch" frames = Get number of frames voiced = Count voiced frames tonality = voiced/frames*100 Edit pause Smooth: 25 Interpolate Rename: "Pitch_Interpolated" mean_fo = Get mean: 0, 0, "Hertz" min_fo = Get minimum: 0, 0, "Hertz", "Parabolic" min_fo_t = Get time of minimum: 0, 0, "Hertz", "Parabolic" min_fo_T = min_fo_t/duration*100 max_fo = Get maximum: 0, 0, "Hertz", "Parabolic" max_fo_t = Get time of maximum: 0, 0, "Hertz", "Parabolic" max_fo_T = max_fo_t/duration*100 range_fo = max_fo - min_fo selectObject: "Sound Sound" plusObject: "Pitch Pitch_Interpolated" To PointProcess (cc) jitter = Get jitter (local): 0, 0, 0.0001, 0.02, 1.3 clearinfo selectObject: "Pitch Pitch_Interpolated" numberOfFrames = Get number of frames inflex_asc = 0 inflex_desc = 0 row = 0 variation = 0 f1_var = 0 i1_var = 0 Create TableOfReal: "voiced_fo", 1, 2 Set column label (index): 1, "frame_no" Set column label (index): 2, "fo" selectObject: "Pitch Pitch_Interpolated" for iframe to numberOfFrames-1 fo_frame = Get value in frame: iframe, "Hertz" fo_frame_bef = Get value in frame: iframe-1, "Hertz" fo_frame_aft = Get value in frame: iframe+1, "Hertz" if fo_frame <> undefined and fo_frame_bef <> undefined and fo_frame_aft <> undefined if fo_frame_aft > fo_frame and fo_frame <= fo_frame_bef inflex_asc +=1 elsif fo_frame_aft < fo_frame and fo_frame >= fo_frame_bef inflex_desc +=1 endif variation += abs(fo_frame_aft - fo_frame) row += 1 selectObject: "TableOfReal voiced_fo" Insert row (index)... row Set value... row 2 row Set value... row 2 fo_frame selectObject: "Pitch Pitch_Interpolated" endif endfor inflex = (inflex_asc + inflex_desc)/duration fosumvar = abs(variation)/duration selectObject: "TableOfReal voiced_fo" nrow = Get number of rows Remove row (index)... nrow start_fo = Get value... 1 2 end_fo = Get value... nrow-1 2 selectObject: "Sound Sound" To Harmonicity (cc): 0.01, 75, 0.1, 1 harmonicity = Get mean: 0, 0 selectObject: "Sound Sound" To Intensity: 75, 0, "yes" mean_AMP = Get mean: 0, 0, "energy" min_AMP = Get minimum: 0, 0, "Parabolic" min_AMP_t = Get time of minimum: 0, 0, "Parabolic" min_AMP_T = min_AMP_t/duration*100 max_AMP = Get maximum: 0, 0, "Parabolic" max_AMP_t = Get time of maximum: 0, 0, "Parabolic" max_AMP_T = max_AMP_t/duration*100 Down to IntensityTier Down to TableOfReal endif nrow = Get number of rows for irow to nrow-1 i1 = Get value: irow, 2 i1_aft = Get value: irow+1, 2 i1_var += abs(i1_aft - i1) endfor varAMP = abs(i1_var)/duration resultline$ = "'filename$' 'duration:3' 'tonality:2' 'mean_fo:2' 'max_fo:2' 'min_fo:2' 'max_fo_T:2' 'min_fo_T:2' 'range_fo:2' 'jitter:2' 'inflex:2' 'fosumvar:2' 'start_fo:2' 'end_fo:2' 'harmonicity:2' 'mean_AMP:2' 'min_AMP:2' 'min_AMP_T:2' 'max_AMP:2' 'max_AMP_T:2' 'varAMP:2'" appendFileLine: "'resultfile$'", "'resultline$'" select all minus Strings fileList Remove endif endfor