1
$\begingroup$

I have successfully implemented the Sony PlayStation 1 reverb effect, until I realized that it strictly works at a sample of 44.1 kHz.

A quick web search shown that (as far as I understand), an IIR reverb effect will only work at the sample rate it's been designed for.

I was planning to use that reverb effect for a game written with Unity 3D, which uses 48 kHz sample rate by default; and as you might have guessed it, the output of the reverb is completely wrong.

The reverb is wrong in the sense that there's some kind of feedback happening and the result is that the sound becomes completely saturated.

My two-folded question is the following,

Given the reverb effect parameters shown below, is there a way to convert them to accommodate another sample rate than 44.1 kHz?

Or is there something of higher-level that I am missing, i.e., the algorithm that produced these values; in other terms, are these parameters not sufficient by themselves to upgrade the reverb effect to work at another sample rate?

  Port      Reg   Name    Type    Expl.
  1F801DC0h rev00 dAPF1   disp    Reverb APF Offset 1
  1F801DC2h rev01 dAPF2   disp    Reverb APF Offset 2
  1F801DC4h rev02 vIIR    volume  Reverb Reflection Volume 1
  1F801DC6h rev03 vCOMB1  volume  Reverb Comb Volume 1
  1F801DC8h rev04 vCOMB2  volume  Reverb Comb Volume 2
  1F801DCAh rev05 vCOMB3  volume  Reverb Comb Volume 3
  1F801DCCh rev06 vCOMB4  volume  Reverb Comb Volume 4
  1F801DCEh rev07 vWALL   volume  Reverb Reflection Volume 2
  1F801DD0h rev08 vAPF1   volume  Reverb APF Volume 1
  1F801DD2h rev09 vAPF2   volume  Reverb APF Volume 2
  1F801DD4h rev0A mLSAME  src/dst Reverb Same Side Reflection Address 1 Left
  1F801DD6h rev0B mRSAME  src/dst Reverb Same Side Reflection Address 1 Right
  1F801DD8h rev0C mLCOMB1 src     Reverb Comb Address 1 Left
  1F801DDAh rev0D mRCOMB1 src     Reverb Comb Address 1 Right
  1F801DDCh rev0E mLCOMB2 src     Reverb Comb Address 2 Left
  1F801DDEh rev0F mRCOMB2 src     Reverb Comb Address 2 Right
  1F801DE0h rev10 dLSAME  src     Reverb Same Side Reflection Address 2 Left
  1F801DE2h rev11 dRSAME  src     Reverb Same Side Reflection Address 2 Right
  1F801DE4h rev12 mLDIFF  src/dst Reverb Different Side Reflect Address 1 Left
  1F801DE6h rev13 mRDIFF  src/dst Reverb Different Side Reflect Address 1 Right
  1F801DE8h rev14 mLCOMB3 src     Reverb Comb Address 3 Left
  1F801DEAh rev15 mRCOMB3 src     Reverb Comb Address 3 Right
  1F801DECh rev16 mLCOMB4 src     Reverb Comb Address 4 Left
  1F801DEEh rev17 mRCOMB4 src     Reverb Comb Address 4 Right
  1F801DF0h rev18 dLDIFF  src     Reverb Different Side Reflect Address 2 Left
  1F801DF2h rev19 dRDIFF  src     Reverb Different Side Reflect Address 2 Right
  1F801DF4h rev1A mLAPF1  src/dst Reverb APF Address 1 Left
  1F801DF6h rev1B mRAPF1  src/dst Reverb APF Address 1 Right
  1F801DF8h rev1C mLAPF2  src/dst Reverb APF Address 2 Left
  1F801DFAh rev1D mRAPF2  src/dst Reverb APF Address 2 Right

The disp, src and dst parameters type are offsets in the reverb working area, i.e. the buffer of 16-bit samples.

The documentation of that reverse-engineered reverb effect:

https://problemkaputt.de/psxspx-sound-processing-unit-spu.htm

I tried to linearly scale these parameters according the different sample rate, but that didn't work at all.

