summaryrefslogtreecommitdiffstats
path: root/src/audio_core/common.h
diff options
context:
space:
mode:
authorChloe Marcec <dmarcecguzman@gmail.com>2021-02-11 08:46:20 +0100
committerbunnei <bunneidev@gmail.com>2021-02-13 03:48:10 +0100
commit4a7fd91857a95dd9ba7c838384671b2a83e46e7d (patch)
tree77dc77e963c2ce5e386d747b76ba19bec89a92b6 /src/audio_core/common.h
parentMerge pull request #5877 from ameerj/res-limit-usage (diff)
downloadyuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.gz
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.bz2
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.lz
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.xz
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.tar.zst
yuzu-4a7fd91857a95dd9ba7c838384671b2a83e46e7d.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/common.h23
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
// and our const ends up being 0x3f04, the 4 bytes are most
// likely the sample history
constexpr std::size_t TOTAL_TEMP_MIX_SIZE = TEMP_MIX_BASE_SIZE + AudioCommon::MAX_SAMPLE_HISTORY;
+constexpr f32 I3DL2REVERB_MAX_LEVEL = 5000.0f;
+constexpr f32 I3DL2REVERB_MIN_REFLECTION_DURATION = 0.02f;
+constexpr std::size_t I3DL2REVERB_TAPS = 20;
+constexpr std::size_t I3DL2REVERB_DELAY_LINE_COUNT = 4;
+using Fractional = s32;
+
+template <typename T>
+constexpr Fractional ToFractional(T x) {
+ return static_cast<Fractional>(x * static_cast<T>(0x4000));
+}
+
+constexpr Fractional MultiplyFractional(Fractional lhs, Fractional rhs) {
+ return static_cast<Fractional>(static_cast<s64>(lhs) * rhs >> 14);
+}
+
+constexpr s32 FractionalToFixed(Fractional x) {
+ const auto s = x & (1 << 13);
+ return static_cast<s32>(x >> 14) + s;
+}
+
+constexpr s32 CalculateDelaySamples(s32 sample_rate_khz, float time) {
+ return FractionalToFixed(MultiplyFractional(ToFractional(sample_rate_khz), ToFractional(time)));
+}
static constexpr u32 VersionFromRevision(u32_le rev) {
// "REV7" -> 7