# Concatenate pairs of sound files with pause according to file names in tab-separated text file # # For each pair of sound files, file names must be listed in order # in 1st 2 columns (minus '.wav'), with 3rd column as name for final concatenated file # **Table must have header row, although names are irrelevant** # # ***Make sure you don't have any spaces in your file paths*** # (i.e. don't use folders with spaces in the name, and make sure there are no extra spaces at the end) # # Useful for AX experiments # # Author: Danielle Daidone 4/27/17 #################################################### form Concatenate sound pairs from table comment Give the directory of the sound files: sentence soundDir C:\Users\ddaidone\Desktop\Test\ comment Give the directory where concatenated sound files will be saved: sentence saveDir C:\Users\ddaidone\Desktop\Test\ comment Give the name of the tab-separated input text file: word inputTable C:\Users\ddaidone\Desktop\Test\Table1.txt comment Specify the silence duration in seconds: positive silenceDur 0.5 endform # remove any objects open in object window select all numberOfSelectedObjects = numberOfSelected () if numberOfSelectedObjects > 0 Remove endif # read in table; first row will be treated as headers Read Table from tab-separated file... 'inputTable$' Rename... table select Table table # get number of rows in table numRows = Get number of rows for i to numRows # get names of sound files and name of final concatenated file filename1$ = Table_table$ [i, 1] filename2$ = Table_table$ [i, 2] concatname$ = Table_table$ [i, 3] # open 1st sound file Read from file... 'soundDir$''filename1$'.wav #get sampling frequency of sound and create silence based on that sampling_freq = Get sampling frequency silence$ = Create Sound from formula... silence Mono 0 silenceDur sampling_freq 0 silenceOne$=selected$("Sound") # open 2nd sound file Read from file... 'soundDir$''filename2$'.wav # now concatenate both sound files with pause in between select all minus Table table Concatenate # save concatenated sounds to wav file Write to WAV file... 'saveDir$''concatname$'.wav select all minus Table table Remove endfor select all Remove writeInfoLine: "Files successfully created!"