Valis: Guide for Agents

This document tells an AI agent how to build and modify instruments and effects processors in Valis using the MCP interface. Read it before calling any tools.

The server also offers this guide and every example as resources, so you can read them without access to the repository: valis://guide, valis://circuits (an index saying what each one is) and valis://circuits/NAME, such as valis://circuits/basic.

Three other files are worth knowing about, and none of them is a substitute for asking the running program:

Quick start

  1. Confirm the circuit is loaded and compiled:

    tools/call  get_diagnostics
    

    If it cannot connect, the server is off. It binds to 127.0.0.1 on port 7676 (VALIS_MCP_PORT changes that) and is enabled from Settings in the plugin. With several instances loaded, each takes the next free port above that, and /health names the one that answered: see the MCP manual.

  2. Read the current circuit and the available element types:

    resources/read  valis://turtle
    resources/read  valis://element-types
    resources/read  valis://circuits        (to choose a starting point)
    
  3. Inspect the graph before making changes:

    tools/call  get_graph
    
  4. Build or modify, then check the result with get_diagnostics and lint, and then listen to it (see Hearing a circuit).

The tools

tool what it does
get_turtle, set_turtle, validate read the circuit's source, replace it, or check source without installing it
load_file, save_file read a Turtle file from disk into the circuit, or write the circuit to one
list_element_types every element class with its ports, ranges and units
describe_element one class in full: what it is for, every port with its range, unit, choices and description, and the options it takes
get_graph the circuit as JSON: elements, properties, arcs
add_node, remove_node add an element by class, or remove one and its arcs
connect, disconnect join or separate two ports
apply_edits several of those four as one: all take effect or none do, installed once
history, undo, redo the versions the circuit has had, and going back and forward over them
diff what changed between two versions, in plain sentences
list_params, get_param, set_param the host parameter bindings, and their live values
morph move every parameter that has two stored ends between them
randomize give the parameters new random values from a seed
get_sample, set_sample the file a player or model element is using, and a different one
get_diagnostics whether the circuit loaded, its size and latency, and problems: what an element recovered from
lint static checks for things that compile and still do not do what was meant
check_stability run the circuit with random settings of its knobs, all jumping at once, and report any that blow up
get_profile what the circuit says it is: its role, signals and cautions
note_on, note_off, all_notes_off play the circuit as a keyboard would
read_outputs the live value of every control output, or one node's
fit_modes turn a recording of a struck bell or drum into the modes of a val:FreeModalBank; returns a val:modes string and a line of Turtle
fit_params search the circuit's parameters for the settings that sound nearest a recording; reports the values, changes nothing
render render the circuit offline to a wav file; reports peak, RMS and a full analysis
measure measure any wav file: pitch, octave levels, brightness, onsets, clipping, loudness (LUFS, true peak), attack and decay times
compare how far apart two wav files are, in dB, and how their loudness differs
sounds_like is this file "a trumpet"? yes, maybe or no, and what it is closest to (needs the neural models)
freesound_search search freesound.org (CC0 by default) for sounds: id, name, author, licence, length, tags. Needs FREESOUND_API_KEY in .env
read_song read a val:Song file (tempo, sections, parts, returns, mix table) and list problems such as a missing circuit or MIDI file; see docs/songs.md
render_song render the stems of a song file: each part is its circuit played by its MIDI file at the song's tempo, each return is its source stem through the return's circuit; writes wavs/<stem>.wav. Private copies of the circuits, so the live one is untouched
score_song play a song's score (patterns of steps, chords, a feel per part, a plan) into a MIDI file for each part it plays; the same score gives the same notes every time
check_stems compare a song's rendered stems with its MIDI files bar by bar: silence where there are notes, clipping, non-finite samples, an empty MIDI file; run it before mix_song
reaper_project write a Reaper project from a song file: a track per rendered stem with the mix's volume and pan, and the song's tempo and meter; never replaces one that exists
mix_song mix a song's stems to mixes/<title>-<version>.wav: levelled, panned, optional per-section levels, fade, room, soft clip, and the song's loudness target. Never replaces an existing version
freesound_download fetch a sound by id into audio/freesound/ as an Ogg preview with a .json naming author and licence; returns the path for a val:Sampler
listen AudioSet labels for a file, and a score for each sentence you give (needs the neural models)

A failed edit leaves the previous circuit playing. Every edit goes through the same validation as a typed one.

Concepts

Elements and arcs

A circuit is a set of elements (nodes) joined by arcs (edges). Elements are typed: val:Oscillator, val:Ladder, val:VCA and so on. An arc connects a named output port on one element to a named input port on another.

