|
| static void | enter (u8 p, u16 c) |
| | Start a phase: set the oracle, zero its frame counter.
|
| static void | load_in_pieces (u8 slot, u8 *data, u8 *end) |
| | Load one filler sample in pieces, one step per frame.
|
| int | main (void) |
| static void | tick (void) |
| | Wait one frame and count it into the current phase.
|
| static void | tint (u16 c) |
| | Backdrop colour per phase, so the run can be followed by eye.
|
| static void | update_voices (u8 count, u16 pitch) |
| | The seven-voice update, one command per voice.
|
Sound effects the way a game engine drives them: voices by number.
Three recipes a game-side sound player is built from, each measured by a luna manifest, with the audio module as it is (no extra layer):
- A looped waveform whose pitch moves every frame - a 64-sample cycle loops on voice 2 and audioSetVoiceVolumePitch() sends the note each frame.
- Stop, then play, on the same voice inside one frame - the "last
arrival cuts the sound in progress" rule: audioStopVoice() followed by audioPlaySampleOn() on the same voice, with no frame in between.
- A sample loaded in pieces - audioLoadSampleBegin() then a small audioLoadSampleStep() per frame while the game keeps running.
A fourth block times seven voices updated every frame. Each block counts the scanlines it used with profileScanlineStart()/End() (1 line = 1364 master cycles) so the cost is read from RAM, not guessed.
Nothing to press: the phases run on their own and the backdrop colour names the phase.
- SNES Concepts
- Looped one-cycle waveform: pitch is the note
- Voice ownership: the game picks the voice, the module just obeys
- Piecewise upload over the APU ports: bounded cost per frame
- What to Observe
- Backdrop: blue while loading, green during the waveform sweep, yellow for the restarts, red for the seven-voice block, then grey and silence.
- Modules Used
- console, dma, audio, profile
- See also
- lib/include/snes/audio.h
-
docs/tutorials/audio_samples.md