resonance 1.0.1
Loading...
Searching...
No Matches
playsound.h File Reference

One-shot sound playback by registered name. More...

#include "app/hudutil.h"
Include dependency graph for playsound.h:

Go to the source code of this file.

Functions

void LookupSound (const HxStr &name, int *pNote, int *pNote2, int *pVelocity, int *pAutoStop)
 Look up the synthesiser notes, the velocity, and the auto-stop flag registered under one name.
void PlaySoundByName (const char *pszName)
 Play the sound registered under one name.
void StopSoundByName (const char *pszName)
 Silence the sound registered under one name.
void PlaySynthSound (int nNote, int nNote2, int nVelocity, int bAutoStop)
 Play one sound of the hardware synthesiser.
void CreateNoteDestroyer ()
 Build the note destroyer that releases the auto-stop notes PlaySynthSound() starts.
void StartNoteDestroyer ()
 Start the note destroyer on the song clock with its epoch at zero.
void StopNoteDestroyer ()
 Withdraw the note destroyer's queued run.
void DestroyNoteDestroyer ()
 Delete the note destroyer and clear the pointer to it.
void PlayActivateSound ()
 Play the note 100 at full velocity with no second note and no release.
void PlayPowerupSound (PowerupType kind)
 Play the sound of a captured powerup.

Detailed Description

One-shot sound playback by registered name.

The PlayStation 2 body lives in AppPlaySoundPS2.cpp, which the mangled name of a file-scope class in the same translation unit records at 0x0012f190. The declaration sits here rather than in a platform header, so a port supplies its own body for the same prototype.

Function Documentation

◆ LookupSound()

void LookupSound ( const HxStr & name,
int * pNote,
int * pNote2,
int * pVelocity,
int * pAutoStop )

Look up the synthesiser notes, the velocity, and the auto-stop flag registered under one name.

The four outputs start at -1, -1, 127, and 0, and a name in the table overwrites the ones it sets. Most names set one note. SND_MET_MUSIC1, SND_MET_MUSIC2, and SND_MET_SLIDE set a second note, the two music names also set the velocity to 75, and the in-game deploy, erase section, caught powerup, win, and crippler-hit names set the auto-stop flag. A name outside the table leaves all four at their starting values. PlaySoundByName() and StopSoundByName() are the callers. The title is inferred.

Parameters
nameThe registered name.
pNoteReceives the note, or is left at -1.
pNote2Receives the second note, or is left at -1.
pVelocityReceives the velocity, or is left at 127.
pAutoStopReceives 1 for a sound that releases itself, or is left at 0.
Ghidra address:
NTSC-U/C: 0x0012e570
Ghidra address:
PAL: 0x0012ece8

◆ PlaySoundByName()

void PlaySoundByName ( const char * pszName)

Play the sound registered under one name.

The routine wraps the name in an HxStr, looks its notes, velocity, and auto-stop flag up through LookupSound(), and plays them through PlaySynthSound(). Every metagame screen sound arrives at the synthesiser through this one entry point.

Parameters
pszNameThe registered name, such as SND_MET_SLIDE.
Ghidra address:
NTSC-U/C: 0x0012f470
Ghidra address:
PAL: 0x0012fc08

◆ StopSoundByName()

void StopSoundByName ( const char * pszName)

Silence the sound registered under one name.

Looks the name up through LookupSound() and sends a note-off for each of its notes to Globals::GetSynth() on the last MIDI channel. The first note is skipped when it is 1, not when it is -1 as for the second. The binary compares against those values. MetRenderer::Stop() is the one caller, and it stops SND_MET_MUSIC1. The title is inferred from the note-off.

Parameters
pszNameThe registered name.
Ghidra address:
NTSC-U/C: 0x0012eba0
Ghidra address:
PAL: 0x0012f318

◆ PlaySynthSound()

void PlaySynthSound ( int nNote,
int nNote2,
int nVelocity,
int bAutoStop )

Play one sound of the hardware synthesiser.

Sends a note-on for nNote on the last MIDI channel through Globals::GetSynth() with the velocity, and when bAutoStop is set queues its release 480 ticks later on the song clock with the note destroyer CreateNoteDestroyer() builds. nNote2 then sounds the same way when it is not -1, and is never queued for release. The first note is skipped when it is 1, not when it is -1, which matches StopSoundByName(). The title is inferred.

Parameters
nNoteThe first note.
nNote2The second note, or -1 for none.
nVelocityThe velocity, from 0 to 127.
bAutoStopNon-zero to release the first note after 480 ticks.
Ghidra address:
NTSC-U/C: 0x0012ea50
Ghidra address:
PAL: 0x0012f1c8

◆ CreateNoteDestroyer()

void CreateNoteDestroyer ( )

Build the note destroyer that releases the auto-stop notes PlaySynthSound() starts.

The destroyer is a file-local TickTask that runs every 120 ticks on the song clock and sends a note-off for each queued note whose release tick has arrived. It is stored in a file-scope pointer. GrooveWorld::StartPlay() is the caller. The title is inferred.

Ghidra address:
NTSC-U/C: 0x0012e460
Ghidra address:
PAL: 0x0012ebd8

◆ StartNoteDestroyer()

void StartNoteDestroyer ( )

Start the note destroyer on the song clock with its epoch at zero.

GrooveWorld::StartPlay() is the caller. The title is inferred.

Ghidra address:
NTSC-U/C: 0x0012f3d8
Ghidra address:
PAL: 0x0012fb70

◆ StopNoteDestroyer()

void StopNoteDestroyer ( )

Withdraw the note destroyer's queued run.

GrooveWorld::Shutdown() is the caller. The title is inferred.

Ghidra address:
NTSC-U/C: 0x0012f400
Ghidra address:
PAL: 0x0012fb98

◆ DestroyNoteDestroyer()

void DestroyNoteDestroyer ( )

Delete the note destroyer and clear the pointer to it.

GrooveWorld::Shutdown() is the caller, after StopNoteDestroyer(). The title is inferred.

Ghidra address:
NTSC-U/C: 0x0012f428
Ghidra address:
PAL: 0x0012fbc0

◆ PlayActivateSound()

void PlayActivateSound ( )

Play the note 100 at full velocity with no second note and no release.

The script commands that activate listen mode, practice mode, and team freqs are among the callers. The title is inferred from them.

Ghidra address:
NTSC-U/C: 0x0012f598
Ghidra address:
PAL: 0x0012fd50

◆ PlayPowerupSound()

void PlayPowerupSound ( PowerupType kind)

Play the sound of a captured powerup.

The neutralizer, crippler, freestyler, autocatcher, bumper, and multiplier each have a sound. The effect powerups and the guides have none. LocalPlayer::DispatchPriv() and the routine at 0x00122ab8 are the callers. The title is inferred.

Parameters
kindThe captured powerup.
Ghidra address:
NTSC-U/C: 0x0012f520
Ghidra address:
PAL: 0x0012fcd8