API Reference Register getters and setters - DhrBaksteen/ArduinoOPL2 GitHub Wiki

getAttack

byte OPL2::getAttack(byte channel, byte operatorNum);

Get the attck rate of the given channel and operator. The higher the value the faster the attack.

  • When set to 0 the sound will never attack
  • When set to 15 the sound will immediately be at maximum level
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to set attack rate: OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte The attack rate of the operator [0, 15]

OPL Registers

Reads register based at 0x60, bit 4 through 7

See also

setAttack, getDecay, getSustain, getRelease

setAttack

void OPL2::setAttack(byte channel, byte operatorNum, byte attack);

Set the attack rate of a channel operator. This defines the time it takes for the operator's output level to rise from 0 to maximum. The attack portion of the envelope is triggered when keyOn of a channel is set to true. The higher the value the faster the attack.

  • When set to 0 the sound will never attack
  • When set to 15 the sound will immediately be at maximum level
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to set attack rate OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte attack - Attack rate [0, 15] where 0 is slowest and 15 is quickest.
OPL2 Registers

This function alters bit 7-4 of the register at base address 0x60.

See also

getAttack, setDecay, setSustain, setRelease, setKeyOn

getBlock

byte OPL2::getBlock(byte channel);

Get the current frequency block for the given channel. The frequency block determines the frequency range of the F-numbers. This is sometimes interpreted as the current octave.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
Returns

byte - The current frequency block of the channel

Block F-num = 1 F-num = 1023
0 0.047 Hz 45.503 Hz
1 0.094 Hz 97.006 Hz
2 0.189 Hz 194.013 Hz
3 0.379 Hz 388.026 Hz
4 0.758 Hz 776.053 Hz
5 1.517 Hz 1,552.107 Hz
6 3.034 Hz 3,104.215 Hz
7 6.068 Hz 6,208.431 Hz
OPL Registers

Reads register based at 0xB0, bits 2 through 4

See also

setBlock, getFrequencyBlock, getFNumber, getFrequency, getFrequencyStep

setBlock

void OPL2::byte setBlock(byte channel, byte block);

Set the frequency block for the given channel. The frequency block determines the frequency range of the F-numbers. The interval between two F-numbers is the same as the frequency of F-num = 1 in the table below.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte block - Frequency block [0, 7]
Block F-num = 1 F-num = 1023
0 0.047 Hz 45.503 Hz
1 0.094 Hz 97.006 Hz
2 0.189 Hz 194.013 Hz
3 0.379 Hz 388.026 Hz
4 0.758 Hz 776.053 Hz
5 1.517 Hz 1,552.107 Hz
6 3.034 Hz 3,104.215 Hz
7 6.068 Hz 6,208.431 Hz
OPL2 Registers

This function alters bits 2 through 4 of the register at base address 0xB0

See also

getBlock, getFrequencyStep, setFNumber, setFrequency, playNote

getDecay

byte OPL2::getDecay(byte channel, byte operatorNum);

Get the decay rate of the given channel and operator. The higher the value the quicker the decay to sustain level will be.

  • When set to 0 the sound will never decay to sustain level, but remain at maximum output level
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to get decay rate of: OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte The decay rate of the operator [0, 15]

OPL Registers

Reads register based at 0x60, bits 0 through 3

See also

setDecay, getAttack, getSustain, getRelease

setDecay

void OPL2::setDecay(byte channel, byte operatorNum, byte decay);

Set the decay rate of the channel operator. This defines the time it takes for the operator's output level to drop from maximum to sustain level. The decay portion of the envelope is triggered immediately after attack. The higher the value the quicker the decay to sustain level will be.

  • When set to 0 the sound will never decay to sustain level, but remain at maximum output level
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to set the decay rate OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte decay - Decay rate [0, 15] where 0 is slowest and 15 is quickest

OPL Registers

This function alters bits 0 through 3 of register at base address 0x60.

See also

getDecaysetAttack, setSustain, setRelease

getDeepTremolo

bool OPL2::getDeepTremolo();

