Commit f9492ecf authored by David Reid's avatar David Reid

Fix a bug with the wet/dry parameters in the delay effect.

Public issue https://github.com/mackron/miniaudio/discussions/547
parent 034cc5f8
...@@ -4772,7 +4772,7 @@ typedef struct ...@@ -4772,7 +4772,7 @@ typedef struct
{ {
ma_delay_config config; ma_delay_config config;
ma_uint32 cursor; /* Feedback is written to this cursor. Always equal or in front of the read cursor. */ ma_uint32 cursor; /* Feedback is written to this cursor. Always equal or in front of the read cursor. */
ma_uint32 bufferSizeInFrames; /* The maximum of config.startDelayInFrames and config.feedbackDelayInFrames. */ ma_uint32 bufferSizeInFrames;
float* pBuffer; float* pBuffer;
} ma_delay; } ma_delay;
...@@ -20899,7 +20899,8 @@ typedef enum ...@@ -20899,7 +20899,8 @@ typedef enum
} MA_PROCESS_LOOPBACK_MODE; } MA_PROCESS_LOOPBACK_MODE;
/* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_process_loopback_params */ /* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_process_loopback_params */
typedef struct { typedef struct
{
DWORD TargetProcessId; DWORD TargetProcessId;
MA_PROCESS_LOOPBACK_MODE ProcessLoopbackMode; MA_PROCESS_LOOPBACK_MODE ProcessLoopbackMode;
} MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS; } MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS;
...@@ -47178,7 +47179,7 @@ MA_API ma_delay_config ma_delay_config_init(ma_uint32 channels, ma_uint32 sample ...@@ -47178,7 +47179,7 @@ MA_API ma_delay_config ma_delay_config_init(ma_uint32 channels, ma_uint32 sample
config.delayInFrames = delayInFrames; config.delayInFrames = delayInFrames;
config.delayStart = (decay == 0) ? MA_TRUE : MA_FALSE; /* Delay the start if it looks like we're not configuring an echo. */ config.delayStart = (decay == 0) ? MA_TRUE : MA_FALSE; /* Delay the start if it looks like we're not configuring an echo. */
config.wet = 1; config.wet = 1;
config.dry = 1; config.dry = 0;
config.decay = decay; config.decay = decay;
return config; return config;
...@@ -47243,18 +47244,18 @@ MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut, ...@@ -47243,18 +47244,18 @@ MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut,
/* Delayed start. */ /* Delayed start. */
/* Read */ /* Read */
pFramesOutF32[iChannel] = pDelay->pBuffer[iBuffer] * pDelay->config.wet; pFramesOutF32[iChannel] = (pDelay->pBuffer[iBuffer] * pDelay->config.wet) + (pFramesInF32[iChannel] * pDelay->config.dry);
/* Feedback */ /* Feedback */
pDelay->pBuffer[iBuffer] = (pDelay->pBuffer[iBuffer] * pDelay->config.decay) + (pFramesInF32[iChannel] * pDelay->config.dry); pDelay->pBuffer[iBuffer] = pFramesInF32[iChannel] + (pDelay->pBuffer[iBuffer] * pDelay->config.decay);
} else { } else {
/* Immediate start */ /* Immediate start */
/* Feedback */ /* Feedback */
pDelay->pBuffer[iBuffer] = (pDelay->pBuffer[iBuffer] * pDelay->config.decay) + (pFramesInF32[iChannel] * pDelay->config.dry); pDelay->pBuffer[iBuffer] = pFramesInF32[iChannel] + (pDelay->pBuffer[iBuffer] * pDelay->config.decay);
/* Read */ /* Read */
pFramesOutF32[iChannel] = pDelay->pBuffer[iBuffer] * pDelay->config.wet; pFramesOutF32[iChannel] = (pDelay->pBuffer[iBuffer] * pDelay->config.wet) + (pFramesInF32[iChannel] * pDelay->config.dry);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment