wavelength 1.0.0
Loading...
Searching...
No Matches
Mixer Class Reference

Volume control of the song's tracks. More...

#include <mixer.h>

Classes

struct  TrackData
 The state of one of the song's tracks. More...
class  VolumeRamp
 Ramp that sends one synthesiser channel's volume. More...

Public Types

enum  Mode { kModeOff = 0 , kModePlaying = 1 , kModeFullMix = 2 , kModeVictoryLap = 3 }
 What the mixer is doing, the values of mMode. More...
enum  Instrument { kInstrumentNone = 0 , kInstrumentAxe = 1 , kInstrumentScratch = 2 }
 The instrument tracks Init() configures the mixer for. More...

Public Member Functions

 Mixer ()
 Construct a mixer with no tracks and one ramp per channel.
 ~Mixer ()
 Destroy the ramps.
void Init (int nTracks, int nInstrument)
 Set the mixer up for a song and read the "mixer" section of the configuration.
bool IsInstrumentTrack (int nTrack) const
 Report whether a track is the instrument track.
void SetVolumes (int nChannel, const std::vector< unsigned char > &volumes)
 Replace a channel's volume list.
void SetInstrumentVolumes (const std::vector< unsigned char > &volumes)
 Replace the volume list the other tracks use while the instrument track is occupied.
void AddPlayer (int nTrack)
 Count one more player on a track and refresh the track's volume.
void RemovePlayer (int nTrack)
 Count one player fewer on a track and refresh the track's volume.
void HoldTrack (int nTrack, int nUntilTick)
 Hold a track until the tick before a song tick, and refresh every other channel.
void ReleaseTrack (int nTrack)
 End the hold on a track and refresh every channel.
void PlayFullMix ()
 Play every track but the effects at mHighVolume.
void StartVictoryLap ()
 Move every channel to the victory lap volume, and an occupied instrument track to mHighVolume, over 1920 ticks.
void Activate ()
 Start following the players and register the track_solo cheat.
void Deactivate ()
 Stop following the players, unregister the cheat, and return every track to full volume.
void FadeOut (int nTicks)
 Fade every track but the effects to silence.
void SetVolume (int nChannel, unsigned char nVolume, int nTicks)
 Move a channel to a volume.
unsigned char GetVolume (int nChannel)
 Report a channel's volume.
void RefreshAll (int nTicks)
 Move every channel to the volume its track's state selects.

Static Public Member Functions

static Mixer * shared ()
 Report the single instance, constructing it on first use.
static void ToggleMuteUnoccupied (DataArray *pCommand, void *pUserData)
 Toggle muting the tracks nobody is on, the track_solo script command.

Static Public Attributes

static constexpr int kChannelCount = 16
 The number of synthesiser channels the mixer controls.
static constexpr int kFxChannel = kChannelCount - 1
 The channel of the effects.

Detailed Description

Volume control of the song's tracks.

The RTTI includes the class name. The one instance is the function-local static of shared(), and TheMixer addresses it. Each of the sixteen synthesiser channels has a VolumeRamp that sends the channel's volume as MIDI controller 17. The last channel is the effects channel.

While the mixer plays (kModePlaying), a track a player is on plays at mHighVolume, and any other track plays at the entry of its volume list that the number of held tracks selects. With an instrument track whose last track is occupied, every other track uses mInstrumentVolumes instead. The track_solo cheat mutes the tracks nobody is on.

Member Enumeration Documentation

◆ Mode

What the mixer is doing, the values of mMode.

Enumerator
kModeOff 

The volumes are left alone.

kModePlaying 

The volumes follow the players.

kModeFullMix 

Every track plays at mHighVolume.

kModeVictoryLap 

The song is ending after a win.

◆ Instrument

The instrument tracks Init() configures the mixer for.

Enumerator
kInstrumentNone 

The song has no instrument track.

kInstrumentAxe 

The last track is played with the axe.

kInstrumentScratch 

The last track is played with the scratcher.

Constructor & Destructor Documentation

◆ Mixer()

Mixer::Mixer ( )

Construct a mixer with no tracks and one ramp per channel.

Ghidra address:
NTSC-U/C: 0x00123870
Ghidra address:
PAL: 0x00124ff0

◆ ~Mixer()

Mixer::~Mixer ( )

Destroy the ramps.

Ghidra address:
NTSC-U/C: 0x00123988
Ghidra address:
PAL: 0x00125108

Member Function Documentation

◆ shared()

Mixer * Mixer::shared ( )
static

Report the single instance, constructing it on first use.

Returns
The instance.
Ghidra address:
NTSC-U/C: 0x00123ee8
Ghidra address:
PAL: 0x00125668

◆ Init()

void Mixer::Init ( int nTracks,
int nInstrument )

Set the mixer up for a song and read the "mixer" section of the configuration.

Every track starts with no players and unheld. Each channel's volume list is the configuration's low_volumes, except the effects channel's, which is fx_volumes. Every channel then moves at once to the first entry of its list.

Parameters
nTracksThe number of tracks in the song.
nInstrumentOne of Instrument.
Ghidra address:
NTSC-U/C: 0x00123ad0
Ghidra address:
PAL: 0x00125250

◆ IsInstrumentTrack()

