Debian Codegraph @

dwtools/SoundFrameIntoSampledFrame.h

raw
1 #ifndef _SoundFrameIntoSampledFrame_h_
2 #define _SoundFrameIntoSampledFrame_h_
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"
22 #include "NUMFourier.h"
23 #include "Sound_extensions.h"
24 #include "Spectrum.h"
25
26 inline integer getSoundFrameSize2_odd (double approximatePhysicalAnalysisWidth, double samplingPeriod) {
27 const double halfFrameDuration = 0.5 * approximatePhysicalAnalysisWidth;
28 const integer halfFrameSamples = Melder_ifloor (halfFrameDuration / samplingPeriod);
29 return 2 * halfFrameSamples + 1;
30 }
31
32 inline integer getSoundFrameSize2 (double physicalAnalysisWidth, double samplingPeriod) {
33 Melder_assert (physicalAnalysisWidth > 0.0);
34 Melder_assert (samplingPeriod > 0.0);
35 return Melder_iround (physicalAnalysisWidth / samplingPeriod);
36 }
37
38 inline double getPhysicalAnalysisWidth2 (double effectiveAnalysisWidth, kSound_windowShape windowShape) {
39 const double physicalAnalysisWidth = ( windowShape == kSound_windowShape::RECTANGULAR ||
40 windowShape == kSound_windowShape::TRIANGULAR || windowShape == kSound_windowShape::HAMMING ||
41 windowShape == kSound_windowShape::HANNING ? effectiveAnalysisWidth : 2.0 * effectiveAnalysisWidth )
42 ;
43 return physicalAnalysisWidth;
44 }
45
46 #endif /* _SoundFrameIntoSampledFrame_h_ */