test_DTW.praat 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # test_DTW.praat
  2. # djmw 20100504, 20120223
  3. printline DTW_test start
  4. stepSize = 0.005
  5. s1 = Create Sound from formula... s1 Mono 0 1 44100 1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)
  6. s2 = Copy... s2
  7. plus s1
  8. dtw = To DTW... 0.015 stepSize 0.1 1/2 < slope < 2
  9. printline 'tab$' Slope constraint
  10. nx = Get maximum consecutive steps... X
  11. assert nx <= 2
  12. ny = Get maximum consecutive steps... Y
  13. assert ny <= 2
  14. for i to 20
  15. t = i * 0.04
  16. ty = Get y time... t
  17. assert (ty - stepSize) < t and t < (ty + stepSize)
  18. tx = Get x time... t
  19. assert (tx - stepSize) < t and t < (tx + stepSize)
  20. endfor
  21. select dtw
  22. printline 'tab$' To Polygon...
  23. pol = To Polygon... 0.1 1/2 < slope < 2
  24. Remove
  25. select dtw
  26. pol = To Polygon... 0.1 1/3 < slope < 3
  27. Remove
  28. select dtw
  29. pol = To Polygon... 0.1 2/3 < slope < 3/2
  30. Remove
  31. printline 'tab$' To Matrix
  32. select dtw
  33. mat = To Matrix (distances)
  34. Remove
  35. select dtw
  36. To Matrix (cum. distances)... 0.05 2/3 < slope < 3/2
  37. Remove
  38. select dtw
  39. plus s1
  40. plus s2
  41. Remove
  42. printline test_DTW end O.K.