Programmer's Guide to Yamaha YMF 262/OPL3 FM Music Synthesizer

Programmer's Guide to

Yamaha YMF 262/OPL3 FM Music Synthesizer

Version 1.00 Nov-24-1994

Written by Vladimir Arnost, QA-Software

HTML Design by Ruslan Gustokashin, LHS Network


This manual can be distributed freely if not modified.

DISCLAIMER: I assume no responsibility for any damages arising out of use or inability to use this text. No warranty is provided about correctness of any information in this file. You are on your own.


The chip I am going to describe is getting more and more common, but programming information is still scarce, so I have decided to fill in this gap. All information contained in this file is a result of my experience in Adlib programming, research (read: reverse engineering) and finally of my effort to write down everything necessary to understand and use this piece of hardware. No official sources (i.e. development kits, books about this topic, etc.) were available to me except:
Adlib Programming Guide - by Tero T”tt”, and The PC Games Programmers Encyclopedia V1.0

The information below is a combination of known features of Adlib (alias Yamaha YM 3812/OPL2) and my own uncountable experiments and failures, which brought out a lot of important details you have to know about the chip.

As far as I know, there are four major sound cards based on OPL3 chip:

I currently have a Sound Blaster Pro II-compatible card only, so all the programming info I provide will be based on this card. (The other cards are quite similar, however. They are just wired at different I/O-port addresses.)

Note: I assume some knowledge of FM music programming (mainly Adlib FM synthesizer) in this manual. If you are new to this topic I recommend you try Adlib first before going higher. Anyway, OPL3 is a direct descendant of OPL2 (what a surprise), so most features of OPL2 are also present on OPL3.


My card's user manual says: "[this card contains] ... a stereo music FM synthesizer with 20 channels consisting of four (4) operators each ... " I thought: "Wow -- that's together eighty operators. This must be a GOOD sound-card." I was wrong. Just another advertising lie.

So let's clear some facts. First, OPL3 has only thirty-six (36) operators which can be combined in several ways:

From the table above you can see that not all channels can be used in four- operator (4-OP) mode -- only a part of the synthesizer is really capable of making 4-OP sounds -- the rest uses traditional two-operator (2-OP) mode.

Second, the manual states this card is capable of "stereo" music. Yes, the quotes are necessary, because the stereo capabilities are very limited. You are given ability to control output going to left or right channel by turning it on and off. That's all. So the sound can flow from very left side, center and very right side. No sound panning, no special stereo effects. :-(

Well, flaming apart, back to the main topic.

The OPL3 chip is capable of making sounds in several ways:

  1. Two-operator Additive Synthesis
    Output of both operators is simply added. It is the simplest way to make any sound, and it works on both OPL2 and OPL3. The diagram should make it clear.
            | Operator 1  |----------+
            +-------------+	         |    +-----------+
                                     +--->| Output    |
            +-------------+          |    +-----------+
            | Operator 2  |----------+

  2. Two-operator Frequency Modulation (FM) Synthesis
    Output from the first operator (Modulator) is sent to the input of the second one (Carrier) and is used to modulate (alter) frequency of the second operator. Only the second operator produces sound. Most of interesting sounds are made this way. This also works on OPL2. Hope the picture helps.
            +------------+         +------------+
            | Operator 1 +-------->| Operator 2 +--------> Output
            |(Modulator) |         | (Carrier)  |
            +------------+         +------------+

  3. Four-operator "Mess" Modulation Synthesis
    All of OPL3's 4-OP configurations are combinations of the above two modes of synthesis. OPL3 combines these two modes in four ways. I have no words to describe these four ways. Only the pictures can show their principle.
    • FM-FM Mode
              ---------    ---------    ---------    ---------
              | Op. 1 |--->| Op. 2 |--->| Op. 3 |--->| Op. 4 |---> Output
              ---------    ---------    ---------    ---------
    • AM-FM Mode
              | Op. 1 +-----------------------------------+
              +-------+                                   |
              +-------+      +-------+      +-------+     |
              | Op. 2 +----->| Op. 3 +----->| Op. 4 +-----+------> Output
              +-------+      +-------+      +-------+
    • FM-AM Mode
              +-------+      +-------+
              | Op. 1 +----->| Op. 2 +-----+
              +-------+      +-------+     |
                                           +-------> Output
              +-------+      +-------+     |
              | Op. 3 |----->| Op. 4 +-----+
              +-------+      +-------+
    • AM-AM Mode
              | Op. 1 +--------------------+
              +-------+                    |
              +-------+      +-------+     |
              | Op. 2 +----->| Op. 3 +-----+------> Output
              +-------+      +-------+     |
              +-------+                    |
              | Op. 4 +--------------------+

    Nice, aren't they?

    The only way I think this can be written is a math formula. Symbol + (plus) means additive synthesis, and * (asterisk) means frequency modulation (Op1 * Op2 means operator 1 modulates operator 2, not vice versa). Here they are:

    • FM-FM Mode: (Op1 * Op2 * Op3 * Op4) ----> Output
    • AM-FM Mode: Op1 + (Op2 * Op3 * Op4) ----> Output
    • FM-AM Mode: (Op1 * Op2) + (Op3 * Op4) --> Output
    • AM-AM Mode: Op1 + (Op2 * Op3) + Op4 ----> Output
  4. Percussion Mode
    In this mode 6 operators are used to produce five different percussion instruments:
    • Bass Drum (2 operators)
    • Snare Drum (1 operator)
    • Tom-Tom (1 operator)
    • Cymbal (1 operator)
    • Hi-Hat (1 operator)

    Because these instruments occupy only three melodic channels, only Bass Drum, Snare Drum and Tom-Tom frequencies can be set. Cymbal and Hi-Hat frequencies are fixed.

    This mode is identical with that of OPL2. For more details see ADLIB.DOC.


