OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
main.c File Reference

Soundboard — the audio v2 engine driven entirely from C. More...

#include <snes.h>
#include <snes/audio.h>
#include <snes/input.h>

Macros

#define PITCH_CELLO   0x08BB
 Cello DSP pitch: krom's C5 ($8BB0 >> 4, as in pitch_mod).
#define PITCH_CELLO_HI   0x0D18
#define PITCH_CELLO_LO   0x05D2
 A fifth below / above (x2/3 and x3/2).
#define SMP_AU   1
#define SMP_CELLO   0
 Sample slots.
#define SMP_PP   3
#define SMP_SS   2

Functions

int main (void)
static void play (u8 sample, u8 vol, u8 pan, u16 pitch, u16 tint)
 Play + tint the backdrop + update the probe oracles.

Variables

u8 brr_au []
u8 brr_au_end []
u8 brr_cello []
u8 brr_cello_end []
u8 brr_pp []
u8 brr_pp_end []
u8 brr_ss []
u8 brr_ss_end []
static u8 echo_on
u8 last_voice
 Probe oracles (WRAM).
static u8 master_vol
 Master volume state (Up/Down).
u16 play_count

Detailed Description

Soundboard — the audio v2 engine driven entirely from C.

The first audio example with ZERO SPC700 assembly: the lib's audio module uploads its own resident driver, and everything below — loading four BRR samples into APU RAM, playing them with pan and pitch, shaping envelopes, switching a concert-hall echo on and off — is plain C calls.

Controls:

  • A: cello note (center) — B: "AU" vowel (left) — X: "SS" hiss (right) — Y: "PP" pop (center)
  • L/R: replay the cello a fifth down / up (pitch demo)
  • Up/Down: master volume
  • START: toggle the echo hall

ROM mode: LoROM (project default).

SNES Concepts
  • Dynamic BRR loading: audioLoadSample() streams samples over the APU I/O ports at runtime — no fixed APU memory image
  • audioPlaySampleEx(): volume/pan/pitch per play, voices round-robin allocated by the engine
  • ADSR set once per voice at init — notes ring and die naturally
  • Echo: audioSetEcho() clears and sizes the ring, FIR tap 0, audioEnableEcho() routes voices in
What to Observe
Every button plays immediately, polyphonic up to 8 voices; START adds a hall around everything. The backdrop tints with each action.
Modules Used
console, audio, input
See also
lib/include/snes/audio.h — the full engine API
.claude/notes/chantiers/audio_v2.md — engine design

Macro Definition Documentation

◆ PITCH_CELLO

#define PITCH_CELLO   0x08BB

Cello DSP pitch: krom's C5 ($8BB0 >> 4, as in pitch_mod).

◆ PITCH_CELLO_HI

#define PITCH_CELLO_HI   0x0D18

◆ PITCH_CELLO_LO

#define PITCH_CELLO_LO   0x05D2

A fifth below / above (x2/3 and x3/2).

◆ SMP_AU

#define SMP_AU   1

◆ SMP_CELLO

#define SMP_CELLO   0

Sample slots.

◆ SMP_PP

#define SMP_PP   3

◆ SMP_SS

#define SMP_SS   2

Function Documentation

◆ main()

int main ( void )

◆ play()

void play ( u8 sample,
u8 vol,
u8 pan,
u16 pitch,
u16 tint )
static

Play + tint the backdrop + update the probe oracles.

Variable Documentation

◆ brr_au

u8 brr_au[]
extern

◆ brr_au_end

u8 brr_au_end[]

◆ brr_cello

u8 brr_cello[]
extern

◆ brr_cello_end

u8 brr_cello_end[]

◆ brr_pp

u8 brr_pp[]
extern

◆ brr_pp_end

u8 brr_pp_end[]

◆ brr_ss

u8 brr_ss[]
extern

◆ brr_ss_end

u8 brr_ss_end[]

◆ echo_on

u8 echo_on
static

◆ last_voice

u8 last_voice

Probe oracles (WRAM).

◆ master_vol

u8 master_vol
static

Master volume state (Up/Down).

◆ play_count

u16 play_count