1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/* praat_MultiSampledSpectrogram.cpp
*
* Copyright (C) 2021-2023 David Weenink
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This code is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this work. If not, see <http://www.gnu.org/licenses/>.
*/
#include "praatM.h"
#include "AnalyticSound.h"
#include "ConstantQSpectrograms.h"
#include "MultiSampledSpectrogram.h"
#include "Sound_and_MultiSampledSpectrogram.h"
#include "Spectrum_and_MultiSampledSpectrogram.h"
DIRECT (CONVERT_EACH_TO_ONE__AnalyticSound_toIntensity) {
CONVERT_EACH_TO_ONE (AnalyticSound)
autoIntensity result = AnalyticSound_to_Intensity (me);
CONVERT_EACH_TO_ONE_END (my name.get())
}
DIRECT (CONVERT_EACH_TO_ONE__AnalyticSound_toSound) {
CONVERT_EACH_TO_ONE (AnalyticSound)
autoSound result = AnalyticSound_to_Sound (me);
CONVERT_EACH_TO_ONE_END (my name.get())
}
FORM (MODIFY_EACH_WEAK__MultiSampledSpectrogram_formula, U"MultiSampledSpectrogram: Formula", U"MultiSampledSpectrogram: Formula...") {
FORMULA (formula, U"Formula", U"2 * self")
OK
DO
MODIFY_EACH_WEAK (MultiSampledSpectrogram)
MultiSampledSpectrogram_formula (me, formula, interpreter);
MODIFY_EACH_WEAK_END
}
FORM (MODIFY_EACH_WEAK__MultiSampledSpectrogram_formula_part, U"MultiSampledSpectrogram: Formula (part)", U"MultiSampledSpectrogram: Formula...") {
REAL (fromTime, U"From time", U"0.0")
REAL (toTime, U"To time", U"0.0 (= all)")
REAL (fromFrequency, U"From frequency (Hz)", U"100.0")
REAL (toFrequency, U"To Frequency (Hz)", U"200.0")
FORMULA (formula, U"Formula", U"2 * self")
OK
DO
MODIFY_EACH_WEAK (MultiSampledSpectrogram)
MultiSampledSpectrogram_formula_part (me, fromTime, toTime, fromFrequency, toFrequency, formula, interpreter);
MODIFY_EACH_WEAK_END
}
FORM (GRAPHICS_EACH__ConstantQLog2FSpectrogram_paint, U"ConstantQLog2FSpectrogram: Paint", nullptr) {
REAL (xmin, U"left Time range (s)", U"0.0")
REAL (xmax, U"right Time range (s)", U"0.0 (= all)")
REAL (ymin, U"left Frequency range (Hz)", U"0.0")
REAL (ymax, U"right Frequency range (Hz)", U"0.0 (= auto)")
POSITIVE (dBRange, U"Dynamic range (dB)", U"50.0")
BOOLEAN (garnish, U"Garnish", true);
OK
DO
GRAPHICS_EACH (ConstantQLog2FSpectrogram)
ConstantQLog2FSpectrogram_paint (me, GRAPHICS, xmin, xmax, ymin, ymax, dBRange, garnish);
GRAPHICS_EACH_END
}
DIRECT (CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Sound) {
CONVERT_EACH_TO_ONE (MultiSampledSpectrogram)
autoSound result = MultiSampledSpectrogram_to_Sound (me);
CONVERT_EACH_TO_ONE_END (my name.get())
}
FORM (CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Sound_frequencyBin, U"MultiSampledSpectrogram: To Sound (frequencyBin)", nullptr) {
NATURAL (frequencyBinNumber, U"Frequency bin number", U"1")
OK
DO
CONVERT_EACH_TO_ONE (MultiSampledSpectrogram)
autoSound result = MultiSampledSpectrogram_to_Sound_frequencyBin (me, frequencyBinNumber);
CONVERT_EACH_TO_ONE_END (my name.get(), U"_",frequencyBinNumber)
}
DIRECT (CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Spectrum) {
CONVERT_EACH_TO_ONE (MultiSampledSpectrogram)
autoSpectrum result = MultiSampledSpectrogram_to_Spectrum (me);
CONVERT_EACH_TO_ONE_END (my name.get())
}
FORM (CONVERT_EACH_TO_ONE__ConstantQLog2FSpectrogram_translateSpectrum, U"", nullptr) {
REAL (fromTime, U"From time", U"0.0")
REAL (toTime, U"To time", U"0.0 (= all)")
REAL (fromFrequency, U"From frequency (Hz)", U"100.0")
REAL (numberOfBins, U"Number of bins", U"5.0")
OK
DO
CONVERT_EACH_TO_ONE (ConstantQLog2FSpectrogram)
autoConstantQLog2FSpectrogram result = ConstantQLog2FSpectrogram_translateSpectrum (me, fromTime, toTime, fromFrequency, numberOfBins);
CONVERT_EACH_TO_ONE_END (my name.get())
}
FORM (CONVERT_EACH_TO_ONE__Sound_to_ConstantQLog2FSpectrogram, U"Sound: To ConstantQLog2FSpectrogram", U"Sound: To ConstantQLog2FSpectrogram...") {
POSITIVE (f1, U"Lowest frequency (Hz)", U"110.0 (=440*2^(-2))")
REAL (fmax, U"Maximum frequency (Hz)", U"0.0 (= Nyquist)")
NATURAL (numberOfFrequencyBinsPerOctave, U"Number of frequency bins / octave", U"24")
POSITIVE (frequencyResolutionInBins, U"Frequency resolution (bins)", U"1.0")
POSITIVE (timeOversamplingFactor, U"Time oversampling factor", U"1.0")
CHOICE_ENUM (kSound_windowShape, filterShape,
U"Filter shape", kSound_windowShape::DEFAULT)
OK
DO
CONVERT_EACH_TO_ONE (Sound)
autoConstantQLog2FSpectrogram result = Sound_to_ConstantQLog2FSpectrogram (me, f1, fmax,
numberOfFrequencyBinsPerOctave, frequencyResolutionInBins, timeOversamplingFactor, filterShape
);
CONVERT_EACH_TO_ONE_END (my name.get())
}
DIRECT (CONVERT_EACH_TO_ONE__Sound_to_AnalyticSound) {
CONVERT_EACH_TO_ONE (Sound)
autoAnalyticSound result = Sound_to_AnalyticSound (me);
CONVERT_EACH_TO_ONE_END (my name.get())
}
FORM (GRAPHICS_EACH__GaborSpectrogram_paint, U"GaborSpectrogram: Paint", nullptr) {
REAL (xmin, U"left Time range (s)", U"0.0")
REAL (xmax, U"right Time range (s)", U"0.0 (= all)")
REAL (ymin, U"left Frequency range (Hz)", U"0.0")
REAL (ymax, U"right Frequency range (Hz)", U"0.0 (= auto)")
POSITIVE (dBRange, U"Dynamic range (dB)", U"50.0")
BOOLEAN (garnish, U"Garnish", true);
OK
DO
GRAPHICS_EACH (GaborSpectrogram)
GaborSpectrogram_paint (me, GRAPHICS, xmin, xmax, ymin, ymax, dBRange, garnish);
GRAPHICS_EACH_END
}
FORM (CONVERT_EACH_TO_ONE__Sound_to_GaborSpectrogram, U"Sound: To GaborSpectrogram", U"Sound: To ConstantQLog2FSpectrogram...") {
REAL (fmax, U"Maximum frequency (Hz)", U"0.0 (= Nyquist)")
POSITIVE (filterBandwidth, U"Filter bandwidth (Hz)", U"40.0")
POSITIVE (frequencyStep, U"Frequency step (hz)", U"20.0")
POSITIVE (timeOversamplingFactor, U"Time oversampling factor", U"1.0")
CHOICE_ENUM (kSound_windowShape, filterShape,
U"Filter shape", kSound_windowShape::DEFAULT)
OK
DO
CONVERT_EACH_TO_ONE (Sound)
autoGaborSpectrogram result = Sound_to_GaborSpectrogram (me, fmax, filterBandwidth,
frequencyStep, timeOversamplingFactor, filterShape
);
CONVERT_EACH_TO_ONE_END (my name.get())
}
void praat_MultiSampledSpectrograms_generics (ClassInfo klas) {
praat_addAction1 (klas, 0, U"Formula...", nullptr, 0,
MODIFY_EACH_WEAK__MultiSampledSpectrogram_formula);
praat_addAction1 (klas, 0, U"Formula (part)...", nullptr, 0,
MODIFY_EACH_WEAK__MultiSampledSpectrogram_formula_part);
praat_addAction1 (klas, 0, U"To Sound", nullptr, 0,
CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Sound);
praat_addAction1 (klas, 0, U"To Sound (frequencyBin)...", nullptr, 0,
CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Sound_frequencyBin);
praat_addAction1 (klas, 0, U"To Spectrum", nullptr, 0,
CONVERT_EACH_TO_ONE__MultiSampledSpectrogram_to_Spectrum);
}
void praat_MultiSampledSpectrogram_init ();
void praat_MultiSampledSpectrogram_init () {
Thing_recognizeClassesByName (classAnalyticSound, classConstantQLog2FSpectrogram, classFrequencyBin,
classGaborSpectrogram, classMultiSampledSpectrogram, nullptr);
praat_addAction1 (classAnalyticSound, 0, U"To Intensity", nullptr, 0,
CONVERT_EACH_TO_ONE__AnalyticSound_toIntensity);
praat_addAction1 (classAnalyticSound, 0, U"To Sound", nullptr, 0,
CONVERT_EACH_TO_ONE__AnalyticSound_toSound);
praat_addAction1 (classConstantQLog2FSpectrogram, 0, U"Paint...", nullptr, 0,
GRAPHICS_EACH__ConstantQLog2FSpectrogram_paint);
praat_MultiSampledSpectrograms_generics (classConstantQLog2FSpectrogram);
praat_addAction1 (classConstantQLog2FSpectrogram, 0, U"Translate spectrum...", nullptr, 0,
CONVERT_EACH_TO_ONE__ConstantQLog2FSpectrogram_translateSpectrum);
praat_addAction1 (classSound, 0, U"To ConstantQLog2FSpectrogram...", U"To ComplexSpectrogram...", GuiMenu_DEPTH_1 | GuiMenu_HIDDEN,
CONVERT_EACH_TO_ONE__Sound_to_ConstantQLog2FSpectrogram);
praat_addAction1 (classSound, 0, U"To AnalyticSound", U"Resample...", GuiMenu_DEPTH_1 | GuiMenu_HIDDEN,
CONVERT_EACH_TO_ONE__Sound_to_AnalyticSound);
praat_addAction1 (classGaborSpectrogram, 0, U"Paint...", nullptr, 0,
GRAPHICS_EACH__GaborSpectrogram_paint);
praat_MultiSampledSpectrograms_generics (classGaborSpectrogram);
praat_addAction1 (classSound, 0, U"To GaborSpectrogram...", U"To ComplexSpectrogram...", GuiMenu_DEPTH_1 | GuiMenu_HIDDEN,
CONVERT_EACH_TO_ONE__Sound_to_GaborSpectrogram);
}
/* End of file praat_MultiSampledSpectrogram.cpp */
|