bool Mixer::IsInstrumentTrack ( int nTrack) const

Report whether a track is the instrument track.

Parameters
nTrackThe track's index.
Returns
Whether the song has an instrument track and the track is the last one.
Ghidra address:
NTSC-U/C: 0x00123e38
Ghidra address:
PAL: 0x001255b8

◆ SetVolumes()

void Mixer::SetVolumes ( int nChannel,
const std::vector< unsigned char > & volumes )

Replace a channel's volume list.

Parameters
nChannelThe channel.
volumesThe volumes.
Ghidra address:
NTSC-U/C: 0x00123e78
Ghidra address:
PAL: 0x001255f8

◆ SetInstrumentVolumes()

void Mixer::SetInstrumentVolumes ( const std::vector< unsigned char > & volumes)

Replace the volume list the other tracks use while the instrument track is occupied.

Parameters
volumesThe volumes.
Ghidra address:
NTSC-U/C: 0x00123ea0
Ghidra address:
PAL: 0x00125620

◆ AddPlayer()

void Mixer::AddPlayer ( int nTrack)

Count one more player on a track and refresh the track's volume.

Parameters
nTrackThe track's index.
Ghidra address:
NTSC-U/C: 0x00123f40
Ghidra address:
PAL: 0x001256c0

◆ RemovePlayer()

void Mixer::RemovePlayer ( int nTrack)

Count one player fewer on a track and refresh the track's volume.

Parameters
nTrackThe track's index.
Ghidra address:
NTSC-U/C: 0x00123fc8
Ghidra address:
PAL: 0x00125748

◆ HoldTrack()

void Mixer::HoldTrack ( int nTrack,
int nUntilTick )

Hold a track until the tick before a song tick, and refresh every other channel.

Nothing happens once the song has passed the tick.

Parameters
nTrackThe track's index.
nUntilTickThe tick the hold ends at.
Ghidra address:
NTSC-U/C: 0x00124070
Ghidra address:
PAL: 0x001257f0

◆ ReleaseTrack()

void Mixer::ReleaseTrack ( int nTrack)

End the hold on a track and refresh every channel.

Parameters
nTrackThe track's index.
Ghidra address:
NTSC-U/C: 0x00124150
Ghidra address:
PAL: 0x001258d0

◆ PlayFullMix()

void Mixer::PlayFullMix ( )

Play every track but the effects at mHighVolume.

Ghidra address:
NTSC-U/C: 0x001241c0
Ghidra address:
PAL: 0x00125940

◆ StartVictoryLap()

void Mixer::StartVictoryLap ( )

Move every channel to the victory lap volume, and an occupied instrument track to mHighVolume, over 1920 ticks.

Ghidra address:
NTSC-U/C: 0x00124220
Ghidra address:
PAL: 0x001259a0

◆ Activate()

void Mixer::Activate ( )

Start following the players and register the track_solo cheat.

A mixer that is not off is unchanged.

Ghidra address:
NTSC-U/C: 0x001242d0
Ghidra address:
PAL: 0x00125a50

◆ Deactivate()

void Mixer::Deactivate ( )

Stop following the players, unregister the cheat, and return every track to full volume.

A mixer that is off is unchanged.

Ghidra address:
NTSC-U/C: 0x00124328
Ghidra address:
PAL: 0x00125aa8

◆ FadeOut()

void Mixer::FadeOut ( int nTicks)

Fade every track but the effects to silence.

Parameters
nTicksThe ticks the fade lasts.
Ghidra address:
NTSC-U/C: 0x001243b0
Ghidra address:
PAL: 0x00125b30

◆ SetVolume()

void Mixer::SetVolume ( int nChannel,
unsigned char nVolume,
int nTicks )

Move a channel to a volume.

Parameters
nChannelThe channel.
nVolumeThe volume.
nTicksThe ticks the move lasts.
Ghidra address:
NTSC-U/C: 0x001244c8
Ghidra address:
PAL: 0x00125c48

◆ GetVolume()

unsigned char Mixer::GetVolume ( int nChannel)

Report a channel's volume.

Parameters
nChannelThe channel.
Returns
The volume.
Ghidra address:
NTSC-U/C: 0x00124508
Ghidra address:
PAL: 0x00125c88

◆ RefreshAll()

void Mixer::RefreshAll ( int nTicks)

Move every channel to the volume its track's state selects.

Parameters
nTicksThe ticks the moves last.
Ghidra address:
NTSC-U/C: 0x00124640
Ghidra address:
PAL: 0x00125dc0

◆ ToggleMuteUnoccupied()

void Mixer::ToggleMuteUnoccupied ( DataArray * pCommand,
void * pUserData )
static

Toggle muting the tracks nobody is on, the track_solo script command.

Parameters
pCommandThe command.
pUserDataUnused.
Ghidra address:
NTSC-U/C: 0x001246a0
Ghidra address:
PAL: 0x00125e20

Member Data Documentation

◆ kChannelCount

int Mixer::kChannelCount = 16
staticconstexpr

The number of synthesiser channels the mixer controls.

◆ kFxChannel

int Mixer::kFxChannel = kChannelCount - 1
staticconstexpr

The channel of the effects.


The documentation for this class was generated from the following file: