| 1 | /* PitchArea.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2012,2014-2022 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 | #include "PitchArea.h"cxx . . $ `<file>/foned/PitchArea.h`/ |
| 20 | #include "Pitch_to_Sound.h"cxx . . $ `<file>/fon/Pitch_to_Sound.h`/ |
| 21 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 22 | |
| 23 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (PitchArea, FunctionArea, 0); |
| 24 | |
| 25 | #define HEIGHT_UNVcxx . . $ `foned/PitchArea.cpp:25:9`! 3.0 |
| 26 | #define HEIGHT_INTENScxx . . $ `foned/PitchArea.cpp:26:9`! 6.0 |
| 27 | #define RADIUScxx . . $ `foned/PitchArea.cpp:27:9`! 2.5 |
| 28 | |
| 29 | |
| 30 | #pragma mark - PitchArea Query selection |
| 31 | |
| 32 | static void QUERY_DATA_FOR_REAL__getPitchcxx . . $ QUERY_DATA_FOR_REAL__getPitch(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 33 | QUERY_DATA_FOR_REALcxx . . $ `sys/EditorM.h:591:9`! |
| 34 | const double result = ( mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).() == mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).() |
| 35 | ? Pitch_getValueAtTimecxx . . $ Pitch_getValueAtTime(b0f5a36024d7459c). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ., 1) |
| 36 | : Pitch_getMeancxx . . $ Pitch_getMean(cc94e07c5e8f52a8). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).(), kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ.) |
| 37 | ); |
| 38 | QUERY_DATA_FOR_REAL_ENDcxx . . $ `sys/EditorM.h:593:9`! (U" Hz") |
| 39 | } |
| 40 | |
| 41 | |
| 42 | #pragma mark - PitchArea Modify whole |
| 43 | |
| 44 | static void menu_cb_setCeilingcxx . . $ menu_cb_setCeiling(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 45 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Change ceiling", nullptr) |
| 46 | POSITIVEcxx . . $ `sys/EditorM.h:117:9`! (ceiling, U"Ceiling (Hz)", U"600.0") |
| 47 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 48 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (ceiling, mycxx . . $ `melder/melder.h:44:9`! pitch() -> ceiling) |
| 49 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 50 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Change ceiling") |
| 51 | Pitch_setCeilingcxx . . $ Pitch_setCeiling(d3990d425b43aa2d). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), ceiling); |
| 52 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 53 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 54 | } |
| 55 | |
| 56 | static void menu_cb_pathFindercxx . . $ menu_cb_pathFinder(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 57 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Path finder", nullptr) |
| 58 | REALcxx . . $ `sys/EditorM.h:95:9`! (silenceThreshold, U"Silence threshold", U"0.03") |
| 59 | REALcxx . . $ `sys/EditorM.h:95:9`! (voicingThreshold, U"Voicing threshold", U"0.45") |
| 60 | REALcxx . . $ `sys/EditorM.h:95:9`! (octaveCost, U"Octave cost", U"0.01") |
| 61 | REALcxx . . $ `sys/EditorM.h:95:9`! (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 62 | REALcxx . . $ `sys/EditorM.h:95:9`! (voicedUnvoicedCost, U"Voiced/unvoiced cost", U"0.14") |
| 63 | POSITIVEcxx . . $ `sys/EditorM.h:117:9`! (ceiling, U"Ceiling (Hz)", U"600.0") |
| 64 | BOOLEANcxx . . $ `sys/EditorM.h:228:9`! (pullFormants, U"Pull formants", false) |
| 65 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 66 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (ceiling, mycxx . . $ `melder/melder.h:44:9`! pitch() -> ceiling) |
| 67 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 68 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Path finder") |
| 69 | Pitch_pathFindercxx . . $ Pitch_pathFinder(1fcb5d56a334b7ea). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), silenceThreshold, voicingThreshold, |
| 70 | octaveCost, octaveJumpCost, voicedUnvoicedCost, ceiling, pullFormants); |
| 71 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 72 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 73 | } |
| 74 | |
| 75 | |
| 76 | #pragma mark - PitchArea Modify selection |
| 77 | |
| 78 | static void menu_cb_octaveUpcxx . . $ menu_cb_octaveUp(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 79 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Octave up") |
| 80 | Pitch_stepcxx . . $ Pitch_step(f6b5eeb97b0728b). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), 2.0, 0.1, mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()); |
| 81 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 82 | } |
| 83 | |
| 84 | static void menu_cb_fifthUpcxx . . $ menu_cb_fifthUp(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 85 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Fifth up") |
| 86 | Pitch_stepcxx . . $ Pitch_step(f6b5eeb97b0728b). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), 1.5, 0.1, mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()); |
| 87 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 88 | } |
| 89 | |
| 90 | static void menu_cb_fifthDowncxx . . $ menu_cb_fifthDown(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 91 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Fifth down") |
| 92 | Pitch_stepcxx . . $ Pitch_step(f6b5eeb97b0728b). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), 1 / 1.5, 0.1, mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()); |
| 93 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 94 | } |
| 95 | |
| 96 | static void menu_cb_octaveDowncxx . . $ menu_cb_octaveDown(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 97 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Octave down") |
| 98 | Pitch_stepcxx . . $ Pitch_step(f6b5eeb97b0728b). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), 0.5, 0.1, mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()); |
| 99 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 100 | } |
| 101 | |
| 102 | static void menu_cb_voicelesscxx . . $ menu_cb_voiceless(e2d33779e573a5f1). (PitchAreacxx . . $ PitchArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 103 | const integercxx . . $ integer# ileft = Melder_clippedLeftcxx . . $ Melder_clippedLeft(f80f7d6260b3ee3a). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).())); |
| 104 | const integercxx . . $ integer# iright = Melder_clippedRightcxx . . $ Melder_clippedRight(f80f7d6260b3ee3a). (Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()), mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> nxcxx . . $ structSampled#nx.); |
| 105 | MODIFY_DATAcxx . . $ `sys/EditorM.h:611:9`! (U"Unvoice") |
| 106 | for (integercxx . . $ integer# iframe = ileft; iframe <= iright; iframe ++) { |
| 107 | const Pitch_Framecxx . . $ Pitch_Frame# frame = & mycxx . . $ `melder/melder.h:44:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 108 | for (integercxx . . $ integer# cand = 1; cand <= frame -> nCandidatescxx . . $ structPitch_Frame#nCandidates.; cand ++) |
| 109 | if (frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).cand]. frequencycxx . . $ structPitch_Candidate#frequency. == 0.0) |
| 110 | stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06). (frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).cand]); |
| 111 | } |
| 112 | MODIFY_DATA_ENDcxx . . $ `sys/EditorM.h:613:9`! |
| 113 | } |
| 114 | |
| 115 | |
| 116 | #pragma mark - PitchArea all menus |
| 117 | |
| 118 | void structPitchAreacxx . . $ structPitchArea# :: v_createMenuscxx . . $ structPitchArea#v_createMenus(49f6e7a06ebc5aa8). () { |
| 119 | PitchArea_Parentcxx . . $ PitchArea_Parent# :: v_createMenuscxx . . $ structDataGui#v_createMenus(49f6e7a06ebc5aa8). (); |
| 120 | |
| 121 | EditorMenucxx . . $ EditorMenu# menu = Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), U"Pitch", 0); |
| 122 | |
| 123 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"- Query selected part of pitch:", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this); |
| 124 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Get pitch", GuiMenu_F5cxx . . $ `sys/Gui.h:841:9`!, |
| 125 | QUERY_DATA_FOR_REAL__getPitchcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 126 | |
| 127 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"- Modify whole pitch:", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this); |
| 128 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Change ceiling...", 0, |
| 129 | menu_cb_setCeilingcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 130 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Path finder...", 0, |
| 131 | menu_cb_pathFindercxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 132 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"- Modify selected part of pitch:", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this); |
| 133 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Unvoice", 0, |
| 134 | menu_cb_voicelesscxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 135 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"-- up and down --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this); |
| 136 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Octave up", 0, |
| 137 | menu_cb_octaveUpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 138 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Fifth up", 0, |
| 139 | menu_cb_fifthUpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 140 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Fifth down", 0, |
| 141 | menu_cb_fifthDowncxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 142 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Octave down", 0, |
| 143 | menu_cb_octaveDowncxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | #pragma mark - PitchArea drawing |
| 148 | |
| 149 | void structPitchAreacxx . . $ structPitchArea# :: v_drawInsidecxx . . $ structPitchArea#v_drawInside(49f6e7a06ebc5aa8). () { |
| 150 | const double dyUnv = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), HEIGHT_UNVcxx . . $ `foned/PitchArea.cpp:25:9`!); |
| 151 | const double dyIntens = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), HEIGHT_INTENScxx . . $ `foned/PitchArea.cpp:26:9`!); |
| 152 | |
| 153 | integercxx . . $ integer# it1, it2; |
| 154 | Sampled_getWindowSamplescxx . . $ Sampled_getWindowSamples(fe99094ed5bb3f6a). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), & it1, & it2); |
| 155 | |
| 156 | /* |
| 157 | Show pitch. |
| 158 | */ |
| 159 | { |
| 160 | const double df = |
| 161 | ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. > 10000.0 ? 2000.0 : |
| 162 | ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. > 5000.0 ? 1000.0 : |
| 163 | ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. > 2000.0 ? 500.0 : |
| 164 | ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. > 800.0 ? 200.0 : |
| 165 | ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. > 400.0 ? 100.0 : |
| 166 | 50.0 |
| 167 | ; |
| 168 | Graphics_Viewportcxx . . $ Graphics_Viewport# previous; |
| 169 | previous =cxx . . $ $anonymous_type_5b6ec70e96eeadfb_0#`operator=`(6a528276102e99b). Graphics_insetViewportcxx . . $ Graphics_insetViewport(b48873d7bfae0d92). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, 1.0, dyUnv, 1.0 - dyIntens); |
| 170 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), 0.0, ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.); |
| 171 | const double radius = Graphics_dxMMtoWCcxx . . $ Graphics_dxMMtoWC(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), RADIUScxx . . $ `foned/PitchArea.cpp:27:9`!); |
| 172 | |
| 173 | /* Horizontal hair at current pitch. */ |
| 174 | |
| 175 | if (ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).() == ourcxx . . $ `melder/melder.h:42:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).() && ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).() >= ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).() && ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).() <= ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).()) { |
| 176 | const double frequency = Pitch_getValueAtTimecxx . . $ Pitch_getValueAtTime(b0f5a36024d7459c). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ., Pitch_LINEARcxx . . $ `fon/Pitch.h:95:9`!); |
| 177 | if (isdefinedcxx . . $ isdefined(f8197d536af80c96). (frequency)) { |
| 178 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_REDcxx . . $ Melder_RED.); |
| 179 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).() - radius, frequency, ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), frequency); |
| 180 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 181 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).() - radius, frequency, Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (frequency, 2)); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /* Horizontal scaling lines. */ |
| 186 | |
| 187 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLUEcxx . . $ Melder_BLUE.); |
| 188 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_DOTTEDcxx . . $ `sys/Graphics.h:288:9`!); |
| 189 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 190 | for (double frequency = df; frequency <= ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.; frequency += df) { |
| 191 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), frequency, ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), frequency); |
| 192 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).() + 0.5 * radius, frequency, frequency, U" Hz"); |
| 193 | } |
| 194 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_DRAWNcxx . . $ `sys/Graphics.h:287:9`!); |
| 195 | |
| 196 | /* |
| 197 | Show candidates. |
| 198 | */ |
| 199 | for (integercxx . . $ integer# it = it1; it <= it2; it ++) { |
| 200 | const Pitch_Framecxx . . $ Pitch_Frame# frame = & ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).it]; |
| 201 | const double time = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), it); |
| 202 | double frequency = frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 203 | if (Pitch_util_frequencyIsVoicedcxx . . $ Pitch_util_frequencyIsVoiced(828b76dce88fac). (frequency, ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.)) { |
| 204 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_MAGENTAcxx . . $ Melder_MAGENTA.); |
| 205 | Graphics_fillCircle_mmcxx . . $ Graphics_fillCircle_mm(8752bb7a78272ca7). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), time, frequency, RADIUScxx . . $ `foned/PitchArea.cpp:27:9`! * 2.0); |
| 206 | } |
| 207 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLACKcxx . . $ Melder_BLACK.); |
| 208 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 209 | for (integercxx . . $ integer# icand = 1; icand <= frame -> nCandidatescxx . . $ structPitch_Frame#nCandidates.; icand ++) { |
| 210 | frequency = frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icand]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 211 | if (Pitch_util_frequencyIsVoicedcxx . . $ Pitch_util_frequencyIsVoiced(828b76dce88fac). (frequency, ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.)) { |
| 212 | const integercxx . . $ integer# strength = Melder_clippedRightcxx . . $ Melder_clippedRight(f80f7d6260b3ee3a). (Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (10.0 * frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icand]. strengthcxx . . $ structPitch_Candidate#strength.), |
| 213 | 9_integercxx . . $ `operator""_integer`(85240eb457c3721a).); // map 0.0-1.0 to 0-9 |
| 214 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), time, frequency, strength); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | Graphics_resetViewportcxx . . $ Graphics_resetViewport(620f27fff4cd4a03). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), previous); |
| 219 | } |
| 220 | |
| 221 | /* |
| 222 | Show intensity. |
| 223 | */ |
| 224 | { |
| 225 | Graphics_Viewportcxx . . $ Graphics_Viewport# previous = Graphics_insetViewportcxx . . $ Graphics_insetViewport(b48873d7bfae0d92). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, 1.0, 1.0 - dyIntens, 1.0); |
| 226 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), 0.0, 1.0); |
| 227 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLACKcxx . . $ Melder_BLACK.); |
| 228 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 229 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), 0.5, U"intens"); |
| 230 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 231 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), 0.5, U"intens"); |
| 232 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 233 | for (integercxx . . $ integer# it = it1; it <= it2; it ++) { |
| 234 | const Pitch_Framecxx . . $ Pitch_Frame# frame = & ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).it]; |
| 235 | const double time = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), it); |
| 236 | const integercxx . . $ integer# strength = Melder_clippedRightcxx . . $ Melder_clippedRight(f80f7d6260b3ee3a). (Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (10.0 * frame -> intensitycxx . . $ structPitch_Frame#intensity. + 0.5), |
| 237 | 9_integercxx . . $ `operator""_integer`(85240eb457c3721a).); // map 0.0-1.0 to 1-9 |
| 238 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), time, 0.5, strength); |
| 239 | } |
| 240 | Graphics_resetViewportcxx . . $ Graphics_resetViewport(620f27fff4cd4a03). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), previous); |
| 241 | } |
| 242 | |
| 243 | if (it1 > 1) |
| 244 | it1 -= 1; |
| 245 | if (it2 < ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> nxcxx . . $ structSampled#nx.) |
| 246 | it2 += 1; |
| 247 | |
| 248 | /* |
| 249 | Show voicelessness. |
| 250 | */ |
| 251 | { |
| 252 | Graphics_Viewportcxx . . $ Graphics_Viewport# previous = Graphics_insetViewportcxx . . $ Graphics_insetViewport(b48873d7bfae0d92). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, 1.0, 0.0, dyUnv); |
| 253 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLUEcxx . . $ Melder_BLUE.); |
| 254 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), 1.0, ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), 1.0); |
| 255 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 256 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), 0.5, U"Unv"); |
| 257 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 258 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), 0.5, U"Unv"); |
| 259 | for (integercxx . . $ integer# it = it1; it <= it2; it ++) { |
| 260 | const Pitch_Framecxx . . $ Pitch_Frame# frame = & ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).it]; |
| 261 | const double time = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), it); |
| 262 | double tleft = time - 0.5 * ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> dxcxx . . $ structSampled#dx., tright = time + 0.5 * ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> dxcxx . . $ structSampled#dx.; |
| 263 | double frequency = frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 264 | if (Pitch_util_frequencyIsVoicedcxx . . $ Pitch_util_frequencyIsVoiced(828b76dce88fac). (frequency, ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.) || tright <= ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).() || tleft >= ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).()) |
| 265 | continue; |
| 266 | Melder_clipLeftcxx . . $ Melder_clipLeft(6245cd023a7d1552). (ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), & tleft); |
| 267 | Melder_clipRightcxx . . $ Melder_clipRight(5b63ce711df1ade7). (& tright, ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).()); |
| 268 | Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), tleft, tright, 0.0, 1.0); |
| 269 | } |
| 270 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLACKcxx . . $ Melder_BLACK.); |
| 271 | Graphics_resetViewportcxx . . $ Graphics_resetViewport(620f27fff4cd4a03). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), previous); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | bool structPitchAreacxx . . $ structPitchArea# :: v_mousecxx . . $ structPitchArea#v_mouse(3d5a26054778c78d). (GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# event, double x_world, double localY_fraction) { |
| 276 | if (! event -> isClickcxx . . $ structGuiDrawingArea_MouseEvent#isClick(50ce9a9e25b4a850).()) |
| 277 | return FunctionEditor_defaultMouseInWideDataViewcxx . . $ FunctionEditor_defaultMouseInWideDataView(f60eeae5fe5430ba). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), event, x_world); // move cursor or drag selection |
| 278 | const double dyUnv = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), HEIGHT_UNVcxx . . $ `foned/PitchArea.cpp:25:9`!); |
| 279 | const double dyIntens = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), HEIGHT_INTENScxx . . $ `foned/PitchArea.cpp:26:9`!); |
| 280 | const double clickedFrequency = (localY_fraction - dyUnv) / (1.0 - dyIntens - dyUnv) * ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling.; |
| 281 | double minimumDf = 1e30; |
| 282 | integercxx . . $ integer# bestCandidate = -1; |
| 283 | |
| 284 | integercxx . . $ integer# ibestFrame = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), x_world); |
| 285 | Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & ibestFrame, ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> nxcxx . . $ structSampled#nx.); |
| 286 | const Pitch_Framecxx . . $ Pitch_Frame# bestFrame = & ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ibestFrame]; |
| 287 | |
| 288 | const double tmid = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).(), ibestFrame); |
| 289 | for (integercxx . . $ integer# icand = 1; icand <= bestFrame -> nCandidatescxx . . $ structPitch_Frame#nCandidates.; icand ++) { |
| 290 | const Pitch_Candidatecxx . . $ Pitch_Candidate# candidate = & bestFrame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icand]; |
| 291 | const double df = clickedFrequency - candidate -> frequencycxx . . $ structPitch_Candidate#frequency.; |
| 292 | if (fabscxx . . $ fabs(fee4f1d22bc8e617). (df) < minimumDf) { |
| 293 | minimumDf = fabscxx . . $ fabs(fee4f1d22bc8e617). (df); |
| 294 | bestCandidate = icand; |
| 295 | } |
| 296 | } |
| 297 | if (bestCandidate != -1) { |
| 298 | const double bestFrequency = bestFrame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).bestCandidate]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 299 | const double distanceWC = (clickedFrequency - bestFrequency) / ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. * (1.0 - dyIntens - dyUnv); |
| 300 | const double dx_mm = Graphics_dxWCtoMMcxx . . $ Graphics_dxWCtoMM(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), x_world - tmid), dy_mm = Graphics_dyWCtoMMcxx . . $ Graphics_dyWCtoMM(f042c24bcd87f07e). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), distanceWC); |
| 301 | if (bestFrequency < ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> ceilingcxx . . $ structPitch#ceiling. && // above ceiling: ignore |
| 302 | ((bestFrequency <= 0.0 && fabscxx . . $ fabs(fee4f1d22bc8e617). (x_world - tmid) <= 0.5 * ourcxx . . $ `melder/melder.h:42:9`! pitchcxx . . $ structPitchArea#pitch(42277c204cacb302).() -> dxcxx . . $ structSampled#dx. && clickedFrequency <= 0.0) || // voiceless: click within frame |
| 303 | (bestFrequency > 0.0 && dx_mm * dx_mm + dy_mm * dy_mm <= RADIUScxx . . $ `foned/PitchArea.cpp:27:9`! * RADIUScxx . . $ `foned/PitchArea.cpp:27:9`!))) // voiced: click within circle |
| 304 | { |
| 305 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (ourcxx . . $ `melder/melder.h:42:9`! bosscxx . . $ structDataGui#boss(ebca83c96e4202ef).(), U"Change path"); |
| 306 | stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06). (bestFrame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], bestFrame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).bestCandidate]); |
| 307 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (ourcxx . . $ `melder/melder.h:42:9`! bosscxx . . $ structDataGui#boss(ebca83c96e4202ef).()); |
| 308 | ourcxx . . $ `melder/melder.h:42:9`! setSelectioncxx . . $ structFunctionArea#setSelection(bc12c9ec15586e6a). (tmid, tmid); // cursor will snap to candidate |
| 309 | return FunctionEditor_UPDATE_NEEDEDcxx . . $ `foned/FunctionEditor.h:222:9`!; |
| 310 | } else { |
| 311 | return FunctionEditor_defaultMouseInWideDataViewcxx . . $ FunctionEditor_defaultMouseInWideDataView(f60eeae5fe5430ba). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), event, x_world); // move cursor or drag selection |
| 312 | } |
| 313 | } |
| 314 | return FunctionEditor_defaultMouseInWideDataViewcxx . . $ FunctionEditor_defaultMouseInWideDataView(f60eeae5fe5430ba). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), event, x_world); // move cursor or drag selection |
| 315 | } |
| 316 | |
| 317 | /* End of file PitchArea.cpp */ |