manual_sound.cpp 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. /* manual_sound.cpp
  2. *
  3. * Copyright (C) 1992-2008,2010-2012,2014-2017 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "ManPagesM.h"
  19. #include "Sound.h"
  20. #include "../kar/UnicodeData.h"
  21. static void draw_SoundDeepen_filter (Graphics g) {
  22. try {
  23. autoSound s = Sound_createSimple (1, 100.0, 10.0);
  24. double alpha = sqrt (log (2.0));
  25. Graphics_setWindow (g, 0.0, 100.0, 0.0, 1.0);
  26. for (int i = 1; i <= s -> nx; i ++) {
  27. double alpha_f = alpha * (s -> x1 + (i - 1) * s -> dx);
  28. double slow = alpha_f / 3.0, fast = alpha_f / 30.0;
  29. s -> z [1] [i] = exp (- fast * fast) - exp (- slow * slow);
  30. }
  31. Graphics_drawInnerBox (g);
  32. Graphics_textBottom (g, true, U"Frequency %f (Hz)");
  33. Graphics_textLeft (g, true, U"Amplitude filter %H (%f)");
  34. Graphics_markLeft (g, 0.0, true, true, false, nullptr);
  35. Graphics_markLeft (g, 0.5, true, true, true, nullptr);
  36. Graphics_markLeft (g, 1.0, true, true, false, nullptr);
  37. Graphics_markRight (g, 1.0, false, true, false, U"0 dB");
  38. Graphics_markRight (g, 0.5, false, true, false, U"-6 dB");
  39. Graphics_markBottom (g, 0.0, true, true, false, nullptr);
  40. Graphics_markBottom (g, 3.0, true, true, true, nullptr);
  41. Graphics_markBottom (g, 30.0, true, true, true, nullptr);
  42. Graphics_markBottom (g, 100.0, true, true, false, nullptr);
  43. Graphics_setColour (g, Graphics_RED);
  44. Sound_draw (s.get(), g, 0.0, 0.0, 0.0, 1.0, false, U"curve");
  45. Graphics_setColour (g, Graphics_BLACK);
  46. } catch (MelderError) {
  47. Melder_clearError ();
  48. }
  49. }
  50. static void draw_SoundDeepen_impulse (Graphics g) {
  51. try {
  52. autoSound s = Sound_create (1, -0.2, 0.2, 1000, 4e-4, -0.1998);
  53. double pibyalpha = NUMpi / sqrt (log (2.0)), twosqrtpitimespibyalpha = 2 * sqrt (NUMpi) * pibyalpha;
  54. Graphics_setWindow (g, -0.2, 0.2, -100.0, 400.0);
  55. for (int i = 1; i <= s -> nx; i ++) {
  56. double pibyalpha_f = pibyalpha * (s -> x1 + (i - 1) * s -> dx);
  57. double slow = pibyalpha_f * 3.0, fast = pibyalpha_f * 30.0;
  58. s -> z [1] [i] = twosqrtpitimespibyalpha * (30.0 * exp (- fast * fast) - 3.0 * exp (- slow * slow));
  59. }
  60. Graphics_drawInnerBox (g);
  61. Graphics_textBottom (g, true, U"Time %t (s)");
  62. Graphics_textLeft (g, true, U"Intensity impulse reponse %h (%t)");
  63. Graphics_markBottom (g, -0.2, true, true, false, nullptr);
  64. Graphics_markBottom (g, 0, true, true, true, nullptr);
  65. Graphics_markBottom (g, 0.2, true, true, false, nullptr);
  66. Graphics_markLeft (g, 0, true, true, true, nullptr);
  67. Graphics_setColour (g, Graphics_RED);
  68. Sound_draw (s.get(), g, 0.0, 0.0, -100.0, 400.0, false, U"curve");
  69. Graphics_setColour (g, Graphics_BLACK);
  70. } catch (MelderError) {
  71. Melder_clearError ();
  72. }
  73. }
  74. void manual_sound_init (ManPages me);
  75. void manual_sound_init (ManPages me) {
  76. MAN_BEGIN (U"Combine to stereo", U"ppgb", 20070129)
  77. INTRO (U"To combine two mono @Sound objects into one single stereo Sound, "
  78. "select the two Sounds in the list and choose ##Combine to stereo# from the ##Combine sounds# menu. "
  79. "A new stereo Sound will appear in the list.")
  80. NORMAL (U"Of the two original mono Sounds, the one that is higher in the list will become the left channel "
  81. "of the new stereo Sound, and the one that is lower in the list will become the right channel of the new Sound.")
  82. MAN_END
  83. MAN_BEGIN (U"Create Sound from formula...", U"ppgb", 20070225)
  84. INTRO (U"A command in the @@New menu@ to create a @Sound with a specified duration and sampling frequency, "
  85. "filled with values from a formula.")
  86. NORMAL (U"See the @Formulas tutorial for explanations and examples.")
  87. /*
  88. Create Sound from formula... blok Mono 0 1 44100 if round(x*377*2) mod 2 then 0.9 else -0.9 fi
  89. Je kunt dus heel veel maken met een scriptje:
  90. form Blokgolf
  91. word Naam blok
  92. real Begintijd_(s) 0.0
  93. real Eindtijd_(s) 1.0
  94. positive Samplefrequentie_(Hz) 22050
  95. positive Frequentie_(Hz) 377
  96. real Amplitude 0.9
  97. endform
  98. Create Sound from formula... 'Naam' Mono begintijd eindtijd samplefrequentie
  99. ... if round(x*frequentie*2) mod 2 then amplitude else -amplitude fi
  100. */
  101. MAN_END
  102. MAN_BEGIN (U"Create Sound as tone complex...", U"ppgb", 20170828)
  103. INTRO (U"A command in the @@New menu@ to create a @Sound as the sum of a number of sine waves "
  104. "with equidistant frequencies.")
  105. ENTRY (U"Settings")
  106. TAG (U"##Name")
  107. DEFINITION (U"the name of the resulting Sound object.")
  108. TAG (U"##Start time (s)")
  109. TAG (U"##End time (s)")
  110. DEFINITION (U"the time domain of the resulting Sound.")
  111. TAG (U"##Sampling frequency (Hz)")
  112. DEFINITION (U"the sampling frequency of the resulting Sound.")
  113. TAG (U"##Phase")
  114. DEFINITION (U"determines whether the result is a sum of %sines or a sum of %cosines, "
  115. "i.e., whether the zero crossings or the maxima of the components are synchronized. "
  116. "This choice has little perceptual consequences.")
  117. TAG (U"##Frequency step (Hz)")
  118. DEFINITION (U"the distance between the components. In first approximation, "
  119. "this is the perceived fundamental frequency.")
  120. TAG (U"##First frequency (Hz)")
  121. DEFINITION (U"the lowest frequency component. If you supply a value of 0, "
  122. "##First frequency# is taken equal to ##Frequency step#.")
  123. TAG (U"##Ceiling (Hz)")
  124. DEFINITION (U"the frequency above which no components are used. If you supply a value of 0 "
  125. "or a value above the Sound's @@Nyquist frequency@, %ceiling is taken equal to "
  126. "the Nyquist frequency.")
  127. TAG (U"##Number of components")
  128. DEFINITION (U"determines how many sinusoids are used. If you supply a value of 0 "
  129. "or a very high value, the maximum number of components is used, "
  130. "limited by #Ceiling.")
  131. ENTRY (U"Example 1: a pulse train")
  132. NORMAL (U"A series of pulses at regular intervals, "
  133. "sampled after low-pass filtering at the Nyquist frequency, "
  134. "can be regarded as a sum of cosine waves. For instance, a 100-Hz pulse train, "
  135. "sampled at 44100 Hz, can be created with:")
  136. CODE (U"Create Sound as tone complex: \"train\", 0, 1, 44100, \"Cosine\", 100, 0, 0, 0")
  137. NORMAL (U"Supplying the value 0 for %firstFrequency yields an unshifted harmonic complex.")
  138. ENTRY (U"Example 2: a shifted harmonic complex")
  139. NORMAL (U"Some experiments on human pitch perception (%%residue pitch%) use "
  140. "a number of sinusoidal components with harmonically "
  141. "related frequencies that are all shifted by a constant amount.")
  142. NORMAL (U"For instance, to get a sum of sine waves with frequencies 105 Hz, 205 Hz, and 305 Hz, "
  143. "you would use:")
  144. CODE (U"Create Sound as tone complex: \"train\", 0.3, 1, 44100, \"Sine\", 100, 105, 0, 3")
  145. NORMAL (U"or")
  146. CODE (U"Create Sound as tone complex: \"train\", 0.3, 1, 44100, \"Sine\", 100, 105, 350, 0")
  147. NORMAL (U"whichever you prefer.")
  148. NORMAL (U"Some of these experiments are described in @@Plomp (1967)@ and @@Patterson & Wightman (1976)@.")
  149. ENTRY (U"Algorithm")
  150. NORMAL (U"For the `sine' phase, the resulting Sound is given by the following formula:")
  151. NORMAL (U"%x(%t) = \\su__%i=1..%numberOfComponents_ sin (2%\\pi\\.c(%firstFrequency + "
  152. "(%i\\--1)\\.c%frequencyStep)\\.c%t)")
  153. ENTRY (U"More flexibility?")
  154. NORMAL (U"Suppose you wanted to vary the relative strengths of the frequency components. "
  155. "You could achieve this by creating a Sound with the command discussed here, "
  156. "take its Fourier transform, run a formula on the resulting Spectrum, "
  157. "and take the inverse Fourier transform.")
  158. NORMAL (U"A more general approach is described shortly.")
  159. NORMAL (U"Suppose you need a sum of sine waves with frequencies 105, 205, 305, ..., 1905 Hz, "
  160. "and with relative amplitudes 1, 1/2, 1/3, ..., 1/19. You could build a script that computes "
  161. "the various components, and add them to each other as you go along. Instead of calling 19 "
  162. "scripts, however, you can achieve this with the following more general script:")
  163. CODE (U"form Add waves with decreasing amplitudes")
  164. CODE1 (U"natural Number_of_components 19")
  165. CODE (U"endform")
  166. CODE (U"\\# Create a Matrix with frequency and amplitude information in each row:")
  167. CODE (U"Create simple Matrix: \"freqAndGain\", number_of_components, 2, ~ 0")
  168. CODE (U"Formula: ~ if col = 1 then row * 100 + 5 else 1 / row fi")
  169. CODE (U"\\# Create a large Matrix with all the component sine waves:")
  170. CODE (U"Create Matrix: \"components\", 0, 1, 10000, 1e-4, 0.5e-4, 1, number_of_components, number_of_components, 1, 1, ~ 0")
  171. CODE (U"Formula: ~ object [\"Matrix freqAndGain\", 2] * sin (2 * pi * object [\"Matrix freqAndGain\", 1] * x)\"")
  172. CODE (U"\\# Integrate:")
  173. CODE (U"Formula: ~ self + self [row - 1, col]")
  174. CODE (U"\\# Publish last row:")
  175. CODE (U"To Sound (slice): number_of_components")
  176. CODE (U"Scale amplitudes: 0.99")
  177. MAN_END
  178. MAN_BEGIN (U"Extract one channel...", U"ppgb", 20110129)
  179. INTRO (U"To extract the left channel of an existing stereo @Sound as a new mono Sound, "
  180. "select that stereo Sound in the list and choose ##Extract one channel...# from the #Convert menu, "
  181. "Then set the #Channel to 1 and click OK. "
  182. "A new mono Sound will appear in the list. For the right channel, set #Channel to 2.")
  183. ENTRY (U"Details")
  184. NORMAL (U"The name of the new mono Sound will be based on the name of the original stereo Sound. "
  185. "For instance, if the original Sound is called #hello and you extract channel 2, the new Sound will be called #hello_ch2.")
  186. NORMAL (U"This command also works if you select more than one stereo Sound. "
  187. "For each of them, Praat creates a new mono Sound.")
  188. MAN_END
  189. MAN_BEGIN (U"Read separate channels from sound file...", U"ppgb", 20111010)
  190. INTRO (U"A command in the @@Open menu@ of the #Objects window. "
  191. "You use this if you want to get the channels of a @stereo (or multi-channel) sound file "
  192. "as two (or more) separate @Sound objects in the list. "
  193. "If the file name is hello.wav, Praat will name the channels hello_ch1, hello_ch2, and so on.")
  194. MAN_END
  195. MAN_BEGIN (U"Record mono Sound...", U"ppgb", 20021212)
  196. INTRO (U"A command in the @@New menu@ to record a @Sound. Creates a @SoundRecorder window, "
  197. "except on very old Macintoshes with 8-bit audio, where it presents a native Macintosh sound-recorder window.")
  198. MAN_END
  199. MAN_BEGIN (U"Record stereo Sound...", U"ppgb", 20021212)
  200. INTRO (U"A command in the @@New menu@ to record a @Sound. Creates a @SoundRecorder window.")
  201. MAN_END
  202. MAN_BEGIN (U"Sound", U"ppgb", 20161013)
  203. INTRO (U"One of the @@types of objects@ in Praat. For tutorial information, see all of the @Intro.")
  204. ENTRY (U"Commands")
  205. NORMAL (U"Creation:")
  206. LIST_ITEM (U"\\bu @@Record mono Sound...@ (from microphone or line input, with the @SoundRecorder)")
  207. LIST_ITEM (U"\\bu @@Record stereo Sound...@")
  208. LIST_ITEM (U"\\bu @@Create Sound from formula...@")
  209. LIST_ITEM (U"\\bu @@Create Sound as tone complex...")
  210. LIST_ITEM (U"\\bu @@Create Sound as gammatone...")
  211. LIST_ITEM (U"\\bu @@Create Sound as Shepard tone...")
  212. NORMAL (U"Opening and saving:")
  213. LIST_ITEM (U"\\bu @@Sound files")
  214. NORMAL (U"You can also use the text and binary (real-valued) formats for Sounds, like for any other class:")
  215. LIST_ITEM (U"\\bu @@Save as text file...")
  216. LIST_ITEM (U"\\bu @@Save as binary file...")
  217. NORMAL (U"Playing:")
  218. LIST_ITEM (U"\\bu @@Sound: Play")
  219. LIST_ITEM (U"\\bu @@PointProcess: Hum")
  220. LIST_ITEM (U"\\bu @@PointProcess: Play")
  221. NORMAL (U"Viewing and editing:")
  222. LIST_ITEM (U"\\bu @SoundEditor, @ManipulationEditor, @TextGridEditor, @PointEditor, @PitchTierEditor, "
  223. "@SpectrumEditor")
  224. NORMAL (U"Queries:")
  225. LIST_ITEM (U"structure:")
  226. LIST_ITEM1 (U"\\bu @@time domain")
  227. LIST_ITEM1 (U"\\bu @@Get number of samples")
  228. LIST_ITEM1 (U"\\bu @@Get sampling period")
  229. LIST_ITEM1 (U"\\bu @@Get sampling frequency")
  230. LIST_ITEM1 (U"\\bu @@Get time from sample number...")
  231. LIST_ITEM1 (U"\\bu @@Get sample number from time...")
  232. LIST_ITEM (U"content:")
  233. LIST_ITEM1 (U"\\bu @@Sound: Get value at time...")
  234. LIST_ITEM1 (U"\\bu @@Sound: Get value at sample number...")
  235. LIST_ITEM (U"shape:")
  236. LIST_ITEM1 (U"\\bu @@Sound: Get minimum...")
  237. LIST_ITEM1 (U"\\bu @@Sound: Get time of minimum...")
  238. LIST_ITEM1 (U"\\bu @@Sound: Get maximum...")
  239. LIST_ITEM1 (U"\\bu @@Sound: Get time of maximum...")
  240. LIST_ITEM1 (U"\\bu @@Sound: Get absolute extremum...")
  241. LIST_ITEM1 (U"\\bu @@Sound: Get nearest zero crossing...")
  242. LIST_ITEM (U"statistics:")
  243. LIST_ITEM1 (U"\\bu @@Sound: Get mean...")
  244. LIST_ITEM1 (U"\\bu @@Sound: Get root-mean-square...")
  245. LIST_ITEM1 (U"\\bu @@Sound: Get standard deviation...")
  246. LIST_ITEM (U"energy:")
  247. LIST_ITEM1 (U"\\bu @@Sound: Get energy...")
  248. LIST_ITEM1 (U"\\bu @@Sound: Get power...")
  249. LIST_ITEM (U"in air:")
  250. LIST_ITEM1 (U"\\bu @@Sound: Get energy in air")
  251. LIST_ITEM1 (U"\\bu @@Sound: Get power in air")
  252. LIST_ITEM1 (U"\\bu @@Sound: Get intensity (dB)")
  253. NORMAL (U"Modification:")
  254. LIST_ITEM (U"\\bu @@Matrix: Formula...")
  255. LIST_ITEM (U"\\bu @@Sound: Set value at sample number...")
  256. LIST_ITEM (U"\\bu @@Sound: Filter with one formant (in-place)...")
  257. LIST_ITEM (U"\\bu @@Sound: Pre-emphasize (in-place)...")
  258. LIST_ITEM (U"\\bu @@Sound: De-emphasize (in-place)...")
  259. NORMAL (U"Annotation (see @@Intro 7. Annotation@):")
  260. LIST_ITEM (U"\\bu @@Sound: To TextGrid...")
  261. NORMAL (U"Periodicity analysis:")
  262. LIST_ITEM (U"\\bu @@Sound: To Pitch...")
  263. LIST_ITEM (U"\\bu @@Sound: To Pitch (ac)...")
  264. LIST_ITEM (U"\\bu @@Sound: To Pitch (cc)...")
  265. LIST_ITEM (U"\\bu @@Sound: To Pitch (shs)...")
  266. LIST_ITEM (U"\\bu @@Sound: To Harmonicity (ac)...")
  267. LIST_ITEM (U"\\bu @@Sound: To Harmonicity (cc)...")
  268. LIST_ITEM (U"\\bu @@Sound: To PointProcess (periodic, cc)...")
  269. LIST_ITEM (U"\\bu @@Sound: To PointProcess (periodic, peaks)...")
  270. LIST_ITEM (U"\\bu @@Sound & Pitch: To PointProcess (cc)")
  271. LIST_ITEM (U"\\bu @@Sound & Pitch: To PointProcess (peaks)...")
  272. LIST_ITEM (U"\\bu @@Sound: To Intensity...")
  273. NORMAL (U"Spectral analysis:")
  274. LIST_ITEM (U"\\bu @@Sound: To Spectrum...")
  275. LIST_ITEM (U"\\bu @@Sound: To Spectrogram...")
  276. LIST_ITEM (U"\\bu @@Sound: To Formant (burg)...")
  277. LIST_ITEM (U"\\bu @@Sound: To Formant (sl)...")
  278. LIST_ITEM (U"\\bu @@Sound: LPC analysis")
  279. LIST_ITEM1 (U"\\bu @@Sound: To LPC (autocorrelation)...")
  280. LIST_ITEM1 (U"\\bu @@Sound: To LPC (covariance)...")
  281. LIST_ITEM1 (U"\\bu @@Sound: To LPC (burg)...")
  282. LIST_ITEM1 (U"\\bu @@Sound: To LPC (marple)...")
  283. NORMAL (U"Filtering (see @Filtering tutorial):")
  284. LIST_ITEM (U"\\bu @@Sound: Filter (pass Hann band)...")
  285. LIST_ITEM (U"\\bu @@Sound: Filter (stop Hann band)...")
  286. LIST_ITEM (U"\\bu @@Sound: Filter (formula)...")
  287. LIST_ITEM (U"\\bu @@Sound: Filter (one formant)...")
  288. LIST_ITEM (U"\\bu @@Sound: Filter (pre-emphasis)...")
  289. LIST_ITEM (U"\\bu @@Sound: Filter (de-emphasis)...")
  290. LIST_ITEM (U"\\bu @@LPC & Sound: Filter...")
  291. LIST_ITEM (U"\\bu @@LPC & Sound: Filter (inverse)")
  292. LIST_ITEM (U"\\bu @@Sound & Formant: Filter")
  293. LIST_ITEM (U"\\bu @@Sound & FormantGrid: Filter")
  294. NORMAL (U"Conversion:")
  295. LIST_ITEM (U"\\bu @@Sound: Resample...")
  296. NORMAL (U"Enhancement:")
  297. LIST_ITEM (U"\\bu @@Sound: Lengthen (overlap-add)...@: lengthen by a constant factor")
  298. LIST_ITEM (U"\\bu @@Sound: Deepen band modulation...@: strenghten intensity modulations in each critical band")
  299. NORMAL (U"Combination:")
  300. LIST_ITEM (U"\\bu @@Sounds: Convolve...")
  301. LIST_ITEM (U"\\bu @@Sounds: Cross-correlate...")
  302. LIST_ITEM (U"\\bu @@Sound: Autocorrelate...")
  303. LIST_ITEM (U"\\bu @@Sounds: Concatenate")
  304. NORMAL (U"Synthesis")
  305. LIST_ITEM (U"\\bu @@Source-filter synthesis@ tutorial")
  306. LIST_ITEM (U"\\bu @Manipulation (@@overlap-add@ etc.)")
  307. LIST_ITEM (U"\\bu @@Spectrum: To Sound")
  308. LIST_ITEM (U"\\bu ##Pitch: To Sound...")
  309. LIST_ITEM (U"\\bu @@PointProcess: To Sound (pulse train)...")
  310. LIST_ITEM (U"\\bu @@PointProcess: To Sound (hum)...")
  311. LIST_ITEM (U"\\bu ##Pitch & PointProcess: To Sound...")
  312. LIST_ITEM (U"\\bu @@Articulatory synthesis@ tutorial")
  313. LIST_ITEM (U"\\bu @@Artword & Speaker: To Sound...")
  314. ENTRY (U"Inside a Sound")
  315. NORMAL (U"With @Inspect, you will see that a Sound contains the following data:")
  316. TAG (U"%x__%min_")
  317. DEFINITION (U"start time, in seconds.")
  318. TAG (U"%x__%max_ > %x__%min_")
  319. DEFINITION (U"end time, in seconds.")
  320. TAG (U"%n__%x_")
  321. DEFINITION (U"the number of samples (\\>_ 1).")
  322. TAG (U"%dx")
  323. DEFINITION (U"sample period, in seconds. The inverse of the sampling frequency (in Hz).")
  324. TAG (U"%x__1_")
  325. DEFINITION (U"the time associated with the first sample (in seconds). "
  326. "This will normally be in the range [%xmin, %xmax]. "
  327. "The time associated with the last sample (i.e., %x__1_ + (%nx \\-- 1) %dx)) "
  328. "will also normally be in that range. Mostly, the sound starts at %t = 0 seconds "
  329. "and %x__1_ = %dx / 2. Also, usually, %x__%max_ = %n__%x_ %dx.")
  330. TAG (U"%z [1] [1..%n__%x_]")
  331. DEFINITION (U"the amplitude of the sound (stored as single-precision floating-point numbers). "
  332. "For the most common applications (playing and file I-O), Praat assumes that "
  333. "the amplitude is greater than -1 and less than +1. "
  334. "For some applications (modelling of the inner ear; "
  335. "articulatory synthesis), Praat assumes that the amplitude is expressed in Pascal units. "
  336. "If these interpretations are combined, we see that the maximum peak amplitude of "
  337. "a calibrated sound is 1 Pascal; for a sine wave, this means 91 dB SPL.")
  338. ENTRY (U"Limitations")
  339. NORMAL (U"Since the Sound object completely resides in memory, its size is limited "
  340. "to the amount of RAM in your computer. For sounds longer than a few minutes, "
  341. "you could use the @LongSound object instead, which you can view in the @LongSoundEditor.")
  342. MAN_END
  343. MAN_BEGIN (U"Sound: De-emphasize (in-place)...", U"ppgb", 20171114)
  344. INTRO (U"A command to change the spectral slope of every selected @Sound object.")
  345. NORMAL (U"The reverse of @@Sound: Pre-emphasize (in-place)...@. For an example, see @@Source-filter synthesis@.")
  346. NORMAL (U"This is the in-place version of @@Sound: Filter (de-emphasis)...@, "
  347. "i.e., it does not create a new Sound object but modifies an existing object.")
  348. ENTRY (U"Setting")
  349. TAG (U"##From frequency (Hz)")
  350. DEFINITION (U"the frequency %F above which the spectral slope will decrease by 6 dB/octave.")
  351. ENTRY (U"Algorithm")
  352. NORMAL (U"The de-emphasis factor %\\al is computed as")
  353. FORMULA (U"%\\al = exp (-2 %\\pi %F \\De%t)")
  354. NORMAL (U"where \\De%t is the sampling period of the sound. Every sample %x__%i_ of the sound, "
  355. "except %x__1_, is then changed, going up from the second sample:")
  356. FORMULA (U"%x__%i_ = %x__%i_ + %\\al %x__%i-1_")
  357. MAN_END
  358. MAN_BEGIN (U"Sound: Deepen band modulation...", U"ppgb", 20101026)
  359. INTRO (U"A command to enhance the fast spectral changes, like %F__2_ movements, in each selected @Sound object.")
  360. ENTRY (U"Settings")
  361. TAG (U"##Enhancement (dB)")
  362. DEFINITION (U"the maximum increase in the level within each critical band. The standard value is 20 dB.")
  363. TAG (U"##From frequency (Hz)")
  364. DEFINITION (U"the lowest frequency that shall be manipulated. The bottom frequency of the first critical band that is to be enhanced. "
  365. "The standard value is 300 Hertz.")
  366. TAG (U"##To frequency (Hz)")
  367. DEFINITION (U"the highest frequency that shall be manipulated (the last critical band may be narrower than the others). The standard value is 8000 Hz.")
  368. TAG (U"##Slow modulation (Hz)")
  369. DEFINITION (U"the frequency %f__%slow_ below which the intensity modulations in the bands should not be expanded. The standard value is 3 Hz.")
  370. TAG (U"##Fast modulation (Hz)")
  371. DEFINITION (U"the frequency %f__%fast_ above which the intensity modulations in the bands should not be expanded. The standard value is 30 Hz.")
  372. TAG (U"##Band smoothing (Hz)")
  373. DEFINITION (U"the degree of overlap of each band into its adjacent bands. Prevents %ringing. The standard value is 100 Hz.")
  374. ENTRY (U"Algorithm")
  375. NORMAL (U"This algorithm was inspired by @@Nagarajan, Wang, Merzenich, Schreiner, Johnston, Jenkins, Miller & Tallal (1998)@, "
  376. "but not identical to it. Now follows the description.")
  377. NORMAL (U"Suppose the settings have their standard values. The resulting sound will composed of the unfiltered part of the original sound, "
  378. "plus all manipulated bands.")
  379. NORMAL (U"First, the resulting sound becomes the original sound, stop-band filtered between 300 and 8000 Hz: "
  380. "after a forward Fourier transform, all values in the @Spectrum at frequencies between 0 and 200 Hz and "
  381. "between 8100 Hz and the Nyquist frequency of the sound are retained unchanged. "
  382. "The spectral values at frequencies between 400 and 7900 Hz are set to zero. "
  383. "Between 200 and 400 Hz and between 7900 and 8100 Hz, the values are multiplied by a raised sine, "
  384. "so as to give a smooth transition without ringing in the time domain (the raised sine also allows us to view "
  385. "the spectrum as a sum of spectral bands). Finally, a backward Fourier transform gives us the filtered sound.")
  386. NORMAL (U"The remaining part of the spectrum is divided into %%critical bands%, i.e. frequency bands one Bark wide. "
  387. "For instance, the first critical band run from 300 to 406 Hz, the second from 406 to 520 Hz, and so on. "
  388. "Each critical band is converted to a pass-band filtered sound by means of the backward Fourier transform.")
  389. NORMAL (U"Each filtered sound will be manipulated, and the resulting manipulated sounds are added to the stop-band filtered sound "
  390. "we created earlier. If the manipulation is the identity transformation, the resulting sound will be equal to the original sound. "
  391. "But, of course, the manipulation does something different. Here are the steps.")
  392. NORMAL (U"First, we compute the local intensity of the filtered sound %x (%t):")
  393. FORMULA (U"%intensity (%t) = 10 log__10_ (%x^2 (%t) + 10^^-6^)")
  394. NORMAL (U"This intensity is subjected to a forward Fourier transform. In the frequency domain, we administer a band filter. "
  395. "We want to enhance the intensity modulation in the range between 3 and 30 Hz. "
  396. "We can achieve this by comparing the very smooth intensity contour, low-pass filtered at %f__%slow_ = 3 Hz, "
  397. "with the intensity contour that has enough temporal resolution to see the place-discriminating %F__2_ movements, "
  398. "which is low-pass filtered at %f__%fast_ = 30 Hz. In the frequency domain, the filter is")
  399. FORMULA (U"%H (%f) = exp (- (%\\al%f / %f__%fast_)^2) - exp (- (%\\al%f / %f__%slow_)^2)")
  400. NORMAL (U"where %\\al equals \\Vrln 2 \\~~ 1 / 1.2011224, so that %H (%f) has its -6 dB points at %f__%slow_ and %f__%fast_:")
  401. PICTURE (5, 3, draw_SoundDeepen_filter)
  402. NORMAL (U"Now, why do we use such a flat filter? Because a steep filter would show ringing effects in the time domain, "
  403. "dividing the sound into 30-ms chunks. If our filter is a sum of exponentials in the frequency domain, it will also "
  404. "be a sum of exponentials in the time domain. The backward Fourier transform of the frequency response %H (%f) "
  405. "is the impulse response %h (%t). It is given by")
  406. FORMULA (U"%h (%t) = 2%\\pi\\Vr%\\pi %f__%fast_/%\\al exp (-(%\\pi%t%f__%fast_/%\\al)^2) - "
  407. "2%\\pi\\Vr%\\pi %f__%slow_/%\\al exp (-(%\\pi%t%f__%slow_/%\\al)^2)")
  408. NORMAL (U"This impulse response behaves well:")
  409. PICTURE (5, 3, draw_SoundDeepen_impulse)
  410. NORMAL (U"We see that any short intensity peak will be enhanced, and that this enhancement will suppress the intensity "
  411. "around 30 milliseconds from the peak. Non-Gaussian frequency-domain filters would have given several maxima and minima "
  412. "in the impulse response, clearly an undesirable phenomenon.")
  413. NORMAL (U"After the filtered band is subjected to a backward Fourier transform, we convert it into power again:")
  414. FORMULA (U"%power (%t) = 10^^%filtered / 2^")
  415. NORMAL (U"The relative enhancement has a maximum that is smoothly related to the basilar place:")
  416. FORMULA (U"%ceiling = 1 + (10^^%enhancement / 20^ - 1) \\.c (1/2 - 1/2 cos (%\\pi %f__%midbark_ / 13))")
  417. NORMAL (U"where %f__%midbark_ is the mid frequency of the band. Clipping is implemented as")
  418. FORMULA (U"%factor (%t) = 1 / (1 / %power (%t) + 1 / %ceiling)")
  419. NORMAL (U"Finally, the original filtered sound %x (%t), multiplied by this factor, is added to the output.")
  420. /*
  421. form Consonantversterker
  422. positive Enhancement_(dB) 20
  423. choice Algoritme: 3
  424. button (1) Luide stukken spreiden in de tijd
  425. button (2) Versterken bij beweging
  426. button (3) Intensiteitscontour filteren
  427. comment Al deze algoritmen werken binnen alle frequentiebanden!
  428. endform
  429. smooth = 100
  430. low = 300
  431. high = 8000
  432. maximumFactor = 10^(Enhancement/20)
  433. Copy... original
  434. # Remove filter bands.
  435. To Spectrum (fft)
  436. Formula... if x<'low'-'smooth' then self else
  437. ... if x<'low'+'smooth' then self*(0.5+0.5*cos(pi*(x-('low'-'smooth'))/(2*'smooth'))) else
  438. ... if x<'high'-'smooth' then 0 else
  439. ... if x<'high'+'smooth' then self*(0.5-0.5*cos(pi*(x-('high'-'smooth'))/(2*'smooth'))) else
  440. ... self fi fi fi fi
  441. To Sound (fft)
  442. Rename... enhanced
  443. min = low
  444. while min < high
  445. mid_bark = hertzToBark (min) + 0.5
  446. max = round (barkToHertz (hertzToBark (min) + 1))
  447. if max > high
  448. max = high
  449. endif
  450. call enhance_one_band
  451. min = max
  452. endwhile
  453. select Spectrum original
  454. plus Sound original
  455. Remove
  456. select Sound enhanced
  457. Rename... 'Algoritme'_'Enhancement'
  458. Scale... 0.99
  459. procedure enhance_one_band
  460. select Sound original
  461. To Spectrum (fft)
  462. Formula... if x<'min'-'smooth'then 0 else
  463. ... if x<'min'+'smooth' then self*(0.5-0.5*cos(pi*(x-('min'-'smooth'))/(2*'smooth'))) else
  464. ... if x<'max'-'smooth' then self else
  465. ... if x<'max'+'smooth' then self*(0.5+0.5*cos(pi*(x-('max'-'smooth'))/(2*'smooth'))) else
  466. ... 0 fi fi fi fi
  467. Rename... band
  468. To Sound (fft)
  469. if Algoritme = 1
  470. To Intensity... 120 0.01
  471. select Intensity band
  472. Erase all
  473. Viewport... 0 6 0 4
  474. Draw... 0 5 0 80 yes
  475. Down to Matrix
  476. Rename... factor
  477. Formula... if Intensity_band [col-2] > self then Intensity_band [col-2] else self fi
  478. Formula... if Intensity_band [col-1] > self then Intensity_band [col-1] else self fi
  479. Formula... if Intensity_band [col+1] > self then Intensity_band [col+1] else self fi
  480. Formula... if Intensity_band [col+2] > self then Intensity_band [col+2] else self fi
  481. Red
  482. Draw rows... 0 5 0 0 0 80
  483. Black
  484. Formula... self - Intensity_band []
  485. Formula... if self > 'Enhancement' then 'Enhancement' else self fi
  486. Formula... 10^(self/20)
  487. Viewport... 0 6 4 8
  488. Draw rows... 0 5 0 0 0 Enhancement
  489. Draw inner box
  490. Text top... yes Band from 'min' to 'max' Hertz
  491. Marks bottom... 2 yes yes no
  492. Marks left every... 1 5 yes yes yes
  493. select Intensity band
  494. Remove
  495. elsif Algoritme = 2
  496. To Intensity... 120 0.01
  497. # Enhance contour
  498. Erase all
  499. Viewport... 0 6 0 4
  500. Draw... 0 5 0 80 yes
  501. Down to Matrix
  502. Rename... factor
  503. Formula... if col = 1 or col = ncol then 1 else
  504. ... (abs (Intensity_band [col-1] - Intensity_band []) +
  505. ... abs (Intensity_band [col+1] - Intensity_band []))*0.5 fi
  506. Formula... if self < 1 then 1 else if self > 'maximumFactor' then 'maximumFactor' else self fi fi
  507. Red
  508. Draw rows... 0 5 0 0 1 maximumFactor
  509. Black
  510. Text top... yes Band from 'min' to 'max' Hertz
  511. Marks right every... 1 1 yes yes yes
  512. select Intensity band
  513. Remove
  514. elsif Algoritme = 3
  515. Copy... intensity
  516. Formula... self^2+1e-6
  517. Formula... 10*log10(self)
  518. To Spectrum (fft)
  519. Rename... intensityfilt
  520. Formula... self*exp(-(x/35)^2)-self*exp(-(x/3.5)^2); if x<3 or x>30 then 0 else self fi;
  521. To Sound (fft)
  522. Erase all
  523. Viewport... 0 6 0 4
  524. Text top... no Band van 'min' tot 'max' Hertz
  525. Draw... 0 5 -10 10 yes
  526. Down to Matrix
  527. Rename... factor
  528. Formula... 10^(Sound_intensityfilt[]/2)
  529. ceiling = 1+(maximumFactor -1)*(0.5-0.5*cos(pi*mid_bark/13))
  530. Formula... 1/(1/self+1/'ceiling')
  531. Viewport... 0 6 4 8
  532. Draw rows... 0 5 0 0 0 ceiling
  533. Draw inner box
  534. Marks bottom... 2 yes yes no
  535. Marks left every... 1 1 yes yes yes
  536. select Sound intensity
  537. plus Spectrum intensityfilt
  538. plus Sound intensityfilt
  539. Remove
  540. endif
  541. select Sound band
  542. Formula... self*Matrix_factor()
  543. select Sound enhanced
  544. Formula... self+Sound_band[]
  545. select Matrix factor
  546. plus Spectrum band
  547. plus Sound band
  548. Remove
  549. endproc
  550. */
  551. MAN_END
  552. /*
  553. Sound: Filter (freq. domain):
  554. >> Nog iets anders. Ik heb het een tijdje geleden met jou gehad over 'troep'
  555. >> die met jouw eenvoudige filtertechniek in geluidsfiles terechtkomt. In de
  556. >> attachment zit een (synthetische) spraakuiting met hier en daar een (echte)
  557. >> stilte erin. Filter die maar eens met een 'telefoonfilter'(alles 0 voor
  558. >> x<300 or x>3400). Hier in Nijmegen krijg ik er dan een hele vieze zoemtoon
  559. >> in, die ook duidelijk te zien is in de stilten van het signaal.
  560. >
  561. >Je bedoelt met de formule if x<300 or x>3400 then 0 else self fi ?
  562. Ja
  563. >De top van de 300-Hz-ringing is bij mij -40 dB bij 0.54 seconde,
  564. >en -46 dB bij 1.89 seconde. Hoort dat niet?
  565. */
  566. MAN_BEGIN (U"Sound: Filter (de-emphasis)...", U"ppgb", 20030309)
  567. INTRO (U"A command to filter every selected @Sound object. The resulting Sound object has a lower spectral slope.")
  568. NORMAL (U"The reverse of @@Sound: Filter (pre-emphasis)...@. For an example, see @@Source-filter synthesis@.")
  569. ENTRY (U"Setting")
  570. TAG (U"##From frequency (Hz)")
  571. DEFINITION (U"the frequency %F above which the spectral slope will decrease by 6 dB/octave.")
  572. ENTRY (U"Algorithm")
  573. NORMAL (U"The de-emphasis factor %\\al is computed as")
  574. FORMULA (U"%\\al = exp (-2 %\\pi %F \\De%t)")
  575. NORMAL (U"where \\De%t is the sampling period of the sound. The new sound %y is then computed recursively as:")
  576. FORMULA (U"%y__1_ = %x__1_")
  577. FORMULA (U"%y__%i_ = %x__%i_ + %\\al %y__%i-1_")
  578. MAN_END
  579. MAN_BEGIN (U"Sound: Filter (formula)...", U"ppgb", 20041123)
  580. INTRO (U"A command to convert every selected @Sound object into a filtered sound.")
  581. NORMAL (U"The filtering is done in the frequency domain. This command is equivalent to the following sequence:")
  582. LIST_ITEM (U"1. @@Sound: To Spectrum...@ yes")
  583. LIST_ITEM (U"2. @@Matrix: Formula...")
  584. LIST_ITEM (U"3. @@Spectrum: To Sound")
  585. NORMAL (U"For a comparative discussion of various filtering methods, see the @Filtering tutorial.")
  586. NORMAL (U"The example formula is the following:")
  587. CODE (U"if x<500 or x>1000 then 0 else self fi; rectangular band")
  588. NORMAL (U"This formula represents a rectangular pass band between 500 Hz and 1000 Hz (%x is the frequency). "
  589. "Rectangular bands are %not recommended, since they may lead to an appreciable amount of %#ringing in the time domain. "
  590. "The transition between stop and pass band should be smooth, as e.g. in @@Sound: Filter (pass Hann band)...@.")
  591. MAN_END
  592. MAN_BEGIN (U"Sound: Filter (one formant)...", U"ppgb", 20030309)
  593. INTRO (U"A command to filter every selected @Sound object, with a single formant of a specified frequency and bandwidth.")
  594. ENTRY (U"Algorithm")
  595. NORMAL (U"Two recursive filter coefficients are computed as follows:")
  596. FORMULA (U"%p = \\--2 exp (\\--%\\pi %bandwidth %dt) cos (2%\\pi %frequency %dt)")
  597. FORMULA (U"%q = exp (\\--2%\\pi %bandwidth %dt)")
  598. NORMAL (U"where %dt is the sample period. The new signal %y is then computed from the old signal %x and itself as")
  599. FORMULA (U"%y__1_ := %x__1_")
  600. FORMULA (U"%y__2_ := %x__2_ \\-- %p %y__1_")
  601. FORMULA (U"\\At%n \\>_ 3: %y__n_ := %x__n_ \\-- %p %y__%n-1_ \\-- %q %y__%n-2_")
  602. NORMAL (U"After filtering, the sound %y is scaled so that its absolute extremum is 0.9.")
  603. NORMAL (U"For a comparative discussion of various filtering methods, see the @Filtering tutorial.")
  604. NORMAL (U"This filter has an in-place version: @@Sound: Filter with one formant (in-place)...@.")
  605. MAN_END
  606. MAN_BEGIN (U"Sound: Filter with one formant (in-place)...", U"ppgb", 20171114)
  607. INTRO (U"A command to filter every selected @Sound object in-place, with a single formant of a specified frequency and bandwidth.")
  608. NORMAL (U"This is the in-place version of @@Sound: Filter (one formant)...@, "
  609. "i.e. it does not create a new Sound object but modifies the selected object.")
  610. MAN_END
  611. MAN_BEGIN (U"Sound: Filter (pass Hann band)...", U"ppgb", 20041123)
  612. INTRO (U"A command to convert every selected @Sound object into a filtered sound.")
  613. NORMAL (U"The filtering is done in the frequency domain. This command is equivalent to the following sequence:")
  614. LIST_ITEM (U"1. @@Sound: To Spectrum...")
  615. LIST_ITEM (U"2. @@Spectrum: Filter (pass Hann band)...")
  616. LIST_ITEM (U"3. @@Spectrum: To Sound")
  617. NORMAL (U"For a comparative discussion of various filtering methods, see the @Filtering tutorial.")
  618. NORMAL (U"For a complementary filter, see @@Sound: Filter (stop Hann band)...@.")
  619. MAN_END
  620. MAN_BEGIN (U"Sound: Filter (stop Hann band)...", U"ppgb", 20041123)
  621. INTRO (U"A command to convert every selected @Sound object into a filtered sound.")
  622. NORMAL (U"The filtering is done in the frequency domain. This command is equivalent to the following sequence:")
  623. LIST_ITEM (U"1. @@Sound: To Spectrum...")
  624. LIST_ITEM (U"2. @@Spectrum: Filter (stop Hann band)...")
  625. LIST_ITEM (U"3. @@Spectrum: To Sound")
  626. NORMAL (U"For a comparative discussion of various filtering methods, see the @Filtering tutorial.")
  627. NORMAL (U"For a complementary filter, see @@Sound: Filter (pass Hann band)...@.")
  628. MAN_END
  629. MAN_BEGIN (U"Sound: Formula...", U"ppgb", 20021206)
  630. INTRO (U"A command for changing the data in all selected @Sound objects.")
  631. NORMAL (U"See the @Formulas tutorial for examples and explanations.")
  632. MAN_END
  633. MAN_BEGIN (U"Sound: Get absolute extremum...", U"ppgb", 20040711)
  634. INTRO (U"A @query to the selected @Sound object.")
  635. ENTRY (U"Return value")
  636. NORMAL (U"the absolute extremum (in Pascal) within a specified time window.")
  637. ENTRY (U"Settings")
  638. TAG (U"%%Time range% (s)")
  639. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  640. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  641. TAG (U"%%Interpolation")
  642. DEFINITION (U"the interpolation method (None, Parabolic, Sinc) of the @@vector peak interpolation@. "
  643. "The standard is Sinc70 because a Sound object is normally a sampled band-limited signal, "
  644. "which can be seen as a sum of sinc functions.")
  645. MAN_END
  646. MAN_BEGIN (U"Sound: Get energy...", U"ppgb", 20070129)
  647. INTRO (U"A @query to the selected @Sound object.")
  648. ENTRY (U"Return value")
  649. NORMAL (U"the energy. If the unit of sound amplitude is Pa (Pascal), the unit of energy will be Pa^2\\.cs.")
  650. ENTRY (U"Setting")
  651. TAG (U"##Time range (s)")
  652. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  653. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  654. ENTRY (U"Algorithm")
  655. NORMAL (U"The energy is defined as")
  656. FORMULA (U"\\in__%%t%1_^^%%t%2^ %x^2(%t) %dt")
  657. NORMAL (U"where %x(%t) is the amplitude of the sound. For stereo sounds, it is")
  658. FORMULA (U"\\in__%%t%1_^^%%t%2^ (%x__1_^2(%t) + %x__2_^2(%t))/2 %dt")
  659. NORMAL (U"where %x__1_(%t) and %x__2_(%t) are the two channels; this definition ensures that "
  660. "if you convert a mono sound to a stereo sound, the energy will stay the same.")
  661. ENTRY (U"See also")
  662. NORMAL (U"For an interpretation of the energy as the sound energy in air, see @@Sound: Get energy in air@. "
  663. "For the power, see @@Sound: Get power...@.")
  664. MAN_END
  665. MAN_BEGIN (U"Sound: Get energy in air", U"ppgb", 20070129)
  666. INTRO (U"A @query to the selected @Sound object.")
  667. ENTRY (U"Return value")
  668. NORMAL (U"The energy in air, expressed in Joule/m^2.")
  669. ENTRY (U"Algorithm")
  670. NORMAL (U"The energy of a sound in air is defined as")
  671. FORMULA (U"1 / (%\\roc) \\in %x^2(%t) %dt")
  672. NORMAL (U"where %x(%t) is the sound pressure in units of Pa (Pascal), %\\ro is the air density "
  673. "(apx. 1.14 kg/m^3), and %c is the velocity of sound in air (apx. 353 m/s). "
  674. "For how stereo sounds are handled, see @@Sound: Get energy...@.")
  675. ENTRY (U"See also")
  676. NORMAL (U"For an air-independent interpretation of the energy, see @@Sound: Get energy...@. "
  677. "For the power, see @@Sound: Get power in air@.")
  678. MAN_END
  679. MAN_BEGIN (U"Sound: Get intensity (dB)", U"ppgb", 20070129)
  680. INTRO (U"A @query to the selected @Sound object.")
  681. ENTRY (U"Return value")
  682. NORMAL (U"the intensity in air, expressed in dB relative to the auditory threshold.")
  683. ENTRY (U"Algorithm")
  684. NORMAL (U"The intensity of a sound in air is defined as")
  685. FORMULA (U"10 log__10_ { 1 / (%T %P__0_^2) \\in%dt %x^2(%t) }")
  686. NORMAL (U"where %x(%t) is the sound pressure in units of Pa (Pascal), %T is the duration of the sound, "
  687. "and %P__0_ = 2\\.c10^^-5^ Pa is the auditory threshold pressure. "
  688. "For how stereo sounds are handled, see @@Sound: Get energy...@.")
  689. ENTRY (U"See also")
  690. NORMAL (U"For the intensity in Watt/m^2, see @@Sound: Get power in air@. For an auditory intensity, "
  691. "see @@Excitation: Get loudness@.")
  692. MAN_END
  693. MAN_BEGIN (U"Sound: Get maximum...", U"ppgb", 20041123)
  694. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  695. "The Info window will show the maximum amplitude (sound pressure in Pascal) within a specified time window.")
  696. ENTRY (U"Settings")
  697. TAG (U"##Time range (s)")
  698. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored, except for purposes of interpolation. "
  699. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  700. TAG (U"##Interpolation")
  701. DEFINITION (U"the interpolation method (#None, #Parabolic, #Cubic, #Sinc) of the @@vector peak interpolation@. "
  702. "The standard is #Sinc70 because a Sound object is normally a sampled band-limited signal, "
  703. "which can be seen as a sum of sinc functions.")
  704. MAN_END
  705. MAN_BEGIN (U"Sound: Get mean...", U"ppgb", 20041123)
  706. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  707. "The Info window will show the mean amplitude (sound pressure in Pascal) within a specified time range.")
  708. ENTRY (U"Setting")
  709. TAG (U"##Time range (s)")
  710. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  711. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  712. ENTRY (U"Mathematical definition")
  713. NORMAL (U"The mean amplitude between the times %t__1_ and %t__2_ is defined as")
  714. FORMULA (U"1/(%t__2_ - %t__1_) \\in__%%t%1_^^%%t%2^ %x(%t) %dt")
  715. NORMAL (U"where %x(%t) is the amplitude of the sound in Pa.")
  716. MAN_END
  717. MAN_BEGIN (U"Sound: Get minimum...", U"ppgb", 20041123)
  718. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  719. "The Info window will show the minimum amplitude (sound pressure in Pascal) within a specified time window.")
  720. ENTRY (U"Settings")
  721. TAG (U"##Time range (s)")
  722. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored, except for purposes of interpolation. "
  723. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  724. TAG (U"%%Interpolation")
  725. DEFINITION (U"the interpolation method (None, Parabolic, Cubic, Sinc) of the @@vector peak interpolation@. "
  726. "The standard is Sinc70 because a Sound object is normally a sampled band-limited signal, "
  727. "which can be seen as a sum of sinc functions.")
  728. MAN_END
  729. MAN_BEGIN (U"Sound: Get nearest zero crossing...", U"ppgb", 20041123)
  730. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  731. "The Info window will show the time associated with the zero crossing nearest to a specified time point. "
  732. "It is @undefined if there are no zero crossings or if the specified time is outside the time domain of the sound. "
  733. "Linear interpolation is used between sample points.")
  734. ENTRY (U"Setting")
  735. TAG (U"##Time (s)")
  736. DEFINITION (U"the time for which you want to get the time of the nearest zero crossing.")
  737. MAN_END
  738. MAN_BEGIN (U"Sound: Get power...", U"ppgb", 20070129)
  739. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  740. "The Info window will show the power within a specified time window. "
  741. "If the unit of sound amplitude is Pa (Pascal), the unit of power will be Pa^2.")
  742. ENTRY (U"Setting")
  743. TAG (U"##Time range (s)")
  744. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  745. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  746. ENTRY (U"Mathematical definition")
  747. NORMAL (U"The power is defined as")
  748. FORMULA (U"1/(%t__2_-%t__1_) \\in__%%t%1_^^%%t%2^ %x^2(%t) %dt")
  749. NORMAL (U"where %x(%t) is the amplitude of the sound. "
  750. "For how stereo sounds are handled, see @@Sound: Get energy...@.")
  751. ENTRY (U"See also")
  752. NORMAL (U"For an interpretation of the power as the sound power in air, see @@Sound: Get power in air@. "
  753. "For the total energy, see @@Sound: Get energy...@.")
  754. MAN_END
  755. MAN_BEGIN (U"Sound: Get power in air", U"ppgb", 20070129)
  756. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  757. "The Info window will show the power in air, expressed in Watt/m^2.")
  758. ENTRY (U"Mathematical definition")
  759. NORMAL (U"The power of a sound in air is defined as")
  760. FORMULA (U"1 / (%\\rocT) \\in %x^2(%t) %dt")
  761. NORMAL (U"where %x(%t) is the sound pressure in units of Pa (Pascal), %\\ro is the air density "
  762. "(apx. 1.14 kg/m^3), %c is the velocity of sound in air (apx. 353 m/s), and %T is the duration of the sound. "
  763. "For how stereo sounds are handled, see @@Sound: Get energy...@.")
  764. NORMAL (U"For an air-independent interpretation of the power, see @@Sound: Get power...@. "
  765. "For the energy, see @@Sound: Get energy in air@. For the intensity in dB, "
  766. "see @@Sound: Get intensity (dB)@.")
  767. MAN_END
  768. MAN_BEGIN (U"Sound: Get root-mean-square...", U"ppgb", 20070129)
  769. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  770. "The Info window will show the root-mean-square (rms) value of the sound pressure, expressed in Pascal.")
  771. ENTRY (U"Setting")
  772. TAG (U"##Time range (s)")
  773. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  774. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  775. ENTRY (U"Mathematical definition")
  776. NORMAL (U"The root-mean-square value is defined as")
  777. FORMULA (U"\\Vr { 1/(%t__2_-%t__1_) \\in__%%t%1_^^%%t%2^ %x^2(%t) %dt }")
  778. NORMAL (U"where %x(%t) is the amplitude of the sound. "
  779. "For how stereo sounds are handled, see @@Sound: Get energy...@.")
  780. MAN_END
  781. MAN_BEGIN (U"Sound: Get standard deviation...", U"ppgb", 20041123)
  782. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  783. "The Info window will show the standard deviation (in Pascal) of the sound pressure within a specified window. "
  784. "If the sound contains less than 2 samples, the value is @undefined.")
  785. ENTRY (U"Setting")
  786. TAG (U"##Time range (s)")
  787. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored. "
  788. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  789. ENTRY (U"Mathematical definition")
  790. NORMAL (U"The standard deviation is defined as")
  791. FORMULA (U"1/(%t__2_-%t__1_) \\in%__%%t%1_^^%%t%2^ (%x(%t) - %\\mu)^2 %dt")
  792. NORMAL (U"where %x(%t) is the amplitude of the sound, and %\\mu is its mean. "
  793. "For our discrete Sound object, the standard deviation is approximated by")
  794. FORMULA (U"1/(%n-1) \\su__%i=%m..%m+%n-1_ (%x__%i_ - %\\mu)^2")
  795. NORMAL (U"where %n is the number of sample centres between %t__1_ and %t__2_. Note the \"minus 1\".")
  796. MAN_END
  797. MAN_BEGIN (U"Sound: Get time of maximum...", U"ppgb", 20041123)
  798. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  799. "The Info window will show the time (in seconds) associated with the maximum pressure in a specified time range.")
  800. ENTRY (U"Settings")
  801. TAG (U"##Time range (s)")
  802. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored, except for purposes of interpolation. "
  803. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  804. TAG (U"##Interpolation")
  805. DEFINITION (U"the interpolation method (#None, #Parabolic, #Cubic, #Sinc) of the @@vector peak interpolation@. "
  806. "The standard is #Sinc70 because a Sound object is normally a sampled band-limited signal, "
  807. "which can be seen as a sum of sinc functions.")
  808. MAN_END
  809. MAN_BEGIN (U"Sound: Get time of minimum...", U"ppgb", 20041107)
  810. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  811. "The Info window will show the time (in seconds) associated with the minimum pressure in a specified time range.")
  812. ENTRY (U"Settings")
  813. TAG (U"##Time range (s)")
  814. DEFINITION (U"the time range (%t__1_, %t__2_). Values outside this range are ignored, except for purposes of interpolation. "
  815. "If %t__1_ is not less than %t__2_, the entire time domain of the sound is considered.")
  816. TAG (U"##Interpolation")
  817. DEFINITION (U"the interpolation method (#None, #Parabolic, #Cubic, #Sinc) of the @@vector peak interpolation@. "
  818. "The standard is #Sinc70 because a Sound object is normally a sampled band-limited signal, "
  819. "which can be seen as a sum of sinc functions.")
  820. MAN_END
  821. MAN_BEGIN (U"Sound: Get value at sample number...", U"ppgb", 20040420)
  822. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  823. "The Info window will show the amplitude (sound pressure in Pascal) at a specified sample number. "
  824. "If the sample number is less than 1 or greater than the number of samples, the result is @undefined.")
  825. ENTRY (U"Setting")
  826. TAG (U"##Sample number")
  827. DEFINITION (U"the sample number at which the value is to be evaluated.")
  828. MAN_END
  829. MAN_BEGIN (U"Sound: Get value at time...", U"ppgb", 20030916)
  830. INTRO (U"A command available in the #Query menu if you select a @Sound object. "
  831. "The Info window will show an estimate of the amplitude (sound pressure in Pascal) at a specified time. "
  832. "If that time is outside the samples of the Sound, the result is equal to the value of the nearest sample; "
  833. "otherwise, the result is an interpolated value.")
  834. ENTRY (U"Settings")
  835. TAG (U"##Time (s)")
  836. DEFINITION (U"the time at which the value is to be evaluated.")
  837. TAG (U"##Interpolation")
  838. DEFINITION (U"the interpolation method, see @@vector value interpolation@. "
  839. "The standard is #Sinc70 because a Sound object is normally a sampled band-limited signal, "
  840. "which can be seen as a sum of sinc functions.")
  841. MAN_END
  842. MAN_BEGIN (U"Sound: Lengthen (overlap-add)...", U"ppgb", 20030916)
  843. INTRO (U"A command to convert each selected @Sound object into a longer new @Sound object.")
  844. ENTRY (U"Settings")
  845. TAG (U"##Minimum frequency (Hz)")
  846. DEFINITION (U"the minimum pitch used in the periodicity analysis. The standard value is 75 Hz. For the voice of a young child, set this to 150 Hz."
  847. "The shortest voiceless interval in the decomposition is taken as 1.5 divided by %%minimum frequency%.")
  848. TAG (U"##Maximum frequency (Hz)")
  849. DEFINITION (U"the maximum pitch used in the periodicity analysis. The standard value is 600 Hz. For an adult male voice, set this to 300 Hz.")
  850. TAG (U"##Factor")
  851. DEFINITION (U"the factor with which the sound will be lengthened. The standard value is 1.5. If you take a value less than 1, "
  852. "the resulting sound will be shorter than the original. A value larger than 3 will not work.")
  853. ENTRY (U"Algorithm")
  854. NORMAL (U"@@overlap-add@.")
  855. MAN_END
  856. MAN_BEGIN (U"audio control panel", U"ppgb", 20050822)
  857. INTRO (U"Your system's way of controlling where sounds will be played, and how loud.")
  858. NORMAL (U"On Windows, double-click the loudspeaker icon in the Start bar. "
  859. "On MacOS X, go to ##System Preferences#, then to #Sound, then to ##Output Volume# "
  860. "(you can put a loudspeaker icon in OSX's menu bar here). "
  861. "On HP-UX, try the ##Use internal loudspeaker...# preference in Praat's #Preferences menu.")
  862. MAN_END
  863. MAN_BEGIN (U"Sound: Play", U"ppgb", 20050822)
  864. INTRO (U"A command to play @Sound objects.")
  865. ENTRY (U"Availability")
  866. NORMAL (U"You can choose this command after selecting one or more Sounds.")
  867. ENTRY (U"Purpose")
  868. NORMAL (U"To play the selected Sounds through the internal or external loudspeakers, "
  869. "the headphones, or the analog or digital outputs of your computer.")
  870. ENTRY (U"Behaviour")
  871. NORMAL (U"All of the Sounds selected are played, "
  872. "in the order in which they appear in the list. If the sampling frequency of the Sound does not match any of "
  873. "the system's sampling frequencies, a fast but inaccurate conversion is performed via linear interpolation.")
  874. ENTRY (U"Usage")
  875. NORMAL (U"The output level and the choice of the output device(s) depend on the settings "
  876. "in your @@audio control panel@.")
  877. MAN_END
  878. MAN_BEGIN (U"Sound: Filter (pre-emphasis)...", U"ppgb", 20030309)
  879. INTRO (U"A command to filter each selected @Sound object. The resulting Sound object has a higher spectral slope.")
  880. NORMAL (U"The reverse of @@Sound: Filter (de-emphasis)...@.")
  881. ENTRY (U"Setting")
  882. TAG (U"##From frequency (Hz)")
  883. DEFINITION (U"the frequency %F above which the spectral slope will increase by 6 dB/octave.")
  884. ENTRY (U"Algorithm")
  885. NORMAL (U"The pre-emphasis factor %\\al is computed as")
  886. FORMULA (U"%\\al = exp (-2 %\\pi %F \\De%t)")
  887. NORMAL (U"where \\De%t is the sampling period of the sound. The new sound %y is then computed as:")
  888. FORMULA (U"%y__%i_ = %x__%i_ - %\\al %x__%i-1_")
  889. MAN_END
  890. MAN_BEGIN (U"Sound: Pre-emphasize (in-place)...", U"ppgb", 20171114)
  891. INTRO (U"A command to change the spectral slope of every selected @Sound object.")
  892. NORMAL (U"The reverse of @@Sound: De-emphasize (in-place)...@.")
  893. NORMAL (U"This is the in-place version of @@Sound: Filter (pre-emphasis)...@, "
  894. "i.e., it does not create a new Sound object but modifies an existing object.")
  895. ENTRY (U"Algorithm")
  896. NORMAL (U"The pre-emphasis factor %\\al is computed as")
  897. FORMULA (U"%\\al = exp (-2 %\\pi %F \\De%t)")
  898. NORMAL (U"where \\De%t is the sampling period of the sound. Every sample %x__%i_ of the sound, "
  899. "except %x__1_, is then changed, going down from the last sample:")
  900. FORMULA (U"%x__%i_ = %x__%i_ - %\\al %x__%i-1_")
  901. MAN_END
  902. MAN_BEGIN (U"Sound: Resample...", U"ppgb", 20040330)
  903. INTRO (U"A command that creates new @Sound objects from the selected Sounds.")
  904. ENTRY (U"Purpose")
  905. NORMAL (U"High-precision resampling from any sampling frequency to any other sampling frequency.")
  906. ENTRY (U"Settings")
  907. TAG (U"##Sampling frequency (Hz)")
  908. DEFINITION (U"the new sampling frequency, in hertz.")
  909. TAG (U"##Precision")
  910. DEFINITION (U"the depth of the interpolation, in samples (standard is 50). "
  911. "This determines the quality of the interpolation used in resampling.")
  912. ENTRY (U"Algorithm")
  913. NORMAL (U"If #Precision is 1, the method is linear interpolation, which is inaccurate but fast.")
  914. /* BUG */
  915. NORMAL (U"If #Precision is greater than 1, the method is sin(%x)/%x (\"%sinc\") interpolation, "
  916. "with a depth equal to #Precision. "
  917. "For higher #Precision, the algorithm is slower but more accurate.")
  918. NORMAL (U"If ##Sampling frequency# is less than the sampling frequency of the selected sound, "
  919. "an anti-aliasing low-pass filtering is performed prior to resampling.")
  920. ENTRY (U"Behaviour")
  921. NORMAL (U"A new Sound will appear in the list of objects, "
  922. "bearing the same name as the original Sound, followed by the sampling frequency. "
  923. "For instance, the Sound \"hallo\" will give a new Sound \"hallo_10000\".")
  924. MAN_END
  925. MAN_BEGIN (U"Sound: Set value at sample number...", U"ppgb", 20140421)
  926. INTRO (U"A command to change a specified sample of the selected @Sound object.")
  927. ENTRY (U"Settings")
  928. TAG (U"##Sample number")
  929. DEFINITION (U"the sample whose value is to be changed. Specify any value between 1 and the number of samples in the Sound. "
  930. "If you specify a value outside that range, you will get an error message.")
  931. TAG (U"##New value")
  932. DEFINITION (U"the value that is to be put into the specified sample.")
  933. ENTRY (U"Scripting")
  934. NORMAL (U"Example:")
  935. CODE (U"selectObject: \"Sound hallo\"")
  936. CODE (U"Set value at sample number: 100, 1/2")
  937. NORMAL (U"This sets the value of the 100th sample to 0.5.")
  938. MAN_END
  939. MAN_BEGIN (U"SoundEditor", U"ppgb", 20170909)
  940. INTRO (U"An @@Editors|Editor@ for viewing and editing a @Sound object. "
  941. "Most of the functions of this editor are described in the @Intro.")
  942. ENTRY (U"The markers")
  943. NORMAL (U"To set the cursor, use the left mouse button. A short horizontal line will also be shown at the left edge (in cyan); "
  944. "the extension of this line crosses the cursor line at the sound's function value (seen as a cyan dot). "
  945. "This function value (shown at the left in cyan) is the sinc-interpolated value, and is generally different from the "
  946. "value that you would expect when looking at the linearly interpolated version of the sampled sound.")
  947. NORMAL (U"To select a part of the time domain, use the @@time selection@ mechanism.")
  948. ENTRY (U"Playing")
  949. NORMAL (U"To play any part of the sound, click on one of the rectangles "
  950. "below or above the sound window (there can be 1 to 8 of these rectangles), "
  951. "or choose a Play command from the View menu.")
  952. NORMAL (U"For multi-channel sounds you can mute one or more channels by a Ctrl-click on the " UNITEXT_SPEAKER " icon at the right side of the corresponding channel number. The icon will turn to " UNITEXT_SPEAKER_WITH_CANCELLATION_STROKE ". In subsequent playing actions the channel will not be played. Another Ctrl-click on a muted channel icon will activate the channel again. ")
  953. ENTRY (U"Publishing")
  954. NORMAL (U"To perform analyses on the selection, or save it to a file, "
  955. "create an independent Sound as a copy of the selection, "
  956. "by clicking on the button that will copy the selection to the List of Objects; "
  957. "the resulting Sound will be called \"Sound untitled\".")
  958. ENTRY (U"Editing")
  959. LIST_ITEM (U"\\bu Cut: cut the selection to the clipboard, for later pasting into the same or another Sound.")
  960. LIST_ITEM (U"\\bu Copy selection to Sound clipboard: copy the selection to the clipboard, for later pasting into the same or another Sound.")
  961. LIST_ITEM (U"\\bu Paste after selection: paste the clipboard to the cursor or after the selection.")
  962. LIST_ITEM (U"\\bu Set selection to zero: set the selected samples to zero.")
  963. LIST_ITEM (U"\\bu Reverse selection: reverse the selected part of the sound.")
  964. NORMAL (U"You can undo these commands with Undo (Command-Z).")
  965. ENTRY (U"The Group button")
  966. NORMAL (U"To synchronize a SoundEditor window with other windows that show a time signal, "
  967. "push the Group button in all the windows that you want to synchronize. "
  968. "You cannot Cut from or Paste into a synchronized SoundEditor window.")
  969. MAN_END
  970. MAN_BEGIN (U"SoundRecorder", U"ppgb", 20110129)
  971. INTRO (U"With the Praat SoundRecorder window you can record a mono or stereo sound "
  972. "for subsequent viewing and analysis in Praat. "
  973. "The SoundRecorder appears on your screen if you choose @@Record mono Sound...@ or @@Record stereo Sound...@ "
  974. "from the @@New menu@.")
  975. NORMAL (U"Depending on your system, the SoundRecorder window may allow you to choose "
  976. "the sampling frequency, the input gain, and the input device (microphone, line, or digital). "
  977. "The sound input level is monitored continuously with one or two meters. "
  978. "The resulting sound has 16 bits per sample, like sounds on an audio CD.")
  979. ENTRY (U"Usage")
  980. NORMAL (U"To record the sound, use the Record and Stop buttons in the SoundRecorder window. "
  981. "Click ##Save to list# to copy the recorded sound to the object window "
  982. "(or ##Save left channel to list# or ##Save right channel to list# "
  983. "to copy the left or right channel if you have a stereo sound). "
  984. "The name of the resulting Sound object will be taken from the text field next to the button clicked.")
  985. ENTRY (U"Size of the recording buffer")
  986. NORMAL (U"The size of the recording buffer determines how many seconds of sound you can record. "
  987. "For instance, if the recording buffer is 20 megabytes (the standard value), you can record 220 seconds in stereo "
  988. "(440 seconds in mono) at a sampling frequency of 22050 Hz, "
  989. "or 110 seconds in stereo (220 seconds in mono) at a sampling frequency of 44100 Hz. "
  990. "You can change the size of the recording buffer "
  991. "with ##Sound input prefs...# from the Preferences menu.")
  992. NORMAL (U"If you recorded a very long sound, it is probable that you cannot copy it to the list of objects. "
  993. "In such a case, you can still write the sound to disk with one of the #Save commands in the #File menu. "
  994. "You can then open such a long sound file in Praat with @@Open long sound file...@ from the Open menu.")
  995. #ifdef macintosh
  996. ENTRY (U"Recording sounds on MacOS X")
  997. NORMAL (U"You can record from the combined microphone / line input. On some computers, these are separate.")
  998. NORMAL (U"Note that in MacOS X you cannot record from the internal CD. This is because the system provides you with something better. "
  999. "If you open the CD in the Finder, you will see the audio tracks as AIFC files! "
  1000. "To open these audio tracks in Praat, use @@Read from file...@ or @@Open long sound file...@.")
  1001. #endif
  1002. #ifdef _WIN32
  1003. ENTRY (U"Recording sounds in Windows")
  1004. NORMAL (U"In Windows, you can choose your input device with the help of the recording mixer that is supplied by Windows or comes with "
  1005. "your sound card. There will usually be a loudspeaker icon in the Start bar; double-click it, and you will see the %playing mixer "
  1006. "(if there is no loudspeaker icon, go to ##Control Panels#, then ##Sounds and Audio Devices#, then #Volume, then #Advanced; "
  1007. "do not blame us for how Windows XP works). In the playing mixer, choose #Properties from the #Option menu, then click #Recording, "
  1008. "then #OK. You are now in the %recording mixer.")
  1009. NORMAL (U"You can watch the input level only while recording.")
  1010. #endif
  1011. ENTRY (U"The File menu")
  1012. NORMAL (U"If your computer has little memory, a very long recorded sound can be too big to be copied to the list of objects. "
  1013. "Fortunately, the File menu contains commands to save the recording "
  1014. "to a sound file on disk, so that you will never have to lose your recording.")
  1015. ENTRY (U"Sound pressure calibration")
  1016. NORMAL (U"Your computer's sound-recording software returns integer values between -32768 and 32767. "
  1017. "Praat divides them by 32768 before putting them into a Sound object, "
  1018. "so that the values in the Sound objects are always between -1 and +1.")
  1019. NORMAL (U"The Praat program considers these numbers to be air pressures in units of Pascal, "
  1020. "but they are probably not the actual true air pressures that went into the microphone. "
  1021. "For how to obtain the true air pressures, perform a @@sound pressure calibration@.")
  1022. MAN_END
  1023. MAN_BEGIN (U"Sounds: Concatenate", U"ppgb", 20110211)
  1024. INTRO (U"A command to concatenate all selected @Sound objects into a single large Sound.")
  1025. NORMAL (U"All sounds must have equal sampling frequencies and equal numbers of channels. "
  1026. "They are concatenated in the order in which they appear in the list of objects (not in the order in which you select them; remember: What You See Is What You Get).")
  1027. ENTRY (U"How to concatenate directly to a file")
  1028. NORMAL (U"If the resulting sound does not fit into memory, use one of the "
  1029. "commands in the @@Save menu@. See @@How to concatenate sound files@.")
  1030. ENTRY (U"See also")
  1031. NORMAL (U"If you want the sounds to fade into each other smoothly, choose @@Sounds: Concatenate with overlap...@ instead.")
  1032. MAN_END
  1033. MAN_BEGIN (U"Sounds: Concatenate with overlap...", U"ppgb", 20170904)
  1034. INTRO (U"A command to concatenate all selected @Sound objects into a single large Sound, with smooth cross-fading between the sounds.")
  1035. NORMAL (U"All sounds must have equal sampling frequencies and equal numbers of channels. "
  1036. "They are concatenated in the order in which they appear in the list of objects (not in the order in which you select them; remember: What You See Is What You Get).")
  1037. ENTRY (U"Settings")
  1038. SCRIPT (5.4, Manual_SETTINGS_WINDOW_HEIGHT (1), U""
  1039. Manual_DRAW_SETTINGS_WINDOW ("Sounds: Concatenate with overlap", 1)
  1040. Manual_DRAW_SETTINGS_WINDOW_FIELD ("Overlap time (s)", "0.01")
  1041. )
  1042. TAG (U"##Overlap time (s)")
  1043. DEFINITION (U"the time by which any two adjacent sounds will come to overlap, "
  1044. "i.e. the time during which the earlier sound fades out and the later sound fades in.")
  1045. ENTRY (U"Procedure")
  1046. NORMAL (U"Suppose we start with the following two sounds. They are both 0.1 seconds long. "
  1047. "The first sound is a sine wave with a frequency of 100 Hz, the second a sine wave with a frequency of 230 Hz:")
  1048. SCRIPT (5.0, 3, U""
  1049. "Create Sound from formula: \"sine100\", 1, 0, 0.1, 10000, ~ 0.9*sin(2*pi*100*x)\n"
  1050. "Draw: 0, 0, -1, 1, \"yes\", \"Curve\"\n"
  1051. "Remove")
  1052. SCRIPT (5.0, 3, U""
  1053. "Create Sound from formula: \"sine230\", 1, 0, 0.1, 10000, ~ 0.9*sin(2*pi*230*x)\n"
  1054. "Draw: 0, 0, -1, 1, \"yes\", \"Curve\"\n"
  1055. "Remove")
  1056. NORMAL (U"If the overlap time is 0.01 seconds, the concatenation of these two sounds will produce a Sound with a duration of 0.19 seconds, "
  1057. "which is the sum of the durations of the two sounds, minus the overlap time.")
  1058. NORMAL (U"The concatenation works in the following way. "
  1059. "The last 0.01 seconds of the first sound is multiplied by a falling raised cosine (the second half of a Hann window, see the first red curve), "
  1060. "and the first 0.01 seconds of the second sound is multiplied by a rising raised cosine (the first half of a Hann window, see the second red curve):")
  1061. SCRIPT (6.7, 5, U""
  1062. "Create Sound from formula: \"sine\", 1, 0, 0.1, 10000, ~ 0.9\n"
  1063. "Formula (part): 0.09, 0.1, 1, 1, ~ self*(0.5-0.5*cos(pi*(xmax-x)/0.01))\n"
  1064. "Select inner viewport: 0.5, 3.5, 0.5, 2.5\n"
  1065. "Red\n"
  1066. "Draw: 0, 0, -1, 1, \"no\", \"Curve\"\n"
  1067. "Formula: ~ self*sin(2*pi*100*x)\n"
  1068. "Black\n"
  1069. "Draw: 0, 0, -1, 1, \"no\", \"Curve\"\n"
  1070. "Draw inner box\n"
  1071. "One mark top: 0, \"yes\", \"yes\", \"no\", \"\"\n"
  1072. "One mark top: 0.09, \"yes\", \"yes\", \"yes\", \"\"\n"
  1073. "One mark top: 0.1, \"yes\", \"yes\", \"no\", \"\"\n"
  1074. "Text top: \"no\", \"Time (s)\"\n"
  1075. "One mark left: -1, \"yes\", \"yes\", \"no\", \"\"\n"
  1076. "One mark left: 0, \"yes\", \"yes\", \"yes\", \"\"\n"
  1077. "One mark left: 1, \"yes\", \"yes\", \"no\", \"\"\n"
  1078. "Formula: ~ 0.9\n"
  1079. "Formula (part): 0, 0.01, 1, 1, ~ self*(0.5-0.5*cos(pi*x/0.01))\n"
  1080. "Select inner viewport: 3.2, 6.2, 2.5, 4.5\n"
  1081. "Red\n"
  1082. "Draw: 0, 0, -1, 1, \"no\", \"Curve\"\n"
  1083. "Formula: ~ self*sin(2*pi*230*x)\n"
  1084. "Black\n"
  1085. "Draw: 0, 0, -1, 1, \"no\", \"Curve\"\n"
  1086. "Draw inner box\n"
  1087. "One mark bottom: 0, \"yes\", \"yes\", \"no\", \"\"\n"
  1088. "One mark bottom: 0.01, \"yes\", \"yes\", \"yes\", \"\"\n"
  1089. "One mark bottom: 0.1, \"yes\", \"yes\", \"no\", \"\"\n"
  1090. "Text bottom: \"no\", \"Time (s)\"\n"
  1091. "One mark right: -1, \"yes\", \"yes\", \"no\", \"\"\n"
  1092. "One mark right: 0, \"yes\", \"yes\", \"yes\", \"\"\n"
  1093. "One mark right: 1, \"yes\", \"yes\", \"no\", \"\"\n"
  1094. "Remove\n"
  1095. )
  1096. NORMAL (U"This figure shows how the two sounds are windowed (faded out and in), as well as how they will overlap.")
  1097. NORMAL (U"Finally, the two windowed (\"cross-faded\") sounds are added to each other:")
  1098. SCRIPT (6.7, 3, U""
  1099. "sine100 = Create Sound from formula... sine100 1 0 0.1 10000 0.9*sin(2*pi*100*x)\n"
  1100. "sine230 = Create Sound from formula... sine100 1 0 0.1 10000 0.9*sin(2*pi*230*x)\n"
  1101. "plus sine100\n"
  1102. "Concatenate with overlap... 0.01\n"
  1103. "Draw... 0 0 -1 1 yes Curve\n"
  1104. "One mark bottom... 0.09 yes yes yes\n"
  1105. "One mark bottom... 0.1 yes yes yes\n"
  1106. "plus sine100\n"
  1107. "plus sine230\n"
  1108. "Remove\n"
  1109. )
  1110. NORMAL (U"This example showed how it works if you concatenate two sounds; "
  1111. "if you concatenate three sounds, there will be two overlaps, and so on.")
  1112. MAN_END
  1113. MAN_BEGIN (U"Sounds: Convolve...", U"ppgb & djmw", 20100404)
  1114. INTRO (U"A command available in the #Combine menu when you select two @Sound objects. "
  1115. "This command convolves two selected @Sound objects with each other. "
  1116. "As a result, a new Sound will appear in the list of objects; "
  1117. "this new Sound is the %convolution of the two original Sounds.")
  1118. ENTRY (U"Settings")
  1119. TAG (U"##Amplitude scaling")
  1120. DEFINITION (U"Here you can choose between the `principled' options #integral, #sum, and #normalize, which are explained in 1, 2 and 3 below. "
  1121. "There is also a `pragmatic' option, namely ##peak 0.99#, which scales the resulting sound in such a way "
  1122. "that its absolute peak becomes 0.99, so that the sound tends to be clearly audible without distortion when you play it "
  1123. "(see @@Sound: Scale peak...@).")
  1124. TAG (U"##Signal outside time domain is...")
  1125. DEFINITION (U"Here you can choose whether outside their time domains the sounds are considered to be #zero "
  1126. "(the standard value), or #similar to the sounds within the time domains. "
  1127. "This is explained in 4 below.")
  1128. ENTRY (U"1. Convolution as an integral")
  1129. NORMAL (U"The convolution %f*%g of two continuous time signals %f(%t) and %g(%t) is defined as the #integral")
  1130. FORMULA (U"(%f*%g) (%t) \\=3 \\in %f(%\\ta) %g(%t-%\\ta) %d%\\ta")
  1131. NORMAL (U"If %f and %g are sampled signals (as Sounds are in Praat), with the same @@sampling period@ %%\\Det%, "
  1132. "the definition is discretized as")
  1133. FORMULA (U"(%f*%g) [%t] \\=3 \\su__%\\ta_ %f[%\\ta] %g[%t-%\\ta] %%\\Det%")
  1134. NORMAL (U"where %\\ta and %t-%\\ta are the discrete times at which %f and %g are defined, respectively.")
  1135. NORMAL (U"Convolution is a commutative operation, i.e. %g*%f equals %f*%g. "
  1136. "This means that the order in which you put the two Sounds in the object list does not matter: you get the same result either way.")
  1137. ENTRY (U"2. Convolution as a sum")
  1138. NORMAL (U"You can see in the formula above that if both input Sounds are expressed in units of Pa, "
  1139. "the resulting Sound should ideally be expressed in Pa^^2^s. "
  1140. "Nevertheless, Praat will express it in Pa, because Sounds cannot be expressed otherwise.")
  1141. NORMAL (U"This basically means that it is impossible to get the amplitude of the resulting Sound correct for all purposes. "
  1142. "For this reason, Praat considers a different definition of convolution as well, namely as the #sum")
  1143. FORMULA (U"(%f*%g) [%t] \\=3 \\su__\\ta_ %f[%\\ta] %g[%t-%\\ta]")
  1144. NORMAL (U"The sum definition is appropriate if you want to filter a pulse train with a finite-impulse-response filter "
  1145. "and expect the amplitudes of each resulting period to be equal to the amplitude of the filter. Thus, the pulse train")
  1146. SCRIPT (5, 3,
  1147. U"Create Sound from formula... peaks mono 0 0.6 1000 x*(col mod 100 = 0)\n"
  1148. "Draw... 0 0 0 0.6 yes curve\n"
  1149. "Remove"
  1150. )
  1151. NORMAL (U"(made with ##@@Create Sound from formula...@ peaks mono 0 0.6 1000 x*(col mod 100 = 0)#), "
  1152. "convolved with the `leaky integrator' filter")
  1153. SCRIPT (5, 3,
  1154. U"Create Sound from formula... leak mono 0 1 1000 exp(-x/0.1)\n"
  1155. "Draw... 0 0 0 1 yes curve\n"
  1156. "Remove"
  1157. )
  1158. NORMAL (U"(made with ##@@Create Sound from formula...@ leak mono 0 1 1000 exp(-x/0.1)#), "
  1159. "yields the convolution")
  1160. SCRIPT (5, 3,
  1161. U"Create Sound from formula... peaks mono 0 0.6 1000 x*(col mod 100 = 0)\n"
  1162. "Create Sound from formula... leak mono 0 1 1000 exp(-x/0.1)\n"
  1163. "plus Sound peaks\n"
  1164. "Convolve... sum zero\n"
  1165. "Draw... 0 0 0 0.8523 yes curve\n"
  1166. "plus Sound peaks\n"
  1167. "plus Sound leak\n"
  1168. "Remove"
  1169. )
  1170. NORMAL (U"The difference between the integral and sum definitions is that in the sum definition "
  1171. "the resulting sound is divided by %%\\Det%.")
  1172. ENTRY (U"3. Normalized convolution")
  1173. NORMAL (U"The %%normalized convolution% is defined as")
  1174. FORMULA (U"(normalized %f*%g) (%t) \\=3 \\in %f(%\\ta) %g(%t-%\\ta) %d%\\ta "
  1175. "/ \\Vr (\\in %f^^2^(%\\ta) %%d\\ta% \\in %g^^2^(%\\ta) %%d\\ta%)")
  1176. ENTRY (U"4. Shape scaling")
  1177. NORMAL (U"The boundaries of the integral in 1 are -\\oo and +\\oo. "
  1178. "However, %f and %g are Sound objects in Praat and therefore have finite time domains. "
  1179. "If %f runs from %t__1_ to %t__2_ and is assumed to be #zero before %t__1_ and after %t__2_, and "
  1180. "%g runs from %t__3_ to %t__4_ and is assumed to be zero outside that domain, "
  1181. "then the convolution will be zero before %t__1_ + %t__3_ and after %t__2_ + %t__4_, "
  1182. "while between %t__1_ + %t__3_ and %t__2_ + %t__4_ it is")
  1183. FORMULA (U"(%f*%g) (%t) = \\in__%%t%1_^^%%t%2^ %f(%\\ta) %g(%t-%\\ta) %d%\\ta")
  1184. NORMAL (U"In this formula, the argument of %f runs from %t__1_ to %t__2_, "
  1185. "but the argument of %g runs from (%t__1_ + %t__3_) - %t__2_ to (%t__2_ + %t__4_) - %t__1_, "
  1186. "i.e. from %t__3_ - (%t__2_ - %t__1_) to %t__4_ + (%t__2_ - %t__1_). "
  1187. "This means that the integration is performed over two equal stretches of time during which %g must be taken zero, "
  1188. "namely a time stretch before %t__3_ and a time stretch after %t__4_, both of duration %t__2_ - %t__1_ "
  1189. "(equivalent equations can be formulated that rely on two stretches of %t__4_ - %t__3_ of zeroes in %f rather than in %g, "
  1190. "or on a stretch of %t__2_ - %t__1_ of zeroes in %g and a stretch of %t__4_ - %t__3_ of zeroes in %f.")
  1191. NORMAL (U"If you consider the sounds outside their time domains as #similar to what they are within their time domains, instead of #zero, "
  1192. "the discretized formula in 1 should be based on the average over the jointly defined values of %f[%\\ta] and %g[%t-%\\ta], "
  1193. "without counting any multiplications of values outside the time domains. "
  1194. "Suppose that %f is defined on the time domain [0, 1.2] with the value of 1 everywhere, "
  1195. "and %g is defined on the time domain [0, 3] with the value 1 everywhere. "
  1196. "Their convolution under the assumption that they are #zero elsewhere is then")
  1197. SCRIPT (5, 3,
  1198. U"Create Sound from formula... short mono 0 1.2 1000 1\n"
  1199. "Create Sound from formula... long mono 0 3 1000 1\n"
  1200. "plus Sound short\n"
  1201. "Convolve... integral zero\n"
  1202. "Draw... 0 0 0 1.5 yes curve\n"
  1203. "One mark left... 1.2 yes yes yes\n"
  1204. "plus Sound short\n"
  1205. "plus Sound long\n"
  1206. "Remove"
  1207. )
  1208. NORMAL (U"but under the assumption that the sounds are #similar (i.e. 1) elsewhere, their convolution should be")
  1209. SCRIPT (5, 3,
  1210. U"Create Sound from formula... short mono 0 1.2 1000 1\n"
  1211. "Create Sound from formula... long mono 0 3 1000 1\n"
  1212. "plus Sound short\n"
  1213. "Convolve... integral similar\n"
  1214. "Draw... 0 0 0 1.5 yes curve\n"
  1215. "One mark left... 1.2 yes yes yes\n"
  1216. "plus Sound short\n"
  1217. "plus Sound long\n"
  1218. "Remove"
  1219. )
  1220. NORMAL (U"i.e. a constant value of 1.2. This is what you get by choosing the #similar option; "
  1221. "if %f is shorter than %g, the first and last parts of the convolution will be divided by a straight line of duration %t__2_ - %t__1_ "
  1222. "to compensate for the fact that the convolution has been computed over fewer values of %f and %g there.")
  1223. ENTRY (U"5. Behaviour")
  1224. NORMAL (U"The start time of the resulting Sound will be the sum of the start times of the original Sounds, "
  1225. "the end time of the resulting Sound will be the sum of the end times of the original Sounds, "
  1226. "the time of the first sample of the resulting Sound will be the sum of the first samples of the original Sounds, "
  1227. "the time of the last sample of the resulting Sound will be the sum of the last samples of the original Sounds, "
  1228. "and the number of samples in the resulting Sound will be the sum of the numbers of samples of the original Sounds minus 1.")
  1229. ENTRY (U"6. Behaviour for stereo and other multi-channel sounds")
  1230. NORMAL (U"You can convolve e.g. a 10-channel sound either with another 10-channel sound or with a 1-channel (mono) sound.")
  1231. NORMAL (U"If both Sounds have more than one channel, the two Sounds have to have the same number of channels; "
  1232. "each channel of the resulting Sound is then computed as the convolution of the corresponding channels "
  1233. "of the original Sounds. For instance, if you convolve two 10-channel sounds, "
  1234. "the resulting sound will have 10 channels, and its 9th channel will be the convolution of the 9th channels "
  1235. "of the two original sounds.")
  1236. NORMAL (U"If one of the original Sounds has multiple channels and the other Sound has only one channel, "
  1237. "the resulting Sound will have multiple channels; each of these is computed as the convolution of "
  1238. "the corresponding channel of the multiple-channel original and the single channel of the single-channel original. "
  1239. "For instance, if you convolve a 10-channel sound with a mono sound, "
  1240. "the resulting sound will have 10 channels, and its 9th channel will be the convolution of the mono sound "
  1241. "with the 9th channel of the original 10-channel sound.")
  1242. NORMAL (U"The amplitude scaling factor will be the same for all channels, so that the relative amplitude of the channels "
  1243. "will be preserved in the resulting sound. For the #normalize scaling, for instance, the norm of %f in the formula above "
  1244. "is taken over all channels of %f. For the ##peak 0.99# scaling, the resulting sound will typically have an absolute peak "
  1245. "of 0.99 in only one channel, and lower absolute peaks in the other channels.")
  1246. ENTRY (U"7. Algorithm")
  1247. NORMAL (U"The computation makes use of the fact that convolution in the time domain corresponds to multiplication in the frequency domain: "
  1248. "we first pad %f with a stretch of %t__4_ - %t__3_ of zeroes and %g with a stretch of %t__2_ - %t__1_ of zeroes (see 4 above), "
  1249. "so that both sounds obtain a duration of (%t__2_ - %t__1_) + (%t__4_ - %t__3_); "
  1250. "we then calculate the spectra of the two zero-padded sounds by Fourier transformation, "
  1251. "then multiply the two spectra with each other, "
  1252. "and finally Fourier-transform the result of this multiplication back to the time domain; "
  1253. "the result will again have a duration of (%t__2_ - %t__1_) + (%t__4_ - %t__3_).")
  1254. MAN_END
  1255. MAN_BEGIN (U"Sounds: Cross-correlate...", U"djmw & ppgb", 20100404)
  1256. INTRO (U"A command available in the #Combine menu when you select two @Sound objects. "
  1257. "This command cross-correlates two selected @Sound objects with each other. "
  1258. "As a result, a new Sound will appear in the list of objects; "
  1259. "this new Sound is the %cross-correlation of the two original Sounds.")
  1260. ENTRY (U"Settings")
  1261. TAG (U"##Amplitude scaling")
  1262. DEFINITION (U"Here you can choose between the `principled' options #integral, #sum, and #normalize, which are explained in 1, 2 and 3 below. "
  1263. "There is also a `pragmatic' option, namely ##peak 0.99#, which scales the resulting sound in such a way "
  1264. "that its absolute peak becomes 0.99, so that the sound tends to be clearly audible without distortion when you play it "
  1265. "(see @@Sound: Scale peak...@).")
  1266. TAG (U"##Signal outside time domain is...")
  1267. DEFINITION (U"Here you can choose whether outside their time domains the sounds are considered to be #zero "
  1268. "(the standard value), or #similar to the sounds within the time domains. "
  1269. "This is explained in 4 below.")
  1270. ENTRY (U"1. Cross-correlation as an integral")
  1271. NORMAL (U"The cross-correlation of two continuous time signals %f(%t) and %g(%t) is a function of the lag time %\\ta, "
  1272. "and defined as the #integral")
  1273. FORMULA (U"cross-corr (%f, %g) (%\\ta) \\=3 \\in %f(%t) %g(%t+%\\ta) %dt")
  1274. NORMAL (U"If %f and %g are sampled signals (as Sounds are in Praat), with the same @@sampling period@ %%\\Det%, "
  1275. "the definition is discretized as")
  1276. FORMULA (U"cross-corr (%f, %g) [%\\ta] \\=3 \\su__%t_ %f[%t] %g[%t+%\\ta] %%\\Det%")
  1277. NORMAL (U"where %\\ta and %t+%\\ta are the discrete times at which %f and %g are defined, respectively.")
  1278. NORMAL (U"Cross-correlation is not a commutative operation, i.e. cross-corr (%g, %f) equals the time reversal of cross-corr (%f, %g). "
  1279. "This means that the order in which you put the two Sounds in the object list does matter: "
  1280. "the two results are each other's time reversals.")
  1281. ENTRY (U"2. Cross-correlation as a sum")
  1282. NORMAL (U"You can see in the formula above that if both input Sounds are expressed in units of Pa, "
  1283. "the resulting Sound should ideally be expressed in Pa^^2^s. "
  1284. "Nevertheless, Praat will express it in Pa, because Sounds cannot be expressed otherwise.")
  1285. NORMAL (U"This basically means that it is impossible to get the amplitude of the resulting Sound correct for all purposes. "
  1286. "For this reason, Praat considers a different definition of cross-correlation as well, namely as the #sum")
  1287. FORMULA (U"cross-corr (%f, %g) [%\\ta] \\=3 \\su__%t_ %f[%t] %g[%t+%\\ta]")
  1288. NORMAL (U"The difference between the integral and sum definitions is that in the sum definition "
  1289. "the resulting sound is divided by %%\\Det%.")
  1290. ENTRY (U"3. Normalized cross-correlation")
  1291. NORMAL (U"The %%normalized cross-correlation% is defined as")
  1292. FORMULA (U"norm-cross-corr (%f, %g) (%\\ta) \\=3 \\in %f(%t) %g(%t+%\\ta) %d%t "
  1293. "/ \\Vr (\\in %f^^2^(%t) %%dt% \\in %g^^2^(%t) %%dt%)")
  1294. ENTRY (U"4. Shape scaling")
  1295. NORMAL (U"The boundaries of the integral in 1 are -\\oo and +\\oo. "
  1296. "However, %f and %g are Sound objects in Praat and therefore have finite time domains. "
  1297. "If %f runs from %t__1_ to %t__2_ and is assumed to be #zero before %t__1_ and after %t__2_, and "
  1298. "%g runs from %t__3_ to %t__4_ and is assumed to be zero outside that domain, "
  1299. "then the cross-correlation will be zero before %t__3_ - %t__2_ and after %t__4_ - %t__1_, "
  1300. "while between %t__3_ - %t__2_ and %t__4_ - %t__1_ it is")
  1301. FORMULA (U"cross-corr (%f, %g) (%\\ta) = \\in__%%t%1_^^%%t%2^ %f(%t) %g(%t+%\\ta) %d%t")
  1302. NORMAL (U"In this formula, the argument of %f runs from %t__1_ to %t__2_, "
  1303. "but the argument of %g runs from %t__1_ + (%t__3_ - %t__2_) to %t__2_ + (%t__4_ - %t__1_), "
  1304. "i.e. from %t__3_ - (%t__2_ - %t__1_) to %t__4_ + (%t__2_ - %t__1_). "
  1305. "This means that the integration is performed over two equal stretches of time during which %g must be taken zero, "
  1306. "namely a time stretch before %t__3_ and a time stretch after %t__4_, both of duration %t__2_ - %t__1_ "
  1307. "(equivalent equations can be formulated that rely on two stretches of %t__4_ - %t__3_ of zeroes in %f rather than in %g, "
  1308. "or on a stretch of %t__2_ - %t__1_ of zeroes in %g and a stretch of %t__4_ - %t__3_ of zeroes in %f.")
  1309. NORMAL (U"If you consider the sounds outside their time domains as #similar to what they are within their time domains, instead of #zero, "
  1310. "the discretized formula in 1 should be based on the average over the jointly defined values of %f[%\\ta] and %g[%t-%\\ta], "
  1311. "without counting any multiplications of values outside the time domains. "
  1312. "Suppose that %f is defined on the time domain [0, 1.2] with the value of 1 everywhere, "
  1313. "and %g is defined on the time domain [0, 3] with the value 1 everywhere. "
  1314. "Their cross-correlation under the assumption that they are #zero elsewhere is then")
  1315. SCRIPT (5, 3,
  1316. U"Create Sound from formula... short mono 0 1.2 1000 1\n"
  1317. "Create Sound from formula... long mono 0 3 1000 1\n"
  1318. "plus Sound short\n"
  1319. "Cross-correlate... integral zero\n"
  1320. "Draw... 0 0 0 1.5 yes curve\n"
  1321. "One mark left... 1.2 yes yes yes\n"
  1322. "plus Sound short\n"
  1323. "plus Sound long\n"
  1324. "Remove"
  1325. )
  1326. NORMAL (U"but under the assumption that the sounds are #similar (i.e. 1) elsewhere, their cross-correlation should be")
  1327. SCRIPT (5, 3,
  1328. U"Create Sound from formula... short mono 0 1.2 1000 1\n"
  1329. "Create Sound from formula... long mono 0 3 1000 1\n"
  1330. "plus Sound short\n"
  1331. "Cross-correlate... integral similar\n"
  1332. "Draw... 0 0 0 1.5 yes curve\n"
  1333. "One mark left... 1.2 yes yes yes\n"
  1334. "plus Sound short\n"
  1335. "plus Sound long\n"
  1336. "Remove"
  1337. )
  1338. NORMAL (U"i.e. a constant value of 1.2. This is what you get by choosing the #similar option; "
  1339. "if %f is shorter than %g, the first and last parts of the cross-correlation will be divided by a straight line of duration %t__2_ - %t__1_ "
  1340. "to compensate for the fact that the cross-correlation has been computed over fewer values of %f and %g there.")
  1341. ENTRY (U"5. Behaviour")
  1342. NORMAL (U"The start time of the resulting Sound will be the start time of %f minus the end time of %g, "
  1343. "the end time of the resulting Sound will be the end time of %f minus the start time of %g, "
  1344. "the time of the first sample of the resulting Sound will be the first sample of %f minus the last sample of %g, "
  1345. "the time of the last sample of the resulting Sound will be the last sample of %f minus the first sample of %g, "
  1346. "and the number of samples in the resulting Sound will be the sum of the numbers of samples of %f and %g minus 1.")
  1347. ENTRY (U"6. Behaviour for stereo and other multi-channel sounds")
  1348. NORMAL (U"You can cross-correlate e.g. a 10-channel sound either with another 10-channel sound or with a 1-channel (mono) sound.")
  1349. NORMAL (U"If both Sounds have more than one channel, the two Sounds have to have the same number of channels; "
  1350. "each channel of the resulting Sound is then computed as the cross-correlation of the corresponding channels "
  1351. "of the original Sounds. For instance, if you cross-correlate two 10-channel sounds, "
  1352. "the resulting sound will have 10 channels, and its 9th channel will be the cross-correlation of the 9th channels "
  1353. "of the two original sounds.")
  1354. NORMAL (U"If one of the original Sounds has multiple channels and the other Sound has only one channel, "
  1355. "the resulting Sound will have multiple channels; each of these is computed as the cross-correlation of "
  1356. "the corresponding channel of the multiple-channel original and the single channel of the single-channel original. "
  1357. "For instance, if you cross-correlate a 10-channel sound with a mono sound, "
  1358. "the resulting sound will have 10 channels, and its 9th channel will be the cross-correlation of the mono sound "
  1359. "with the 9th channel of the original 10-channel sound.")
  1360. NORMAL (U"The amplitude scaling factor will be the same for all channels, so that the relative amplitude of the channels "
  1361. "will be preserved in the resulting sound. For the #normalize scaling, for instance, the norm of %f in the formula above "
  1362. "is taken over all channels of %f. For the ##peak 0.99# scaling, the resulting sound will typically have an absolute peak "
  1363. "of 0.99 in only one channel, and lower absolute peaks in the other channels.")
  1364. ENTRY (U"7. Algorithm")
  1365. NORMAL (U"The computation makes use of the fact that cross-correlation in the time domain corresponds to multiplication "
  1366. "of the time-reversal of %f with %g in the frequency domain: "
  1367. "we first pad %f with a stretch of %t__4_ - %t__3_ of zeroes and %g with a stretch of %t__2_ - %t__1_ of zeroes (see 4 above), "
  1368. "so that both sounds obtain a duration of (%t__2_ - %t__1_) + (%t__4_ - %t__3_); "
  1369. "we then calculate the spectra of the two zero-padded sounds by Fourier transformation, "
  1370. "then multiply the complex conjugate of the spectrum of %f with the spectrum of %g, "
  1371. "and finally Fourier-transform the result of this multiplication back to the time domain; "
  1372. "the result will again have a duration of (%t__2_ - %t__1_) + (%t__4_ - %t__3_).")
  1373. MAN_END
  1374. MAN_BEGIN (U"Sound: Autocorrelate...", U"djmw & ppgb", 20100404)
  1375. INTRO (U"A command available in the #Periodicity menu when you select one or more @Sound objects. "
  1376. "This command autocorrelates the selected @Sound object. "
  1377. "As a result, a new Sound will appear in the list of objects; "
  1378. "this new Sound is the %autocorrelation of the original Sound.")
  1379. ENTRY (U"Settings")
  1380. TAG (U"##Amplitude scaling")
  1381. DEFINITION (U"Here you can choose between the `principled' options #integral, #sum, and #normalize, which are explained in 1, 2 and 3 below. "
  1382. "There is also a `pragmatic' option, namely ##peak 0.99#, which scales the resulting sound in such a way "
  1383. "that its absolute peak becomes 0.99, so that the sound tends to be clearly audible without distortion when you play it "
  1384. "(see @@Sound: Scale peak...@).")
  1385. TAG (U"##Signal outside time domain is...")
  1386. DEFINITION (U"Here you can choose whether outside its time domain the sound is considered to be #zero "
  1387. "(the standard value), or #similar to the sound within the time domain. "
  1388. "This is explained in 4 below.")
  1389. //DEFINITION (U"Here you can choose whether outside its time domain the sound is considered to be #zero "
  1390. // "(the standard value), or #similar to the sound within the time domain, or #periodic, i.e. that "
  1391. // "outside the time domain the waveforms is a repetition of the waveform within the time domain. "
  1392. // "This is explained in 4 below.")
  1393. ENTRY (U"1. Autocorrelation as an integral")
  1394. NORMAL (U"The autocorrelation of a continuous time signal %f(%t) is a function of the lag time %\\ta, "
  1395. "and defined as the #integral")
  1396. FORMULA (U"%R__%f_ (%\\ta) \\=3 \\in %f(%t) %f(%t+%\\ta) %dt")
  1397. NORMAL (U"If %f is a sampled signal (as Sounds are in Praat), with @@sampling period@ %%\\Det%, "
  1398. "the definition is discretized as")
  1399. FORMULA (U"%R__%f_ [%\\ta] \\=3 \\su__%t_ %f[%t] %f[%t+%\\ta] %%\\Det%")
  1400. NORMAL (U"where %\\ta and %t+%\\ta are the discrete times at which %f is defined.")
  1401. NORMAL (U"The autocorrelation is symmetric: %R__%f_ (-%\\ta) = %R__%f_ (%\\ta).")
  1402. ENTRY (U"2. Autocorrelation as a sum")
  1403. NORMAL (U"You can see in the formula above that if the input Sound is expressed in units of Pa, "
  1404. "the resulting Sound should ideally be expressed in Pa^^2^s. "
  1405. "Nevertheless, Praat will express it in Pa, because Sounds cannot be expressed otherwise.")
  1406. NORMAL (U"This basically means that it is impossible to get the amplitude of the resulting Sound correct for all purposes. "
  1407. "For this reason, Praat considers a different definition of autocorrelation as well, namely as the #sum")
  1408. FORMULA (U"%R__%f_ [%\\ta] \\=3 \\su__%t_ %f[%t] %g[%t+%\\ta]")
  1409. NORMAL (U"The difference between the integral and sum definitions is that in the sum definition "
  1410. "the resulting sound is divided by %%\\Det%.")
  1411. ENTRY (U"3. Normalized autocorrelation")
  1412. NORMAL (U"The %%normalized autocorrelation% is defined as")
  1413. FORMULA (U"norm-autocorr (%f) (%\\ta) \\=3 \\in %f(%t) %f(%t+%\\ta) %d%t / \\in %f^^2^(%t) %%dt%")
  1414. ENTRY (U"4. Shape scaling")
  1415. NORMAL (U"The boundaries of the integral in 1 are -\\oo and +\\oo. "
  1416. "However, %f is a Sound object in Praat and therefore has a finite time domain. "
  1417. "If %f runs from %t__1_ to %t__2_ and is assumed to be #zero before %t__1_ and after %t__2_, "
  1418. "then the autocorrelation will be zero before %t__1_ - %t__2_ and after %t__2_ - %t__1_, "
  1419. "while between %t__1_ - %t__2_ and %t__2_ - %t__1_ it is")
  1420. FORMULA (U"%R__%f_ (%\\ta) = \\in__%%t%1_^^%%t%2^ %f(%t) %f(%t+%\\ta) %d%t")
  1421. NORMAL (U"In this formula, the argument of the first %f runs from %t__1_ to %t__2_, "
  1422. "but the argument of the second %f runs from %t__1_ + (%t__1_ - %t__2_) to %t__2_ + (%t__2_ - %t__1_), "
  1423. "i.e. from %t__1_ - (%t__2_ - %t__1_) to %t__2_ + (%t__2_ - %t__1_). "
  1424. "This means that the integration is performed over two equal stretches of time during which %f must be taken zero, "
  1425. "namely a time stretch before %t__1_ and a time stretch after %t__2_, both of duration %t__2_ - %t__1_.")
  1426. NORMAL (U"If you consider the sound outside its time domains as #similar to what it is within its time domain, instead of #zero, "
  1427. "the discretized formula in 1 should be based on the average over the jointly defined values of %f[%\\ta] and %f[%t-%\\ta], "
  1428. "without counting any multiplications of values outside the time domain. "
  1429. "Suppose that %f is defined on the time domain [0, 1.2] with the value of 1 everywhere. "
  1430. "Its autocorrelation under the assumption that it is #zero elsewhere is then")
  1431. SCRIPT (5, 3,
  1432. U"Create Sound from formula... sound mono 0 1.2 1000 1\n"
  1433. "Autocorrelate... integral zero\n"
  1434. "Draw... 0 0 0 1.5 yes curve\n"
  1435. "One mark left... 1.2 yes yes yes\n"
  1436. "plus Sound sound\n"
  1437. "Remove"
  1438. )
  1439. NORMAL (U"but under the assumption that the sound is #similar (i.e. 1) elsewhere, its autocorrelation should be")
  1440. SCRIPT (5, 3,
  1441. U"Create Sound from formula... sound mono 0 1.2 1000 1\n"
  1442. "Autocorrelate... integral similar\n"
  1443. "Draw... 0 0 0 1.5 yes curve\n"
  1444. "One mark left... 1.2 yes yes yes\n"
  1445. "plus Sound sound\n"
  1446. "Remove"
  1447. )
  1448. NORMAL (U"i.e. a constant value of 1.2. This is what you get by choosing the #similar option; "
  1449. "the autocorrelation will be divided by a triangular function "
  1450. "to compensate for the fact that the autocorrelation has been computed over fewer values closer to the edges; "
  1451. "this procedure is followed in all autocorrelation-based pitch computations in Praat (see @@Sound: To Pitch...@). "
  1452. "For examples, see @@Boersma (1993)@.")
  1453. ENTRY (U"5. Behaviour")
  1454. NORMAL (U"The start time of the resulting Sound will be the start time of %f minus the end time of %f, "
  1455. "the end time of the resulting Sound will be the end time of %f minus the start time of %f, "
  1456. "the time of the first sample of the resulting Sound will be the first sample of %f minus the last sample of %f, "
  1457. "the time of the last sample of the resulting Sound will be the last sample of %f minus the first sample of %f, "
  1458. "and the number of samples in the resulting Sound will be twice the number of samples of %f, minus 1.")
  1459. ENTRY (U"6. Behaviour for stereo and other multi-channel sounds")
  1460. NORMAL (U"If the selected Sound has more than one channel, each channel of the resulting Sound is computed "
  1461. "as the cross-correlation of the corresponding channel "
  1462. "of the original Sound. For instance, if you autocorrelate a 10-channel sound, "
  1463. "the resulting sound will again have 10 channels, and its 9th channel will be the autocorrelation of the 9th channel "
  1464. "of the original sound.")
  1465. NORMAL (U"The amplitude scaling factor will be the same for all channels, so that the relative amplitude of the channels "
  1466. "will be preserved in the resulting sound. For the #normalize scaling, for instance, the squared norm of %f in the formula above "
  1467. "is taken over all channels of %f. For the ##peak 0.99# scaling, the resulting sound will typically have an absolute peak "
  1468. "of 0.99 in only one channel, and lower absolute peaks in the other channels.")
  1469. ENTRY (U"Algorithm")
  1470. NORMAL (U"The autocorrelation is calculated as the @@Sounds: Cross-correlate...|cross-correlation@ of a sound with itself.")
  1471. MAN_END
  1472. MAN_BEGIN (U"Sound: Scale intensity...", U"ppgb", 20120614)
  1473. INTRO (U"A command available in the #Modify menu when you select one or more @Sound objects. "
  1474. "With this command you multiply the amplitude of each Sound in such a way that its average (i.e. root-mean-square) intensity becomes "
  1475. "the ##new average intensity# that you specify (see Settings).")
  1476. ENTRY (U"Settings")
  1477. TAG (U"##New average intensity (dB SPL)")
  1478. DEFINITION (U"the new average intensity of the Sound. The standard value is 70 dB SPL. This means that the root-mean-square amplitude "
  1479. "of the sound will come to lie 70 dB above the assumed auditory threshold of 0.00002 Pa. Please check whether as a result a peak in the sound "
  1480. "does not get below -1 Pa or above +1 Pa. If that happens, the sound will be clipped when played, which will be audible as distortion; "
  1481. "in thast case you may want to set this number to 60 dB or even lower.")
  1482. MAN_END
  1483. MAN_BEGIN (U"Sound: Scale peak...", U"ppgb", 20100328)
  1484. INTRO (U"A command available in the #Modify menu when you select one or more @Sound objects. "
  1485. "With this command you multiply the amplitude of each Sound in such a way that its absolute peak becomes "
  1486. "the ##new absolute peak# that you specify (see Settings).")
  1487. ENTRY (U"Settings")
  1488. TAG (U"##New absolute peak")
  1489. DEFINITION (U"the new absolute peak of the Sound. The standard value is 0.99: this maximizes the audibility of the Sound "
  1490. "(sounds with lower amplitude are weaker) without distorting it "
  1491. "(sounds with absolute peaks above 1 are clipped when they are played).")
  1492. ENTRY (U"Examples")
  1493. NORMAL (U"The absolute peak of the following sound is 0.033:")
  1494. SCRIPT (6.0, 3.0,
  1495. U"Create Sound from formula... 033 mono 0 0.1 10000 -0.02*(sin(2*pi*205*x)+sin(2*pi*5*x))+0.007\n"
  1496. "Draw... 0 0 -0.033 0.0247 yes curve\n"
  1497. "Remove"
  1498. )
  1499. NORMAL (U"This sound will play rather weakly. To make it louder, you can do ##Scale peak...# with a ##new absolute peak# of 0.99. "
  1500. "Praat will then multiply the waveform by 30, changing the sound to the following:")
  1501. SCRIPT (6.0, 3.0,
  1502. U"Create Sound from formula... 033 mono 0 0.1 10000 -0.6*(sin(2*pi*205*x)+sin(2*pi*5*x))+0.21\n"
  1503. "Draw... 0 0 -0.99 0.741 yes curve\n"
  1504. "Remove"
  1505. )
  1506. NORMAL (U"The absolute peak is now 0.99, and the sound will play loudly.")
  1507. NORMAL (U"The reverse is also possible. The absolute peak of the following sound is 19.8:")
  1508. SCRIPT (6.0, 3.0,
  1509. U"Create Sound from formula... 033 mono 0 0.1 10000 12*(sin(2*pi*305*x)+sin(2*pi*5*x))-4.2\n"
  1510. "Draw... 0 0 -15.28 19.8 yes curve\n"
  1511. "Remove"
  1512. )
  1513. NORMAL (U"This sound will not play correctly: all samples with an amplitude outside the [-1;+1] range will be clipped to -1 or +1. "
  1514. "To make this sound nicer to play, you can again do ##Scale peak...# with a ##new absolute peak# of 0.99. "
  1515. "Praat will then divide the waveform by 20, changing the sound to the following:")
  1516. SCRIPT (6.0, 3.0,
  1517. U"Create Sound from formula... 033 mono 0 0.1 10000 0.6*(sin(2*pi*305*x)+sin(2*pi*5*x))-0.21\n"
  1518. "Draw... 0 0 -0.764 0.99 yes curve\n"
  1519. "Remove"
  1520. )
  1521. NORMAL (U"The absolute peak is now 0.99, and the sound will play without distortion.")
  1522. MAN_END
  1523. }
  1524. /* End of file manual_sound.cpp */