| 1 | #ifndef _SoundEditor_h_ |
| 2 | #define _SoundEditor_h_ |
| 3 | /* SoundEditor.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2005,2007,2009-2012,2014-2016,2018,2020,2022 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 "FunctionEditor.h" |
| 22 | #include "LongSoundArea.h" |
| 23 | #include "SoundAnalysisArea.h" |
| 24 | |
| 25 | Thing_define (SoundEditor, FunctionEditor) { |
| 26 | DEFINE_FunctionArea (1, SoundArea, soundArea) |
| 27 | DEFINE_FunctionArea (2, SoundAnalysisArea, soundAnalysisArea) |
| 28 | |
| 29 | void v1_dataChanged (Editor sender) override { |
| 30 | SoundEditor_Parent :: v1_dataChanged (sender); |
| 31 | Thing_cast (SampledXY, soundOrLongSound, our data()); |
| 32 | our soundArea() -> functionChanged (soundOrLongSound); |
| 33 | our soundAnalysisArea() -> functionChanged (soundOrLongSound); |
| 34 | } |
| 35 | void v_createMenuItems_help (EditorMenu menu) |
| 36 | override; |
| 37 | void v_distributeAreas () override { |
| 38 | if (our soundAnalysisArea() -> hasContentToShow ()) { |
| 39 | our soundArea() -> setGlobalYRange_fraction (0.5, 1.0); |
| 40 | our soundAnalysisArea() -> setGlobalYRange_fraction (0.0, 0.5); |
| 41 | } else { |
| 42 | our soundArea() -> setGlobalYRange_fraction (0.0, 1.0); |
| 43 | our soundAnalysisArea() -> setGlobalYRange_fraction (0.0, 0.0); |
| 44 | } |
| 45 | } |
| 46 | void v_draw () override { |
| 47 | FunctionArea_prepareCanvas (our soundArea().get()); |
| 48 | if (our soundAnalysisArea() -> instancePref_pulses_show()) |
| 49 | our soundAnalysisArea() -> v_draw_analysis_pulses (); |
| 50 | FunctionArea_drawInside (our soundArea().get()); |
| 51 | if (our soundAnalysisArea() -> hasContentToShow ()) { |
| 52 | FunctionArea_prepareCanvas (our soundAnalysisArea().get()); |
| 53 | our soundAnalysisArea() -> v_draw_analysis (); |
| 54 | } |
| 55 | } |
| 56 | void v_play (double startTime, double endTime) override { |
| 57 | SoundArea_play (our soundArea().get(), startTime, endTime); |
| 58 | } |
| 59 | void v_drawLegends () override { |
| 60 | const bool pulsesAreVisible = our soundAnalysisArea() -> hasPulsesToShow (); |
| 61 | FunctionArea_drawLegend (our soundArea().get(), |
| 62 | pulsesAreVisible ? FunctionArea_legend_POLES U" %%derived pulses" : nullptr, |
| 63 | Melder_GREY, |
| 64 | FunctionArea_legend_WAVEFORM U" ##modifiable sound", |
| 65 | DataGui_defaultForegroundColour (our soundArea().get(), false) |
| 66 | ); |
| 67 | SoundAnalysisArea_drawDefaultLegends (our soundAnalysisArea().get()); |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | autoSoundEditor SoundEditor_create ( |
| 72 | conststring32 title, |
| 73 | SampledXY data // either a Sound or a LongSound |
| 74 | ); |
| 75 | |
| 76 | /* End of file SoundEditor.h */ |
| 77 | #endif |