resample22_8.praat 1.6 KB

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