ScummVM API documentation
Gob::AdLib Class Referenceabstract

#include <adlib.h>

Inheritance diagram for Gob::AdLib:
Gob::ADLPlayer Gob::MUSPlayer

Public Member Functions

 AdLib (int callbackFrequency)
 
bool isPlaying () const
 Are we currently playing?
 
int32 getRepeating () const
 Return number of times left to loop.
 
void setRepeating (int32 repCount)
 
void startPlay ()
 
void stopPlay ()
 
void syncVolume ()
 

Protected Types

enum  kVoice {
  kVoiceMelody0 = 0, kVoiceMelody1 = 1, kVoiceMelody2 = 2, kVoiceMelody3 = 3,
  kVoiceMelody4 = 4, kVoiceMelody5 = 5, kVoiceMelody6 = 6, kVoiceMelody7 = 7,
  kVoiceMelody8 = 8, kVoiceBaseDrum = 6, kVoiceSnareDrum = 7, kVoiceTom = 8,
  kVoiceCymbal = 9, kVoiceHihat = 10
}
 
enum  kParam {
  kParamKeyScaleLevel = 0, kParamFreqMulti = 1, kParamFeedback = 2, kParamAttack = 3,
  kParamSustain = 4, kParamSustaining = 5, kParamDecay = 6, kParamRelease = 7,
  kParamLevel = 8, kParamAM = 9, kParamVib = 10, kParamKeyScaleRate = 11,
  kParamFM = 12, kParamWaveSelect = 13
}
 

Protected Member Functions

void writeOPL (byte reg, byte val)
 
void end (bool killRepeat=false)
 
virtual uint32 pollMusic (bool first)=0
 
virtual void rewind ()=0
 
bool isPercussionMode () const
 
void setPercussionMode (bool percussion)
 
void enableWaveSelect (bool enable)
 
void setPitchRange (uint8 range)
 
void setTremoloDepth (bool tremoloDepth)
 
void setVibratoDepth (bool vibratoDepth)
 
void setKeySplit (bool keySplit)
 
void setVoiceTimbre (uint8 voice, const uint16 *params)
 
void setVoiceVolume (uint8 voice, uint8 volume)
 
void bendVoicePitch (uint8 voice, uint16 pitchBend)
 
void noteOn (uint8 voice, uint8 note)
 
void noteOff (uint8 voice)
 
void setTimerFrequency (int timerFrequency)
 

Static Protected Attributes

static const int kOperatorCount = 18
 Number of operators.
 
static const int kParamCount = 14
 Number of operator parameters.
 
static const int kPitchStepCount = 25
 Number of pitch bend steps in a half tone.
 
static const int kOctaveCount = 8
 Number of octaves we can play.
 
static const int kHalfToneCount = 12
 Number of half tones in an octave.
 
static const int kOperatorsPerVoice = 2
 Number of operators per voice.
 
static const int kMelodyVoiceCount = 9
 Number of melody voices.
 
static const int kPercussionVoiceCount = 5
 Number of percussion voices.
 
static const int kMaxVoiceCount = 11
 Max number of voices.
 
static const int kNoteCount = kHalfToneCount * kOctaveCount
 
static const int kMaxVolume = 0x007F
 
static const int kMaxPitch = 0x3FFF
 
static const int kMidPitch = 0x2000
 
static const int kStandardMidC = 60
 A mid C in standard MIDI.
 
static const int kOPLMidC = 48
 A mid C for the OPL.
 

Detailed Description

Base class for a player of an AdLib music format.

Member Enumeration Documentation

◆ kParam

enum Gob::AdLib::kParam
protected

Operator parameters.

Member Function Documentation

◆ setRepeating()

void Gob::AdLib::setRepeating ( int32  repCount)

Set the loop counter.

Parameters
repCountNumber of times to loop (i.e. number of additional paythroughs to the first one, not overall). A negative value means infinite looping.

◆ writeOPL()

void Gob::AdLib::writeOPL ( byte  reg,
byte  val 
)
protected

Write a value into an OPL register.

◆ end()

void Gob::AdLib::end ( bool  killRepeat = false)
protected

Signal that the playback ended.

Parameters
killRepeatExplicitly request that the song is not to be looped.

◆ pollMusic()

virtual uint32 Gob::AdLib::pollMusic ( bool  first)
protectedpure virtual

The callback function that's called for polling more AdLib commands.

Parameters
firstIs this the first poll since the start of the song?
Returns
The number of ticks until the next poll.

Implemented in Gob::MUSPlayer, and Gob::ADLPlayer.

◆ rewind()

virtual void Gob::AdLib::rewind ( )
protectedpure virtual

Rewind the song.

Implemented in Gob::MUSPlayer, and Gob::ADLPlayer.

◆ isPercussionMode()

bool Gob::AdLib::isPercussionMode ( ) const
protected

Return whether we're in percussion mode.

◆ setPercussionMode()

void Gob::AdLib::setPercussionMode ( bool  percussion)
protected

Set percussion or melody mode.

◆ enableWaveSelect()

void Gob::AdLib::enableWaveSelect ( bool  enable)
protected

Enable/Disable the wave select operator parameters.

When disabled, all operators use the sine wave, regardless of the parameter.

◆ setPitchRange()

void Gob::AdLib::setPitchRange ( uint8  range)
protected

Change the pitch bend range.

Parameters
rangeThe range in half tones from 1 to 12 inclusive. See bendVoicePitch() for how this works in practice.

◆ setTremoloDepth()

void Gob::AdLib::setTremoloDepth ( bool  tremoloDepth)
protected

Set the tremolo (amplitude vibrato) depth.

Parameters
tremoloDepthfalse: 1.0dB, true: 4.8dB.

◆ setVibratoDepth()

void Gob::AdLib::setVibratoDepth ( bool  vibratoDepth)
protected

Set the frequency vibrato depth.

Parameters
vibratoDepthfalse: 7 cent, true: 14 cent. 1 cent = 1/100 half tone.

◆ setKeySplit()

void Gob::AdLib::setKeySplit ( bool  keySplit)
protected

Set the keyboard split point.

◆ setVoiceTimbre()

void Gob::AdLib::setVoiceTimbre ( uint8  voice,
const uint16 *  params 
)
protected

Set the timbre of a voice.

Layout of the operator parameters is as follows:

  • First 13 parameter for the first operator
  • First 13 parameter for the second operator
  • 14th parameter (wave select) for the first operator
  • 14th parameter (wave select) for the second operator

◆ setVoiceVolume()

void Gob::AdLib::setVoiceVolume ( uint8  voice,
uint8  volume 
)
protected

Set a voice's volume.

◆ bendVoicePitch()

void Gob::AdLib::bendVoicePitch ( uint8  voice,
uint16  pitchBend 
)
protected

Bend a voice's pitch.

The pitchBend parameter is a value between 0 (full down) and kMaxPitch (full up). The actual frequency depends on the pitch range set previously by setPitchRange(), with full down being -range half tones and full up range half tones.

◆ noteOn()

void Gob::AdLib::noteOn ( uint8  voice,
uint8  note 
)
protected

Switch a voice on.

Plays one of the kNoteCount notes. However, the valid range of a note is between 0 and 127, of which only 12 to 107 are audible.

◆ noteOff()

void Gob::AdLib::noteOff ( uint8  voice)
protected

Switch a voice off.

◆ setTimerFrequency()

void Gob::AdLib::setTimerFrequency ( int  timerFrequency)
protected

Set the OPL timer frequency

Member Data Documentation

◆ kNoteCount

const int Gob::AdLib::kNoteCount = kHalfToneCount * kOctaveCount
staticprotected

Number of notes we can play.


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