Returns whether deep tremolo is enabled. This is a chip-wide setting that applies to all operators.

  • When disabled (default) tremolo depth is 1.0 dB
  • when deep tremolo is enabled all tremolos have a depth of 4.8 dB
Returns

bool If true then deep tremolo applies for all operators

OPL Registers

Reads register 0xBD, bit 7

See also

setDeepTremolo, getTremolo, getDeepVibrato

setDeepTremolo

void OPL2::byte setDeepTremolo(bool enable);

This setting enables deeper tremolos. Normally tremolos will make the channel's output level vibrate with a 1.0dB depth, but when this setting is enabled tremolos wil have a 4.8dB depth. This is a chip-wide setting, meaning that it will affect all channels. By default this setting is disabled.

Arguments
  • bool enable - Enables deeper tremolos when true
OPL Registers

Alters register 0xBD, bit 7.

See also

getDeepTremolo, getTremolo, setTremolo

getDeepVibrato

bool OPL2::getDeepVibrato();

Returns whether deep vibrato is enabled. This is a chip-wide setting that applies to all operators.

  • When disabled (default) vibrato will be 7/100 semi-tones
  • When enabled it will be doubled to 14/100 semi-tones
Returns

bool When true then deep vibrato is enabled for all operators

OPL Registers

Reads register 0xBD, bit 6

See also

setDeepVibrato, getVibrato, getDeepTremolo

setDeepVibrato

void OPL2::byte setDeepVibrato(bool enable);

This setting enables deeper vibratos. By default this setting is disabled.

  • When disabled (default) vibrato will be 7/100 semi-tones
  • When enabled it will be doubled to 14/100 semi-tones
Arguments
  • bool enable - Enables deeper vibratos when true
OPL Registers

Alters register 0xBD, bit 6.

See also

getDeepVibrato, getVibrato, setVibrato

getDrums

byte OPL2::getDrums();

Returns a value where each bit indicates what drum sound is currently active. In order to play drum sounds the OPL2 must be set into percussive mode first using setPercussive.

Returns

byte A value that indicates what drum sounds are currently playing:

Bit Drum Sound Bit mask Library Definition
0 Hi-hat 0x01 DRUM_HI_HAT
1 Cymbal 0x02 DRUM_CYMBAL
2 Tom tom 0x04 DRUM_TOM
3 Snare drum 0x08 DRUM_SNARE
4 Bass drum 0x10 DRUM_BASS
OPL Registers

Reads from register 0xBD, bits 0 through 4

See also

setDrums, getPercussive

setDrums

void OPL2::byte setDrums(bool bass, bool snare, bool tom, bool cymbal, bool hihat);

Plays various drum sounds. In order to play a drumsound the OPL2 must be placed in percussive mode using setPercussion(true). This function works the same as setKeyOn. To play a drum sound the respective parameter must be set to true and disabled first by setting it to false before the same drum sound can be triggered again.

Arguments
  • bool bass - Plays a bass drum sound
  • bool snare - Plays a snare drum sound
  • bool tom - Plays a tom tom drum sound
  • bool cymbal - Plays a cymbal sound
  • bool hihat - Plays a hi-hat sound
OPL Registers

Alters register 0xBD by setting bits 0 through 4 depending on what drum sounds are enabled or disabled

See also

getDrums, setPercussion

getEnvelopeScaling

bool OPL2::getEnvelopeScaling(byte channel, byte operatorNum);

Returns wheter envelope scaling (KSR) is enabled. When enabled the duration of the envelope will be shorter as the frequency of the operator increases. By default envelope scaling will be disabled.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to get KSR: OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

bool If true then envelope scaling is enabled

OPL Registers

Reads from register based at 0x20, bit 4

See also

setEnvelopeScaling

setEnvelopeScaling

void OPL2::setEnvelopeScaling(byte channel, byte operatorNum, bool enable);

When enabled scale the duration of the envelope as the frequency rises. By default envelope scaling is disabled.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to set envelope scaline OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • bool enable - Enabled envelope scaling when set to true
OPL2 Registers