Every element class, with its port symbols, value ranges and units, is declared in the ontology. Always call list_element_types or read valis://element-types before wiring ports. Symbol names are exact and case-sensitive.

list_element_types is the whole catalogue and says little about each entry. When you are about to use an element you do not know, call describe_element with its name (val:Ladder, Ladder or ladder). It returns what the element is for and how to wire it, in the ontology's own words; every port with its default, range, unit and named choices; and the options it takes besides its ports. A misspelt name comes back with the nearest real ones.

Four kinds of port

kind carries arc
audio a signal at the sample rate val:Arc
control one value per 32-sample block val:ControlArc
event notes and other timed events, sent to the host none; the element sends them itself
buffer material one element owns and another reads val:Arc between two buffer ports

Use audio ports ("in", "out", "left", "right") with val:Arc and control ports ("frequency", "cv", "cutoff") with val:ControlArc. The connect tool works out which kind an arc is from the ports, so you do not say. A buffer output joins only a buffer input; an input takes one source and an output can feed any number of inputs. list_element_types names each port's kind in rate.

Control arcs replace, they do not add

A control arc overwrites the destination port's value every block. If a val:ControlArc targets val:Ladder.cutoff, any fixed val:cutoff set on the Ladder instance is ignored while the arc is connected.

Consequence: the resting value of a controlled port must live in the control source, not on the element. For a filter sweep, put the base cutoff in val:Scale.min and the peak in val:Scale.max, then route Envelope → Scale → Ladder.cutoff. Do not set val:cutoff directly on the Ladder when an arc reaches that port.

Options

Some properties are not ports. A file name (val:file), a pattern (val:pattern on a val:StepSequencer), a tuning file (val:tuning) and a buffer length (val:seconds) are options, set on the element in the Turtle. An option that cannot be applied, such as a file that does not exist, fails the load with a message naming the element and the option. list_element_types shows ports only; describe_element lists the options an element takes, with what each means.

A relative file path is looked up in the working directory, then in circuits/, then in the repository root.

Parameters

A val:Param binding exposes an element's property as a host parameter knob. Up to 64 slots (0 to 63) are available. Slots do not need to be contiguous. list_params shows which are bound; set_param changes a value in real time. Give a binding a lv2:minimum and lv2:maximum when the element's own range is wider than a knob should be.

A binding that also declares val:valueA and val:valueB takes part in morph: position 0 sets it to A, position 1 to B, and in between to the straight-line blend, so one call moves every such knob at once.

Node IDs

Every node has a full IRI, such as urn:valis:basic#vcf. The local prefix is the circuit's base IRI. Use exact IRIs when calling add_node, connect, disconnect and remove_node. Class names are written val:Ladder.

Time and the host

Anything that depends on musical time reads the host's position, so a circuit stays in time when the host loops or relocates. val:Transport gives phase and pulse signals, and val:StepSequencer plays a pattern against the position. When the host is stopped they run on their own at the last tempo it reported. valis-render --tempo 130 --rolling gives an offline render a playing host.

Stereo

val:Input has out (the channels summed), left and right. val:Output has in (both channels) and left and right. Elements are mono, so a stereo circuit is two chains. A val:Subcircuit written once and instantiated per channel is the tidy way; see circuits/subcircuit.ttl.

Workflow

Build from scratch

  1. Start from the closest example if there is one: load_file with a path under circuits/, then change it.

  2. Otherwise call set_turtle with a complete, valid Turtle document. This is the fastest path when you have a clear design in mind. Use validate first to check it without installing. A circuit needs exactly one val:Output.

  3. To extend a circuit that is loaded without rewriting it, send the edits together in one apply_edits call (see Several edits at once):

    get_graph          → read current nodes and arcs
    apply_edits        → add the new elements and wire them
    set_param          → tweak parameter slots if needed
    get_diagnostics    → confirm it compiled
    lint               → find what compiled and is still wrong
    

Several edits at once

apply_edits takes a list of add_node, remove_node, connect and disconnect edits and applies them as one.

apply_edits  {"edits": [
  {"op": "add_node", "id": "osc", "class": "val:Oscillator"},
  {"op": "add_node", "id": "vca", "class": "val:VCA"},
  {"op": "connect", "from_node": "osc", "from_port": "out", "to_node": "vca", "to_port": "in"},
  {"op": "connect", "from_node": "vca", "from_port": "out", "to_node": "out", "to_port": "in"}
]}

For an edit to a value or a parameter, there is no batch form: use set_turtle, or set_param after the structure is in place.

Trying things safely

