script2.praat 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. writeFile ("kanweg.txt", "hello")
  2. appendFileLine ("kanweg.txt", " é", 3, "oeps")
  3. appendFile ("kanweg.txt", "갡갳")
  4. writeFileLine ("kanweg2.txt", "hello2")
  5. text$ = readFile$ ("kanweg2.txt")
  6. assert text$ = "hello2" + newline$
  7. writeFileLine ("kanweg2.txt", sqrt (100))
  8. number = readFile ("kanweg2.txt")
  9. assert number = 10
  10. writeInfoLine (2, "hallo", 3)
  11. assert info$ ( ) = "2hallo3" + newline$
  12. assert number (info$ ()) = 2
  13. writeInfoLine (undefined)
  14. assert number (info$ ()) = undefined
  15. do ("Erase all")
  16. writeInfoLine ("Test...")
  17. p = do ("Create Sound as pure tone...", "a", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01)
  18. do ("Play")
  19. do ("Save as WAV file...", "kanweg.wav")
  20. beep = do ("Read from file...", "kanweg.wav")
  21. do ("Play")
  22. do ("View & Edit")
  23. editor Sound kanweg
  24. do ("Zoom...", 0.1, 0.3)
  25. do ("Play or stop")
  26. Zoom... 0.1 0.3
  27. Play or stop
  28. endeditor
  29. q = do ("Create Sound from tone complex...", "sweep", 0, 1, 44100, "Cosine", 100, 0, 0, 0)
  30. do ("Play")
  31. r = do ("Create Sound from formula...", "fff", "Mono", 0, - do ("Get value at sample number...", 1, 2), exp(10), "do (""Get value at sample number..."", 1, 1) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x) * sin (2*pi*400*x)")
  32. a = do ("Play") and do ("Play") and do ("Play") and do ("Play") and do ("Play") and do ("Play")
  33. do ("Draw...", 0, 0, 0, 0, "yes", "Curve")
  34. select q
  35. numberOfSamples = do ("Get number of samples")
  36. stopwatch
  37. for i to numberOfSamples
  38. a = Get value at sample number... 1 i
  39. endfor
  40. time = stopwatch
  41. appendInfoLine ("first method: ", fixed$ (time, 6))
  42. stopwatch
  43. for i to numberOfSamples
  44. a = do ("Get value at sample number...", 1, i)
  45. endfor
  46. time = stopwatch
  47. appendInfoLine ("second method: ", time)
  48. stopwatch
  49. for i to numberOfSamples
  50. a = Get value at sample number: 1, i
  51. endfor
  52. time = stopwatch
  53. appendInfoLine ("third method: ", time)
  54. Formula: ~ col
  55. a = do("Get value at sample number...", 10 + sin (0))
  56. b = do("Get value at sample number...", 100 + sin (0)) + 5
  57. c = 20 + do("Get value at sample number...", 1000 + sin (0)) + 50
  58. appendInfoLine: a, " ", b, " ", c
  59. a = do ("Play")
  60. spectrum = do ("To Spectrum...", "yes")
  61. appendInfoLine (a, " ", q, " ", spectrum, " ", r, " samples=", numberOfSamples, " ", beep)
  62. demoShow()
  63. removeObject: p, beep, q, r, spectrum