| 1 | /* Excitations.cpp |
| 2 | * |
| 3 | * Copyright (C) 1993-2017 David Weenink, 2016 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. See the GNU |
| 13 | * 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 | #include "Excitations.h"cxx . . $ `<file>/dwtools/Excitations.h`/ |
| 20 | |
| 21 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ExcitationList, Ordered, 0); |
| 22 | |
| 23 | void ExcitationList_addItem_copycxx . . $ ExcitationList_addItem_copy(fad269555cffcb79). (ExcitationListcxx . . $ ExcitationList# me, Excitationcxx . . $ Excitation# you) { |
| 24 | try { |
| 25 | if (mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size. > 0) |
| 26 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (yourcxx . . $ `melder/melder.h:46:9`! nx == mycxx . . $ `melder/melder.h:44:9`! at [1] -> nx, |
| 27 | U"Dimension of ", you, U" should agree with the rest."); |
| 28 | |
| 29 | autoExcitationcxx . . $ autoExcitation# newItem = Data_copycxx . . $ Data_copy(97a542a26794c80e). (you); |
| 30 | mycxx . . $ `melder/melder.h:44:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (newItemcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 31 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 32 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": item not added."); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | void ExcitationList_addItemscxx . . $ ExcitationList_addItems(768d7c0e9dc8a8eb). (ExcitationListcxx . . $ ExcitationList# me, OrderedOfcxx . . $ OrderedOf# <structExcitationcxx . . $ structExcitation#> * list) { |
| 37 | for (integercxx . . $ integer# item = 1; item <= list->sizecxx . . $ CollectionOf#size.; item ++) { |
| 38 | ExcitationList_addItem_copycxx . . $ ExcitationList_addItem_copy(fad269555cffcb79). (me, list->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).item]); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | autoExcitationListcxx . . $ autoExcitationList# Excitations_to_ExcitationListcxx . . $ Excitations_to_ExcitationList(8a4202259a081342). (OrderedOfcxx . . $ OrderedOf# <structExcitationcxx . . $ structExcitation#> * me) { |
| 43 | try { |
| 44 | autoExcitationListcxx . . $ autoExcitationList# you = ExcitationList_createcxx . . $ ExcitationList_create(b268301dce5319ee). (); |
| 45 | ExcitationList_addItemscxx . . $ ExcitationList_addItems(768d7c0e9dc8a8eb). (you.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), me); |
| 46 | return youcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 47 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 48 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No ExcitationList created from Excitation(s)."); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | autoPatternListcxx . . $ autoPatternList# ExcitationList_to_PatternListcxx . . $ ExcitationList_to_PatternList(42adb813450b988c). (ExcitationListcxx . . $ ExcitationList# me, integercxx . . $ integer# join) { |
| 53 | try { |
| 54 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! size > 0); |
| 55 | Excitationcxx . . $ Excitation# excitation = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]; |
| 56 | if (join < 1) |
| 57 | join = 1; |
| 58 | |
| 59 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! size % join == 0, |
| 60 | U"Number of rows should be a multiple of the join."); |
| 61 | |
| 62 | autoPatternListcxx . . $ autoPatternList# thee = PatternList_createcxx . . $ PatternList_create(aadf1a410a0e0153). (mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size. / join, join * excitation -> nxcxx . . $ structSampled#nx.); |
| 63 | integercxx . . $ integer# r = 0, c = 1; |
| 64 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 65 | const constVECcxx . . $ constVEC# z = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i] -> zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 66 | if ((i - 1) % join == 0) { |
| 67 | r ++; |
| 68 | c = 1; |
| 69 | } |
| 70 | for (integercxx . . $ integer# j = 1; j <= excitation -> nxcxx . . $ structSampled#nx.; j ++) |
| 71 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).r] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).c ++] = z [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 72 | } |
| 73 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 74 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 75 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no PatternList created."); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | autoTableOfRealcxx . . $ autoTableOfReal# ExcitationList_to_TableOfRealcxx . . $ ExcitationList_to_TableOfReal(41adeb9d4679e). (ExcitationListcxx . . $ ExcitationList# me) { |
| 80 | try { |
| 81 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! size > 0); |
| 82 | Excitationcxx . . $ Excitation# excitation = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]; |
| 83 | autoTableOfRealcxx . . $ autoTableOfReal# thee = TableOfReal_createcxx . . $ TableOfReal_create(e573ed3514e79d3). (mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size., excitation -> nxcxx . . $ structSampled#nx.); |
| 84 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 85 | const constVECcxx . . $ constVEC# z = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i] -> zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 86 | for (integercxx . . $ integer# j = 1; j <= excitation -> nxcxx . . $ structSampled#nx.; j ++) { |
| 87 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = z [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 88 | } |
| 89 | } |
| 90 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 91 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 92 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": TableOfReal not created."); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | autoExcitationcxx . . $ autoExcitation# ExcitationList_extractItemcxx . . $ ExcitationList_extractItem(fe4ffba5787cf080). (ExcitationListcxx . . $ ExcitationList# me, integercxx . . $ integer# item) { |
| 97 | try { |
| 98 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (item > 0 && item <= mycxx . . $ `melder/melder.h:44:9`! size, |
| 99 | U"Item number should be in the range [1, ", mycxx . . $ `melder/melder.h:44:9`! size, U"]."); |
| 100 | |
| 101 | autoExcitationcxx . . $ autoExcitation# thee = Data_copycxx . . $ Data_copy(97a542a26794c80e). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).item]); |
| 102 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).item])); |
| 103 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 104 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 105 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": Excitation not extracted."); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /* End of file Excitations.cpp */ |