This function alters bit 4 of register at base address 0x20.

See also

getEnvelopeScaling

getFeedback

byte OPL2::getFeedback(byte channel);

Get the feedback modulation factor for the given channel. When set to a value greater than 0 then operator 1 will send part of its otput back into itself.

Arguments
  • byte channel - Index of the channel for which to get feedback factor [0, MAX_CHANNEL]
Returns

byte Feedback modulation factor of the given channel

Feedback Factor
0 0, No feedback
1 π/16
2 π/8
3 π/4
4 π/2
5 π
6
7
OPL Registers

Reads from register based at 0xC0, bits 1 through 3

See also

setFeedback

setFeedback

void OPL2::byte setFeedback(byte channel, byte feedback);

Set the feedback modulation factor of the given channel. This causes operator 1 to send a portion of its output back into itself when enabled. By default operator feedback is disabled.

Arguments
  • byte channel - The channel to set feedback factor
  • byte feedback - Feedback modulation factor [0, 7]
Feedback Factor
0 0, No feedback
1 π/16
2 π/8
3 π/4
4 π/2
5 π
6
7
OPL Registers

This function alters bits 1 through 3 of register with base address 0xC0

See also

getFeedback

getFNumber

short OPL2::getFNumber(byte channel);

Get the frequency number for the given channel. The actual frequency of the channel depends on the frequency block set using the setBlock function. When the F-number of a channel is set to 0 then its output frequency will always be 0 Hz, regardless of the block.

Arguments
  • byte channel - Index of the channel for which to get the F-number [0, MAX_CHANNEL]
Returns

short The frequency number [0, 1023]

OPL Registers

Reads from register based at 0xB0, bits 0 and 1 for the hi bits of the F-number and register based at 0xA0 for the lower 8 bits

See also

setFNumber, getFrequency, getBlock, getFrequencyBlock

setFNumber

void OPL2::setFNumber(byte channel, short fNumber);

Sets the frequency number for the given channel. The actual frequency of the channel depends on the frequency block set using the setBlock function. When the F-number of a channel is set to 0 then its output frequency will always be 0 Hz, regardless of the block.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • short fNumber - The frequency number [0, 1023]
OPL Registers

This function sets the lower byte of the F-number to register at base address 0xA0 and the upper two bits to bits 0 and 1 of register at base address 0xB0

See also

getFNumber, setBlock

getKeyOn

bool OPL2::getKeyOn(byte channel);

Returns whether the channel is currently generating a sound.

Arguments
  • byte channel - Index of the channel for which to get key on [0, MAX_CHANNEL]
Returns

bool If true then the channel is generating sound, if false then the channel is in the release portion of its envelope or silent

OPL Registers

Reads from register based at 0xB0, bit 5

See also

setKeyOn

setKeyOn

void OPL2::setKeyOn(byte channel, bool keyOn);

Enable or disable audio output on a given channel. When a channel is enabled the attack portion of the channel envelope is triggered and the channel starts to output a tone at the set frequency that rises in volume according to the set attack rate. When disabled the release portion of the envelope is triggered that makes the note fade out at the set release rate until the channel is silent.

  • Note that when percussion mode is enabled keyOn of channels 6, 7 and 8 must remain false as drum sounds are triggered differently.
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • bool keyOn - Boolean value that enables audio output on the given channel when true
OPL Registers

This function sets or clears bit 5 of register at base 0xB0.

See also

getKeyOn, setDrums

getMaintainSustain

bool OPL2::getMaintainSustain(byte channel, byte operatorNum);

Returns whether sustain is enabled on the given channel and operator.

  • If sustain is enabled then setSustain can be used to define a sustain level of an operator. The operator will remain at sustain level until the key is set to off with setKeyOn (false)
  • If disabled (default) then the operator will immediately jump to the release portion of its envelope after the decay period
Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to get wheter sustain is enabled: OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

bool If true then sustain is enabled on the operator

OPL Registers

Reads from register based at 0x20, bit 5

See also

setMaintainSustain, setSustain, setKeyOn

