test_Sound_draw_where.praat 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Sound_drawWhere_test.praat
  2. # djmw 20091031,20100912, 20110524
  3. appendInfoLine: "Sound_drawWhere_test.praat"
  4. Erase all
  5. Select outer viewport: 0, 6, 0, 3
  6. @sawtooth
  7. Select outer viewport: 0, 6, 3, 6
  8. @three_samples
  9. Select outer viewport: 0, 6, 6, 9
  10. @three_samples_stereo
  11. Select outer viewport: 0, 6, 9, 12
  12. @randomAmplitudes
  13. procedure sawtooth
  14. appendInfoLine: "Sound_drawWhere_test.praat"
  15. # maximally steep
  16. appendInfoLine: tab$, "Top: sawtooth in black with parts above 0.5 in Red + blue line"
  17. s = Create Sound from formula: "s", 1, 0, 1, 44100, "20*((x mod 0.1) - 0.05)"
  18. ymin = -1.1
  19. ymax = 1.1
  20. Colour: "Red"
  21. Draw where: 0, 0.4, ymin, ymax, "no", "Curve", "self>0.5"
  22. Colour: "Black"
  23. Draw where: 0, 0.4, ymin, ymax, "no", "Curve", "self<=0.5"
  24. One mark left: 0.5, "yes", "yes", "yes", ""
  25. Draw inner box
  26. Text top: "no", "sawtooth in blue with parts above 0.5 in red"
  27. removeObject: s
  28. endproc
  29. procedure three_samples
  30. appendInfoLine: tab$, "Interpolation between 3 sample points: parts above 0.5 in red"
  31. s = Create Sound from formula: "s", 1, 0, 0.0003, 10000, "0"
  32. Colour: "Red"
  33. Formula: "if col=2 then -1 else 1 fi"
  34. Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
  35. Colour: "Black"
  36. Draw where: 0, 0, ymin, ymax, "no", "Curve", "self<=0.5"
  37. One mark left: 0.5, "yes", "yes", "yes", ""
  38. Formula: "if col=2 then 1 else -1 fi"
  39. Colour: "Red"
  40. Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
  41. Colour: "Black"
  42. Draw where: 0, 0, ymin, ymax, "no", "Curve", "self<=0.5"
  43. One mark left: 0.5, "yes", "yes", "yes", ""
  44. Draw inner box
  45. Text top: "no", "Interpolation between 3 sample points: parts above 0.5 in red"
  46. removeObject: s
  47. endproc
  48. procedure three_samples_stereo
  49. appendInfoLine: tab$, "Stereo, interpolation between sample points: three sample points, parts above 0.5 in Red"
  50. s = Create Sound from formula: "s", 2, 0, 0.0003, 10000, "0"
  51. Formula: "if row = 1 then if col=2 then -1 else 1 fi else self fi"
  52. Formula: "if row = 2 then if col=2 then 1 else -1 fi else self fi"
  53. Colour: "Red"
  54. Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
  55. Colour: "Black"
  56. Draw where: 0, 0, ymin, ymax, "yes", "Curve", "self<=0.5"
  57. Formula: "0.6"
  58. Colour: "Red"
  59. Draw where: 0, 0, ymin, ymax, "no", "Curve", "1"
  60. Colour: "Black"
  61. Draw where: 0, 0, ymin, ymax, "no", "Curve", "0"
  62. Text top: "no", "Parts above 0.5 in red. One line at 0.6"
  63. removeObject: s
  64. endproc
  65. procedure randomAmplitudes
  66. s = Create Sound from formula: "s", 1, 0, 0.01, 10000, "randomUniform (-1, 1)"
  67. appendInfoLine: tab$, "Random amplitudes: parts > 0.5 in red only in the first half of every 0.001 s"
  68. Select outer viewport: 0, 6, 9, 12
  69. Colour: "Red"
  70. Draw where: 0.001, 0.01, ymin, ymax, "no", "Curve", "(self>0.5 and x mod 0.001 < 0.0005)"
  71. Colour: "Black"
  72. Draw where: 0.001, 0.01, ymin, ymax, "no", "Curve", "not (self>0.5 and x mod 0.001 < 0.0005)"
  73. One mark left: 0.5, "yes", "yes", "yes", ""
  74. Marks bottom every: 1, 0.0005, "no", "yes", "yes"
  75. Marks bottom every: 1, 0.001, "yes", "yes", "yes"
  76. Draw inner box
  77. Text top: "no", "Random amplitudes: parts > 0.5 red in the first half of every 0.001 s"
  78. Colour: "Black"
  79. removeObject: s
  80. endproc
  81. appendInfoLine: "Sound_drawWhere_test.praat End"