############################################################ # File extractor for gating experiments # Written by Kyuchul Yoon (kyoon@ling.osu.edu) # When prompted for selection, user select a section, the direction of extraction # and the number and interval of extraction # The script outputs file extractions as filename-##.wav where ## indicates numbers # Window types: Rectangular, Parabolic, Gaussian1, Hamming ############################################################ # Get the user input form Select files and parameters comment Add some more options? word fileToProcess_(without_extension) soundfile word subFolderToCreate gating.stimuli real stepOfGate 0.01 natural numOfExtraction 5 word windType Parabolic choice directionToExtract 1 button To the RIGHT button To the LEFT endform Read from file... 'fileToProcess$'.wav Rename... masterFile # Show the Editor window for user selection select Sound masterFile Edit editor Sound masterFile pause Select the interval # Remember the begin and end of the selection beginSel = Get begin of selection endSel = Get end of selection # Depending on the direction of the extraction # Move the end of the selection rightward by the step specified in the beginning if directionToExtract = 1 for i to numOfExtraction Select... beginSel endSel Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing Play... beginSel endSel Extract windowed selection... 'i' 'windType$' 1 yes endSel = endSel + stepOfGate endfor # Otherwise, move the beginning of the selection leftward else for i to numOfExtraction Select... beginSel endSel Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing Play... beginSel endSel Extract windowed selection... 'i' 'windType$' 1 yes beginSel = beginSel - stepOfGate endfor endif # Close the Editor window Close endeditor # Create the subdirectory system mkdir 'subFolderToCreate$' # Write the extracted files with appropriate filenames for iFile to numOfExtraction select Sound 'iFile' if directionToExtract = 1 Write to WAV file... 'subFolderToCreate$'\'fileToProcess$'--to-the-right--'iFile'.wav else Write to WAV file... 'subFolderToCreate$'\'fileToProcess$'--to-the-left--'iFile'.wav endif endfor ############# END OF SCRIPT ################