JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
FrequencyBands.h
Go to the documentation of this file.
1//
2// ██╗██████╗ ██╗ ██╗██████╗ ███████╗
3// ██║██╔══██╗ ██║ ██║██╔══██╗██╔════╝ ** JPL Spatial **
4// ██║██████╔╝ ██║ ██║██████╔╝███████╗
5// ██ ██║██╔═══╝ ██║ ██║██╔══██╗╚════██║ https://github.com/Jaytheway/JPLSpatial
6// ╚█████╔╝██║ ███████╗██║██████╔╝███████║
7// ╚════╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
8//
9// Copyright 2026 Jaroslav Pevno, JPL Spatial is offered under the terms of the ISC license:
10//
11// Permission to use, copy, modify, and/or distribute this software for any purpose with or
12// without fee is hereby granted, provided that the above copyright notice and this permission
13// notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
14// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
16// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#pragma once
21
22#include "JPLSpatial/Core.h"
26
27namespace JPL
28{
31
32 //======================================================================
33 // Currently we simulate propagation in 4 frequency bands:
34 // 20-176 Hz, 176-775 Hz, 775-3408 Hz, and 3408-22050 Hz
35 // ..or as center frequencies: 59 Hz, 369 Hz, 1625 Hz, 8669 Hz
37
38 //======================================================================
41 {
42 float F1 = 176.0f, F2 = 775.0f, F3 = 3408.0f;
43
44 [[nodiscard]] constexpr bool operator==(const SplitFrequencies&) const noexcept = default;
45 };
46
48 inline constexpr SplitFrequencies cDefaultFrequencySplits{ .F1 = 176.0f, .F2 = 775.0f, .F3 = 3408.0f };
49
50 //======================================================================
57
68
70 {
71 float centers2[4]{};
73
74 const float f3 = centers2[3] / nyquist;
75 const float f2 = centers2[2] / f3;
76 const float f1 = centers2[1] / f2;
77
78 return SplitFrequencies{ .F1 = f1, .F2 = f2, .F3 = f3 };
79 }
80
81
86
90
91} // namespace JPL
JPL_INLINE constexpr T Sqrt(T x) noexcept
Definition Math.h:269
Definition AcousticMaterial.h:36
const FreqBandCenters cBandCenters
Definition FrequencyBands.h:89
constexpr SplitFrequencies cDefaultFrequencySplits
At the moment JPL Spatial uses these frequency sptits for sound propagation.
Definition FrequencyBands.h:48
JPL_INLINE SplitFrequencies SplitFrequenciesFromBandCenters(const FreqBandCenters &bandCenters, float nyquist=22050.0f)
Definition FrequencyBands.h:69
JPL_INLINE FreqBandCenters ComputeBandLowerThirdCenters(const SplitFrequencies &splitFrequenciesHz, float nyquist=22050.0f)
Definition FrequencyBands.h:58
JPL_INLINE simd round(const simd &vec) noexcept
Element-wise round to nearest integer value.
Definition SIMD.h:1930
simd pow(const simd &x, const simd &y) noexcept
Definition SIMDMath.h:372
JPL_INLINE simd min(const simd &a, const simd &b) noexcept
Element-wise min.
Definition SIMD.h:1813
JPL_INLINE FreqBandCenters ComputeBandCenters(const SplitFrequencies &splitFrequenciesHz, float nyquist=22050.0f)
Definition FrequencyBands.h:51
Split frequencies points for crossover.
Definition FrequencyBands.h:41
float F1
Definition FrequencyBands.h:42
float F2
Definition FrequencyBands.h:42
float F3
Definition FrequencyBands.h:42
constexpr bool operator==(const SplitFrequencies &) const noexcept=default
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60