Difference between revisions of "Willy"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(Compatible Serdaco soundcards)
(Compatible Serdaco soundcards)
 
(44 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
* https://pulkomandy.github.io/shinra.github.io/willy.html
 
* https://pulkomandy.github.io/shinra.github.io/willy.html
 
* [http://www.roudoudou.com/ACE-DL/ OPL3 Player Pack] Huge pack containing 3887 OPL2/OPL3 tunes to be played on Amstrad CPC
 
* [http://www.roudoudou.com/ACE-DL/ OPL3 Player Pack] Huge pack containing 3887 OPL2/OPL3 tunes to be played on Amstrad CPC
 +
* [https://opl.wafflenet.com/ The OPL archive] [https://vgmrips.net/packs/chip/ym3812 VGMrips OPL2] [https://vgmrips.net/packs/chip/ymf262 VGMrips OPL3]
  
 
<br>
 
<br>
Line 25: Line 26:
 
<br>
 
<br>
  
== Technical information ==
+
== Compatible Serdaco soundcards ==
 +
*[https://www.serdashop.com/S2P S2P soundcard] aka Roland MT-32 or General MIDI Wavetable Synthesizer - based on SAM2695 (2014) - [[media:SAM2695.pdf|Datasheet]]
 +
*[https://www.serdashop.com/OPL3LPT OPL3LPT soundcard] aka AdLib Gold or Sound Blaster 16 - based on OPL3 (1990) - [[Media:YMF262 199110.pdf|OPL3 datasheet]] [[Media:Yamaha yac512 datasheet.pdf|DAC datasheet]]
 +
*[https://www.serdashop.com/OPL2LPT OPL2LPT soundcard] [https://github.com/zjuyzj/OPL2LPT-Replica OPL2LPT-Replica] aka AdLib or Sound Blaster - based on OPL2 (1985) - [[media:Yamaha_YM3812.pdf|Datasheet]]
 +
*[https://www.serdashop.com/CMSLPT CMSLPT soundcard] aka Creative Music System or Game Blaster - based on two SAA1099 (1986) - [[media:Philips_saa1099.pdf|Datasheet]]
 +
*[https://www.serdashop.com/TNDLPT TNDLPT soundcard] aka PCjr or Tandy Sound - based on SN76489 (1979) - [[media:Texas_instruments_sn76489an.pdf|Datasheet]]
 +
*[https://www.serdashop.com/CVX4 CVX4 soundcard] aka Covox Speech Thing - [https://scalibq.wordpress.com/2017/11/28/the-covox-years/ Technical analysis]
 +
 
 +
Note: Unlike the [[AMSDAP]] OPL4 & YRW801 ROM solution, the S2P soundcard natively supports Wavetable MIDI without requiring a software translation layer. The Willy with S2P soundcard recreates what it was like to connect an Amstrad CPC via a [[Music Machine]] MIDI port to a Roland MT-32 synthesizer in 1987.
 +
 
 +
<br>
 +
 
 +
== I/O Ports ==
 
2 ports are used to control the MIDI soundcard: &FEAC for data, and &FEAD for control and status.
 
2 ports are used to control the MIDI soundcard: &FEAC for data, and &FEAD for control and status.
  
 
3 ports are used to control the OPL3 soundcard:  &FEBC and &FEBE are register select ports, and &FEBD is the data port.
 
3 ports are used to control the OPL3 soundcard:  &FEBC and &FEBE are register select ports, and &FEBD is the data port.
  
OPL3 is register compatible with OPL2, with twice the number of signal sources, 4 new operator modes, 4 new selectable waveforms (including square wave) and stereo output.
+
<br>
 +
 
 +
== OPL3 sound chip ==
 +
 
 +
The OPL3, released by Yamaha in 1990, is an upgraded version of the OPL2, which came out in 1985.
 +
 
 +
OPL3 is register compatible with OPL2, with twice the number of signal sources, 4 new operator modes, 4 new selectable waveforms, and stereo output.
  
 
OPL3 offers 18 FM 2-op chans in its standard mode, but that can be configured:
 
OPL3 offers 18 FM 2-op chans in its standard mode, but that can be configured:
* One setting converts 3 of the FM chans into a 5-chan FM percussion set (Bass Drum, Snare Drum, Tom-Tom, Top-Cymbal, Hi-Hat)
+
* One setting converts 3 of the FM chans into a 5-chan FM percussion set
 
* Another setting pairs 12 of the FM chans into 6 FM 4-op chans
 
* Another setting pairs 12 of the FM chans into 6 FM 4-op chans
 
* Both settings can be used at the same time, to obtain 6 FM 4-op chans + 3 FM 2-op chans + 5-chan FM percussion set
 
* Both settings can be used at the same time, to obtain 6 FM 4-op chans + 3 FM 2-op chans + 5-chan FM percussion set
Line 39: Line 58:
 
<br>
 
<br>
  
== Compatible Serdaco soundcards ==
+
=== Basic Components ===
*[https://www.serdashop.com/S2P S2P soundcard] aka Roland MT-32 or General MIDI Wavetable Synth - [[media:SAM2695.pdf|Datasheet]]
+
 
*[https://www.serdashop.com/OPL3LPT OPL3LPT soundcard] aka AdLib Gold or Sound Blaster 16 - [[Media:YMF262 199110.pdf|Datasheet]]
+
The most basic elements of an OPL FM synthesiser are:
*[https://www.serdashop.com/OPL2LPT OPL2LPT soundcard] aka AdLib or Sound Blaster - [[media:Yamaha_YM3812.pdf|Datasheet]]
+
 
*[https://www.serdashop.com/CMSLPT CMSLPT soundcard] aka Creative Music System or Game Blaster - [[media:Philips_saa1099.pdf|Datasheet]]
+
* envelope generators, which vary volume over time;
*[https://www.serdashop.com/TNDLPT TNDLPT soundcard] aka PCjr or Tandy Sound - [[media:Texas_instruments_sn76489an.pdf|Datasheet]]
+
 
*[https://www.serdashop.com/CVX4 CVX4 soundcard] aka Covox Speech Thing - [https://scalibq.wordpress.com/2017/11/28/the-covox-years/ Technical analysis]
+
* phase generators, which produce a waveform such as a sine wave at a programmatic rate;
 +
 
 +
* operators, which combine an envelope generator and a phase generator;
 +
 
 +
* a global low-frequency oscillator which can provide additional vibrato (i.e. back-and-forth modification of frequency) and tremolo (like vibrato, but for volume) to operators;
 +
 
 +
* channels, which combine operators to produce a single tone output;
 +
 
 +
* a distinct rhythm section, which incorporates a noise generator with some of the parts above to provide a few fixed percussion noises.
 +
 
 +
<br>
 +
 
 +
=== Operators ===
 +
 
 +
On an OPL1 or 2, each channel consists of two operators. On an OPL3 it may also consist of four. In either case, the basic FM synthesis operation is the same:
 +
 
 +
The output of one operator is used to modulate the current phase of another. The former is known as the modulator, the latter as the carrier.
 +
 
 +
In two-operator frequency modulation mode, the output of the carrier, after modulation, is the audio output.
 +
 
 +
In four-operator mode there are some more complicated options involving routing outputs between operators.
 +
 
 +
<br>
 +
 
 +
=== Logsin and Exponent tables ===
 +
 
 +
The OPL chips use two look-up tables, each containing 256 entries. [https://g.co/kgs/Da1vEi4 Source]
 +
 
 +
They produce the sound without any multiplication or other costly arithmetic operations, using for 2-op "frequency modulated" (actually phase modulated) synthesis the formula:
 +
 
 +
out = exp(logsin(phase2 + exp(logsin(phase1) + gain1)) + gain2)
 +
 
 +
==== Exponential table ====
 +
 
 +
x = 0..255, y = round((power(2, x/256)-1)*1024)
 +
 
 +
When such a table is used for calculation of the exponential, the table is read at the position given by the 8 LSB's of the input. The value + 1024 (the hidden bit) is then the significand of the floating point output and the yet unused MSB's of the input are the exponent of the floating point output.
 +
 
 +
==== Log-sin table ====
 +
 
 +
x = 0..255, y = round(-log(sin((x+0.5)*pi/256/2))/log(2)*256)
 +
 
 +
This is the first (rising) quarter of sine wave. The rest can be constructed by flipping all the bits of x and/or by changing the sign of the samples.
 +
 
 +
<br>
 +
 
 +
=== Waveforms ===
 +
 
 +
The original OPL only has access to the sine wave.
 +
 
 +
From the OPL2 onwards other waves are also available, specifically a half sine (i.e. the positive part only, silence for the second half of the period), rectified sine (the positive part repeated twice per cycle) or quarter sine (just the first ramp from 0 to 1, repeated twice, providing harmonics a lot like a sawtooth).
 +
 
 +
The OPL3 goes even further, adding some extra sine options plus a square wave and a logarithmic sawtooth.
 +
 
 +
[[File:Waveforms OPL3.jpg]]
 +
 
 +
<br>
 +
 
 +
=== FM Percussion Set ===
 +
 
 +
FM synthesis does a great job relative to its hardware requirements at reproducing melodic instruments but isn't especially useful for harsh percussion noises like drums. Yamaha provides separate drum noises for this purpose. The programmer has to forfeit three channels of regular FM synthesis, freeing up six operators for five rhythm instruments.
 +
 
 +
A global random level generator is implemented for this mode; it's a standard LFSR just like the noise generator on simple chips like the AY-3-8910 or SN76489, so it provides a one-bit semi-random output. [https://www.reddit.com/r/EmuDev/comments/gdhjt0/a_primer_on_fm_synthesis/ Source]
 +
 
 +
The OPL can then generate:
 +
 
 +
* a bass drum, which is just another FM noise;
 +
 
 +
* a tom tom, which is the unmodulated output of a single operator;
 +
 
 +
* a snare drum, which combines the phase of a single operator with the random noise bit;
 +
 
 +
* a cymbal which XORs six bits from the phase of two operators;
 +
 
 +
* a high-hat, which uses the same XOR as the cymbal and combines it with the random noise bit.
 +
 
 +
<br>
 +
 
 +
== OPL3 undeserved reputation ==
 +
 
 +
The OPL3 soundchip has been underused and unfairly criticized, largely due to 2 factors:
 +
* As OPL3 is compatible with OPL2, PC game producers did not make the effort to specifically exploit the OPL3 soundchip capabilities, instead they relied on inferior OPL2 tunes. These are the equivalent of the Speccy ports that gave the Amstrad CPC a bad reputation.
 +
* Western PC game developers in the early 90's also tended to produce music by using a master MIDI track on Roland MT-32, and then downgrading it for the various PC soundchips. The result was a cheesy so-called "MIDI" music. That was unfair for OPL3 (but also for MIDI, as Wavetable MIDI sounds way better than that).
 +
 
 +
=== Examples of proper OPL3 music ===
 +
 
 +
* [https://www.youtube.com/watch?v=a7I-QmrkAak MoonDriver]
 +
* [https://www.youtube.com/watch?v=uyVOy02tW88 Paul the Penguin]
 +
* [https://www.youtube.com/watch?v=6JlFIFz1CFY Zen Challenge]
  
 
[[Category:Music and sound]] [[Category:Peripherals]]
 
[[Category:Music and sound]] [[Category:Peripherals]]

Latest revision as of 18:47, 26 October 2024

Willy - MIDI and OPL3 Soundcard adapter for CPC

Willy1.jpg


Demonstrations


Weblinks


Cost

The cost for a Willy soundcard adapter is 10€. This does not include any soundcard, you have to buy those separately.


Compatible Serdaco soundcards

Note: Unlike the AMSDAP OPL4 & YRW801 ROM solution, the S2P soundcard natively supports Wavetable MIDI without requiring a software translation layer. The Willy with S2P soundcard recreates what it was like to connect an Amstrad CPC via a Music Machine MIDI port to a Roland MT-32 synthesizer in 1987.


I/O Ports

2 ports are used to control the MIDI soundcard: &FEAC for data, and &FEAD for control and status.

3 ports are used to control the OPL3 soundcard: &FEBC and &FEBE are register select ports, and &FEBD is the data port.


OPL3 sound chip

The OPL3, released by Yamaha in 1990, is an upgraded version of the OPL2, which came out in 1985.

OPL3 is register compatible with OPL2, with twice the number of signal sources, 4 new operator modes, 4 new selectable waveforms, and stereo output.

OPL3 offers 18 FM 2-op chans in its standard mode, but that can be configured:

  • One setting converts 3 of the FM chans into a 5-chan FM percussion set
  • Another setting pairs 12 of the FM chans into 6 FM 4-op chans
  • Both settings can be used at the same time, to obtain 6 FM 4-op chans + 3 FM 2-op chans + 5-chan FM percussion set


Basic Components

The most basic elements of an OPL FM synthesiser are:

  • envelope generators, which vary volume over time;
  • phase generators, which produce a waveform such as a sine wave at a programmatic rate;
  • operators, which combine an envelope generator and a phase generator;
  • a global low-frequency oscillator which can provide additional vibrato (i.e. back-and-forth modification of frequency) and tremolo (like vibrato, but for volume) to operators;
  • channels, which combine operators to produce a single tone output;
  • a distinct rhythm section, which incorporates a noise generator with some of the parts above to provide a few fixed percussion noises.


Operators

On an OPL1 or 2, each channel consists of two operators. On an OPL3 it may also consist of four. In either case, the basic FM synthesis operation is the same:

The output of one operator is used to modulate the current phase of another. The former is known as the modulator, the latter as the carrier.

In two-operator frequency modulation mode, the output of the carrier, after modulation, is the audio output.

In four-operator mode there are some more complicated options involving routing outputs between operators.


Logsin and Exponent tables

The OPL chips use two look-up tables, each containing 256 entries. Source

They produce the sound without any multiplication or other costly arithmetic operations, using for 2-op "frequency modulated" (actually phase modulated) synthesis the formula:

out = exp(logsin(phase2 + exp(logsin(phase1) + gain1)) + gain2)

Exponential table

x = 0..255, y = round((power(2, x/256)-1)*1024)

When such a table is used for calculation of the exponential, the table is read at the position given by the 8 LSB's of the input. The value + 1024 (the hidden bit) is then the significand of the floating point output and the yet unused MSB's of the input are the exponent of the floating point output.

Log-sin table

x = 0..255, y = round(-log(sin((x+0.5)*pi/256/2))/log(2)*256)

This is the first (rising) quarter of sine wave. The rest can be constructed by flipping all the bits of x and/or by changing the sign of the samples.


Waveforms

The original OPL only has access to the sine wave.

From the OPL2 onwards other waves are also available, specifically a half sine (i.e. the positive part only, silence for the second half of the period), rectified sine (the positive part repeated twice per cycle) or quarter sine (just the first ramp from 0 to 1, repeated twice, providing harmonics a lot like a sawtooth).

The OPL3 goes even further, adding some extra sine options plus a square wave and a logarithmic sawtooth.

Waveforms OPL3.jpg


FM Percussion Set

FM synthesis does a great job relative to its hardware requirements at reproducing melodic instruments but isn't especially useful for harsh percussion noises like drums. Yamaha provides separate drum noises for this purpose. The programmer has to forfeit three channels of regular FM synthesis, freeing up six operators for five rhythm instruments.

A global random level generator is implemented for this mode; it's a standard LFSR just like the noise generator on simple chips like the AY-3-8910 or SN76489, so it provides a one-bit semi-random output. Source

The OPL can then generate:

  • a bass drum, which is just another FM noise;
  • a tom tom, which is the unmodulated output of a single operator;
  • a snare drum, which combines the phase of a single operator with the random noise bit;
  • a cymbal which XORs six bits from the phase of two operators;
  • a high-hat, which uses the same XOR as the cymbal and combines it with the random noise bit.


OPL3 undeserved reputation

The OPL3 soundchip has been underused and unfairly criticized, largely due to 2 factors:

  • As OPL3 is compatible with OPL2, PC game producers did not make the effort to specifically exploit the OPL3 soundchip capabilities, instead they relied on inferior OPL2 tunes. These are the equivalent of the Speccy ports that gave the Amstrad CPC a bad reputation.
  • Western PC game developers in the early 90's also tended to produce music by using a master MIDI track on Roland MT-32, and then downgrading it for the various PC soundchips. The result was a cheesy so-called "MIDI" music. That was unfair for OPL3 (but also for MIDI, as Wavetable MIDI sounds way better than that).

Examples of proper OPL3 music