diff options
| author | 2021-02-11 18:46:20 +1100 | |
|---|---|---|
| committer | 2021-02-12 18:48:10 -0800 | |
| commit | 4a7fd91857a95dd9ba7c838384671b2a83e46e7d (patch) | |
| tree | 77dc77e963c2ce5e386d747b76ba19bec89a92b6 /src/audio_core/common.h | |
| parent | Merge pull request #5877 from ameerj/res-limit-usage (diff) | |
| download | yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.gz yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.xz yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.zip | |
audren: Implement I3dl2Reverb
Most notable fix is the voices in Fire Emblem Three Houses
Diffstat (limited to 'src/audio_core/common.h')
| -rw-r--r-- | src/audio_core/common.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/audio_core/common.h b/src/audio_core/common.h index ec59a3ba9..fe546c55d 100644 --- a/src/audio_core/common.h +++ b/src/audio_core/common.h | |||
| @@ -33,6 +33,29 @@ constexpr std::size_t TEMP_MIX_BASE_SIZE = 0x3f00; // TODO(ogniK): Work out this | |||
| 33 | // and our const ends up being 0x3f04, the 4 bytes are most | 33 | // and our const ends up being 0x3f04, the 4 bytes are most |
| 34 | // likely the sample history | 34 | // likely the sample history |
| 35 | constexpr std::size_t TOTAL_TEMP_MIX_SIZE = TEMP_MIX_BASE_SIZE + AudioCommon::MAX_SAMPLE_HISTORY; | 35 | constexpr std::size_t TOTAL_TEMP_MIX_SIZE = TEMP_MIX_BASE_SIZE + AudioCommon::MAX_SAMPLE_HISTORY; |
| 36 | constexpr f32 I3DL2REVERB_MAX_LEVEL = 5000.0f; | ||
| 37 | constexpr f32 I3DL2REVERB_MIN_REFLECTION_DURATION = 0.02f; | ||
| 38 | constexpr std::size_t I3DL2REVERB_TAPS = 20; | ||
| 39 | constexpr std::size_t I3DL2REVERB_DELAY_LINE_COUNT = 4; | ||
| 40 | using Fractional = s32; | ||
| 41 | |||
| 42 | template <typename T> | ||
| 43 | constexpr Fractional ToFractional(T x) { | ||
| 44 | return static_cast<Fractional>(x * static_cast<T>(0x4000)); | ||
| 45 | } | ||
| 46 | |||
| 47 | constexpr Fractional MultiplyFractional(Fractional lhs, Fractional rhs) { | ||
| 48 | return static_cast<Fractional>(static_cast<s64>(lhs) * rhs >> 14); | ||
| 49 | } | ||
| 50 | |||
| 51 | constexpr s32 FractionalToFixed(Fractional x) { | ||
| 52 | const auto s = x & (1 << 13); | ||
| 53 | return static_cast<s32>(x >> 14) + s; | ||
| 54 | } | ||
| 55 | |||
| 56 | constexpr s32 CalculateDelaySamples(s32 sample_rate_khz, float time) { | ||
| 57 | return FractionalToFixed(MultiplyFractional(ToFractional(sample_rate_khz), ToFractional(time))); | ||
| 58 | } | ||
| 36 | 59 | ||
| 37 | static constexpr u32 VersionFromRevision(u32_le rev) { | 60 | static constexpr u32 VersionFromRevision(u32_le rev) { |
| 38 | // "REV7" -> 7 | 61 | // "REV7" -> 7 |