API Reference Low level access - DhrBaksteen/ArduinoOPL2 GitHub Wiki

write

void OPL2::write(byte reg, byte data);

Write the a value to the given OPL register. Bare in mind that when write it called directly it will not update the shadow registers. You cannot rely on the getters and setters of the OPL2 library if you use this function directly.

Arguments
  • byte reg - The OPL register to write to
  • byte data - The value to write to the register

getChipRegister

byte OPL2::getChipRegister(short reg);

Get the value of a chip-wide register from the shadow registers.

Arguments
  • byte reg - The chip-wide register to read {0x01, 0x08, 0xBD}
Returns

byte The value stored in the given register. If reg is out of range then the value of register 0x01 is returned

setChipRegister

void OPL2::setChipRegister(short reg, byte value);

Set the value of a chip-wide register in the shadow registers and write it to the chip.

Arguments
  • byte reg - The chip-wide register to alter {0x01, 0x08, 0xBD}

If reg is not one of the chip-wide registers then the value will be written to 0x01.

getChipRegisterOffset

byte OPL2::getChipRegisterOffset(short reg);

Get the offset of the chip-wide register within the shadow register array.

Arguments

  • byte reg - The chip-wide register {0x01, 0x08, 0xBD}
Returns

byte The offset to the chip-wide register in the array of shadow registers. If reg is not a chip-wide register then 0 will be returned

getChannelRegister

byte OPL2::getChannelRegister(byte baseRegister, byte channel);

Get the value of a channel register using the given base register from shadow registers.

Arguments
  • byte baseRegister - The base register {0xA0, 0xB0, 0xC0}
  • byte channel - The channel [0, MAX_CHANNEL]

If the given baseRegister is not a channel register then baseRegister will be 0xA0. If the given channel is out of range then channel will be channel % getNumChannels().

Returns

byte The value stored at the channel register

setChannelRegister

void OPL2::setChannelRegister(byte baseRegister, byte channel, byte value);

Set the value of a channel register in shadow registers and write it to the chip.

Arguments
  • byte baseRegister - The base register {0xA0, 0xB0, 0xC0}
  • byte channel - The channel [0, MAX_CHANNEL]

If the given baseRegister is not a channel register then baseRegister will be 0xA0. If the given channel is out of range then channel will be channel % getNumChannels().

getChannelRegisterOffset

byte OPL2::getChannelRegisterOffset(byte baseRegister, byte channel);

Get the offset to the requested channel register within the shadow register array.

Arguments
  • byte baseRegister - The base register {0xA0, 0xB0, 0xC0}
  • byte channel - The channel [0, MAX_CHANNEL]

If the given baseRegister is not a channel register then baseRegister will be 0xA0. If the given channel is out of range then channel will be channel % getNumChannels().

Returns

byte The offset to the channel register within the shadow register array

getOperatorRegister

byte OPL2::getOperatorRegister(byte baseRegister, byte channel, byte op);

Get the value of an operator register from the shadow registers.

Arguments
  • byte baseRegister - The base register {0x20, 0x40, 0x60, 0x80, 0xE0}
  • byte channel - The channel [0, MAX_CHANNEL]
  • byte op - The operator [0, 1] or {OPERATOR1, OPERATOR2, MODULATOR, CARRIER}

If the given baseRegister is not a channel register then baseRegister will be 0x20. If the given channel is out of range then channel will be channel % getNumChannels(). If then given op is out of range then op will be op % 2.

Returns

byte The value stored at the requested operator register from shadow registers

setOperatorRegister

void OPL2::setOperatorRegister(byte baseRegister, byte channel, byte op, byte value);

Set the value for the given operator register in the shadow registers and write it to the chip.

Arguments
  • byte baseRegister - The base register {0x20, 0x40, 0x60, 0x80, 0xE0}
  • byte channel - The channel [0, MAX_CHANNEL]
  • byte op - The operator [0, 1] or {OPERATOR1, OPERATOR2, MODULATOR, CARRIER}
  • byte value - The value to set the operator register to

If the given baseRegister is not a channel register then baseRegister will be 0x20. If the given channel is out of range then channel will be channel % getNumChannels(). If then given op is out of range then op will be op % 2.

getOperatorRegisterOffset

short getOperatorRegisterOffset(byte baseRegister, byte channel, byte operatorNum);

Get the offset of the given operator register within the shadow registers array.

Arguments
  • byte baseRegister - The base register {0x20, 0x40, 0x60, 0x80, 0xE0}
  • byte channel - The channel [0, MAX_CHANNEL]
  • byte op - The operator [0, 1] or {OPERATOR1, OPERATOR2, MODULATOR, CARRIER}

If the given baseRegister is not a channel register then baseRegister will be 0x20. If the given channel is out of range then channel will be channel % getNumChannels(). If then given op is out of range then op will be op % 2.

Returns

short The offset to requested operator register within the shadow registers array

getRegisterOffset

byte getRegisterOffset(byte channel, byte operatorNum);

Get the offset to the operator register on the chip for a given channel operator.

Arguments
  • byte channel - The channel [0, MAX_CHANNEL]
  • byte operatorNum - The operator [0, 1] or {OPERATOR1, OPERATOR2, MODULATOR, CARRIER}

If the given channel is out of range then channel will be channel % getNumChannels(). If then given operatorNum is out of range then operatorNum will be operatorNum % 2.

Returns

byte The operator register offset for the given channel

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