Cochleagram_and_Excitation.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Cochleagram_and_Excitation.cpp
  2. *
  3. * Copyright (C) 1992-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. /*
  19. * pb 1993/12/20
  20. * pb 2002/07/16 GPL
  21. * pb 2011/05/05 type
  22. * pb 2011/05/09 C++
  23. */
  24. #include "Cochleagram_and_Excitation.h"
  25. autoExcitation Cochleagram_to_Excitation (Cochleagram me, double t) {
  26. try {
  27. integer column = Matrix_xToNearestColumn (me, t);
  28. if (column < 1) column = 1;
  29. if (column > my nx) column = my nx;
  30. autoExcitation thee = Excitation_create (my dy, my ny);
  31. for (integer ifreq = 1; ifreq <= my ny; ifreq ++)
  32. thy z [1] [ifreq] = my z [ifreq] [column];
  33. return thee;
  34. } catch (MelderError) {
  35. Melder_throw (me, U": slice at time ", t, U" seconds not extracted to Excitation.");
  36. }
  37. }
  38. /* End of file Cochleagram_and_Excitation.cpp */