|
wavelength 1.0.0
|
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. | |
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.
| enum Mixer::Mode |
| enum Mixer::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. |
| Mixer::Mixer | ( | ) |
Construct a mixer with no tracks and one ramp per channel.
| Mixer::~Mixer | ( | ) |
Destroy the ramps.
|
static |
Report the single instance, constructing it on first use.
| 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.
| nTracks | The number of tracks in the song. |
| nInstrument | One of Instrument. |
| bool Mixer::IsInstrumentTrack | ( | int | nTrack | ) | const |
Report whether a track is the instrument track.
| nTrack | The track's index. |
| void Mixer::SetVolumes | ( | int | nChannel, |
| const std::vector< unsigned char > & | volumes ) |
Replace a channel's volume list.
| nChannel | The channel. |
| volumes | The volumes. |
| void Mixer::SetInstrumentVolumes | ( | const std::vector< unsigned char > & | volumes | ) |
Replace the volume list the other tracks use while the instrument track is occupied.
| volumes | The volumes. |
| void Mixer::AddPlayer | ( | int | nTrack | ) |
Count one more player on a track and refresh the track's volume.
| nTrack | The track's index. |
| void Mixer::RemovePlayer | ( | int | nTrack | ) |
Count one player fewer on a track and refresh the track's volume.
| nTrack | The track's index. |
| 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.
| nTrack | The track's index. |
| nUntilTick | The tick the hold ends at. |
| void Mixer::ReleaseTrack | ( | int | nTrack | ) |
End the hold on a track and refresh every channel.
| nTrack | The track's index. |
| void Mixer::PlayFullMix | ( | ) |
Play every track but the effects at mHighVolume.
| void Mixer::StartVictoryLap | ( | ) |
Move every channel to the victory lap volume, and an occupied instrument track to mHighVolume, over 1920 ticks.
| void Mixer::Activate | ( | ) |
Start following the players and register the track_solo cheat.
A mixer that is not off is unchanged.
| void Mixer::Deactivate | ( | ) |
Stop following the players, unregister the cheat, and return every track to full volume.
A mixer that is off is unchanged.
| void Mixer::FadeOut | ( | int | nTicks | ) |
Fade every track but the effects to silence.
| nTicks | The ticks the fade lasts. |
| void Mixer::SetVolume | ( | int | nChannel, |
| unsigned char | nVolume, | ||
| int | nTicks ) |
Move a channel to a volume.
| nChannel | The channel. |
| nVolume | The volume. |
| nTicks | The ticks the move lasts. |
| unsigned char Mixer::GetVolume | ( | int | nChannel | ) |
Report a channel's volume.
| nChannel | The channel. |
| void Mixer::RefreshAll | ( | int | nTicks | ) |
Move every channel to the volume its track's state selects.
| nTicks | The ticks the moves last. |
|
static |
Toggle muting the tracks nobody is on, the track_solo script command.
| pCommand | The command. |
| pUserData | Unused. |
|
staticconstexpr |
The number of synthesiser channels the mixer controls.
|
staticconstexpr |
The channel of the effects.