Debian Codegraph @

foned/SoundAnalysisArea.h

raw symbols SCIP
1 #ifndef _SoundAnalysisArea_h_
2 #define _SoundAnalysisArea_h_
3 /* SoundAnalysisArea.h
4 *
5 * Copyright (C) 1992-2005,2007-2024,2026 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 3 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"
22 #include "Sound_and_Spectrogram.h"
23 #include "Pitch.h"
24 #include "Intensity.h"
25 #include "Formant.h"
26 #include "PointProcess.h"
27 #include "LongSound.h"
28
29 #include "SoundAnalysisArea_enums.h"
30
31 Thing_define (SoundAnalysisArea, FunctionArea) {
32 SampledXY soundOrLongSound() const { return static_cast <SampledXY> (our function()); }
33 Sound sound() const {
34 return our soundOrLongSound() && Thing_isa (our soundOrLongSound(), classSound) ? (Sound) our soundOrLongSound() : nullptr;
35 }
36 LongSound longSound() const {
37 return our soundOrLongSound() && Thing_isa (our soundOrLongSound(), classLongSound) ? (LongSound) our soundOrLongSound() : nullptr;
38 }
39
40 autoSpectrogramList d_spectrogramList;
41 double d_spectrogram_cursor;
42 autoPitch d_pitch;
43 autoIntensity d_intensity;
44 autoFormant d_formant;
45 autoPointProcess d_pulses;
46 GuiMenuItem spectrogramToggle, pitchToggle, intensityToggle, formantToggle, pulsesToggle;
47 GuiMenuItem pitchFilteredAutocorrelationToggle, pitchRawCrossCorrelationToggle, pitchRawAutocorrelationToggle,
48 pitchFilteredCrossCorrelationToggle;
49
50 virtual bool v_hasSpectrogram () { return true; }
51 virtual bool v_hasPitch () { return true; }
52 virtual bool v_hasIntensity () { return true; }
53 virtual bool v_hasFormants () { return true; }
54 virtual bool v_hasPulses () { return true; }
55 virtual void v_reset_analysis ();
56
57 virtual void v_spectrogramInfo () const;
58 virtual void v_pitchInfo () const;
59 virtual void v_intensityInfo () const;
60 virtual void v_formantsInfo () const;
61 virtual void v_pulsesInfo () const;
62
63 protected:
64 void v_computeAuxiliaryData () override {
65 our v_reset_analysis ();
66 }
67
68 public:
69 void v_windowChanged () override {
70 our v_reset_analysis ();
71 }
72 bool hasContentToShow () {
73 return our instancePref_spectrogram_show() || our instancePref_pitch_show() ||
74 our instancePref_intensity_show() || our instancePref_formant_show();
75 }
76 bool hasPulsesToShow () {
77 return our instancePref_pulses_show() && our endWindow() - our startWindow() <= our instancePref_longestAnalysis() && our d_pulses;
78 }
79
80 public:
81 void v1_info ()
82 override;
83 bool v_mouse (GuiDrawingArea_MouseEvent event, double x_world, double localY_fraction)
84 override;
85 virtual void v_draw_analysis ();
86 virtual void v_draw_analysis_pulses ();
87 virtual void v_draw_analysis_formants ();
88 void v_createMenus ()
89 override;
90 virtual void v_createMenuItems_formant (EditorMenu menu);
91 void v_updateMenuItems ()
92 override;
93
94 #include "SoundAnalysisArea_prefs.h"
95 double dynamic_instancePref_pitch_floor ();
96 double dynamic_instancePref_pitch_ceilingOrTop ();
97 kPitch_unit dynamic_instancePref_pitch_unit ();
98 kSoundAnalysisArea_pitch_drawingMethod dynamic_instancePref_pitch_drawingMethod ();
99 double dynamic_instancePref_pitch_viewFrom ();
100 double dynamic_instancePref_pitch_viewTo ();
101 bool dynamic_instancePref_pitch_veryAccurate ();
102 integer dynamic_instancePref_pitch_maximumNumberOfCandidates ();
103 double dynamic_instancePref_pitch_silenceThreshold ();
104 double dynamic_instancePref_pitch_voicingThreshold ();
105
106 void v9_repairPreferences () override;
107 };
108
109 DEFINE_FunctionArea_create (SoundAnalysisArea, Sound)
110
111 void SoundAnalysisArea_haveVisibleSpectrogram (SoundAnalysisArea me);
112 void SoundAnalysisArea_haveVisiblePitch (SoundAnalysisArea me);
113 void SoundAnalysisArea_haveVisibleIntensity (SoundAnalysisArea me);
114 void SoundAnalysisArea_haveVisibleFormants (SoundAnalysisArea me);
115 void SoundAnalysisArea_haveVisiblePulses (SoundAnalysisArea me);
116
117 bool SoundAnalysisArea_mouse (SoundAnalysisArea me, GuiDrawingArea_MouseEvent event, double x_world, double y_fraction);
118
119 inline void SoundAnalysisArea_drawDefaultLegends (SoundAnalysisArea me) {
120 if (my hasContentToShow () && my endWindow() - my startWindow() <= my instancePref_longestAnalysis())
121 FunctionArea_drawLegend (me,
122 my instancePref_spectrogram_show() ? FunctionArea_legend_GREYS U" %%derived spectrogram" : U"", 1.2 * Melder_BLACK,
123 my instancePref_formant_show() ? FunctionArea_legend_SPECKLES U" %%derived formants" : U"", 1.2 * Melder_RED,
124 my instancePref_intensity_show() ? FunctionArea_legend_LINES U" %%derived intensity" : U"", 1.2 * Melder_GREEN,
125 my instancePref_pitch_show() ? FunctionArea_legend_LINES_SPECKLES U" %%derived pitch" : U"", 1.2 * Melder_BLUE
126 );
127 }
128
129 /* End of file SoundAnalysisArea.h */
130 #endif