Art_Speaker_to_VocalTract.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Art_Speaker_to_VocalTract.cpp
  2. *
  3. * Copyright (C) 1992-2005,2008,2011,2015-2017 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "Delta.h"
  19. #include "Speaker_to_Delta.h"
  20. #include "Art_Speaker_Delta.h"
  21. #include "Art_Speaker_to_VocalTract.h"
  22. autoVocalTract Art_Speaker_to_VocalTract (Art art, Speaker speaker) {
  23. autoDelta delta = Speaker_to_Delta (speaker);
  24. Art_Speaker_intoDelta (art, speaker, delta.get());
  25. double area [300];
  26. constexpr double sectionLength = 0.001; // one millimetre
  27. integer numberOfSections = 0;
  28. for (integer isection = 1; isection <= 27; isection ++) {
  29. Delta_Tube tube = delta -> tube + 37 + isection;
  30. integer numberOfConstantSections = Melder_iround (tube -> Dxeq / sectionLength);
  31. double constantArea = tube -> Dyeq * tube -> Dzeq;
  32. for (integer jsection = 1; jsection <= numberOfConstantSections; jsection ++)
  33. area [++ numberOfSections] = constantArea;
  34. }
  35. autoVocalTract thee = VocalTract_create (numberOfSections, sectionLength);
  36. for (integer isection = 1; isection <= numberOfSections; isection ++)
  37. thy z [1] [isection] = area [isection];
  38. return thee;
  39. }
  40. /* End of file Art_Speaker_to_VocalTract.cpp */