Editor Reference

v7.0.16 18/12/2022

Introduction

This is an editor for the sounds that the synthesiser produces. It is not a Midi file editor for which there are many good examples. There are however no editors for this synthesiser as it is my design, so I had to create an editor to produce the Sound Set. The Sound Set is equivalent to the Sound Font that Wavetable Synths use although the format is totally different and the size is tiny compared to Sound Font files.

The instrument editor displays a copy of the current instrument as selected by the patch number. The displayed copy is called the user instrument and all user parameters are displayed in this window. The controls are grouped into blocks that control the main parts of a generator. Refer to the Generator Block Diagram for details about the generator design. The group labelled 'Instrument' does not control parameters and is described below. In the following table 'user' refers to the currently displayed instrument parameters for editing.

Control Description

Control Function
Patch The current instrument patch number. It's name and bank are shown beneath.
The name is part of the instrument definition and can be edited but is not a real parameter.
Reload Saves 'user' in 'temp', reloads 'user' with the current instrument, and displays
"saved in temp". If already saved in temp, loads 'temp' back into 'user'.
Whilst editing, this can be used to toggle between a modified version and the original.
Clear Clears 'user', i.e. the current edit.
Delete Clears 'user' and deletes the current instrument.
Swap First press selects the current instrument and displays "Swap with ?".
Second press swaps the previously selected instrument with the current instrument.
Swaps everything except the name.
Save Saves 'user' in the current instrument.
Save New Saves 'user' in the next free bank above the current instrument.
This is useful when creating variations of an instrument.
Backup Saves everything in the data file "SoundSet". This will be restored at start up.
Also creates the following 3 files, a 'c' source file which can be used in the source code
as the default instrument set, a text file of the current patch list, and a csv version of
the patch list.

Variable parameters are adjusted by slider controls, most have a logarithmic law. If the slider resolution is not good enough, values can also be entered directly using the writable icons associated with each slider. Switches are controlled using option buttons.

When entering values into writable icons, "Return" must be pressed to enter the new value.

It is impossible to break anything by fiddling with the parameters in the editor. However it is very easy to end up with no sound at all. Start with a stored instrument that is near what you want and tweek it a bit. The key is to only make small changes. When you're happy with the result, select "Save New" and before exiting the application select "Backup". This ensures that everything will be restored next time. Your new instrument will be saved in the next free bank up from the source instrument. If there was no free bank a new one will be created. You can rename your new instrument and it's new bank if one was created.

To discard all the changes, simply don't select "Backup" and the state before editing will be restored at the next start up. Even if you do backup and then regret it, simply delete or rename the SoundSet file in the MidiPlay directory and next time you start up, the default set will be used.
Until "Save" or "Save New" are selected, moving to another instrument overwrites any changes that have been made.
SoundSet files of any name, as long as they are filetyped data, can be dropped on any window to load them.

The Bank name and Sound Set name are not part of an instrument definition and any changes that are made to these, once "Return" has been entered, will update those names without selecting "Save" or "Save New". The save buttons only apply to the instrument definitions. However until "Backup" is selected, nothing is permanently changed.

While the editor or keyboard windows have the input focus, the PageUp and PageDown keys select the next and previous instrument patch.

Keyboard

For editing instrument definitions it is essential to be able to play notes. The keyboard window displays a 6 octave keyboard where notes can be entered via the mouse. A mouse left click is a normal key down / key up operation. A mouse right click is key down only, for entering chords. When a Midi file is played by the player, the notes will be displayed if the keyboard menu "Player" option is selected. A different highlight colour is used for each of the 16 channels. The keyboard menu also allows selection between percussion and melodic channel display from the Player.
The channel highlight colours are shown below.

The computer keyboard can also be used for entering notes. For this to work, the Keyboard window must have the focus. When the window is first opened it has the focus, but if a writable icon elsewhere is selected, focus will be transferred. To regain the focus move the keyboard window slightly. The following diagram shows which keys of the computer keyboard are used for note entry. Holding the SHIFT key down shifts the note up by 2 octaves. Notes are displayed in the keyboard window. More than one key can be pressed at the same time but the number depends on which keys are pressed, the keyboard design, and the operating system.

