skode
Skode / “ands”: a typed model of the Skred command language.
Follows the C lexer (parts/ands.c in octetta/pulp), not just the output of any one converter:
- atoms are letters plus ! % ^ * _ = : “ ’ < > ? / \ |
; numbers are [-.0-9]+, sov0w1f440is three commands and440 fworks likef440` ,is whitespace;;, newline and EOT end a chunk[text]strings,( ... )float arrays with sentinels,$N&N@N#comments run to the end of the chunk (so;ends one)+n/~ndefer the rest of the chunk (beats / seconds, negative = ticks); blanks between the sigil and its amount are accepted (seedefer_blanks)[name]: body;macro definitions (text substitution happens at runtime, so a macro call is just an atom here) Commands run “one step behind”: an atom takes every number up to the next atom (at most 8), plus numbers that came before it if nothing was pending.
Not modelled: macro expansion and $$N, the C parser’s persistent
string/array buffers beyond what was parsed since a command last fired,
and anything the engine does with a command once it is dispatched.
Types
One chunk: what ends at ;, a newline or EOT. A comment is always last.
pub type Chunk {
Chunk(ops: List(Op), remark: option.Option(String))
}
Constructors
-
Chunk(ops: List(Op), remark: option.Option(String))
pub type Command {
Command(
atom: String,
args: List(Arg),
array: option.Option(List(Arg)),
string: option.Option(String),
)
}
Constructors
-
Command( atom: String, args: List(Arg), array: option.Option(List(Arg)), string: option.Option(String), )
+ is beats, ~ is seconds. A negative amount means ticks (tempo steps).
pub type DeferMode {
Beats
Seconds
}
Constructors
-
Beats -
Seconds
pub type Num {
Value(Float)
Rest
Tie
}
Constructors
-
Value(Float) -
Restlone
-e-----: plain NaN, “keep the existing value” / rest -
Tielone
._.....__: NaN with payload 0x7FF8000000000001, a tie
pub type Op {
Voice(Int)
Note(midi: Int, cents: option.Option(Float))
MasterVolume(db: Float)
Freq(Float)
Amp(db: Float)
Level(Float)
Pan(Float)
Wave(Int)
Mode(Int)
Loop(Bool)
Bend(Float)
BendRange(Int)
Glide(time: Float, curve: option.Option(Int))
Slew(time: Float, curve: option.Option(Int))
Detune(wave: Int, cents: Float)
SampleWindow(option.Option(#(Int, Int)))
WaveLoop(wave: Int, start: Int, end: Int)
Pattern(Int)
MasterPattern(Int)
PatternSpeed(Int)
Run(Bool)
QueueStart(Bool)
ClockSpeed(Int)
Ratchet(Int)
Goto(Int)
Clock(bpm: Int, subdivision: Int)
EmitEvent(Int)
Step(ops: List(Op), at: Int)
OnEvent(ops: List(Op), id: Int)
Puts(String)
LoadWave(path: String, id: Int)
NameWave(name: String, id: Int)
Defer(mode: DeferMode, amount: Arg, body: List(Op))
MacroDef(name: String, body: String)
Stray(List(Arg))
Generic(Command)
}
Constructors
-
Voice(Int) -
Note(midi: Int, cents: option.Option(Float)) -
MasterVolume(db: Float) -
Freq(Float) -
Amp(db: Float) -
Level(Float) -
Pan(Float) -
Wave(Int) -
Mode(Int) -
Loop(Bool) -
Bend(Float) -
BendRange(Int) -
Glide(time: Float, curve: option.Option(Int)) -
Slew(time: Float, curve: option.Option(Int)) -
Detune(wave: Int, cents: Float) -
SampleWindow(option.Option(#(Int, Int))) -
WaveLoop(wave: Int, start: Int, end: Int) -
Pattern(Int) -
MasterPattern(Int) -
PatternSpeed(Int) -
Run(Bool) -
QueueStart(Bool) -
ClockSpeed(Int) -
Ratchet(Int) -
Goto(Int) -
Clock(bpm: Int, subdivision: Int) -
EmitEvent(Int) -
Step(ops: List(Op), at: Int)[ops] x12 -
OnEvent(ops: List(Op), id: Int)[ops] e>3 -
Puts(String) -
LoadWave(path: String, id: Int) -
NameWave(name: String, id: Int) -
+4 rest-of-chunk; consecutive defers in one chunk accumulate in the engine -
MacroDef(name: String, body: String) -
Stray(List(Arg))numbers with no command to take them (the C parser drops these)
-
Generic(Command)any other atom, or a known atom with sentinel/variable/odd arguments
Values
pub fn arg_to_string(a: Arg) -> String
pub fn chunk_to_string(c: Chunk) -> String
pub const defer_blanks: Bool
Whether + 4 v0 / ~ 1.5 f 440 (blanks between the sigil and its amount)
read as the guide documents them. This matches the fixed C parser
(ands-defer-space.patch). Set it to False to preview against an engine
build that predates the fix, where such a defer is a zero delay whose body
starts with the number.
pub fn generic_atoms(ops: List(Op)) -> List(String)
Atoms the typed layer doesn’t know (still valid, still sent as typed).
pub fn op_to_string(op: Op) -> String
pub fn ops_to_string(ops: List(Op)) -> String
A defer swallows the rest of its chunk, so an op list that puts anything after a Defer will not read back the same. Parsed chunks never do.
pub fn parse_ops(src: String) -> List(Op)
All ops of a program, chunk boundaries and comments dropped.
pub fn parse_program(src: String) -> List(Chunk)
pub fn program_to_string(chunks: List(Chunk)) -> String
pub const pulp_version: String
Upstream Pulp / Skred audio engine release version this AST aligns with.