setMaintainSustain

void OPL2::setMaintainSustain(byte channel, byte operatorNum, bool enable);

Alters whether the operator's envelope should maintain sustain level. When enabled the operator will hold the output at sustain level until the release phase of the envelope is triggered by disabling output with setKeyOn(false). If disabled the release phase of the envelope will trigger immediately after the decay phase. Note that setKeyOn must still be disabled before triggering the next note in this case. By default sustain will be disabled.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to enable or disable sustain OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • bool enable - Enables sustain for the given operator when true
OPL Registers

This function alters bit 5 of register at base address 0x20.

See also

getMaintainSustain, setSustain

getMultiplier

byte OPL2::getMultiplier(byte channel, byte operatorNum);

Get the frequency multiplication factor of the given channel and operator. The multiplication factor will be equal to the value set, except when set to 0 (default) when then multiplication factor will be 0.5. The F-number is multiplied by this multiplication factor to get the eventual frequency number.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get frequency multiplication rate OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte The F-number multiplication factor [0, 15]

OPL Registers

Reads from register based at 0x20, bits 0 through 3

See also

setMultiplier, setFNumber

setMultiplier

void OPL2::setMultiplier(byte channel, byte operatorNum, byte multiplier);

Set the frequency multiplication factor for the given operator.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to set the multiplier OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte multiplier - The multiplier to set for the operator [0, 15]. A value of 0 multiplies the frequency by 0.5
OPL Registers

This function alters bits 0 through 3 of register at abse address 0x20

See also

getMultiplier

getPercussion

bool OPL2::getPercussion();

Returns whether percussion mode is currently enabled or not. When enabled setDrums can be used to play various drum sounds, but the number of available channels will drop from 9 to 6 as the OPL2 requires 6 operators to produce the drum sounds. By default percussion mode is disabled.

Returns

bool When true then the OPL2 is in percussive mode, if false then the OPL2 is in melodic mode

OPL Registers

Reads from register 0xBD, bit 5

See also

setPercussion, setDrums

setPercussion

void OPL2::byte setPercussion(bool enable);

Set whether percussion mode is enabled or not. When enabled setDrums can be used to play various drum sounds, but the number of available channels will drop from 9 to 6 as the OPL2 requires 6 operators to produce the drum sounds. By default percussion mode is disabled.

Arguments
  • bool enable - Enables percussion mode when true
OPL Registers

This function alters bit 5 of register 0xBD

See also

getPercussion, setDrums

getRelease

byte OPL2::getRelease(byte channel, byte operatorNum);

Get the release rate of the given channel and operator. The higher the value the quicker the release.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get the release rate OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte The release rate of the operator [0, 15]

OPL Registers

Reads from register based at 0x80, bits 0 through 3

See also:

setRelease, setAttack, getDecay, getSustain

setRelease

void OPL2::setRelease(byte channel, byte operatorNum, byte release);

Set the release rate of the given channel and operator. The higher the value the quicker the release.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get the release rate OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • release - The release rate for the operator [0, 15]
OPL Registers

Writes to register based at 0x80, bits 0 through 3

See also:

getRelease, setAttack, setDecay, setSustain

getScalingLevel

byte OPL2::getScalingLevel(byte channel, byte operatorNum);

Get the key scale level of the given channel and operator. This determines the attenuation of the output level as the frequency of an operator increases.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get key scale level OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte Key scaling level of the given operator [0, 3]

Value Attenuation
0 -
1 3.0 dB / Octave
2 1.5 dB / Octave
3 6.0 dB / Octave
OPL Registers

Reads from register based at 0x40, bits 6 and 7

See also

setScalingLevel

setScalingLevel

void OPL2::setScalingLevel(byte channel, byte operatorNum, byte scaling);

Set the key scale level of the given channel and operator. This determines the attenuation of the output level as the frequency of the operator increases.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get key scale level OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • scaling - The key scale factor for the operator
Value Attenuation
0 -
1 3.0 dB / Octave
2 1.5 dB / Octave
3 6.0 dB / Octave
OPL Registers

