resample16_8.praat 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Erase all
  2. Times
  3. 12
  4. depth = 200
  5. sweep = Create Sound from formula: "sweep", 1, 0, 10, 16000,
  6. ... ~ sin (2 * pi * 400 * x^2)
  7. To Spectrogram: 0.05, 8000, 0.002, 20, "Gaussian"
  8. Select outer viewport: 0, 6, 0, 3
  9. Paint: 0, 0, 0, 8000, 100, "yes", 90, 0, 0, "yes"
  10. Remove
  11. selectObject: sweep
  12. sweep_8k = Resample: 8000, 50
  13. To Spectrogram: 0.05, 8000, 0.002, 20, "Gaussian"
  14. Select outer viewport: 0, 6, 3, 6
  15. Paint: 0, 0, 0, 8000, 100, "yes", 90, 0, 0, "yes"
  16. Remove
  17. cutoff = 3800
  18. filter_mat = Create Matrix: "filter1", -depth / 16000, depth / 16000,
  19. ... depth*2, 1 / 16000, (-depth+0.5) / 16000,
  20. ... 1, 1, 1, 1, 1, ~ if x = 0 then 1 else sin (2*pi*x*cutoff) / (2*pi*x*cutoff)
  21. ... * (0.5 + 0.5 * cos (pi * x*16000 / depth)) fi
  22. sum = Get sum
  23. Formula: ~ self / sum
  24. filter = To Sound
  25. selectObject: sweep, filter
  26. sweep_low = Convolve: "sum", "zero"
  27. mooi = Create Sound from formula: "mooi", 1, 0, 10, 16000/2, ~ object [sweep_low, col*2]
  28. To Spectrogram: 0.05, 8000, 0.002, 20, "Gaussian"
  29. Select outer viewport: 0, 6, 6, 9
  30. Paint: 0, 0, 0, 8000, 100, "yes", 90, 0, 0, "yes"
  31. Remove
  32. #
  33. # Write to Info window in base-0 C format.
  34. #
  35. writeInfo: "static double filter_2 [", depth*2, "] = { "
  36. for i to depth*2
  37. value = object [filter, i]
  38. appendInfo: if abs (value) < 1e-12 then 0 else fixed$ (value, 12) fi, ", "
  39. endfor
  40. appendInfoLine: "};"
  41. removeObject: filter_mat, filter, sweep_low, sweep, sweep_8k, mooi