Skip to content

InstrumentEditor

LTVA1 edited this page Sep 17, 2023 · 36 revisions

The instrument editor view shows parameters that control the sound synthesis and the instrument program editor. The parameters are a quick way to add simple and common effects to the sound such as vibrato or pulse width modulation. The program is a more comprehensive way to achieve the same and much more.

Parameters

https://github.com/LTVA1/klystrack/blob/master/instrument_editor.png

https://github.com/LTVA1/klystrack/blob/master/instrument_editor.png

Attributes

Base note

This parameter is what note is played when C-4 is triggered. In other words, if the base note is raised one half tone to C#4, pressing the key for C-4 will trigger C#4.

Lock note

Use this flag to make the instrument always trigger at the base note. Useful for drums and sound effects. This is doubly useful when using pattern transposing on combined drum and bassline patterns, only the bassline being transposed.

Drum

This flag makes the instrument enable the noise waveform for the duration of the very first tick. A nod towards the Hubbard play routine.

Key sync

Triggering the note resets the oscillators.

Enable vibrato

This flips the vibrato bit, i.e. the vibrato bit is considered to be on except if the bit is set in the track data.

Enable tremolo

This flips the tremolo bit, i.e. the tremolo bit is considered to be on except if the bit is set in the track data.

Set pulse width

Resets the pulse width to the pulse width parameter when a note is triggered.

Set cutoff

Resets the cutoff frequency to the cutoff parameter when a note is triggered.

FX

If enabled, this instrument will output to the chain set by FX BUS (see below.)

Waveform

PUL, SAW, TRI, NOI and SINE select pulse (a.k.a. square wave), sawtooth, triangle, noise and sine waveforms, respectively. If multiple forms are selected, they are bitwise ANDed to form a combination. You can change osc. mix mode to have different mixing.

The PW parameter controls the pulse width (duty cycle) of the pulse wave. 7FF is a symmetric square wave and 0 is no wave at all. 0x900 sounds like 0x700, 0xf00 like 0x100 etc. Generally, the higher the value, the deeper the sound is and small values produce a thin sound.

Triangle wave is an approximation of a sine wave. It's useful for soft sounds.

Sawtooth makes a sound that is in between of square wave and triangle wave.

The noise waveform can be controlled with the METAL flag which makes the noise values loop, in effect producing audible ringing when the played frequency is high enough. Refer to the cowbell example instrument.

Sine wave is... sine wave. PH. SHIFT is sine phase shift (relative to other waveforms). Each increment shifts sine phase for pi/8. Mostly useful in 4OP FM described below, but you can achieve interesting effects by combining sine wave with other waveforms.

Using the 1/4th switch, it is possible to make the pitch two octaves lower (original frequency divided by four). This is so that there is more low range, in effect this makes the lowest pitch C--7 (C-0 minus seven octaves.) Can be useful for hard sync and ring mod things.

LOCK NOI PITCH makes noise to stay at constant "note" defined at the right side of this checkbox. This frequency is affected only by 1/4th switch and not affected by current main note, portamento/slide, vibrato etc. Refer to Commands to see how you can control this separate noise pitch.

ENABLE 1-BIT NOISE makes noise to swing between only 2 volume levels (NES/Gameboy) instead of going through intermediate values (SID/AY). See on oscilloscope how signals differ.

Wavetable

WAVE is used to associate a wavetable sample with the instrument. Multiple instruments can share the same sample. OENV overrides the ADSR envelope for the sample, which can be useful when combining samples with the synth. The L flag locks the sample at its base note (set in the wavetable editor), also useful when combining with the synth and using the sample as a attack sound that always plays at the same pitch.

Volume envelope

The volume envelope is a standard attack-decay-sustain-release type envelope. When the note is triggered, the attack (ATK) parameter controls the speed at which the volume rises to the level specified by the volume (VOL) parameter. The volume then decays (DEC) to the sustain (SUS) level (which is relative to the overall volume). When a note-off is triggered, the played sound then releases (fades out) at the rate controlled by the REL parameter.

If RELATIVE is checked, all volume commands will be relative to the volume. That is, the command 0C20 will set the audible volume to 25% (32/128) of VOL. If RELATIVE is not checked, 0C20 will set the audible volume to 32 no matter what the instrument volume is.

E.V. lets you set exponential volume scale instead of default linear one. Exponential volume is used by AY and a lot of FM chips. Linear is used by NES and Gameboy. ATK, DEC and REL let you change shape of corresponding envelope sections. Attack is curved upwards as on OPL3/OPL4 chips.

