#Cross-splicing script with for two sounds with #associated TextGrids written by Holger Mitterer #In order to run the script, be sure that two sounds #are selected beforehand, and the two textgrids for #these sounds are in the list as will. #Both TextGrids have two contain (at least) two intervals #The script takes the second interval from the first sound #in the list and splices it after the first interval of the #second sound. #There are three control parameters that can be adjusted in the form #1. Word: this is how the name of the spliced sound starts #2. window: In the time around the splicing point specified # by this parameter, the sounds are cross-faded, # i.e., the first sound is faded out and the second one # faded in. Set to zero for classic cross-splicing #3. AdjustAmplitude: If on, the script adjust the maximum amplitude # of both sounds to the same value form adjust amplitude word name_(start_of_the_spliced_sound's_name) spliced real window_(cross_fading_window_at_splice_point) 0.02 boolean AdjustAmplitude 1 endform if numberOfSelected("Sound") <>2 exit You have to select two sounds!! endif one = selected("Sound",1) two = selected("Sound",2) one$ = selected$("Sound",1) two$ = selected$("Sound",2) #get target-info from one select TextGrid 'one$' t1 = Get end point... 1 1 t2 = Get end point... 1 2 a$ = Get label of interval... 1 2 select 'one' s1 = Get sample number from time... 't1' Copy... hastarget max_target = Get absolute extremum... 't1' 't2' None dur_target = t2 - t1 sr = Get sampling frequency fs_target = round(sr * t1) #get syllable from two select TextGrid 'two$' t3 = Get end point... 1 1 b$ = Get label of interval... 1 1 dur_syl = t3 + window/2 select 'two' s3 = Get sample number from time... 't3' Extract part... 0 'dur_syl' Rectangular 1 no Rename... start max_start = Get absolute extremum... 0 0 None #impose maximal amplitude from 1st target syllable on syllable context if adjustAmplitude Multiply... max_target/max_start endif #calculate the sounds duration dur_exp = dur_syl + dur_target - window/2 #round the sample values s1 = round(s1) s3 = round(s3) Create Sound... 'name$'_'b$'_'a$' 0 'dur_exp' 'sr' 0 #put start from Sound two in Formula... if x < ('dur_syl' - 'window') then Sound_start[col] else self fi #cross-fade Formula... if ( x > ('dur_syl' - 'window') & x < ('dur_syl')) then (Sound_start[col] * ('dur_syl' - x)/'window') else self fi Formula... if ( x > ('dur_syl' - 'window') & x < ('dur_syl')) then self[col] + ((x - ('dur_syl'-'window'))/'window') * Sound_hastarget[col - 's3' + 's1'] else self fi #target from Sound two Formula... if x > 'dur_syl' then Sound_hastarget[col - 's3' + 's1'] else self fi #aufräumen select Sound start plus Sound hastarget Remove