|
resonance 1.0.1
|
Per-track MIDI mixer that sits between a track graph and the synthesiser. More...
#include <mixer.h>


Public Member Functions | |
| Mixer (int nTrack, unsigned char nChannel) | |
| Construct a mixer on one channel. | |
| virtual | ~Mixer () |
| void | SetGainFactor (int nIndex, unsigned char nFactor) |
| Set one of the four gain factors and send the combined level. | |
| void | SetMuted (int bMuted) |
| Mute or unmute the channel. | |
| void | ApplyControlChange (StdMidiMsg *pMsg) |
| Act on one control-change message. | |
| void | SendPan () |
| Send the pan for the current section. | |
| Public Member Functions inherited from MsgSink | |
| void * | operator new (size_t nSize) |
| Allocate a sink from the tagged heap under the tag "MsgSink". | |
| void | operator delete (void *pBlock) |
| Release a sink to the tagged heap. | |
| virtual | ~MsgSink () |
| virtual void | Dispatch (Message *pMsg) |
| Accept a message. | |
Public Attributes | |
| MsgSink * | mOutput |
| The sink every message this mixer emits is sent to. | |
Protected Member Functions | |
| void | OnTrackSelect (TrackSelectMsg *pMsg) |
| React to a TrackSelectMsg. | |
| void | OnTracksOn (TracksOnMsg *pMsg) |
| React to a TracksOnMsg. | |
| void | RecomputeGain () |
| Recompute the gain from the game state and send it as gain factor 3. | |
| virtual void | DispatchPriv (Message *pMsg) |
| Act on a message. | |
Per-track MIDI mixer that sits between a track graph and the synthesiser.
Its RTTI descriptor is at 0x008f0770. It has MsgSink as its one base, and the inherited vptr sits at offset 0. The allocations in BGTrackGraph::CreateMixer() and ScoreTrackGraph's constructor both measure the object at 0x58 bytes. Its vtable is at 0x007df900 and runs four entries.
It is a MIDI filter on one channel. Every message it emits is a StdMidiMsg built on the stack and handed to mOutput, with the channel taken from mChannel. A StdMidiMsg arriving with a control-change status goes through ApplyControlChange().
SetGainFactor() is what fixes the four factors. It multiplies all four together and divides by 127 cubed, which normalises a product of four 7-bit values back into a 7-bit value, and sends that as controller 11. Four independent gains therefore scale one channel's expression.
The name comes from the RTTI descriptor.
| Mixer::Mixer | ( | int | nTrack, |
| unsigned char | nChannel ) |
Construct a mixer on one channel.
The routine reads mOwnsPan from configuration code 0x398, mBoostVolume from code 0x399, and mTrackLevels from code 0x39f, sets mLevel and all four gain factors to 127, mTracksOnBar to -1, and mSelection to NullPlayer::sInstance, and zeroes mZeroedBytes twice over. mEndBar takes PlayMap::GetEndBar() of Globals::GetPlayMap(). It does not write mOutput.
| nTrack | The track this mixer serves. BGTrackGraph passes -1, which matches no track. |
| nChannel | The MIDI channel every message it emits is sent on. |
|
virtual |
| void Mixer::SetGainFactor | ( | int | nIndex, |
| unsigned char | nFactor ) |
Set one of the four gain factors and send the combined level.
Recomputes the product of all four factors divided by 127 cubed. When the result differs from the level already sent, and the channel is not muted, it stores the result and sends it as controller 11 on mChannel.
The compiler emits its divide-by-zero check against the constant divisor, so the trap it guards can never fire.
| nIndex | Which factor, 0 through 3. |
| nFactor | The factor, 0 through 127. |
| void Mixer::SetMuted | ( | int | bMuted | ) |
Mute or unmute the channel.
A change to unmuted sends the level already computed as controller 11, and a change to muted sends zero. A call that does not change the flag sends nothing.
| bMuted | Non-zero to mute. |
| void Mixer::ApplyControlChange | ( | StdMidiMsg * | pMsg | ) |
Act on one control-change message.
A 41-entry jump table over controller numbers 0x0a through 0x32 decides what happens. Controllers 0x2f through 0x32 set gain factors 0 through 3, controller 0x2e drives SetMuted(), controller 0x0b is discarded because the mixer sends its own expression, controller 0x0a is discarded while mOwnsPan is set and forwarded otherwise, and everything else including a controller outside the table's range is forwarded to mOutput unchanged.
The member is inline. DispatchPriv() has its own emission of the whole body with its own copy of the jump table, which is why two addresses exist for one member.
| pMsg | The control-change message. |
| void Mixer::SendPan | ( | ) |
Send the pan for the current section.
Derives a three-bit index from mTrack less mLastSection and maps it through a six-entry jump table to one of 0, 0, 0x20, 0x40, 0x60, and 0x7f, which it sends as controller 10. An index the table does not reach sends zero.
|
protected |
React to a TrackSelectMsg.
A message for mTrack installs its player as mSelection and recomputes the gain. Then, for any track, a selection whose Player::GetInputSlot() reports zero takes the message's track as mLastSection and, when mOwnsPan is set, sends the pan.
| pMsg | The TrackSelectMsg. |
|
protected |
React to a TracksOnMsg.
Stores the message's bar in mTracksOnBar and its track count in mLevelIndex, and recomputes the gain.
| pMsg | The TracksOnMsg. |
|
protected |
Recompute the gain from the game state and send it as gain factor 3.
While GameStats::mCompleted is set the factor is 115. Otherwise a real mSelection gets 127, and the stand-in gets 127 less the low byte of mTrackLevels[mLevelIndex].
Inline. OnTrackSelect() and OnTracksOn() expand it, and the image keeps this out-of-line copy.
|
protectedvirtual |
Act on a message.
Table slot 3.
| pMsg | The message. |
Implements MsgSink.
| MsgSink* Mixer::mOutput |
The sink every message this mixer emits is sent to.
The constructor does not write it. Public because BGTrackGraph::AttachMixerToSynth() stores it directly at 0x001404c4, and the image has no accessor. +0x04