OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Echo Effects

Functions

u8 audioDisableEcho (void)
 Disable echo for all voices.
u8 audioEnableEcho (u8 voiceMask)
 Enable echo for specific voices.
u8 audioReleaseEcho (void)
 Turn the echo off and give its ring back to the samples.
u8 audioSetEcho (u8 delay, s8 feedback, s8 volumeL, s8 volumeR)
 Configure echo parameters.
u8 audioSetEchoFilter (const s8 fir[8])
 Set FIR filter coefficients for echo.

Detailed Description

Function Documentation

◆ audioDisableEcho()

u8 audioDisableEcho ( void )

Disable echo for all voices.

Mutes the echo and stops the ring's writes. The ring keeps its memory: audioEnableEcho() brings the same echo back.

◆ audioEnableEcho()

u8 audioEnableEcho ( u8 voiceMask)

Enable echo for specific voices.

Parameters
voiceMaskBitmask (bit 0 = voice 0, etc.)

After audioDisableEcho(), this starts the echo again as audioSetEcho() configured it, on a cleared ring (~9 ms per unit of delay in the driver; the call itself returns at once).

◆ audioReleaseEcho()

u8 audioReleaseEcho ( void )

Turn the echo off and give its ring back to the samples.

Does what audioDisableEcho() does, then frees the ring: the sample area reaches $FFC0 again (audioGetFreeMemory() counts it at once), and samples may be loaded where the ring was as soon as this returns — the driver answers only once the sound chip has stopped writing there.

For a game that wants an echo in one scene only: audioSetEcho() when the scene starts, this when it ends. audioEnableEcho() alone no longer brings an echo back afterwards; audioSetEcho() does, with its usual wait (16 ms per unit of the delay released), and it answers AUDIO_ERR_NO_MEMORY while samples loaded in the meantime occupy the ring it needs.

Returns
AUDIO_OK, or AUDIO_ERR_TIMEOUT if the driver does not answer (the ring is then still counted as taken)

◆ audioSetEcho()

u8 audioSetEcho ( u8 delay,
s8 feedback,
s8 volumeL,
s8 volumeR )

Configure echo parameters.

Parameters
delayEcho delay 1-7 (delay_ms = value * 16; values above 7 are clamped). The echo ring takes delay x 2 KB at the top of the sample area: see audioGetFreeMemory()
feedbackFeedback amount (-128 to 127)
volumeLLeft echo volume (-128 to 127)
volumeRRight echo volume (-128 to 127)

This call blocks. The S-DSP takes a new delay only when the ring it is running reaches its end, so the driver keeps the ring silent for that long before it uses the new one: up to 240 ms on the first call, 16 ms per unit of the previous delay after; then it clears the new ring (~9 ms per unit). Call it at scene setup or with the screen off, never during play. To turn the same echo off and on, use audioDisableEcho() and audioEnableEcho(): they cost one command. Call this BEFORE audioEnableEcho().

Returns
AUDIO_OK; AUDIO_ERR_NO_MEMORY when samples already loaded reach into the ring this delay needs (nothing is changed then); AUDIO_ERR_TIMEOUT if the driver does not answer

◆ audioSetEchoFilter()

u8 audioSetEchoFilter ( const s8 fir[8])

Set FIR filter coefficients for echo.

Parameters
firArray of 8 signed coefficients

Optional: from audioInit() the filter is { 127, 0, 0, 0, 0, 0, 0, 0 }, which passes the echo through unchanged. (Until 2026-10-13 it was all zeros, and an echo configured without this call was silent.)