# ChangeDuration.psc # This script change the duration of certain parts of the selected sound # and optionally outputs it to a WAV file. # # This script is distributed under the GNU General Public License. # # Copyright Rory Turnbull 08/04/2008 # Parameters form form Change duration - input parameters comment This script modifies the duration of a section of a sound file. comment START - this is the start of the section to be modified (seconds) comment END - this is the end of the section to be modified (seconds) comment NEWDUR - this is the new duration of the modified section (seconds) comment OUTPUTNAME - this is the name of the output sound comment WRITETOFILE - if ticked, the output will be written to a WAV file comment OUTPUTFOLDER - this is the path of the output file; the name is as above real start 0 positive end 1 positive newdur 0.5 word outputfile SoundMod boolean writetofile 1 word outputfolder .../ endform # Check that the selected file is a sound # (There's probably an easier way to do this) numberOfSelectedSounds = numberOfSelected ("Sound") if numberOfSelectedSounds <= 0 exit Please select a sound file. elseif numberOfSelectedSounds = 1 call MainProc endif # Main procedure procedure MainProc # Define variables sound$ = selected$ ("Sound") olddur = 'end' - 'start' select selected ("Sound") sounddur = Get duration To Manipulation... 0.1 75 600 # Create the DurationTier according to input parameters Create DurationTier... alter 0 'sounddur' Add point... 0.000 1 Add point... start-0.00001 1 Add point... start newdur/olddur Add point... end newdur/olddur Add point... end+0.00001 1 # Synthesise the new sound plus Manipulation 'sound$' Replace duration tier minus DurationTier alter Edit editor Manipulation 'sound$' Publish resynthesis Close endeditor Rename... 'outputfile$' # Check if the file is to be written if writetofile = 1 call Write endif # Tidy up the objects select DurationTier alter plus Manipulation 'sound$' Remove endproc # Write procedure - writes output to WAV file, then removes object procedure Write Write to WAV file... 'outputfolder$'/'outputfile$'.wav Remove endproc # End of script