You can use custom volume envelope (see below).

Buzzer

The buzzer effect emulates the common technique from the YM2149 sound chip. The sound chip had a very simple envelope that had the (relatively unique) ability to repeat the envelope curve indefinitely.

Basically, the buzzer effect is just fast amplitude modulation relative to the player frequency. Generally, the envelope frequency is one octave higher than the played note. This makes the player waveform much more varied even if it was a square wave (the YM2149 only had very basic square wave oscillators). For the original buzzer sound from the Atari ST, use a pulse wave at pulse width of 7FF.

Note: Buzzer overrides the ADSR envelope.

Detune/Fine

The DETUNE parameter controls the semitone the buzzer modulates the player waveform. The FINE parameter controls the fine tuning.

Shape

The shape parameter sets the shape of the envelope. 0-1 are saw waves and 2-3 are triangle waves.

AY8930

Enables AY8930-type buzzer. It works the same as default one, but has 32 volume steps instead of 16.

Note: According to datasheet, original AY chips have linear volume and AY8930 has exponential volume. Nevertheless, here and in some emulators AY also has exponential volume.

Sync/ring modulation

The SYNC and RING parameters control whether the oscillator synchronization and ring modulation are enabled. The SRC parameters specify the source channel that controls the modulation. If the source is set to FF, the same channel as the instrument is played on is used as source.

Oscillator synchronization makes the source oscillator to reset the oscillator that the instrument is playing on every time the source oscillator cycles and the counter wraps over.

Ring modulation multiplies the source waveform with the instrument waveform.

Filter

Resembles SID filter and has a linear cutoff curve (0 = 5 Hz, 0xFFF = 20000 Hz, 0x800 = 10005 Hz etc.). You can select lowpass, highpass, bypass filter modes of their combinations (combined modes do not act like SID filter, this is just a sum of signals of individual modes). Resonance is amplifying cutoff frequency, 0 means no resonance, 0xF means max resonance.

Filter slope is controlling how steep the frequency responce curve slope is. The higher the slope, the more frequencies not in filter bandwidth are suppressed. If you will set big resonance on a big slope, you will have pretty damn loud noise instead of your waveform, so don't do that.

Programs

You can have up to 32 independent instrument programs in main instrument and up to 16 for each FM operator from 4-op synth. They are executed fully independently, so program period setting, loops, jumps etc. are affecting only the program they are in. Each tick programs are executed from 0th to the last one, so the programs which have higher number may overwrite some actions performed by lower number ones.

Program number

The number of program that is selected right now. klystrack would not allow you to increase it until your program contains some actual commands besides loop, jump etc. instructions. Programs which number is higher than the max number you can reach in instrument/FM op editor are not executed during song playback. By default only 1st program (program 0) is executed.

Program name

You can name each program. It is advised, if you have more than one program, to give them meaningful names like arp, cutoff sweep, waveform, retrigger etc.

Program period

Program period specifies how many ticks does it take for the program to advance one step. The setting is individual for each program. 00 means 01.

Misc

Slide

The slide parameter controls the time it takes for the previous note to change into the new note if the slide bit is set in the track data. A bigger value means shorter time.

Program period

Program period specifies how many ticks does it take for the program to advance one step.

NOTE: From 0.10.0-alpha2 moved in different place (see upper)

Vibrato

VIB modulates instrument pitch at the set speed (VIB.S) and depth (VIB.D) if the vibrato bit is set in the track data or if the VIB flag is set for the instrument (which inverses the bit). V.DEL sets the delay time it takes for the vibrato depth to rise to the full depth (useful for "auto" vibrato). VIB.SH sets the vibrato shape, available waveforms are sine wave, ramp up, ramp down, pulse, triangle (starting from up or down sections) and cyclic random values.

Vibrato can also be achieved with a little program that uses the portamento commands (01xx and 02xx) to modulate the played note.

Tremolo

Tremolo modulates volume of playing instrument. You can select speed, shape and depth of modulation. FF depth means that volume will swing between 0 and twice the current instrument volume.

Also can be achieved with volfadeup and volfadedn commands.

Pulse width modulation

PWM modulates the pulse width parameter at the set speed (PWM.S) and depth (PWM.D). PWM is useful for making square wave instruments like leads sound more varied with little effort. The modulating waveform can be set with PWM, the same waveforms are available as there are for vibrato.

As with vibrato, related commands can be used to create PWM using the instrument program.

FX bus

