| 1 | /* SpectrogramArea.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2005,2007-2012,2014-2022,2026 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 3 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 "SpectrogramArea.h"cxx . . $ `<file>/foned/SpectrogramArea.h`/ |
| 20 | |
| 21 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (SpectrogramArea, FunctionArea, 0); |
| 22 | |
| 23 | void structSpectrogramAreacxx . . $ structSpectrogramArea# :: v_drawInsidecxx . . $ structSpectrogramArea#v_drawInside(49f6e7a06ebc5aa8). () { |
| 24 | integercxx . . $ integer# itmin, itmax; |
| 25 | Sampled_getWindowSamplescxx . . $ Sampled_getWindowSamples(fe99094ed5bb3f6a). (ourcxx . . $ `melder/melder.h:42:9`! spectrogramcxx . . $ structSpectrogramArea#spectrogram(b33433959faebf7).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).(), & itmin, & itmax); |
| 26 | |
| 27 | /* |
| 28 | Autoscale frequency axis. |
| 29 | */ |
| 30 | ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum. = ourcxx . . $ `melder/melder.h:42:9`! spectrogramcxx . . $ structSpectrogramArea#spectrogram(b33433959faebf7).() -> ymaxcxx . . $ structSampledXY#ymax.; |
| 31 | |
| 32 | 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`! maximumcxx . . $ structSpectrogramArea#maximum.); |
| 33 | Spectrogram_paintInsidecxx . . $ Spectrogram_paintInside(83c4be78517e8a4d). (ourcxx . . $ `melder/melder.h:42:9`! spectrogramcxx . . $ structSpectrogramArea#spectrogram(b33433959faebf7).(), 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, 0.0, true, |
| 34 | 60, 6.0, 0, kSpectrogram_colourMapcxx . . $ kSpectrogram_colourMap#::GREYcxx . . $ kSpectrogram_colourMap#GREY., false); |
| 35 | |
| 36 | /* |
| 37 | Horizontal scaling lines. |
| 38 | */ |
| 39 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, 1.0, 0.0, ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.); |
| 40 | 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`!); |
| 41 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_REDcxx . . $ Melder_RED.); |
| 42 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_DOTTEDcxx . . $ `sys/Graphics.h:288:9`!); |
| 43 | const integercxx . . $ integer# df = 1000; |
| 44 | for (integercxx . . $ integer# f = 0; f <= ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.; f += df) { |
| 45 | if (f != 0.0 && f != ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.) |
| 46 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, f, 1.0, f); |
| 47 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, f, f, U" Hz"); |
| 48 | } |
| 49 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Graphics_DRAWNcxx . . $ `sys/Graphics.h:287:9`!); |
| 50 | if (ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor. > 0.0 && ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor. < ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.) { |
| 51 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 0.0, ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor., 1.0, ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor.); |
| 52 | 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`!); |
| 53 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), 1.0, ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor., Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor.), U" Hz"); |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | Vertical cursor lines. |
| 58 | */ |
| 59 | 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`! maximumcxx . . $ structSpectrogramArea#maximum.); |
| 60 | if (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).()) |
| 61 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), 0, ourcxx . . $ `melder/melder.h:42:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.); |
| 62 | if (ourcxx . . $ `melder/melder.h:42:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).() > ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).() && ourcxx . . $ `melder/melder.h:42:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).() < ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).()) |
| 63 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).(), 0, ourcxx . . $ `melder/melder.h:42:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.); |
| 64 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), Melder_BLACKcxx . . $ Melder_BLACK.); |
| 65 | } |
| 66 | |
| 67 | bool structSpectrogramAreacxx . . $ structSpectrogramArea# :: v_mousecxx . . $ structSpectrogramArea#v_mouse(3d5a26054778c78d). (GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# event, double x_world, double localY_fraction) { |
| 68 | ourcxx . . $ `melder/melder.h:42:9`! frequencyCursorcxx . . $ structSpectrogramArea#frequencyCursor. = localY_fraction * ourcxx . . $ `melder/melder.h:42:9`! maximumcxx . . $ structSpectrogramArea#maximum.; |
| 69 | const integercxx . . $ integer# clickedFrame = Melder_clippedcxx . . $ Melder_clipped(5eb09607cedc971b). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (ourcxx . . $ `melder/melder.h:42:9`! spectrogramcxx . . $ structSpectrogramArea#spectrogram(b33433959faebf7).(), x_world), ourcxx . . $ `melder/melder.h:42:9`! spectrogramcxx . . $ structSpectrogramArea#spectrogram(b33433959faebf7).() -> nxcxx . . $ structSampled#nx.); // TODO |
| 70 | return FunctionEditor_defaultMouseInWideDataViewcxx . . $ FunctionEditor_defaultMouseInWideDataView(f60eeae5fe5430ba). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), event, x_world) || true; |
| 71 | } |
| 72 | |
| 73 | /* End of file SpectrogramArea.cpp */ |