Writes to register based at 0x40, bits 6 and 7

See also

getScalingLevel

getSustain

byte OPL2::getSustain(byte channel, byte operatorNum);

Get the sustain level of the given channel and operator. The lower the sustain value the louder the sound. Note that in order for the OPL2 to apply a sustain the sustain bit of the operator must be set using setMaintainSustain, oterwise sustain will not be applied and the envelope will continue with its release portion immediately after the decay period.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get sustain level OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte - The sustain level of the operator [0, 15]

OPL Registers

Reads from register based at 0x80, bits 4 through 7

See also

setSustain, getMaintainSustain, setAttack, getDecay, getRelease

setSustain

void OPL2::getSustain(byte channel, byte operatorNum, byte sustain);

Set the sustain level of the given channel and operator. The lower the sustain value the louder the sound. Note that in order for the OPL2 to apply a sustain the sustain bit of the operator must be set using setMaintainSustain, oterwise sustain will not be applied and the envelope will continue with its release portion immediately after the decay period.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get sustain level OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • sustain - The sustain value [0, 15] for the operator
OPL Registers

Reads from register based at 0x80, bits 4 through 7

See also

getSustain, setMaintainSustain, setAttack, setDecay, setRelease

getSynthMode

byte OPL2::getSynthMode(byte channel);

Returns whether the given channel is using additive synth (AM) of frequency modulation (FM). By default each channel will operate in FM-synthesis mode.

  • When a channel is put into additive synth mode the output of the two operators is added together
  • In FM-synthesis mode only operator 2 will produce sound, but operator 1, the modulator, will be sent to the input of operator 2, the carrier, to modulate the frequency of operator 2
Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
Returns

byte Where 0 or SYNTH_MODE_FM for FM and 1 or SYNTH_MODE_AM for AM

OPL Registers

Reads from register based at 0xC0, bit 0

See also

setSynthMode

setSynthMode

void OPL2::setSynthMode(byte channel, byte synthMode);

Set whether the given channel is using additive synth (AM) of frequency modulation (FM). By default each channel will operate in FM-synthesis mode.

  • When a channel is put into additive synth mode the output of the two operators is added together
  • In FM-synthesis mode only operator 2 will produce sound, but operator 1, the modulator, will be sent to the input of operator 2, the carrier, to modulate the frequency of operator 2
Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • synthMode - Synth mode for the given channel [0, 1] or {SYNTH_MODE_FM, SYNTH_MODE_AM} respectively
OPL Registers

Alters register based at 0xC0, bit 0

See also

getSynthMode

getTremolo

bool OPL2::getTremolo(byte channel, byte operatorNum);

Returns whether tremolo is enabled on the given channel and operator. When enabled tremolo causes the operator's amplitude to vibrate. By default this setting is disabled. When enabled normally this will cause the output level to fluctuate by 1.0 dB, but when deep tremolo is enabled by setDeepTremolo(true) then tremolos on all channels will be 4.8 dB.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get whether tremolo is enabled OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

bool If true then tremolo is enabled

OPL Registers

Reads from register based at 0x20, bit 7

See also

setTremolo, getDeepTremolo, getVibrato

setTremolo

void OPL2::setTremolo(byte channel, byte operatorNum, bool enable);

Apply amplitude modulation to a certain channel operator, causing a tremolo effect. The depth of the tremolo can either be 1 dB, or 4.8 dB. This is controlled by setDeepTremolo which is common to all operators. By default tremolo is disabled.

Arguments
  • byte channel - Index of the channel [0, 8]
  • byte operatorNum - The operator for which to set tremolo OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • bool enable - Enables tremolo for the given operator when true
OPL Registers

This function alters bit 7 of registers at base address 0x20

See also

getTremolo, getDeepTremolo, setVibrato

getVibrato

bool OPL2::getVibrato(byte channel, byte operatorNum);

