| 1 | #cxx . . $ `<file>/dwtools/SoundFrameIntoSampledFrame.h`/ifndef _SoundFrameIntoSampledFrame_h_ |
| 2 | #define _SoundFrameIntoSampledFrame_h_cxx . . $ `dwtools/SoundFrameIntoSampledFrame.h:2:9`! |
| 3 | /* SoundFrameIntoSampledFrame.h |
| 4 | * |
| 5 | * Copyright (C) 2024-2025 David Weenink |
| 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. See the GNU |
| 15 | * 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 "melder.h"cxx . . $ `<file>/melder/melder.h`/ |
| 22 | #include "NUMFourier.h"cxx . . $ `<file>/dwsys/NUMFourier.h`/ |
| 23 | #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/ |
| 24 | #include "Spectrum.h"cxx . . $ `<file>/fon/Spectrum.h`/ |
| 25 | |
| 26 | inline integercxx . . $ integer# getSoundFrameSize2_oddcxx . . $ getSoundFrameSize2_odd(e4170d96af58b73c). (double approximatePhysicalAnalysisWidth, double samplingPeriod) { |
| 27 | const double halfFrameDuration = 0.5 * approximatePhysicalAnalysisWidth; |
| 28 | const integercxx . . $ integer# halfFrameSamples = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (halfFrameDuration / samplingPeriod); |
| 29 | return 2 * halfFrameSamples + 1; |
| 30 | } |
| 31 | |
| 32 | inline integercxx . . $ integer# getSoundFrameSize2cxx . . $ getSoundFrameSize2(e4170d96af58b73c). (double physicalAnalysisWidth, double samplingPeriod) { |
| 33 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (physicalAnalysisWidth > 0.0); |
| 34 | Melder_assertcxx . . $ abort(15d318a79ddce9e0). (samplingPeriod > 0.0); |
| 35 | return Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (physicalAnalysisWidth / samplingPeriod); |
| 36 | } |
| 37 | |
| 38 | inline double getPhysicalAnalysisWidth2cxx . . $ getPhysicalAnalysisWidth2(746d57f737047cdc). (double effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape# windowShape) { |
| 39 | const double physicalAnalysisWidth = ( windowShape == kSound_windowShapecxx . . $ kSound_windowShape#::RECTANGULARcxx . . $ kSound_windowShape#RECTANGULAR. || |
| 40 | windowShape == kSound_windowShapecxx . . $ kSound_windowShape#::TRIANGULARcxx . . $ kSound_windowShape#TRIANGULAR. || windowShape == kSound_windowShapecxx . . $ kSound_windowShape#::HAMMINGcxx . . $ kSound_windowShape#HAMMING. || |
| 41 | windowShape == kSound_windowShapecxx . . $ kSound_windowShape#::HANNINGcxx . . $ kSound_windowShape#HANNING. ? effectiveAnalysisWidth : 2.0 * effectiveAnalysisWidth ) |
| 42 | ; |
| 43 | return physicalAnalysisWidth; |
| 44 | } |
| 45 | |
| 46 | #endif /* _SoundFrameIntoSampledFrame_h_ */ |