Though not ideal, it appears that I do have an option to remediate to this; rely on the operating system (Windows in this case) to perform real-time resampling to accommodate this issue.

But ideally, if I could solve that problem at the root and in the meantime learn something new, that would be great.

$\endgroup$
4
  • $\begingroup$ This is kinda icky, so I don't want to dive into any code. If you have a reverb algorithm that works at sample rate 44.1 kHz, it should work fine at 48 kHz or 96 kHz, but it won't sound the same, of course. If you increase the sample rate, you will also have to increase the delay amounts (delay measured in sample periods) by proportionately the same amount. $\endgroup$ May 20, 2023 at 18:10
  • $\begingroup$ I'm not much into audio effects, but if "reverb" means "sounds like it's in a room with echos" -- at a design sample rate of 44.1kHz and an actual sample rate of 48kHz, it should just sound like it's a smaller room. I wouldn't characterize that as "all wrong", so I wonder if you have something else going on. $\endgroup$
    – TimWescott
    May 20, 2023 at 23:43
  • $\begingroup$ @robertbristow-johnson Getting closer, I think I've spotted where the problem is :) $\endgroup$
    – aybe
    May 21, 2023 at 2:02
  • $\begingroup$ @TimWescott I've updated the question, it starts like so, but the end sounds terribly loud. $\endgroup$
    – aybe
    May 21, 2023 at 2:03

2 Answers 2

1
$\begingroup$

A quick web search shown that (as far as I understand), an IIR reverb effect will only work at the sample rate it's been designed for.

That's generally not true. 48 kHz and 44.1 kHz are only 10% apart and this should work reasonably well as is. It will sound somewhat different, but it should still sound like a reverb and the difference should be less than, say, the difference between "studio" and "room".

I was planning to use that reverb effect for a game written with Unity 3D, which uses 48Khz sample rate by default; and as you might have guessed it, the output of the reverb is completely wrong.

You probably need to be more specific about what exactly is wrong. If the only change is really just the sample rate, than this shouldn't be the case.

Given the reverb effect parameters shown below, is there a way to convert them to accommodate another sample rate than 44.1Khz?

Typically yes. What to do depends on the type of register

  1. Mixing volumes should stay constant
  2. Feedback volumes should scale. The exact scaling function is complicated but for a 10% change it's not a big deal: you can start with "scale 10% closer to 1" (or -1 if negative). If in doubt, leave them alone
  3. Memory distance registers should scale directly with the sample rate
  4. Memory location register depend on how the memory management is done which I can't tell from the documentation. I'm guessing they should also scale, but I'm not sure.

If it's completely broken without changing any register settings, something else is wrong: could be memory management, clipping, out of cycles, clocking, etc.

$\endgroup$
3
  • $\begingroup$ Updated my question and getting closer, for whatever reason I screwed some volume calculation, looking into it! $\endgroup$
    – aybe
    May 21, 2023 at 2:04
  • $\begingroup$ I would start with using the exact same parameters as 44.1 kHz. Once that works you can start tweaking gently $\endgroup$
    – Hilmar
    May 21, 2023 at 4:43
  • $\begingroup$ It turns out to be trickier, just realized the reverb in fact works at 22Khz!!! As I don't yet have means to resample within Unity, your trick of scaling offsets by two already sounds closer to the emulator. Next step is to port everything again to any rate using floats. But in the mean time, as I have a PS1 and CRT laying around, I thought I'd just record it on the real hardware to have an exact point of comparison. Hope to be done soon! $\endgroup$
    – aybe
    May 21, 2023 at 22:44
1
$\begingroup$

I guess you could generate the reverb at 44.1kHz, sample its impulse response, resample it to 48kHz, then use that impulse response in a purely FIR/convolution reverb?

That would make it hard to tweak parameters dynamically though.

$\endgroup$
1
  • $\begingroup$ I have been thinking about that, including the fact to replicate into own Unity's reverb. Thing is, their reverb parameters (docs.unity3d.com/Manual/class-AudioReverbFilter.html) are kinda weird and working that out is most likely beyond reach for me, at least in a reasonable time frame. $\endgroup$
    – aybe
    May 21, 2023 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.