Syntax Reference
Complete syntax reference for Relanote.
Comments
rela
; Single line commentLiterals
Intervals
rela
R ; Root (unison)
M2 ; Major second
m3 ; Minor third
A4 ; Augmented fourth
d5 ; Diminished fifth
P5+ ; Perfect fifth, octave up
M3- ; Major third, octave downAbsolute Pitches
Absolute pitch notation for specifying the key (root note):
rela
C4 ; Middle C (MIDI note 60)
D4 ; D above middle C
Bb3 ; B-flat below middle C
F#4 ; F-sharp above middle C
G3 ; G below middle CFormat: [Note][Accidental][Octave]
- Note: C, D, E, F, G, A, B
- Accidental (optional):
#(sharp) orb(flat) - Octave: 0-9 (4 is the middle C octave)
Numbers
rela
42 ; Integer
3.14 ; FloatStrings
rela
"Hello, World!"Booleans
rela
true
falseVariables
Let Binding
rela
let name = value
; With type annotation (optional)
let name: Type = valueSet Bindings
The set keyword is used for built-in configuration variables:
Key (Root Note)
rela
set key = C4 ; Root is middle C (default)
set key = Bb3 ; Root is B-flat below middle C
set key = G4 ; Root is G above middle CAll intervals are calculated relative to this pitch. If not specified, the default key is C4 (MIDI note 60).
Tempo
rela
set tempo = 120 ; 120 beats per minute (default)
set tempo = 80 ; Slower tempo
set tempo = 140 ; Faster tempoLet...In Expression
rela
let x = 10 in
x + 5 ; Returns 15Blocks
Basic Block
rela
| note1 note2 note3 |With Scale Degrees
rela
| <1> <2> <3> |With Rests
rela
| <1> - <3> |Note Duration
Individual notes, rests, and chords can have explicit durations using the :n syntax:
rela
| <1>:2 <2> <3> | ; First note is 2 slots long, others are 1 slot
| <1>:4 - - - | ; Note held for 4 slots
| <1>:2 -:2 <3>:2 | ; Each element is 2 slots
| [R, M3, P5]:4 | ; Chord held for 4 slotsThe number after : represents how many "slots" the note occupies. Within a block, all slots share the block's total duration equally. So :2 means the note takes twice as long as a normal slot.
Examples:
rela
; Half notes and quarter notes
| <1>:2 <2>:2 | ; Two half notes
; Dotted rhythm
| <1>:3 <2> | ; Dotted quarter + eighth
; Whole note
| <1>:4 | ; One whole note (4 slots worth)
; With articulations
| <1>^:2 <2>*:2 | ; Accented half note, staccato half noteScale and Chord
Scale Definition
rela
scale Major = { R, M2, M3, P4, P5, M6, M7 }Chord Definition
rela
chord MajorTriad = [ R, M3, P5 ]Functions
Lambda Expression
rela
\x -> x + 1
\x, y -> x + yFunction Application
rela
f(x)
f(x, y)Pipe Operator
rela
x |> f ; Same as f(x)
x |> f |> g ; Same as g(f(x))Function Composition
rela
f >> g ; Same as \x -> g(f(x))Control Flow
If Expression
rela
if condition then
true_expr
else
false_exprMatch Expression
rela
match value with
| pattern1 -> result1
| pattern2 -> result2
| _ -> defaultOperators
Arithmetic
rela
a + b ; Addition
a - b ; Subtraction
a * b ; Multiplication
a / b ; DivisionComparison
rela
a == b ; Equal
a != b ; Not equal
a < b ; Less than
a > b ; Greater than
a <= b ; Less or equal
a >= b ; Greater or equalLogical
rela
a and b
a or b
not aBlock Operations
rela
a ++ b ; ConcatenationArticulations
rela
<1>' ; Staccato
<1>^ ; AccentSynth Definition
Basic Synth
rela
synth MyLead = {
osc: Saw,
env: { A: 0.02, D: 0.15, S: 0.7, R: 0.2 },
filter: LowPass(3000, 0.3)
}Synth Properties
| Property | Values | Description |
|---|---|---|
osc | Sine, Square, Saw, Triangle, Noise | Oscillator waveform |
env | { A: s, D: s, S: level, R: s } | ADSR envelope |
filter | LowPass, HighPass, BandPass | Filter type with cutoff and Q |
detune | number (cents) | Oscillator detune |
Filter Types
rela
LowPass(cutoff_hz, resonance)
HighPass(cutoff_hz, resonance)
BandPass(cutoff_hz, resonance)Built-in Functions
Block Transformations
rela
melody |> reverse ; Reverse the block
melody |> transpose P5 ; Transpose by interval
melody |> repeat 2 ; Repeat n times
melody |> map (\n -> n + P8) ; Transform each noteSynth Functions
rela
melody |> voice Lead ; Apply synth preset
melody |> cutoff 1000 ; Set filter cutoff (Hz)
melody |> resonance 0.5 ; Set filter resonance (0-1)
melody |> detune 10 ; Set detune (cents)
melody |> adsr 0.1 0.2 0.7 0.3 ; Set envelopeSynth Presets
Classic:
Lead- Bright sawtooth leadSoftPad- Warm sustained padFatBass- Thick detuned bassPluck- Short attack pluckStrings- Slow attack stringsOrgan- Harmonic sine organ
8-bit:
Chiptune- Classic square waveChip8bit- Pure square, fast decayNES- Nintendo-style soundGameBoy- Narrow pulse wave
Drums:
Kick- Kick drumSnare- Snare drumHiHat- Closed hi-hatOpenHat- Open hi-hatTom- Tom drumClap- Hand clap