The FXBUS parameter selects the effect chain this instrument will send its output to if FX is checked.

No prog restart

This flag disables restarting of the instrument program when a note is triggered. The program will continue executing where it was (in that channel, even if the previous instrument was not the same as the newly triggered instrument.) Use 7D00 to manually restart the program.

Key scaling

Allows you to have more naturally sounding instruments. Volume key scaling means that if note is higher (than instrument base note), the volume will be lower, so perceived volume should stay the same (if you have good headphones of course which do not amplify or suppress some frequencies). If note is lower, volume is higher. Envelope key scaling shortens attack, decay and release if note is higher than base note and makes them longer if note is lower than base note. Think of it as a piano simulator: you've probably noticed that if you press rightmost piano key, you have very short burst of high-pitch sound, but if you press leftmost and hold it, you have very long sound. You can control degree of these key scalings by corresponding "Level" parameters.

Oscilloscope

Useful for creating instruments you saw in "that cool oscilloscope view". Tries to hold the wave still. Has zero-cross trigger (horizontal midline level), so if your wave has several zero crosses per cycle or it is not crossing the midline at all it would be displayed "as is" and will jump/slide towards left or right.

Instrument program

When an instrument is triggered, the program starts executing from the beginning (unless NO PROG RESTART is set). The program executes an instruction according to the P.PRD (program period) parameter. If P.PRD is set to 1, the program will update every tick. If P.PRD is set to 2, the program will update every second check and so on.

A program modifies the played waveform and can be used to create more interesting sounds. The commands are the same as the track commands. This means the program can also be thought as a macro: you do not need to enter the same track commands if the instrument executes has the same commands in the program.

The program can be edited by moving to the program and pressing return on the instruction you want to edit.

The following example is a simple 0-4-7 major arpeggio:

00 00 0000   set arpeggio note to 0 (the same note as played)
01 01 0004   set arpeggio note to 4 (played note plus 4 semitones)
02 02 0007   set arpeggio note to 7
03 03 FF00   jump back to step 00

Note that you can also specify the arpeggio notes by using the track command 10xy. This makes it possible to use the same instrument to play different arpeggio chords. In the program, you can refer to those two notes with 00f0 and 00f1. For the above example, the following program and track data achieves the same:

00 00 0000   set arpeggio note to 0 (the same note as played)
01 01 00F0   set arpeggio note to external arpeggio note 0 
02 02 00F1   set arpeggio note to external arpeggio note 1
03 03 FF00   jump back to step 00

And the track data:

C-4 00 .. .... 0047

Tip: If you want to play 2-note or 3-note chord, you can do it by checking "Multiosc." checkbox and having 00xy command in pattern. You don't need anything in instrument program then, and by inputting 0047 with C-4 note you will have C major chord. Filters, envelopes and other settings affect all three "subchannels" playing the chord.

By that you can use only 1 channel for pads and any other chords, which is veeery cool.

Tip: A handy way to debug instrument programs is to set the program period (execution speed) to 10 or more and then pay attention to the little marker that shows current program tick. That way you'll notice if e.g. a jump doesn't point to the correct command.

Combining commands

Use Space to combine the currently selected command with the command that is directly below it. This means klystrack sees the combined commands as one, meaning they are executed at the same time.

00 00 000C ╮   set arpeggio note to +12 semitones  (press Space here)
01    0918 ╯   set PW
02 01 0000 ╮   set arpeggio note to +0 semitones   (press Space here)  <--╮
03    0102 |   portamento up by (2 * 4)/256 semitones (press Space here)  |
04    0710 ╯   PW down by 10                                              |
05 02 FF02     jump to location 02 ---------------------------------------╯

Note how the second column doesn't follow the leftmost column as it did in the previous examples. This is because some of the commands are no longer executed separately. Also note that the jump is to the number in the leftmost column.

Envelope editor

https://github.com/LTVA1/klystrack/blob/master/envelope_editor.png

Works mostly like FastTracker II envelope editor but envelopes are running on sound engine rate (around 44 kHz), not on tracker rate (usually 50 or 60 Hz), thus they are much smoother.

Envelope points placement resolution is 1/100th of a second.

Each 4-op FM operator has an envelope identical to this one. Operator's envelope editors can be accessed in 4-op menu.

Enable envelope

Allows you to enable one of the envelopes. Note that enabling volume envelope overrides the ADSR envelope, and thus its parameters are no longer affecting the sound (except VOLUME).

Fadeout

