Author Topic: Recalculating EAXEnvironment into BASS_DX8_REVERB  (Read 217 times)

DeepDigger

  • Posts: 21
Dear experts,

How do I precisely convert EAX forest environment (0.111 volume, 3.145 decay, 0.472 damp) into BASS_DX8_REVERB structure (fReverbMix, fReverbTime, fHighFreqRTRatio)?

Thank you.
« Last Edit: 28 Aug '22 - 15:20 by DeepDigger »

Ian @ un4seen

  • Administrator
  • Posts: 24730
Re: Recalculating EAXEnvironment into BASS_DX8_REVERB
« Reply #1 on: 29 Aug '22 - 15:32 »
It won't be possible to emulate EAX environments with the BASS_FX_DX8_REVERB effect, as it has limited configurability, but you may have more luck with the BASS_FX_DX8_I3DL2REVERB effect. If you look in the DSOUND.H header, you will find presets corresponding to the EAX ones, eg. I3DL2_ENVIRONMENT_PRESET_FOREST. For example, you can use them in a BASS_FXSetParameters call like this:

Code: [Select]
BASS_DX8_I3DL2REVERB param = { I3DL2_ENVIRONMENT_PRESET_FOREST }; // "forest" preset parameters
BASS_FXSetParameters(revfx, &param); // apply the parameters

Note BASS_FX_DX8_I3DL2REVERB is only available on Windows. Also note that its output is 100% wet. If you want wet/dry control, you will need to implement that yourself. You can do so by using a "dummy" stream to apply the effect on a copy of the data and then mix that with the original data at the wanted levels. The copying/applying/mixing can be done in a DSPPROC callback. It could all look something like this:

Code: [Select]
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(stream, &info); // get stream info
revstream = BASS_StreamCreate(info.freq, info.chans, info.flags | BASS_STREAM_DECODE, STREAMPROC_DUMMY, 0); // create dummy stream with same format
revfx = BASS_ChannelSetFX(revstream, BASS_FX_DX8_I3DL2REVERB, 0); // set I3DL2 reverb effect on it
BASS_DX8_I3DL2REVERB param = { I3DL2_ENVIRONMENT_PRESET_FOREST }; // "forest" preset parameters
BASS_FXSetParameters(revfx, &param); // apply the parameters
BASS_ChannelSetDSP(stream, ReverbDSP, 0, 0); // set DSP function to apply reverb on main stream

...

void CALLBACK ReverbDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user)
{
float *data = (float*)buffer;
float *temp = new float[length / sizeof(float)]; // temp array
memcpy(temp, data, length); // copy data to temp array
BASS_ChannelGetData(revstream, temp, length); // apply dummy stream's effect(s) to it
for (int a = 0; a < length / sizeof(float); a++)
data[a] = data[a] * dry + temp[a] * wet; // mix the dry and wet data
delete temp;
}

Note this is assuming that the BASS_SAMPLE_FLOAT flag is set on the stream, which I would recommend doing. Please see the documentation for details on the mentioned functions.

DeepDigger

  • Posts: 21
Re: Recalculating EAXEnvironment into BASS_DX8_REVERB
« Reply #2 on: 29 Aug '22 - 16:18 »
Thank you very very much for the in-depth review!

DeepDigger

  • Posts: 21
Re: Recalculating EAXEnvironment into BASS_DX8_REVERB
« Reply #3 on: 7 Sep '22 - 17:43 »
Could it be an idea for further development of BASS functionality?
It could be a remarkable feature - just to place a sound into specific environment.
 ???

Ian @ un4seen

  • Administrator
  • Posts: 24730
Re: Recalculating EAXEnvironment into BASS_DX8_REVERB
« Reply #4 on: 8 Sep '22 - 12:42 »
There are currently no plans for EAX emulation, so I'm afraid it won't be in the next BASS release at least. It would be nice to have though, so I wouldn't totally rule it out for a future release if something can be worked out.