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

Functions

u8 snesmodLoadEffect (u16 sfxIndex)
 Load a sound effect from the soundbank.
u8 snesmodPlayEffect (u16 effectId, u8 volume, u8 pan, u16 pitch)
 Play a sound effect.

Detailed Description

Function Documentation

◆ snesmodLoadEffect()

u8 snesmodLoadEffect ( u16 sfxIndex)

Load a sound effect from the soundbank.

Loads a single source/sample for use as a sound effect.

Parameters
sfxIndexSource index in the soundbank
Returns
Effect slot ID for use with snesmodPlayEffect, 0-15; 0xFF when the 16 slots are taken (nothing is loaded — until 2026-10-03 a 17th load returned 16, which snesmodPlayEffect played as 0)

◆ snesmodPlayEffect()

u8 snesmodPlayEffect ( u16 effectId,
u8 volume,
u8 pan,
u16 pitch )

Play a sound effect.

Triggers a sound effect, potentially interrupting module playback on one channel temporarily.

Parameters
effectIdEffect slot ID (from snesmodLoadEffect or soundbank.h), 0-15: the driver command carries it in four bits
volumeVolume level (0-127; the command keeps its top 4 bits, so 16 steps)
panPan position (0=left, 128=center, 255=right; 16 steps)
pitchPlayback rate, 0-15: use SNESMOD_PITCH_LOW (4, 16 kHz), SNESMOD_PITCH_NORMAL (8, 32 kHz) or SNESMOD_PITCH_HIGH (12, 48 kHz). NOT the $1000-style pitch of audio.h: only the low four bits are sent (the routine masks the rest, 2026-09-20 — it used to OR the whole low byte into the effect-id nibble, so 0x1000 played at rate 0 and 0x1800 too).
Returns
Unspecified. The command is only queued for the SPC700; no channel is known on the CPU side. (Documented as "channel used" until 2026-09-20; the value was the packed command byte. The return type is an open item of the API audit.)
// Play jump sound at full volume, center pan, normal pitch
// Play with higher pitch
#define SNESMOD_PITCH_NORMAL
Definition snesmod.h:348
#define SNESMOD_PITCH_HIGH
Definition snesmod.h:349
u8 snesmodPlayEffect(u16 effectId, u8 volume, u8 pan, u16 pitch)
Play a sound effect.