The specification document is in an early drafting phase.
Kunquat, the Specification
State Machine
Kunquat audio rendering is based around a state machine and three factors: initialisation set used to initialise the machine, audio rate used to control resolution of the execution, and a stream of commands that is used to request audio from and to interact with the state machine.
The state machine is initialised with a set of key/value pairs that define available audio units (i.e. instrument and effects) and a connection graph that connects the instruments through various effects to a stereo output. The initialisation data may also contain an album of songs described as note data that can be used to control the audio units without human intervention.
In addition to providing an initialisation set, the user needs to select an audio rate. The audio rate affects the resolution at which the audio rendering and event processing are done. A higher audio rate produces a more accurate estimation of the sound described by the parameters and make it possible to interact with the state machine more tightly. Specifying a lower audio rate reduces the amount of computation required.
Once the state machine has been initialised, the operation proceeds by feeding commands to the state machine. The possible commands are:
render
- Produce a chunk of audio data together with information of any events that were processed during the rendering of the audio chunk.
fire
- Feed external events into the state machine.
get_events
-
Retrieve a set of events that were processed during the last call of
render
orfire
.
Event
The events fired by the state machine contain one or zero parameters. Firing an event modifies the internal state of the state machine.
Trigger
Triggers are used for launching events in an automated fashion. A trigger consists of an event name and an expression. Processing a trigger includes evaluating the expression and launching an event with the value of the expression as a parameter.
Channel
Channels are numbers used for addressing audio unit controls. At any given time a channel has one or zero selected note outputs and one or zero active audio units. Some channel events affect the audio unit either directly or through the selected note output.
Environment
Environment is a variable space that can be used to parameterise parts of the automated playback.
Connection Graph
Connection graph connects instruments through effects into master output.
Randomness
Kunquat composition defines a global random seed that is used to initialise random number generators for various contexts at the start of playback.
Initialisation Set
kqtc00/p_composition.json kqtc00/p_connections.json kqtc00/p_random_seed.json
Album Description
kqtc00/album/p_manifest.json kqtc00/album/p_tracks.json
Audio Unit Description
kqtc00/au_00/hit_00/p_hit_proc_filter.json kqtc00/au_00/hit_00/p_manifest.json kqtc00/au_00/p_connections.json kqtc00/au_00/p_expressions.json kqtc00/au_00/p_manifest.json kqtc00/au_00/p_streams.json
Processor Description
kqtc00/au_00/proc_00/c/mod_00/p_f_pitch.json kqtc00/au_00/proc_00/c/mod_00/p_f_volume.json kqtc00/au_00/proc_00/c/p_base.wav kqtc00/au_00/proc_00/c/p_hm_hit_map.json kqtc00/au_00/proc_00/c/p_nm_note_map.json kqtc00/au_00/proc_00/c/smp_000/p_sh_sample.json kqtc00/au_00/proc_00/c/smp_000/p_sample.wv kqtc00/au_00/proc_00/c/tone_00/p_f_pan.json kqtc00/au_00/proc_00/c/tone_00/p_f_pitch.json kqtc00/au_00/proc_00/c/tone_00/p_f_volume.json kqtc00/au_00/proc_00/p_manifest.json
Pattern Description
kqtc00/pat_000/col_00/p_triggers.json kqtc00/pat_000/instance_000/p_manifest.json kqtc00/pat_000/p_length.json kqtc00/pat_000/p_manifest.json
Tuning Table Description
kqtc00/tuning_00/p_tuning_table.json
Song Description
kqtc00/song_00/p_manifest.json kqtc00/song_00/p_order_list.json kqtc00/song_00/p_tempo.json
Events
The events are categorised based on their scope and intended use.
About Slide Events
Some parameters in the playback state can be controlled with slides. Such parameters include note force and pitch, among others. Most slides are specified with a slide target event (denoted by forward slash ‘/’ in the event name) and a slide length event (denoted by forward slash and equals sign ‘/=’ in the event name). Oscillation parameter changes are always performed with slides (with slide length of 0 by default), even though their slide target events are not named with the forward slash.
The slide target event starts the slide progress from the current parameter value to the target value. The slide is initialised with the length specified by the latest corresponding slide length event, or length 0 if no length has been specified. However, it is also possible to specify the slide length after the slide target in the same trigger row. If a slide length is updated while the slide is in progress, the remaining part of the slide will have the length specified by the new slide length event.
All slides are linear in the scale in which they are documented. For example, when a force value is slid from 0 to -6 dBFS, the active force will be -3 dBFS exactly halfway through the slide. Note, however, that tempo adjustments affect the speeds of all slides, since the slide lengths are specified in timestamps.
Triggers for Name/Value Pair Control
Several events (stream, environment variable and device events) control values that are specified with a name setting event (e.g. ‘.s’ modifies a stream whose name is specified with ‘.sn’). For these event pairs, triggers support syntactic sugar of the form [.s:foo x] that is equivalent to triggers [.sn 'foo'] [.s x].
Control Events
Control events are used for controlling generic playback-related behaviour. They are mostly intended to be used by editors and, to certain extent, interactive compositions. Most control events may cause infinite loops in compositions; therefore, control events specified in triggers are ignored by default.
cpause |
|
---|---|
cresume |
|
cpattern |
|
c.gp |
|
c.gr |
|
cg |
|
cinfinite+ |
|
cinfinite- |
|
c.evn |
|
c.ev |
|
General Events
# Do nothing with string value x ? Event_general_cond ?if Event_general_if ?else Event_general_else ?end Event_general_end_if calln Do nothing with string value x call Do nothing with any value x
Master Events
mpd |
|
---|---|
m.jc |
|
m.jp |
|
m.jr |
|
mj |
|
m.t |
|
m/t |
|
m/=t |
|
m.v |
|
m/v |
|
m/=v |
|
m.r |
|
m.rfp |
|
m.rc |
|
m.ro |
|
mmr |
|
m<r |
|
Channel Events
.a |
|
---|---|
n+ |
|
h |
|
n- |
|
.f |
|
/f |
|
/=f |
|
ts |
|
td |
|
t/=s |
|
t/=d |
|
->f+ |
|
->f- |
|
/p |
|
/=p |
|
vs |
|
vd |
|
v/=s |
|
v/=d |
|
->p+ |
|
->p- |
|
.sn |
|
.s |
|
/s |
|
/=s |
|
os |
|
od |
|
o/=s |
|
o/=d |
|
->s+ |
|
->s- |
|
.xc |
|
.x |
|
->x+ |
|
->x- |
|
.dn |
|
d |
|
Audio Unit Events
abp+ |
|
---|---|
abp- |
|
a.s |
|
a/s |
|
a/=s |
|
aos |
|
aod |
|
ao/=s |
|
ao/=d |
|
ad |
|
a.sus |
|
Query Events
Query events are used to request information from the rendering engine.
qlocation Force generation of events Atrack, Asystem and Arow qvoices Force generation of event Avoices qf Force generation of event Af.
Auto Events
Auto events fired with the fire command are ignored. The rendering engine creates auto events to report updates in the playback status.
Atrack Do nothing with the current track number x. Asystem Do nothing with the current system number x. Arow Do nothing with the current pattern location timestamp x. Avoices Do nothing with the current active voice count x. Af Do nothing with the current actual force x of an active note.
Appendix A: Module Format
The save feature in Kunquat Tracker stores initialization sets in zip files. Such saved files are called Kunquat modules. The keys of the initialization set are presented as file paths in the zip file and the values are stored as contents of the corresponding files. In addition to the values required for playback, the tracker extends the initialisation set with some metadata. See Appendix B for description of the metadata.
Appendix B: Metadata and Interface Data
kqtc00/au_00/m_name.json contains the name of the audio unit kqtc00/m_authors.json kqtc00/m_title.json kqtc00/i_grid_enabled.json kqtc00/i_grid_patterns.json kqtc00/pat_000/i_base_grid.json kqtc00/pat_000/col_00/i_overlay_grids.json
Appendix C: Rendering Limitations
It is often desirable to specify limitations for rendering software. While implementing Kunquat, we have specified such limits for the amount of polyphony, the amount of active jump counters, the amount of nested ifs, the resolution of tempo slides, and the number of unconditional jumps performed without rendering audio between the jumps.
Appendix D: Editing Behaviour
Editors may wish to change the initialization set during rendering. This may cause the rendered sound to differ from the specified outcome during editing. In many cases this could be reasonable trade-off as working with an editor is largely about modifying the initialization set.