############################################################ # 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 # Automatically creates a subfolder with the same filename as the input wav file # Version 4: Lets you make detailed selections ############################################################ # Get the user input form Select files and parameters comment Add some more options? word fileToProcess_(without_extension) soundfile comment A subfolder with the name of the sound file will be created natural numOfExtraction 5 choice windowType 2 button Parabolic button Rectangular button Gaussian1 button Hamming choice directionToExtract 1 button To the RIGHT button To the LEFT endform # real stepOfGate 0.02 # Assign relevant strings to the variable of window shape if windowType = 1 windType$ = "Parabolic" elsif windowType = 2 windType$ = "Rectangular" elsif windowType = 3 windType$ = "Gaussian1" else windType$ = "Hamming" endif 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 newBeginSel = beginSel endSel = Get end of selection newEndSel = endSel # Depending on the direction of the extraction # Move the end of the selection rightward by the step specified in the beginning if directionToExtract = 1 viewBegin = beginSel - 0.02 for i to numOfExtraction newEndSel = Get end of selection Select... newBeginSel newEndSel Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing viewEnd = newEndSel + 0.05 Zoom... viewBegin viewEnd Select... newBeginSel newEndSel Play... newBeginSel newEndSel Extract windowed selection... 'i' 'windType$' 1 yes pause Select next end endfor # Otherwise, move the beginning of the selection leftward else viewEnd = endSel + 0.02 for i to numOfExtraction newBeginSel = Get begin of selection Select... newBeginSel newEndSel Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing viewBegin = newBeginSel - 0.05 Zoom... viewBegin viewEnd Select... newBeginSel newEndSel Play... newBeginSel newEndSel Extract windowed selection... 'i' 'windType$' 1 yes pause Select next beginning endfor endif # Close the Editor window Close endeditor # Create the subdirectory system mkdir 'fileToProcess$' # Write the extracted files with appropriate filenames for iFile to numOfExtraction select Sound 'iFile' if directionToExtract = 1 Write to WAV file... 'fileToProcess$'\'fileToProcess$'--to-the-right--'iFile'.wav else Write to WAV file... 'fileToProcess$'\'fileToProcess$'--to-the-left--'iFile'.wav endif endfor ############# END OF SCRIPT ################