SNBasic - a SN76489 meta-engine
by Shiru 07'2017


Very basic SN76489 PSG engine, the first one created to test out 
1tracker capabilities in areas besides ZX Spectrum beeper music.

It is not a real engine as in coded in Z80 assembly or such. Instead,
it  is 1tracker script that produces a stream of SN76489 register
writes inside a VGM file container. 

There is no envelopes or effects, just three channels of tone and one 
channel of noise with volumes and detune, all tied to the actual chip
capabilities and limitations. All noise modes supported. The clock
frequency is set to the Master System/Game Gear one, so tone channels
can't get below A-2.


The columns are:

Sp T1 dVo T2 dVo T3 dVo NseVo
.. ...... ...... ...... .....
   |    | |    | |    | |   |
   +-ch1+ +-ch2+ +-ch3+ +ch4+
   
Sp : Speed, 1..99

T1,T2,T3 : Tone channels
   Tn : Note, A-2..B-8
    d : Detune, 1..9
   Vo : Volume, 1..16 (lowest to loudest)

T4 : Noise channel
  Nse : Noise note, see below
   Vo : Volume, 1..16 (lowest to loudest)

   
Noise channel has eight modes, some of which also hijack third tone
channel. The modes selected with a note in the Nse field. The note
effect repeats in series of 8.

Pitch in variable pitch modes controlled with notes in the T3 channel.
Both channel volumes affect to the sound, so tone component can also be
heard. To avoid this, and keep noise sound only set T3 volume to 1.

Periodic noise is a metallic sounding note that sounds more like a
different timbre than actual noise. It is the only way to go below A-2
on SN76489.

C-6 : Fixed high pitch periodic noise
C#6 : Fixed mid pitch periodic noise
D-6 : Fixed low pitch periodic noise
D#6 : Variable pitch periodic noise
E-6 : Fixed high pitch white noise
F-6 : Fixed mid pitch white noise
F#6 : Fixed low pitch white noise
G-6 : Variable pitch white noise
