NB: This was the very first thing I wrote for Patel, and is *horribly
horribly out of date*. Some parts are just plain *wrong* (eg: the section
on ADSR envelopes, which I basically wrote from memory of how they work),
and various bits of nomenclature have changed, etc etc.

In short, it no longer properly describes how Patel synthesizes sound,
and should be taken with several large pinches of salt.
It'll be fixed in a later version.


----

SYNTHESIS
=========
In keeping with the "chiptune" style of sound, Patel synthesizes tones
in a fairly primitive way. It uses a small set of basic building blocks,
combinable within limits.

BASICS
======
The most important component, is the wave. All tones are rendered as at
least one wave, with frequency depending on the note to be played (and
also on temperament). Waves come in various flavours:
Sine (the most basic, the rounded wave that is a pure tone)
Square (a set of flattened peaks and troughs, with no levels in between)
Ramp (constantly rising amplitude that regularly and instantaneously drops back)
     (this might be sawtooth, or triangle, depending on who you ask)
Hill (gradually rises at a constant rate, then falls down again at a constant
      rate, like a set of triangular hills)
      (this might be triangle, or sawtooth, depending on who you ask)
Pulse? (exactly one positive sample per wave, rest at 0? Not sure about
       this at all)
Others may be added later.
Each type of wave will normally range in amplitude from -1 to 1, particularly
when used for playing tones. However, range can be selectable to run from
0 to 1, or 0.5 to 1, for various reasons. The most significant reason is for
performing amplitude modulation, about which more later.

The second component, is the envelope. Envelopes are used to shape the
amplitude of tones that are played. They consist of a set of volume ramps,
which can be defined in various ways. The main way, is ASDR.

  1|         ----
   |        /    \
 .8|       /      \
   |      /        \
 .6|     /          \
   |    /            --------
 .4|   /                     |
   |  /                      |
 .2| /                       |
   |/                        |
   ------------------------------
     ----time----
 In this diagram, an ASDR-based envelope is shown. The rising period at the
start is the "attack" slope, which starts as soon as the note is played.
The level period at the top, just after attack, is "sustain" time. The
downward slope after this is the "decay" slope. After this is the *release*,
which I'm not sure how it works :P I'll have to look it up.

 Envelopes could be encoded in other ways though. They're only to describe
the volume of the wave.

 Now, comes "amplitude modulation", which is a process rather than any sort
of data-type! Amplitude modulation is the technique by which envelopes are
applied to tones - you couldn't "hear" a volume envelope without it being
applied to a tone.
 Amplitude modulation works by *multiplying* the amplitude levels of two
signals together. The effect is that the tone has at any one time the volume
of the wave that modulates it -but the result is *exactly* the same regardless
of which signal you consider to "modulate" the other. And as such, you *do not*
have to use only envelopes with notes, you can also modulate notes with *other*
waves, in various ranges, for different effects.
 For example, if you modulate a note with a 4Hz square wave ranging from 0 to 1,
the output will be a note switching on and off 4 times a second. As said above,
it makes no difference which signal you consider to modulate the other, so the
note could well be modulated by a signal that's in the audible range, etc, if
you felt so inclined.

Now, having established all those concepts, there are the "instruments" that
can be constructed using these building blocks.
INSTRUMENTS
===========

-Each "instrument" type in Patel, primarily has a tone, which is played at the
frequency of the note required. This we refer to as just "tone". Tones can
be any waveform.

-The tone may optionally have "harmonics", which are other waves whose
amplitudes are added to those of the tone; you can have either, neither, or
both, of a relative harmonic or an absolute harmonic. Absolute harmonics are
just fixed frequencies that do not vary with the note played; relative
harmonics are a given number of semitones above or below the note.
Harmonics do not have to be the same waveform as the tone.

If you have any harmonics in an instrument, you must select a set of amplitudes
for each harmonic, in the range 0 to 1. An amplitude of 0 obviously has no
volume.
The amplitude of the tone is reduced such that it plus the amplitudes of the
harmonics comes to 1- so if the amplitudes of the harmonics are too high, the
tone will be silent, and it is an error for them to be set higher still.

-The instrument may have one envelope or none.

-The instrument may also have an optional modulating tone as described in the
amplitude modulation description. This we refer to as the "modulation wave".
Modulation waves may (and often will) have amplitude ranges that do not go
below 0. Tones may also, but that might seem rather pointless.

-----------
I'm not sure how much more there is to say :)

