test_Ltas_reportSpectralTilt.praat 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. # test_Ltas_reportSpectralTilt.praat
  2. # djmw 20130813, 2017
  3. appendInfoLine: "test_Ltas_reportSpectralTilt"
  4. for k to 10
  5. @ltas
  6. endfor
  7. procedure ltas
  8. .s [1] = Create Sound from formula: "sineWithNoise", 1, 0, 1, 44100, "randomGauss(0,0.1)"
  9. .s [2] = Filter (de-emphasis): 50
  10. # some of the following values are rough guesses, if the assertion failes adapt the values somewhat
  11. .slope [1] = 0 ; dB/Hz (this value is exact)
  12. .slopemargin[1] = 0.5 ; approximate
  13. .slope [2] = -20 ; dB/decade (this value is exact)
  14. .slopemargin[2] = 1.5 ; approximate
  15. .offset [1] = 30.8 ; dB approximate
  16. .offsetmargin[1] = 3 ; approximate
  17. .offset [2] = 95 ; dB ; approximate
  18. .offsetmargin [2] = 4 ; approximate
  19. for .i to 2
  20. selectObject: .s [.i]
  21. .ltas = To Ltas: 100
  22. .info$ = Report spectral tilt: 100, 10000, "Logarithmic", "Robust"
  23. .slope = extractNumber (.info$, "Slope:")
  24. .offset = extractNumber (.info$, "Offset:")
  25. .slopediff = (.slope - .slope [.i])
  26. .offsetdiffr = (.offset - .offset [.i]) / .offset
  27. appendInfoLine: tab$, "Slope difference = ", .slopediff, " (slope [", .i, "] = ", .slope [.i], ")"
  28. appendInfoLine: tab$, "Rel. offset diff = ", .offsetdiffr, " (Offset [", .i, "] = ", .offset [.i], ")"
  29. removeObject: .s [.i], .ltas
  30. endfor
  31. endproc
  32. appendInfoLine ("test_Ltas_reportSpectralTilt OK")