Every change made through these tools is kept as a version, so an experiment costs nothing.

A change made in the plugin's editor, outside these tools, is kept as its own version ("changed outside these tools") the next time you use one of them, so undo does not lose it. If the editor holds text that does not compile, undo puts back the last text that did. At most 100 versions are kept, and numbers are never reused. A failed edit is not a version.

Modify an existing circuit

  1. Call get_turtle to read the current source.
  2. Plan the change: which nodes to add, remove or rewire.
  3. For small edits, use add_node, remove_node, connect and disconnect individually, or together in apply_edits. Each call is atomic; a failed call leaves the circuit unchanged.
  4. For large restructures, edit the Turtle and call set_turtle.

Check your work

get_diagnostics returns whether the circuit loaded, its element and arc counts and its latency. Parse errors carry a line and column; structural errors name the element or arc. An element can load and still report a problem it recovered from, such as a missing sound file: those are in problems, one entry per element, and an empty list means there were none.

lint reports what compiled but is probably not what you meant. Run it after every structural change; it costs nothing and it finds the mistakes that are hardest to hear. Before calling a circuit finished, also run check_stability.

code severity means
nothing-reaches-output error nothing is connected to the output, so the circuit is silent
control-overrides-value warning a value is set on a port that a control arc replaces every block, so it is never used
knob-overridden warning a parameter is bound to a port that a control arc replaces, so the knob does nothing
not-heard warning an element has no path to the output, so it cannot be heard
mixed-rate-arc warning an arc joins an audio port to a control port, so the compiler drops it
value-out-of-range info a value is outside the range its port declares, and the element may clamp it
param-range-wider info a parameter's range is wider than its port's, so the top of the knob may do nothing
reads-silence warning an effect has nothing connected to any audio input
unknown-property warning a val: property on an element is neither a port nor an option of it, usually a misspelt port name, which sets nothing; the finding offers the nearest real names
duplicate-param-symbol warning two parameters share a symbol, which a host uses to identify automation
no-profile info the circuit declares no trn:PluginProfile

Each finding names the node and port and says what to do. A warning is not always a mistake (an element can be unheard on purpose, while you build), but it is always worth knowing about.

Hearing a circuit

You cannot listen, so measure. Loading is not the same as working: a circuit can compile and be silent, or clip.

Patterns

Synthesiser (MIDI-driven)

Minimum: MidiPitch → Oscillator → Output

MidiPitch.out  ──ControlArc──► Oscillator.frequency
Oscillator.out ──Arc──────────► Output.in

Add amplitude shaping:

Envelope.out ──ControlArc──► VCA.cv
Oscillator.out ──Arc────────► VCA.in
VCA.out ──Arc───────────────► Output.in

The Envelope gates on and off from host MIDI automatically unless a val:NoteGate is wired to its gate port.

Filter sweep

Route the envelope through val:Scale so the resting cutoff is controllable:

Envelope.out ──ControlArc──► Scale.in
Scale.out    ──ControlArc──► Ladder.cutoff

Set val:min on Scale to the base cutoff (Hz) and val:max to the peak cutoff. Do not set val:cutoff on the Ladder, because the arc overwrites it.

Effects processor (audio in and out)

Input.out ──Arc──► [effect chain] ──Arc──► Output.in

Use val:Input for the plugin's audio input and val:Output for its output. To keep the dry signal at full level and add an effect to it, send both to a val:Mixer; circuits/dd3.ttl does this.

LFO modulation

LFO.out ──ControlArc  val:depth 0.3 ──► Oscillator.frequency

Set val:depth on the arc (0 to 1) to scale the modulation amount. At depth 0 the arc is connected but has no effect, which is useful for a rate-controlled vibrato that starts off. val:LFO also takes a retrigger gate, a sync in beats to lock it to the host, and a drawn curve in val:curve.

Sequenced parts

A val:StepSequencer plays a pattern in time with the host. Its gate goes to an envelope and its pitch (in hertz) to an oscillator:

:bass a val:StepSequencer ;
    val:pattern "F2 F3 F2 F3 . . Eb2 Eb3" ;   # a note name, a number, or . for a rest
    val:division 0.25 .                        # a sixteenth a step

circuits/blue-monday-sketch.ttl has a bass and four drum parts this way.

Per-note drum voices

Use val:NoteGate to route a specific MIDI note number to an envelope or trigger:

NoteGate.gate ──ControlArc──► Envelope.gate

Set val:note on the NoteGate to the MIDI note number (0 to 127) the voice should respond to.