When the release is triggered, the envelope starts to "fade" if fadeout number is higher than 0. The bigger the number is, the faster the envelope fades out. For volume envelope this means just the decrease in volume, for panning envelope this means that envelope is affecting the panning less and less.

Note: Panning envelope is "centered" around whatever panning you choose, so it is affected by channel default panning and 17xx, 18xx and 19xx commands executed both from instrument program and pattern.

Zoom

Allows you to zoom in or out for more convenient envelope editing.

Editor window

Click on the dot to select it. In upper right corner you will see the information about the point. Drag the point around to change its position.

Add, Delete

Add or delete the dot. If you select the last dot the new dot will be created with small offset to the right from selected dot. Otherwise it will be created at the center of the line between selected and next dot.

Sustain

Specifies the dot on which envelope will stop. It will continue its execution after release is triggered.

Loop

Specifies loop begin and loop end points. When envelope reaches loop end point it jumps to loop begin one.

Note: If sustain and loop are not used, envelope stops at last point.

4-op FM editor

https://github.com/LTVA1/klystrack/blob/master/4op_editor.png

You can open it by clicking "OPEN MENU" button next to 4-OP checkbox.

This is fully-functional 4-op FM synth akin to what you can find inside Sega MD/Genesis, PC-98, OPL3 (which has a special switches to combine 2 2-op channels to form 1 4-op channel). It also has additional capabilities described below.

4-op module is a self-sustained synth which means that it has no connection (except program and base note, see below) with main instrument. It means that you effectively have 4-op + 2-op FM synth on every channel.

Enable 3ch exp mode

Allows you to set an arbitrary frequency for each operator as in main instrument (base note + finetune). If disabled, instrument base note will be applied to all operators.

Algorithm

Lets you set one of 13 algorithms. In upper left corner of algorithm scheme window you will see hints about if some common 4-op FM capable chip has this algorithm.

Volume

Sets master volume for 4-op synth output. The master volume does not affect the shape of output, it just makes it louder or quieter.

Use instrument program

Allows you to rule all operators from main instrument program(s), so a lot of effects will change operators' corresponding parameters. If disabled, each operator can be controlled only from its respective program(s).

Bypass main instrument filter

Allows you to route 4OP FM signal around main instrument filter, so it does not affect how 4OP FM sounds. Useful if you want to e.g. combine classic C64 bass with lowpass filter cutoff sweep and some 4OP Genesis-style bass: if this option is selected, filter sweep would not affect FM part of the sound.

Algorithm scheme window

Lets you see how your operators are connected. By clicking on an operator's rectangle you select it and the whole editor starts showing its parameters. By default 1st operator is selected. If you set some feedback, a special contour will emerge on the scheme on top of selected operator. The brighter the contour is, the higher feedback value is.

Parameters

Most parameters are like in main instrument editor. Filter is individual for every operator and is applied before main instrument filter.

MUL, DT, DT2

Let you change the frequency of the operator. The left MUL number lets you divide the frequency, the right one multiplies it. DT shifts the pitch up or down by around 1 cent with each increment/decrement. DT2 shifts the pitch up by around several semitones for each increment (good for creating inharmonic sounds). If you enable 3ch exp mode, you will see base note and finetune settings there.

SSG-EG

Resembles classic SSG-EG from YM2612. The difference is that sustain level does not affect how it works -- it always swings the envelope between max volume ("TL") level and 0 volume, and attack rate is not accounted too, so you have only 2 controls: decay rate and operator volume. All 8 SSG-EG modes are implemented.

Trigger delay

Lets you delay a specific operator triggering. For example, if your song rate is 50 (default value), and you set this parameter to 3F (decimal: 63), than this particular operator will be triggered around 1.2 seconds later than general instrument trigger. Note that the operators' program execution will also start later by the same ~1.2 seconds.

CSM timer

When enabled, it cycles with frequency determined by note and finetune settings. Each cycle it resets phase of operator's waves (including wavetables/samples) and resets the operator's envelope: every time envelope is put into release phase and made to decay from highest volume (so, like with SSG-EG, the only way to control volume is operator volume parameter).

LOCK TO OP NOTE means that CSM timer frequency will depend on the note in pattern. E.g. if main instrument note (or FM op note in ch3 exp mode) is C-4 and CSM timer note is C-3 than if you play F-4 using this instrument the CSM timer will have F-3 frequency.

NOTE: if you will do some e.g. portamento after that trigger CSM timer note will not change, so if you want FM op and CSM timer frequencies to be synced you would need to do the exact same CSM timer portamento too.

Clone this wiki locally