Skip to content

Neuroscript Guide

Neuroscript is the Rust-backed, line-based DSL for MIDI transforms. Each line is evaluated in order, and the current event is passed through unless you explicitly drop it.

Basics

  • One statement per line.
  • Lines run top-to-bottom.
  • If nothing drops the event, it is emitted unchanged.

Example:

keep note
when vel > 100: event(vel = 100)

Selectors (Filters)

Selectors describe which event types a keep or drop statement targets. You can combine selectors with commas.

keep note, cc
drop clock, realtime

Supported selectors:

  • Event types: note, cc, pc, bend, aftertouch, clock, start, stop, continue, realtime, all

Conditions (where / when)

Use where to add a condition to a keep or drop:

keep note where vel >= 80
drop cc where cc in [1, 7, 10]

Use when to apply an action conditionally:

when note in C3..C4: event(note = note + 12)

Operators:

  • Comparators: =, !=, <, <=, >, >=
  • Boolean: and, or, not
  • Lists: in [a, b, c]

Fields:

  • type, ch, note, vel, cc, value, prog, bend

Transforming Events

Use event(...) to edit the current event:

event(note = clamp(note + 12, 0, 127))
event(vel = clamp(vel + 10, 1, 127))
event(ch = 2)

Emitting Extra Events

Use emit.* to create new events:

emit.cc(74, value)
emit.noteOn(note, vel)
emit.noteOff(note)

Dropping Events

Use a bare drop statement to discard the current event:

drop

Examples

Lo-fi drums

keep note where ch == 10
event(vel = clamp(vel, 35, 95))
when vel > 95: event(vel = 85)

Ambient pads

keep note where ch == 2
event(note = clamp(note + 12, 0, 127))
event(vel = clamp(vel, 40, 100))

Utility glue

drop clock, start, stop, continue, realtime
when type == cc and cc == 1: emit.cc(74, value)

CLI

You can parse scripts via the Rust CLI:

cargo run -p neuroscript-cli -- parse Sources/NeurodeMIDITransforms/Resources/Scripts/Neuroscript/Examples/01_drop_system_spam.ns
cargo run -p neuroscript-cli -- tokens Sources/NeurodeMIDITransforms/Resources/Scripts/Neuroscript/Examples/01_drop_system_spam.ns

Simulator

Use the Neuroscript Simulator to run single-event tests in the browser with the Rust WASM engine.

Built with ❤️ for musicians