v0.02 26/11/2024
Instrument definitions are a set of parameters that a generator uses to produce a sound. A definition can be for a pitched (melodic) instrument, a percussion instrument, or a sound effect. They are held in an array in any order and are selected by their index or position in the array.
A bank selects 128 instruments and consists of indexes to the array of instruments. A zero index
is used to indicate an empty location so valid indexes start from 1. The indexes are 16 bit to
allow access of up to 65535 instruments. If a zero index is selected, the bank 0 instrument will
be used.
Bank maps are used to select the above banks. There are two maps, one for pitched instruments,
and one for drum kits. A zero entry means the bank is not defined, and bank 0 is used. Up to 128
Instrument banks and up to 128 drum kits can be defined.
In this synthesiser, For pitched instruments, Bank-Lo is used to select the bank, and Program
to select the instrument within the bank. For Drum Kits Program is used to select the Drum Kit,
which is really just another bank, and the Key is used to select the Drum Kit Part.
Waveforms are a single cycle of the waveform. A waveform can be used by more than one instrument definition. They are not stored as waveforms in the Sound Set but the first 32 harmonics are stored and these are transformed into waveforms when the sound set is loaded. Harmonics are used because they require far less space and it is much easier to modify a waveform by manipulating its harmonics than by using the waveform directly.
A Patch is a MIDI Program/Bank-Hi/Bank-Lo selection and is used when loading a voice for
editing. Patch numbers are only used by the editor and are not used by MIDI commands. The patch list is
updated when a Backup is made and when Sound Sets are loaded or instruments created or deleted.
When a key mapped drum kit is loaded, the individual parts cannot be edited. To overcome this
the following scheme is implemented. If Bank-HI is 127, key mapped percussion programs (complete
drum kits) are loaded which cannot be edited. If Bank-Hi is 128, the percussion instrument selected
by the program number and the Bank-Lo is loaded for editing.
Banks greater than 127 are used for this because they are invalid MIDI bank numbers and are only used
internally to load drum kit parts for editing. Drum kit parts cannot be loaded by MIDI commands, only
complete Drum kits can.
These are the instrument definition parameters and they completely define an instrument. Set a value to zero if its function is not required. An instrument with all parameters set to zero will produce no sound. The editor window adjusts the parameter set of the user copy of the current instrument.
Filters used for the envelopes and glide are first order IIR, equivalent to simple RC networks in hardware. The main signal filter is a State Variable filter which provides Low pass, Band pass, and High pass outputs. A problem with state variable filters is that they can become unstable with certain combinations of cutoff frequency and resonance. However in this design that is prevented from happening.
Time constants
The envelope sample period is 2ms.
Units for envelope step rates are 65536*2ms/(time constant in ms) e.g. 1311 produces a time
constant of 100ms
Envelope targets are linear volume, 32767 = max volume (0dB) e.g. 16384 = -6dB, 3277 = -20dB
Tone Glide
Tone glide time is 0 for instant, 32767 for forever.
If initial pitch offset is zero, initial pitch is the last note played by the generator.
Parameter | Description | Range | Units |
---|---|---|---|
-1 | Name | Up to 24 chars | Text |
0 | Tone 1 wave number | waveform number | |
1 | Tone 1 final pitch offset | -128 to 127 | Midi key |
2 | Tone 1 initial pitch offset | -128 to 127 | Midi key |
3 | Tone 1 pitch glide time | 0 to 32767 | Time constant |
4 | Tone 1 env attack delay | 0 to 1023 | Envelope sample period (2ms) |
5 | Tone 1 env attack step | 0 to 32767 | Time constant |
6 | Tone 1 env attack target | 0 to 32767 | Linear volume |
7 | Tone 1 env attack hold | 0 to 1023 | Envelope sample period (2ms) |
8 | Tone 1 env decay step | 0 to 32767 | Time constant |
9 | Tone 1 env decay target | 0 to 32767 | Linear volume |
10 | Tone 1 env sustain step | 0 to 32767 | Time constant |
11 | Tone 1 env release step | 0 to 32767 | Time constant |
12 | Tone 2 wave number | waveform number | |
13 | Tone 2 final pitch offset | -128 to 127 | Midi key |
14 | Tone 2 initial pitch offset | -128 to 127 | Midi key |
15 | Tone 2 pitch glide time | 0 to 32767 | Time constant |
16 | Tone 2 env attack delay | 0 to 1023 | Envelope sample period (2ms) |
17 | Tone 2 env attack step | 0 to 32767 | Time constant |
18 | Tone 2 env attack target | 0 to 32767 | Linear volume |
19 | Tone 2 env attack hold | 0 to 1023 | Envelope sample period (2ms) |
20 | Tone 2 env decay step | 0 to 32767 | Time constant |
21 | Tone 2 env decay target | 0 to 32767 | Linear volume |
22 | Tone 2 env sustain step | 0 to 32767 | Time constant |
23 | Tone 2 env release step | 0 to 32767 | Time constant |
24 | Noise env attack delay | 0 to 1023 | Envelope sample period (2ms) |
25 | Noise env attack step | 0 to 32767 | Time constant |
26 | Noise env attack target | 0 to 32767 | Linear volume |
27 | Noise env attack hold | 0 to 1023 | Envelope sample period (2ms) |
28 | Noise env decay step | 0 to 32767 | Time constant |
29 | Noise env decay target | 0 to 32767 | Linear volume |
30 | Noise env sustain step | 0 to 32767 | Time constant |
31 | Noise env release step | 0 to 32767 | Time constant |
32 | Filter env attack delay | 0 to 1023 | Envelope sample period (2ms) |
33 | Filter env attack step | 0 to 32767 | Time constant |
34 | Filter env attack target | 0 to 32767 | Linear volume |
35 | Filter env attack hold | 0 to 1023 | Envelope sample period (2ms) |
36 | Filter env decay step | 0 to 32767 | Time constant |
37 | Filter env decay target | 0 to 32767 | Linear volume |
38 | Filter env sustain step | 0 to 32767 | Time constant |
39 | Filter env release step | 0 to 32767 | Time constant |
40 | Switches | ||
41 | Filter cutoff | -128 to 127 | Midi key |
42 | Filter resonance | 0 to 1023 | 0 = over damped, 1023 = oscillate |
43 | Retrigger rate | 0 to 2047 | Envelope sample period (2ms) |
44 | Modulation wave | waveform number | |
45 | Modulation rate | 0 to 8191 | |
46 | Modulation depth | 0 to 32767 | Linear magnitude |
47 | FM modulation depth | 0 to 32767 | |
48 | Pitch detune | 0 to 1023 | approx. 1 semitone max. |
49 | Gain | 0 to 4096 | Linear volume, 1024 = 0dB gain |
These are the switches of parameter 40. The final value is the hexadecimal addition of all set bits.
Bit | Hex | Description |
---|---|---|
0 | 00000001 | Low pass filter |
1 | 00000002 | Band pass filter |
2 | 00000004 | High pass filter |
3 | 00000008 | Filtered tone generator |
4 | 00000010 | Tone 1 output enable |
5 | 00000020 | Tone 2 output enable |
6 | 00000040 | Tone 1 and tone 2 ring modulation (tone 1 * tone 2) |
7 | 00000080 | Tone 1 pitch modulation |
8 | 00000100 | Tone 2 pitch modulation |
9 | 00000200 | Tone 1 amplitude modulation |
10 | 00000400 | Tone 1 amplitude ring modulation (tone 1 * mod) |
11 | 00000800 | Tone 2 amplitude modulation |
12 | 00001000 | Tone 2 amplitude ring modulation (tone 2 * mod) |
13 | 00002000 | Noise amplitude modulation |
14 | 00004000 | Filter pitch modulation |
15 | 00008000 | Tone envelope retrigger |
16 | 00010000 | Noise envelope retrigger |
17 | 00020000 | Filter envelope retrigger |
18 | 00040000 | Tone pitch key track |
19 | 00080000 | Filter frequency key track |
20 | 00100000 | Tone envelope time constant pitch track |
21 | 00200000 | Noise envelope time constant pitch track |
22 | 00400000 | Filter envelope time constant pitch track |
23 | 00800000 | Inverted filter envelope |
24 | 01000000 | Defined length, no key up required |
25 | 02000000 | Monophonic keyboard scan |
This is a list of the waveforms used by the synthesiser. All waveforms start at a zero crossing and are band limited and filtered to have a zero DC bias. The names are not significant and a waveform should just be treated as a collection of harmonics. The synthesiser assumes that waveform 0 is a first harmonic sine wave. The waveform numbers are referenced by parameters 0, 12, 44.
|
Generator Block Diagram
The diagram shows the operational blocks of one generator. The main signal flow is from left to
right. It is drawn like a hardware block diagram because that is what the software is emulating,
an old fashioned analog synthesiser. Tone 1 and Tone 2 are the oscilators waveform 1 and 2.
EnvelopesThe envelopes used for the Tones, Filter, and Noise implement a Delay, Attack, Hold, Decay, Sustain, Release sequence. When a key is pressed the envelope starts at the Delay state and continues automatically through to the Sustain state. This state will persist until one of two things happen. Either the amplitude has fallen to zero or the key is released before that point and then the Release state is entered. The resulting envelope amplitude is used to control the tone amplitude, the filter pitch, and the noise amplitude. The following 8 parameters define the envelope shape.
The diagram shows the states labelled blue and the parameters labelled turquoise. It was created using the following parameter values.
The maximum values for any of the parameters is 32767. The envelope sample rate is 500Hz, the period is 2ms. The step parameters except attack are time constants. The time constants can be scaled for the pitch. The scaling is relative to middle C and doubles/halves every 2 octaves. The targets are scaled for the key velocity. The Attack Step is a linear step and not a time constant as an exponential rise would give the wrong shape. FormulaeIn general, there is no need to know the following formulae, it is provided for information. Just adjust the sliders for the desired sound. The range and law of the sliders are optimised for each parameter. There are situations where a more precise adjustment than can be obtained from slider control is required, FM depth is one. For these, it may be necessary to input the value directly in the writable icon associated with each slider, but this is rarely needed. All that matters is the result, not how it was obtained. Envelopes
Modulation Oscillator
Retrigger rate
Glide Filter
© 2024 Peter Everett
|