JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
LateReverb.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>
28
29#include <span>
30
31namespace JPL
32{
33 //==========================================================================
37 {
38 static constexpr uint32 cFDNChannels = 16; // FDN order
39 static constexpr uint32 cScratchSize = 480;
40
41 // Arbitrary min/max reverb time range
42 static constexpr float cMinRT60 = 0.03f;
43 static constexpr float cMaxRT60 = 10.0f;
44
45 static constexpr float cMinSlope = -60.0f / cMinRT60;
46 static constexpr float cMaxSlope = -60.0f / cMaxRT60;
47
48 //======================================================================
50 struct AttenuationFilter
51 {
52 JPL_INLINE void Prepare(float sampleRate, const SplitFrequencies& splits)
53 {
54 Crossover.Prepare(sampleRate, splits);
55 }
56
57 [[nodiscard]] JPL_INLINE float Process(float sample)
58 {
59 return Crossover.ProcessSample(sample, DecayGains);
60 }
61
63 JPL_INLINE void UpdateParameters(float delaySeconds, const simd& decaySlopeDbPerSecond)
64 {
66 DecayGains = dBToGain(dbLossPerLoop);
67 }
68
69 FourBandCrossover Crossover;
70 simd DecayGains{ 0.999f };
71 };
72
74
75 public:
76 //======================================================================
77 ReverbBus() = default;
79
83
87
93
98 void ProcessInterleaved(std::span<const float> input, std::span<float> output, uint32 numFrames);
99
100 private:
101 FDN mFDN;
102
104 using SafeRT60Write = typename SafeRT60::ScopedAccess<JPL::ThreadType::nonRealtime>;
105 using SafeRT60Read = typename SafeRT60::ScopedAccess<JPL::ThreadType::realtime>;
106 SafeRT60 mDecaySlopeDbPerSecond{ -60.0f / 1.0f};
107 };
108} // namespace JPL
Definition LateReverb.h:37
void ProcessInterleaved(std::span< const float > input, std::span< float > output, uint32 numFrames)
void SetRT60(const simd &newRT60Seconds)
void Prepare(float sampleRate, const SplitFrequencies &splits={})
ReverbBus()=default
void SetDecaySlope(const simd &newDecaySlope)
~ReverbBus() noexcept=default
Definition AcousticMaterial.h:36
JPL_INLINE T dBToGain(const T &dB) noexcept
Definition DecibelsAndGain.h:40
std::uint32_t uint32
Definition Core.h:311
JPL_INLINE simd min(const simd &a, const simd &b) noexcept
Element-wise min.
Definition SIMD.h:1813
4th order Linkwitz-Riley 4-band crossover
Definition CrossoverFilter.h:417
Split frequencies points for crossover.
Definition FrequencyBands.h:41
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60