Returns whether vibrato is enabled on the given channel and operator. Vibrato causes the frequency of an operator to fluctuate. By default this setting is disabled. When enabled, normally the frequency will vibrate by 7/100 of a semi-tone. When deep vibrato is enabled by setDeepVibrato(true) then vibrato on all channels will be 14/100 of a semi-tone.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get whether vibrato is enabled OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

bool If true then vibrato is enabled

OPL Registers

Reads from register based at 0x20, bit 6

See also

setVibrato, getDeepVibrato, getTremolo

setVibrato

byte OPL2::setVibrato(byte channel, byte operatorNum, bool enable);

Sets whether vibrato is enabled on the given channel and operator. Vibrato causes the frequency of an operator to fluctuate. By default this setting is disabled. When enabled, normally the frequency will vibrate by 7/100 of a semi-tone. When deep vibrato is enabled by setDeepVibrato(true) then vibrato on all channels will be 14/100 of a semi-tone.

Arguments
  • byte channel - Index of the channe; [0, 8]
  • byte operatorNum - The operator for which to set vibrato OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte enable - Enables vibrato for the given operator when true
OPL2 Registers

This function alters bit 6 of registers at base address 0x20

See also

getVibrato, setDeepVibrato, setTremolo

getVolume

byte OPL2::getVolume(byte channel, byte operatorNum);

Get the volume of the given channel and operator. For the volume; the lower the value, the greater the volume.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get the output level OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte - The volume of the given operator [0, 63]. The lower the value, the louder the volume.

OPL Registers

Reads from register based at 0x40, bits 0 through 5

See also

setVolume, getScalingLevel

setVolume

void OPL2::setVolume(byte channel, byte operatorNum, byte volume);

Set the output level of a channel's operator. The lower the value, the higher the output level.

Arguments
  • byte channel - Index of the channel [0, 8]
  • byte operatorNum - Operator to change volume OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte volume - Volume to set [0, 63] where 0 is loudest, 63 is silent
OPL Registers

This function alters bits 0 through 5 of register at base 0x40

See also

getVolume, setScalingLevel

getWaveForm

byte OPL2::getWaveForm(byte channel, byte operatorNum);

Return the currently selected waveform for the given channel and operator. Note that the waveform select bit must be enabled on the OPL2 using setWaveFormSelect to allow for different waveforms per operator, otherwise all channels will use a sine wave.

Arguments
  • channel - Index of the channel [0, MAX_CHANNEL]
  • operatorNum - The operator for which to get the current wave form OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
Returns

byte The currently selected wave form for the operator

Value Waveform
0
1
2
3
OPL Registers

Reads from register based at 0xE0, bits 0 through 2

See also

setWaveForm, getWaveFormSelect

setWaveForm

void OPL2::setWaveForm(byte channel, byte operatorNum, byte waveForm);

Select the waveform to use for a certain channel operator. To take effect waveform selection must be enabled with setWaveFormSelect(true) first. By default each operator will use a sinewave.

Arguments
  • byte channel - Index of the channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator for which to change the waveform OPERATOR1 / MODULATOR or OPERATOR2 / CARRIER
  • byte waveForm - The wavefor to set for the operator [0, 3]
Value Waveform
0
1
2
3
OPL Registers

This function alters bits 0 through 2 of register at base address 0xE0

See also

getWaveForm, setWaveFormSelect

getWaveFormSelect

bool OPL2::getWaveFormSelect();

Returns whether waveform selection is enabled on the OPL2. If true then setWaveForm can be used to select different waveforms per operator. If false then all operators will use a sinewave. By default this will be set to false.

Returns

bool When true then different wave forms can be set per channel operator

OPL Registers

Reads from register 0x01, bit 5

See also

setWaveFormSelect, getWaveForm

setWaveFormSelect

void OPL2::setWaveFormSelect(bool enable);

Enable or disable waveform selection for each individual channel operator. If disabled then all operators will output a basic sine wave. By default wave form selection is disabled.

Arguments
  • bool enable - Enables wave form selection on all operators when set to true
OPL2 Reference

This function alters bit 5 of register 0x01

See also

getWaveFormSelect, setWaveForm

⚠️ **GitHub.com Fallback** ⚠️