Built-in Functions Reference
Complete reference for Relanote's built-in functions.
Block Transformations
reverse
Reverses the order of notes in a block.
reverse : Block -> Block
| <1> <2> <3> | |> reverse
; Result: | <3> <2> <1> |transpose
Shifts all notes by a given interval.
transpose : Interval -> Block -> Block
| <1> <3> <5> | |> transpose P5
; All notes shifted up by a perfect fifth
| <1> <3> <5> | |> transpose (R - P8)
; Transpose down an octave (use parentheses for expressions)repeat
Repeats a block n times.
repeat : Int -> Block -> Block
| <1> <2> | |> repeat 3
; Result: | <1> <2> <1> <2> <1> <2> |Synth Functions
voice
Applies a synth preset or custom synth to a block.
voice : Synth -> Block -> Part
| <1> <3> <5> | |> voice Lead
| <1> <3> <5> | |> voice Chiptune
| <1> <3> <5> | |> voice MyCustomSynthcutoff
Sets the filter cutoff frequency in Hz.
cutoff : Float -> Part -> Part
melody |> voice Lead |> cutoff 800 ; Dark sound
melody |> voice Lead |> cutoff 4000 ; Bright soundresonance
Sets the filter resonance (Q factor).
resonance : Float -> Part -> Part
melody |> voice Lead |> resonance 0.3 ; Subtle
melody |> voice Lead |> resonance 0.8 ; Resonant peakRange: 0.0 to 1.0
detune
Detunes the oscillators in cents.
detune : Float -> Part -> Part
melody |> voice Lead |> detune 10 ; Slight thickening
melody |> voice Lead |> detune 50 ; Heavy chorus effectadsr
Sets the ADSR envelope (Attack, Decay, Sustain, Release).
adsr : Float -> Float -> Float -> Float -> Part -> Part
; adsr attack decay sustain release
melody |> voice Lead |> adsr 0.01 0.1 0.7 0.3 ; Quick attack
melody |> voice Lead |> adsr 0.5 0.2 0.8 1.0 ; Slow padParameters:
- Attack: Time in seconds to reach peak volume
- Decay: Time in seconds to reach sustain level
- Sustain: Volume level during sustain (0.0 - 1.0)
- Release: Time in seconds to fade after note off
env
Creates an ADSR envelope value for use in synth definitions.
env : Float -> Float -> Float -> Float -> ADSR
let myEnv = env 0.1 0.2 0.7 0.4Oscillator Constructors
Oscillators generate the raw waveform for a synth. Use these when defining custom synths.
Sine
Pure sine wave - smooth, fundamental tone.
Sine : Oscillator
synth Pad = {
osc: Sine,
env: { A: 0.3, D: 0.1, S: 0.8, R: 0.5 }
}Saw
Sawtooth wave - bright, rich harmonics. Classic lead sound.
Saw : Oscillator
synth BrightLead = {
osc: Saw,
env: { A: 0.02, D: 0.1, S: 0.6, R: 0.2 }
}Square
Square wave - hollow, woody tone. Classic chiptune sound.
Square : Oscillator
synth Retro = {
osc: Square,
env: { A: 0.01, D: 0.1, S: 0.5, R: 0.1 }
}Triangle
Triangle wave - softer than square, flute-like.
Triangle : Oscillator
synth Soft = {
osc: Triangle,
env: { A: 0.1, D: 0.2, S: 0.7, R: 0.3 }
}Pulse
Pulse wave with variable duty cycle (0.0 - 1.0). Creates different timbres.
Pulse : Float -> Oscillator
synth NES = {
osc: Pulse 0.25, ; 25% duty cycle
env: { A: 0.01, D: 0.05, S: 0.4, R: 0.1 }
}Noise
White noise - used for drums, percussion, and effects.
Noise : Oscillator
synth Snare = {
osc: Noise,
env: { A: 0.001, D: 0.1, S: 0.0, R: 0.1 }
}Filter Constructors
Filters shape the harmonic content of a sound. Use these when defining custom synths.
LowPass
Low-pass filter - removes high frequencies. Makes sound darker/warmer.
LowPass : Float -> Float -> Filter
; LowPass cutoff_hz resonance
synth Warm = {
osc: Saw,
filter: LowPass 800 0.3,
env: { A: 0.1, D: 0.2, S: 0.6, R: 0.3 }
}HighPass
High-pass filter - removes low frequencies. Makes sound thinner/brighter.
HighPass : Float -> Float -> Filter
; HighPass cutoff_hz resonance
synth Thin = {
osc: Saw,
filter: HighPass 500 0.2,
env: { A: 0.05, D: 0.1, S: 0.7, R: 0.2 }
}BandPass
Band-pass filter - keeps only frequencies around the cutoff. Creates nasal, focused sound.
BandPass : Float -> Float -> Filter
; BandPass center_hz resonance
synth Telephone = {
osc: Saw,
filter: BandPass 1000 0.8,
env: { A: 0.02, D: 0.1, S: 0.5, R: 0.2 }
}Effect Functions
reverb
Applies reverb effect.
reverb : Float -> Block -> Part
melody |> reverb 0.5 ; 50% wetRange: 0.0 (dry) to 1.0 (fully wet)
hall_reverb
Applies hall-style reverb preset.
hall_reverb : Block -> Part
melody |> hall_reverbroom_reverb
Applies room-style reverb preset.
room_reverb : Block -> Part
melody |> room_reverbplate_reverb
Applies plate-style reverb preset.
plate_reverb : Block -> Part
melody |> plate_reverbdry
Creates a dry (no reverb) part.
dry : Block -> Part
melody |> dryvolume
Sets the volume level.
volume : Float -> Block -> Part
volume : Float -> Part -> Part
melody |> volume 0.8 ; 80% volume
melody |> voice Lead |> volume 0.5 ; Chain with synthRange: 0.0 (silent) to 1.0 (full volume)
Rhythm Functions
swing
Applies swing feel to a block.
swing : Block -> Block
| <1> <2> <3> <4> | |> swingdouble_time
Doubles the tempo (halves note durations).
double_time : Block -> Block
| <1> <2> <3> <4> | |> double_timemetronome
Creates a metronome click track.
metronome : Int -> Int -> Block
metronome 4 4 ; 4 beats, 4 barsComposition Functions
compose
Combines sections into a song.
compose : [Section] -> Song
compose [intro, verse, chorus, verse, chorus, outro]play
Adds a block to an existing part.
play : Block -> Part -> Part
part |> play newMelodyArray Functions
take
Takes the first n elements from an array.
take : Int -> [a] -> [a]
[1, 2, 3, 4, 5] |> take 3
; Result: [1, 2, 3]drop
Drops the first n elements from an array.
drop : Int -> [a] -> [a]
[1, 2, 3, 4, 5] |> drop 2
; Result: [3, 4, 5]zip
Combines two arrays into an array of tuples.
zip : [a] -> [b] -> [(a, b)]
zip [1, 2, 3] ["a", "b", "c"]
; Result: [(1, "a"), (2, "b"), (3, "c")]concat
Concatenates two arrays.
concat : [a] -> [a] -> [a]
concat [1, 2] [3, 4]
; Result: [1, 2, 3, 4]len
Returns the length of an array or string.
len : [a] -> Int
len : String -> Int
len [1, 2, 3]
; Result: 3
len "hello"
; Result: 5foldl
Left fold - accumulates from left to right.
foldl : (a -> b -> a) -> a -> [b] -> a
; foldl f z [a,b,c] = f (f (f z a) b) c
foldl (\acc x -> acc + x) 0 [1, 2, 3, 4]
; Result: 10foldr
Right fold - accumulates from right to left.
foldr : (a -> b -> b) -> b -> [a] -> b
; foldr f z [a,b,c] = f a (f b (f c z))
foldr (\x acc -> x :: acc) [] [1, 2, 3]
; Result: [1, 2, 3]map
Transforms each element of an array.
map : (a -> b) -> [a] -> [b]
map (\x -> x * 2) [1, 2, 3]
; Result: [2, 4, 6]filter
Keeps elements matching a predicate.
filter : (a -> Bool) -> [a] -> [a]
filter (\x -> x > 2) [1, 2, 3, 4]
; Result: [3, 4]flatMap
Maps a function over an array and flattens the result.
flatMap : (a -> [b]) -> [a] -> [b]
flatMap (\x -> [x, x * 2]) [1, 2, 3]
; Result: [1, 2, 2, 4, 3, 6]find
Returns the first element matching a predicate, or Unit if not found.
find : (a -> Bool) -> [a] -> a | Unit
find (\x -> x > 2) [1, 2, 3, 4]
; Result: 3any
Checks if any element satisfies a predicate.
any : (a -> Bool) -> [a] -> Bool
any (\x -> x > 3) [1, 2, 3, 4]
; Result: true
any (\x -> x > 5) [1, 2, 3, 4]
; Result: falseall
Checks if all elements satisfy a predicate.
all : (a -> Bool) -> [a] -> Bool
all (\x -> x > 0) [1, 2, 3, 4]
; Result: true
all (\x -> x > 2) [1, 2, 3, 4]
; Result: falseSynth Presets Reference
Classic Synths
| Name | Description | Best for |
|---|---|---|
Lead | Bright sawtooth | Melodies, solos |
SoftPad | Warm sustained | Chords, atmosphere |
FatBass | Thick detuned | Bass lines |
Pluck | Short attack | Arpeggios, staccato |
Strings | Slow attack | Pads, swells |
Organ | Harmonic sines | Keys, chords |
8-bit Synths
| Name | Description | Best for |
|---|---|---|
Chiptune | Classic square | Retro melodies |
Chip8bit | Pure square | Beeps, blips |
NES | Nintendo style | Game music |
GameBoy | Narrow pulse | Lo-fi sounds |
Drum Synths
| Name | Description | Best for |
|---|---|---|
Kick | Synthesized kick | Bass drum |
Snare | Noise + tone | Backbeat |
HiHat | Filtered noise | Rhythm |
OpenHat | Longer decay | Accents |
Tom | Pitched drum | Fills |
Clap | Hand clap | Accents |
Practical Examples
Creating a Complete Track
scale Major = { R, M2, M3, P4, P5, M6, M7 }
; Melody with synth and effects
let melody = | <1> <3> <5> <8> |
|> transpose P5
|> voice Lead
|> cutoff 2000
|> reverb 0.3
; Bass line with custom envelope
let bass = | <1>:2 <5>:2 |
|> repeat 4
|> voice FatBass
|> adsr 0.02 0.1 0.8 0.2
|> volume 0.9
; Chiptune arpeggio
let arp = | <1> <3> <5> <3> |
|> double_time
|> voice Chiptune
|> volume 0.6
layer [melody, bass, arp]Using Map for Algorithmic Composition
scale Minor = { R, M2, m3, P4, P5, m6, m7 }
; Generate a sequence of intervals
let intervals = [P1, M3, P5, M7, P8]
; Map to create variations
let melody = intervals
|> map (\i -> i + M2) ; Transpose each up a step
; Transform a block note by note
let pattern = | <1> <2> <3> <4> |
let octave_up = pattern |> map (\n -> n + P8)Building Reusable Transformations
scale Major = { R, M2, M3, P4, P5, M6, M7 }
; Compose transformations
let jazz_up = transpose P5 >> swing >> reverb 0.4
let thicken = voice FatBass >> detune 15 >> volume 0.8
; Apply to different parts
let melody = | <1> <3> <5> <3> | |> jazz_up
let bass = | <1> <5> | |> thickenSwing and Rhythm
scale Blues = { R, m3, P4, A4, P5, m7 }
; Straight rhythm
let straight = | <1> <3> <4> <5> <3> <1> - - |
; Apply swing for jazz feel
let swung = straight |> swing
; Double time for energy
let fast = straight |> double_time
swung |> voice Lead |> reverb 0.3Custom Synth Definition
scale Major = { R, M2, M3, P4, P5, M6, M7 }
; Define a warm pad synth
synth WarmPad = {
osc: Saw,
filter: LowPass 1200 0.4,
env: { A: 0.4, D: 0.2, S: 0.7, R: 0.8 },
detune: 8
}
; Define a plucky bass
synth PluckBass = {
osc: Square,
filter: LowPass 600 0.6,
env: { A: 0.01, D: 0.3, S: 0.0, R: 0.2 }
}
let chords = | [R, M3, P5] [P4, M6, R] |
|> voice WarmPad
|> volume 0.7
let bass = | <1>:2 <5>:2 |
|> voice PluckBass
|> volume 0.9
layer [chords, bass]