Debian Codegraph @

foned/SoundArea.h

raw symbols SCIP
1 #cxx . . $ `<file>/foned/SoundArea.h`/ifndef _SoundArea_h_
2 #define _SoundArea_h_cxx . . $ `foned/SoundArea.h:2:9`!
3 /* SoundArea.h
4 *
5 * Copyright (C) 2022,2023 Paul Boersma
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "FunctionArea.h"cxx . . $ `<file>/foned/FunctionArea.h`/
22 #include "Sound.h"cxx . . $ `<file>/fon/Sound.h`/
23 #include "LongSound.h"cxx . . $ `<file>/fon/LongSound.h`/
24 #include "SoundArea_enums.h"cxx . . $ `<file>/foned/SoundArea_enums.h`/
25
26 /*
27 One derived data cache, namely for global extrema.
28 TODO: add a second cache, namely for channel extrema (or profile the scrolling speed).
29 */
30 struct SoundArea_GlobalExtremaCachecxx . . $ SoundArea_GlobalExtremaCache# {
31 void getcxx . . $ SoundArea_GlobalExtremaCache#get(97efd918a016aeeb). (Soundcxx . . $ Sound# sound, LongSoundcxx . . $ LongSound# longSound, double *out_minimum, double *out_maximum) {
32 if (! _validcxx . . $ SoundArea_GlobalExtremaCache#_valid.) {
33 _computecxx . . $ SoundArea_GlobalExtremaCache#_compute(958e0c0c9e371393). (sound, longSound);
34 _validcxx . . $ SoundArea_GlobalExtremaCache#_valid. = true;
35 }
36 *out_minimum = _minimumcxx . . $ SoundArea_GlobalExtremaCache#_minimum.;
37 *out_maximum = _maximumcxx . . $ SoundArea_GlobalExtremaCache#_maximum.;
38 }
39 void invalidatecxx . . $ SoundArea_GlobalExtremaCache#invalidate(49f6e7a06ebc5aa8). () {
40 _validcxx . . $ SoundArea_GlobalExtremaCache#_valid. = false;
41 }
42 private:
43 bool _validcxx . . $ SoundArea_GlobalExtremaCache#_valid.;
44 double _minimumcxx . . $ SoundArea_GlobalExtremaCache#_minimum., _maximumcxx . . $ SoundArea_GlobalExtremaCache#_maximum.;
45 void _computecxx . . $ SoundArea_GlobalExtremaCache#_compute(958e0c0c9e371393). (Soundcxx . . $ Sound# sound, LongSoundcxx . . $ LongSound# longSound) {
46 if (sound) {
47 Matrix_getWindowExtremacxx . . $ Matrix_getWindowExtrema(d50591dd897af896). (sound, 1, sound -> nxcxx . . $ structSampled#nx., 1, sound -> nycxx . . $ structSampledXY#ny., & _minimumcxx . . $ SoundArea_GlobalExtremaCache#_minimum., & _maximumcxx . . $ SoundArea_GlobalExtremaCache#_maximum.);
48 } else {
49 Melder_assertcxx . . $ abort(15d318a79ddce9e0). (longSound);
50 _minimumcxx . . $ SoundArea_GlobalExtremaCache#_minimum. = -1.0;
51 _maximumcxx . . $ SoundArea_GlobalExtremaCache#_maximum. = +1.0;
52 }
53 }
54 };
55
56 Thing_definecxx . . $ autoSoundArea# (SoundArea, FunctionArea) {
57 /*
58 Accessors.
59 */
60 SampledXYcxx . . $ SampledXY# soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() const { return static_cast <SampledXYcxx . . $ SampledXY#> (ourcxx . . $ `melder/melder.h:42:9`! functioncxx . . $ structFunctionArea#function(8985a8e07d4255bd).()); }
61 Soundcxx . . $ Sound# soundcxx . . $ structSoundArea#sound(f0b31236b65da120).() const {
62 return ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() && Thing_isacxx . . $ Thing_isa(8cbb12e93d03b2a1). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).(), classSoundcxx . . $ classSound.) ? (Soundcxx . . $ Sound#) ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() : nullptr;
63 }
64 LongSoundcxx . . $ LongSound# longSoundcxx . . $ structSoundArea#longSound(6208252a0c36139e).() const {
65 return ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() && Thing_isacxx . . $ Thing_isa(8cbb12e93d03b2a1). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).(), classLongSoundcxx . . $ classLongSound.) ? (LongSoundcxx . . $ LongSound#) ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() : nullptr;
66 }
67
68 /*
69 Derived data cache: global extrema.
70 */
71 private:
72 SoundArea_GlobalExtremaCachecxx . . $ SoundArea_GlobalExtremaCache# _globalExtremaCachecxx . . $ structSoundArea#_globalExtremaCache.;
73 public:
74 void getGlobalExtremacxx . . $ structSoundArea#getGlobalExtrema(a695690fb8d46395). (double *out_minimum, double *out_maximum) {
75 _globalExtremaCachecxx . . $ structSoundArea#_globalExtremaCache.. getcxx . . $ SoundArea_GlobalExtremaCache#get(97efd918a016aeeb). (ourcxx . . $ `melder/melder.h:42:9`! soundcxx . . $ structSoundArea#sound(f0b31236b65da120).(), ourcxx . . $ `melder/melder.h:42:9`! longSoundcxx . . $ structSoundArea#longSound(6208252a0c36139e).(), out_minimum, out_maximum);
76 }
77 /*
78 Manage all derived data caches.
79 */
80 protected:
81 void v_invalidateAllDerivedDataCachescxx . . $ structSoundArea#v_invalidateAllDerivedDataCaches(49f6e7a06ebc5aa8). () override {
82 _globalExtremaCachecxx . . $ structSoundArea#_globalExtremaCache.. invalidatecxx . . $ SoundArea_GlobalExtremaCache#invalidate(49f6e7a06ebc5aa8). ();
83 SoundArea_Parentcxx . . $ SoundArea_Parent# :: v_invalidateAllDerivedDataCachescxx . . $ structFunctionArea#v_invalidateAllDerivedDataCaches(49f6e7a06ebc5aa8). ();
84 }
85
86 /*
87 Auxiliary data: channelOffset.
88
89 For multi-channel sounds, Praat will never show more than 8 channels at a time:
90 if there are more than 8 channels, the user can scroll through them, in groups of 8.
91 The value of channelOffset is determined as follows:
92 - if there are at most 8 channels, channelOffset will always be 0;
93 - if there are more than 8 channels, channelOffset will be an integer multiple of 8;
94 for instance, if there are 30 channels, channelOffset can have the following values:
95 - 0 to show channels 1 throguh 8 (the first 8 channels);
96 - 8 to show channels 9 through 16 (the second 8 channels);
97 - 16 to show channels 17 through 24 (the third 8 channels);
98 - 24 to show channels 25 through 30 (the last 6 channels).
99 At initialization, channelOffset stays at zero, i.e. only the first 8 channels are shown.
100 */
101 public:
102 integercxx . . $ integer# channelOffsetcxx . . $ structSoundArea#channelOffset.;
103 private:
104 void _computeChannelOffsetcxx . . $ structSoundArea#_computeChannelOffset(49f6e7a06ebc5aa8). () {
105 Melder_assertcxx . . $ abort(15d318a79ddce9e0). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSound());
106 Melder_assertcxx . . $ abort(15d318a79ddce9e0). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSound() -> ny > 0);
107 Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & ourcxx . . $ `melder/melder.h:42:9`! channelOffsetcxx . . $ structSoundArea#channelOffset., (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() -> nycxx . . $ structSampledXY#ny. - 1) / 8 * 8); // works correctly even during initialization (offset will stay 0)
108 }
109 /*
110 Auxiliary data: muteChannels.
111
112 At initialization, no channels are muted.
113 */
114 public:
115 autoBOOLVECcxx . . $ autoBOOLVEC# muteChannelscxx . . $ structSoundArea#muteChannels.;
116 private:
117 void _computeMuteChannelscxx . . $ structSoundArea#_computeMuteChannels(49f6e7a06ebc5aa8). () {
118 Melder_assertcxx . . $ abort(15d318a79ddce9e0). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSound() && ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSound() -> ny > 0);
119 if (ourcxx . . $ `melder/melder.h:42:9`! muteChannelscxx . . $ structSoundArea#muteChannels..sizecxx . . $ autovector#size. != ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() -> nycxx . . $ structSampledXY#ny.) // condition works correctly even during initialization (when size is still 0, but ny is not)
120 ourcxx . . $ `melder/melder.h:42:9`! muteChannelscxx . . $ structSoundArea#muteChannels. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_BOOLVECcxx . . $ zero_BOOLVEC(ba622805578e0bb3). (ourcxx . . $ `melder/melder.h:42:9`! soundOrLongSoundcxx . . $ structSoundArea#soundOrLongSound(e416179ecdeca61e).() -> nycxx . . $ structSampledXY#ny.);
121 }
122 /*
123 Maintain all auxiliary data.
124 */
125 protected:
126 void v_computeAuxiliaryDatacxx . . $ structSoundArea#v_computeAuxiliaryData(49f6e7a06ebc5aa8). () override {
127 SoundArea_Parentcxx . . $ SoundArea_Parent# :: v_computeAuxiliaryDatacxx . . $ structFunctionArea#v_computeAuxiliaryData(49f6e7a06ebc5aa8). ();
128 _computeChannelOffsetcxx . . $ structSoundArea#_computeChannelOffset(49f6e7a06ebc5aa8). ();
129 _computeMuteChannelscxx . . $ structSoundArea#_computeMuteChannels(49f6e7a06ebc5aa8). ();
130 }
131
132 public:
133 virtual conststring32cxx . . $ conststring32# v_getChannelNamecxx . . $ structSoundArea#v_getChannelName(7b348ebc2004441d). (integercxx . . $ integer# /* channelNumber */) { return nullptr; }
134
135 protected:
136 void v_drawInsidecxx . . $ structSoundArea#v_drawInside(49f6e7a06ebc5aa8). ()
137 override;
138 public:
139 void v1_infocxx . . $ structSoundArea#v1_info(49f6e7a06ebc5aa8). ()
140 override;
141 bool v_mousecxx . . $ structSoundArea#v_mouse(3d5a26054778c78d). (GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# event, double x_world, double localY_fraction)
142 override;
143 void v_createMenuItems_savecxx . . $ structSoundArea#v_createMenuItems_save(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu)
144 override;
145 void v_createMenuItems_editcxx . . $ structSoundArea#v_createMenuItems_edit(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu)
146 override;
147 void v_createMenuscxx . . $ structSoundArea#v_createMenus(49f6e7a06ebc5aa8). ()
148 override;
149 void v_updateMenuItemscxx . . $ structSoundArea#v_updateMenuItems(49f6e7a06ebc5aa8). ()
150 override;
151 GuiMenuItemcxx . . $ GuiMenuItem# writeAiffButtoncxx . . $ structSoundArea#writeAiffButton., saveAs24BitWavButtoncxx . . $ structSoundArea#saveAs24BitWavButton., saveAs32BitWavButtoncxx . . $ structSoundArea#saveAs32BitWavButton., writeAifcButtoncxx . . $ structSoundArea#writeAifcButton., writeWavButtoncxx . . $ structSoundArea#writeWavButton., writeNextSunButtoncxx . . $ structSoundArea#writeNextSunButton., writeNistButtoncxx . . $ structSoundArea#writeNistButton., writeFlacButtoncxx . . $ structSoundArea#writeFlacButton.;
152 GuiMenuItemcxx . . $ GuiMenuItem# cutButtoncxx . . $ structSoundArea#cutButton., copyButtoncxx . . $ structSoundArea#copyButton., pasteBeforeButtoncxx . . $ structSoundArea#pasteBeforeButton., pasteOverButtoncxx . . $ structSoundArea#pasteOverButton., pasteAfterButtoncxx . . $ structSoundArea#pasteAfterButton., zeroButtoncxx . . $ structSoundArea#zeroButton., reverseButtoncxx . . $ structSoundArea#reverseButton.;
153 GuiMenuItemcxx . . $ GuiMenuItem# drawButtoncxx . . $ structSoundArea#drawButton.;
154 GuiMenuItemcxx . . $ GuiMenuItem# publishButtoncxx . . $ structSoundArea#publishButton., publishPreserveButtoncxx . . $ structSoundArea#publishPreserveButton., publishWindowButtoncxx . . $ structSoundArea#publishWindowButton., publishOverlapButtoncxx . . $ structSoundArea#publishOverlapButton.;
155
156 #include "SoundArea_prefs.h"cxx . . $ `<file>/foned/SoundArea_prefs.h`/
157 };
158
159 void SoundArea_drawcxx . . $ SoundArea_draw(c8a312b6aaea1713). (SoundAreacxx . . $ SoundArea# me);
160
161 bool SoundArea_mousecxx . . $ SoundArea_mouse(65721cdfd2db412a). (SoundAreacxx . . $ SoundArea# me, GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# event, double x_world, double globalY_fraction);
162
163 void SoundArea_playcxx . . $ SoundArea_play(8591d98d1e7b94a5). (SoundAreacxx . . $ SoundArea# me, double startTime, double endTime);
164
165 DEFINE_FunctionArea_createcxx . . $ autoSoundArea# (SoundArea, Sound)
166
167 /* End of file SoundArea.h */
168 #endif