Midi notes have a number range between 0 and 127, and middle C is 60. In this synthesiser middle C is called C5 and A6 is tuned to 440Hz. This gives,
lowest possible note, C0 = 8.176 Hz
highest possible note, G10 = 12.543 kHz

Some manufacturers call the lowest note C-2 which makes middle C C3, there is no real standard.

Reference

Instrument definitions

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.

Instrument Banks and Bank Maps

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, Bank-Lo is used to select the bank, and Program to select the instrument within the bank.

Waveform definitions

Waveform definitions are a single cycle of the waveform. A waveform can be used by more than one instrument definition.

Patch List

A Patch is a MIDI Program/Bank-Hi/Bank-Lo selection and is used when loading a voice for playing with the keyboard. Patch numbers are only used by the editor and are not used by MIDI commands from the player. They select instruments using their Program/Bank. The patch list is udated when a Backup is made and when Sound Sets are loaded or instruments created.
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 128, key mapped percussion programs (complete drum kits) are loaded which cannot be edited. If Bank-Hi is 129, 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, and so will never be used to locate instruments. Drum kit parts cannot be loaded by MIDI commands, the percussion channel is used by MIDI commands to load complete Drum kits.

Parameters

These are the instrument definition parameters. They completely define an instrument and are applicable to the USER command. 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.

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

Switches

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

Waveforms

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.

Number Description
0 Sine 1st
1 Sine 1st 2nd
2 Sine 1st 2nd 3rd
3 Sine 1st 2nd 3rd 4th
4 Sine 1st 2nd 3rd 4th 5th
5 Sine 1st 2nd 4th
6 Sine 1st 3rd 5th 7th
7 Sine 3rd 5th
8 Sine 2nd 3rd 4th 6th 8th
9 Sine 2nd 3rd
10 Sine 4th 5th 6th
11 Ramp (Sawtooth)
12 Triangle
13 Square
14 Pulse
15 Parabola
16 Cubic 1
17 Cubic 2
18 French Horn
19 Trumpet
20 Alto Sax
21 Flute
22 Piano
23 Glockenspiel

Number Description
24 Violin
25 Piano 2
26 Rhodes Piano
27 Chorused Piano
28 Harpsichord
29 Clavichord
30 Celesta
31 Music Box
32 Vibraphone
33 Xylophone
34 Tubular Bells
35 Hammond Organ
36 Percussive Organ
37 Rock Organ
38 Church Organ
39 Reed Organ
40 Accordian
41 Harmonica
42 Acoustic Bass
43 Electric Guitar
44 Acoustic Guitar
45 Orchestral Harp
46 Cymbal 1

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.
The Red components execute at the audio sample rate, and the Black components at the envelope rate of 500Hz. The Green components operate with MIDI note numbers and are translated by the 'exp' blocks into linear frequencies before being applied. The blue numbers refer to parameter numbers and bit numbers of parameter 40. The switches are shown in commonly used states.

Envelopes

The 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.

  1. Delay Time. The time that the entire sequence is delayed from the key down event
  2. Attack Step. The rate of the attack from zero to the attack target
  3. Attack Target.
  4. Hold Time. The time that the envelope stays at the attack target.
  5. Decay Step. The rate of decay from the attack target to the decay target.
  6. Decay Target.
  7. Sustain Step. The rate of decay from the decay target to zero.
  8. Release Step. The rate of decay from the sustain level when the key was released, to zero.

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, .

Formulae

In 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
step (except attack) = 131072 / tc (where tc is the required time constant in ms)
Time to reach x% of target

step 50% tc(63.2%) 90%
13 6.9sec 10sec 23sec
131 690ms 1sec 2.3sec
1311 69ms 100ms 230ms
13107 6.9ms 10ms 23ms

Modulation Oscillator
rate = f * 131.072 (where f is the desired frequency in Hz)

Retrigger rate
count = 500 / f (where f is the desired retrigger rate in Hz)

Glide Filter
step = 32768 - 65536 / tc (where tc is the required time constant in ms)
Time to reach x% of target

step 50% tc(63.2%) 90%
32762 6.9sec 10sec 23sec
32703 690ms 1sec 2.3sec
32113 69ms 100ms 230ms
26215 6.9ms 10ms 23ms
16384 4ms
0 2ms


© 2022 Peter Everett
contact: peverett33@gmail.com