OPL3 may be found at the following addresses:

   Sound Blaster Pro II         220h or 240h (selectable), also 388h
Adlib Gold 388h
Pro Audio Spectrum Plus/16 ? (if you have a PAS you should know it)

The base address of the synthesizer will be called "base".

The chip occupies four I/O addresses:

base+0 Primary index register (write), Status register (read)
base+1 Primary data register (write-only)
base+2 Secondary index register (write)
base+3 Secondary data register (write-only)

The index registers are used to select internal registers and data registers are used to write to them. Status register returns the state of two timers built in the chip.
OPL3 contains two sets of registers. The Primary set maps to channels 0-8 (operators 0-17) and the secondary maps to channels 9-17 (operators 18-35). The reason for this is simple: all these registers wouldn't fit into single register set.

Unlike Adlib (OPL2), OPL3 doesn't need delay between register writes. With OPL2 you had to wait 3.3 æs after index register write and another 23 æs after data register write. On the contrary OPL3 doesn't need (almost) any delay after index register write and only 0.28 æs after data register write. This means you can neglect the delays and slightly speed up your music driver. But using reasonable delays will certainly do no harm.

The data registers can't be read (they are write-only) on both OPL2 and OPL3.


The registers are grouped in the same manner as in the OPL2 chip. Programs using both OPL2 and OPL3 chips may use the same code provided that their direct I/O interface is well written. The only thing you have to change is operator-to-register mapping, which must accomodate the fact that registers are spread between two register sets.

(The register map is nearly the same so I dared to copy it from ADLIB.DOC.)

Status Register (base+0):
D7 D6 D5 D4 D3 D2 D1 D0
IRQFlag T1Flag T2Flag

Data Registers (base+1, base+3):
D4 D3 D2 D1 D0
Test Register
Timer 1 Count (80 msec resolution)
Timer 2 Count (320 msec resolution)
04*IRQResetT1MaskT2MaskT2 StartT1 Start
04**4-OP B-E4-OP A-D4-OP 9-C4-OP 2-54-OP 1-44-OP 0-3
20-35TremoloVibratoSustainKSRFrequency Multiplication Factor
40-55Key Scale LevelOutput Level
60-75Attack RateDecay Rate
80-95Sustain LevelRelease Rate
A0-A8Frequency Number ( Lower 8 bits )
B0-B8KEY-ONBlock NumberF-Num (hi bits)
BDTrem DepVibr DepPercModeBD OnSD OnTT OnCY OnHH On
C0-C8RightLeftFeedBack Modulation FactorSynthTyp
E0-F5Waveform Select

* This applies only to port base+1
** This applies only to port base+3
For register bases A0, B0 and C0 there is one register per output channel. The primary register set holds the first nine channels (0-8) and the secondary holds last nine channels (9-17).
For bases 20, 40, 60, 80 and E0 there are two registers per channel. Each register maps to one operator. Unfortunately the operator's register numbers are not continuous. The following table shows which operator maps to which register set and offset (in hex).

Op. Set/Offset Op. Set/Offset
0 0/00 18 1/00
1 0/01 19 1/01
2 0/02 20 1/02
3 0/03 21 1/03
4 0/04 22 1/04
5 0/05 23 1/05
6 0/08 24 1/08
7 0/09 25 1/09
8 0/0A 26 1/0A
9 0/0B 27 1/0B
10 0/0C 28 1/0C
11 0/0D 29 1/0D
12 0/10 30 1/10
13 0/11 31 1/11
14 0/12 32 1/12
15 0/13 33 1/13
16 0/14 34 1/14
17 0/15 35 1/15

The following tables summarize which operators form a channel in various modes:

  1. Two-operator Melodic Mode
    000102030405 060708091011 121314151617
    Operator 1
    Operator 2
    000102060708 121314181920 242526303132
    030405091011 151617212223 272829333435

  2. Two-operator Melodic and Percussion Mode
    Channel012345 BDSDTTCYHH 91011121314151617
    Operator 1012678 1216141713 181920242526303132
    Operator 234591011 15 212223272829333435

  3. Four-operator Melodic Mode
    Channel01267 89101115 1617
    Operator 10121213 1418192030 3132
    Operator 23451516 1721222333 3435
    Operator 3678 242526
    Operator 491011 272829

    Channels 3, 4, 5 and 12, 13, 14 can't be used separately because their operators became part of channels 0, 1, 2 and 9, 10, 11 respectively. For instance a four-operator channel 1 consists of two two-operator channels number 1 and 4. (The second 2-OP channel number is always the first 2-OP channel number plus three.)

    OPL3 allows you to enable/disable 4-OP mode separately for any of channels 0, 1, 2, 9, 10 and 11 (see register 104h in the reference below). This means for instance when you switch only channel 2 into 4-OP mode, channels number 0, 1, 3, 4, 6, 7, 8, 9, etc. will be still independent 2-OP channels.

    Channels 6, 7, 8 and 15, 16, 17 are always two-operator ones. They can't be grouped to form four-operator channels.

  4. Four-operator Melodic and Percussion Mode
    Channel012BDSD TTCYHH910 11151617
    Operator 10121216 1417131819 20303132
    Operator 234515 2122 23333435
    Operator 3678 2425 26
    Operator 491011 2728 29



Because the registers of OPL3 are almost the same as of OPL2, I have copied their descriptions from file ADLIB.DOC.