# # Praat Script: RE-QUANTISATION # # This program changes the quantisation rate of a sound file. # Important advice: runtime per 1 second of sound file is appr. 5 sec. # i.e. long files can take a long time to be processed. It is recommended # to use it for short files only. # # written by Floki # # ### Create user interface window ################################################ form Floki's waveform re-quantisation comment Finding the file you want to re-quantise comment Please specify the path: text Path C:\Dokumente und Einstellungen\Flok\Desktop\ comment Please specify the filename: text Filename quantiseTest.wav comment ---------------------------------------------------------------------------------------------------------------------- comment Please specify the quantisation rate of your sine wave in bit: optionmenu quantisation_rate: 1 option 16 bit option 12 bit option 8 bit option 4 bit option 2 bit option 1 bit endform ### Read file and change its quantisation level ################################# Read from file... 'path$''filename$' filename$ = filename$-".wav" Down to Matrix if quantisation_rate = 1 bitLevel$ = "_16bit" elsif quantisation_rate = 2 quantisation = 2048 bitLevel$ = "_12bit" call changeBitRate elsif quantisation_rate = 3 quantisation = 128 bitLevel$ = "_8bit" call changeBitRate elsif quantisation_rate = 4 quantisation = 8 bitLevel$ = "_4bit" call changeBitRate elsif quantisation_rate = 5 quantisation = 2 bitLevel$ = "_2bit" call changeBitRate elsif quantisation_rate = 6 quantisation = 1 bitLevel$ = "_1bit" call changeBitRate endif procedure changeBitRate select Sound 'filename$' numberOfSamples = Get number of samples for i to numberOfSamples x = Get value at index... 'i' x = floor(x*quantisation)/quantisation Set value at index... 'i' 'x' endfor endproc ### Final adjustments ########################################################### select Matrix 'filename$' Remove select Sound 'filename$' Rename... 'filename$''bitLevel$'