For val:TwinTBridge drum resonators: connect the amplitude envelope directly to the VCA cv, and route the NoteGate velocity to TwinTBridge.velocity. Do not route velocity through the VCA cv path. Velocity goes to 0 on note-off, which closes the VCA before the resonator finishes its decay.

To make sounds on one voice cut each other off (a closed hi-hat stopping an open one), send the other sounds' gates through a val:ControlMax into the player's choke; circuits/dmx.ttl shows it.

Sample players, stretching and granulation

Songs

A song is a Turtle file of type val:Song beside its MIDI files: tempo, sections, one part per circuit, returns that send a part through an effect, and the mix (level, pan and high-pass per stem, the room, the fade, a target loudness). read_song checks it, render_song writes a stem per part and mix_song writes a versioned reference mix, all measured, not heard. The notes can be data as well: val:score names a file of patterns, chords and a plan, and score_song writes the MIDI; generated parts stay in a script. See songs.md for the vocabulary, making-a-track.md for the whole route to a Reaper project, and the write-a-song skill for the method.

Sectioned knob panel

Group related parameters with val:section:

:p0 a val:Param ; val:slot 0 ; val:target :env ; val:property val:attack ;
    lv2:name "Attack" ; lv2:symbol "attack" ; val:section "Envelope" .

The Controls view draws a thin separator and label between sections.

Saying what a circuit is

Every shipped circuit declares a trn:PluginProfile: its role, what it accepts and produces, and any caution. get_profile reads it. Add one to a circuit you build, so a catalogue can list it; see any file in circuits/ for the properties.

Choosing an element

The full list, with every port, is in manual/elements.md. This table is a start for common jobs. Each port named in it exists; the test tests/docs/GuideTest.cpp fails if one stops existing.

