########################################################
#                                                               
# NAME: lst2f0.pscn                               
#                                                               
# INPUT: - list of filenames; the filenames in the list don't have an extension.
#        - for each item in list sound file.   
#                                                                                                                
# USAGE/COMMENTS:                                                                                                    
# This script carries out all the repetitive actions involved in the checking 
# of F0 tracks. The scripts calculates the Pitch object , and then writes the 
# Pitch object to a file. Batch processing using file list. 
#                                                               
# BY:   Bert Remijsen  (changed by hannover@csd.uoc.gr)                                         
# LAST CHANGE: 26/07/2006                                             
#                                                                                                          
########################################################

form Make and check Pitch objects for batch
comment filename of inputlist (without extension .txt):
text listfile files
comment list and files are located in dir:
text inputdir /home/hannover/Documents/enterface/CMU-ARCTIC/cmu_us_awb_arctic/wav/wav
comment output files are written to input dir.
comment Minimum and maximum of range within which F0 is detected:
positive left_range 75
positive right_range 350
comment Get an F0 measurement every (s):
positive step 0.0125
comment The section of the F0 track between the end of interval
comment one and the start of the last interval is plotted to the 
comment Picture window.
endform

Read Strings from raw text file... 'inputdir$'/'listfile$'.txt
end = Get number of strings

for fileteller from 1 to 'end'
  select Strings 'listfile$'
  file$ = Get string... 'fileteller'
  echo Processing 'file$', file 'fileteller' out of a total of 'end' 
  Read from file... 'inputdir$'/'file$'.wav
  To Pitch... 'step' 'left_range' 'right_range'
  Erase all
  Viewport... 0 12 0 8
  select Sound 'file$'
  Erase all
  select Pitch 'file$'
  Write to text file... 'inputdir$'/'file$'.Pitch
  select Sound 'file$'
  plus Pitch 'file$'
  Remove
endfor