class role key ports
val:Oscillator band-limited VCO frequency, shape, out
val:Wavetable morphing wavetable oscillator frequency, position, set, out
val:Noise white or pink noise colour, out
val:LFO low-frequency oscillator rate, shape, retrigger, sync, out
val:StepSequencer pattern of notes and rests against the host division, gatelength, gate, note, pitch
val:MidiPitch note to hertz, with an optional tuning reference, root, out
val:MidiVelocity note velocity, 0 to 1 out
val:Glottal a vocal-fold pulse oscillator: Rosenberg, Klatt, LF, Radiated, Cosine, Saw, Pulse; open quotient, jitter, shimmer, breath, tilt out
val:MidiCC the last value of MIDI controller controller (1 is the mod wheel), 0 to 1, initial until it is sent out
val:NoteGate per-note gate note, gate
val:Envelope ADSR attack, decay, sustain, release, gate, out
val:Ladder Moog-style low-pass in, cutoff, resonance, drive, out
val:StateVariable 12 dB filter with all three responses at once in, cutoff, resonance, drive, lp, bp, hp
val:Biquad shelves, bell, notch, low and high cut in, mode, frequency, q, out
val:OnePole 6 dB low-pass or high-pass in, cutoff, mode, out
val:VCA voltage-controlled amplifier in, cv, out
val:Gain fixed gain in decibels in, gain, out
val:Mixer audio sum in, left, right, out
val:DryWet crossfade a processed signal against the original dry, wet, mix, out
val:Scale remap 0 to 1 onto a range in, min, max, out
val:ControlMultiply multiply two controls a, b, out
val:ControlAdd add three controls a, b, c, out
val:Slew glide a control to its target over a time in, rise, fall, out
val:ControlMax the largest of three controls; an OR for gates a, b, c, out
val:AudioSelect pick one of three audio inputs a, b, c, select, out
val:DiodePair soft clipper in, seriesResistance, out
val:Tanh tanh saturator in, gain, out
val:Tape saturation, wow, flutter and hiss in, drive, wow, flutter, hiss, out
val:Delay clean delay line with feedback in, time, feedback, out
val:BucketBrigade analogue-style delay that darkens as it lengthens in, time, feedback, bandwidth, out
val:Reverb feedback delay network reverb in, size, decay, damping, mix, out
val:Compressor compressor with an optional upward stage in, threshold, ratio, attack, release, out
val:Limiter lookahead brickwall limiter in, ceiling, release, out
val:PitchShift pitch shift in semitones in, pitch, mix, out
val:FreqShifter shift every partial by hertz in, shift, feedback, out
val:RingModulator audio times a sine carrier in, frequency, mix, out
val:Vocoder band-by-band vocoder, modulator and carrier in, carrier, bands, low, high, attack, release, mix, out
val:ToneStack Fender Bassman treble, middle and bass network in, treble, middle, bass, out
val:Reed waveguide clarinet voice frequency, pressure, stiffness, damping, out
val:Brass lip-reed waveguide trumpet or horn voice frequency, pressure, lip, breath, damping, out
val:Shaker PhISEM shaken-particle percussion (maracas, cabasa, guiro) trigger, velocity, particles, shake, sound, frequency, resonance, regularity, scrape, out
val:Pluck short plucked-string exciter for a string or comb; position and hardness set the tone trigger, velocity, frequency, position, hardness, out
val:TwinTBridge bridged-T drum resonator frequency, decay, trigger, velocity, out
val:SampleLoad plays a sound file speed, start, loop, trigger, choke, out
val:Sampler plays recorded sounds from notes, as a keyboard or a kit gain, tune, attack, release, velocity, loop, keytrack, oneshot, choke, out
val:TimeStretch a sound file at its own speed and pitch speed, pitch, formant, loop, out
val:PitchTracker pitch of a monophonic signal as control outputs (YIN) in, low, high, threshold, floor, frequency, note, voiced, clarity
val:SampleHold copies a control value when its trigger rises and holds it (a note's velocity for the length of a drum) in, trigger, out
val:OctaveDivider analogue octave-down: Schmitt trigger and flip-flops, one note at a time in, division, hysteresis, dry, wet, out
val:Convolver convolves the input with an impulse response file (a room, a cabinet); no latency in, mix, gain, out
val:Input plugin audio input out, left, right
val:Output plugin audio output in, left, right

Worked example: a minimal synth through the tools

Start from an empty or placeholder circuit, then build it in one call.

# 1. Replace with a skeleton
set_turtle  →  (paste the Turtle below)

@prefix val: <http://purl.org/stuff/valis/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix :    <urn:valis:new#> .
:main a val:Circuit ; rdfs:label "New" ; val:element :out .
:out  a val:Output .

# 2. Add and wire everything at once. The kind of each arc, audio or control, is worked out
#    from its ports. Ids without a colon are in this circuit's namespace.
apply_edits  {"edits": [
  {"op": "add_node", "id": "pitch", "class": "val:MidiPitch"},
  {"op": "add_node", "id": "osc",   "class": "val:Oscillator"},
  {"op": "add_node", "id": "env",   "class": "val:Envelope"},
  {"op": "add_node", "id": "vca",   "class": "val:VCA"},
  {"op": "connect", "from_node": "osc",   "from_port": "out", "to_node": "vca", "to_port": "in"},
  {"op": "connect", "from_node": "vca",   "from_port": "out", "to_node": "out", "to_port": "in"},
  {"op": "connect", "from_node": "pitch", "from_port": "out", "to_node": "osc", "to_port": "frequency"},
  {"op": "connect", "from_node": "env",   "from_port": "out", "to_node": "vca", "to_port": "cv"}
]}

# 3. Check it loaded, that nothing is wrong that still compiles, and that it sounds
get_diagnostics
lint
render  {"path": "/tmp/new.wav", "note": 60, "seconds": 2}      # peak and RMS must not be 0

Common mistakes

Mixing audio and control ports. An audio output into a control input, or the reverse, is a compile error naming the ports. Check each port's rate in list_element_types.

Setting a fixed value on a port that a control arc already targets. The arc wins every block. Move the resting value into the control path.

Reusing a parameter slot. Each slot (0 to 63) may only be bound once. Check list_params before adding a val:Param.

Targeting a port symbol that does not exist. Port symbols are exact. "cutoff" is not "Cutoff". A "no port" error names the nearest real ports and lists the ones of the right direction, so read it before looking elsewhere. val:StateVariable has no out; it has lp, bp and hp.

A misspelt property in the Turtle. val:cutof 800 is not an error: any val: property that is not a port is taken as an option, and an option nothing reads does nothing. lint reports it as unknown-property with the nearest real names; run it after writing Turtle by hand.

Two arcs into one audio input. Only val:Mixer sums its inputs. Anywhere else it is an error, so add a Mixer.

Creating a feedback loop without val:UnitDelay. A cycle in the audio graph is an error unless every cycle passes through a val:UnitDelay to break it. A feedback amount inside an element, such as a delay's feedback, is not a cycle in the graph and needs nothing.

A circuit with no val:Output, or two. There must be exactly one.

Loading is not working. A circuit that compiles can still be silent or clip. Run lint, render it, and read the analysis's notes before saying it is done.

Forgetting that an effect needs input. render feeds an effect nothing. Use valis-render --tone or -i to run audio through it.

An unreadable option. A misspelt note in a val:pattern, a file that is not there or a tuning file with a bad line fails the load, and the message names the element and the option.