Event Model
Understanding MIDI events in NeuroScript.
Event Fields
In NeuroScript, you work directly with MIDI event fields using simple identifiers:
Note Events
neuroscript
# Access note fields
note # Note number (0-127)
vel # Velocity (0-127)
ch # Channel (1-16)Control Change (CC) Events
neuroscript
# Access CC fields
cc # CC controller number (0-127)
value # CC value (0-127)
ch # Channel (1-16)Other MIDI Events
neuroscript
bend # Pitch bend value (-8192 to +8191)
prog # Program change number (0-127)
pressure # Channel pressure/aftertouch (0-127)Event Types
NeuroScript automatically handles different MIDI message types:
| Event Type | Available Fields | Description |
|---|---|---|
| Note On/Off | note, vel, ch | Notes pressed/released |
| Control Change | cc, value, ch | Controller movements |
| Pitch Bend | bend, ch | Pitch wheel changes |
| Program Change | prog, ch | Instrument selection |
| Aftertouch | pressure, ch | Pressure sensitivity |
Common CC Numbers
| CC | Name | Typical Use |
|---|---|---|
| 1 | Mod Wheel | Vibrato, modulation |
| 7 | Volume | Channel volume |
| 10 | Pan | Stereo position |
| 11 | Expression | Dynamic expression |
| 64 | Sustain Pedal | Hold notes (0-63 = off, 64-127 = on) |
| 74 | Filter Cutoff | Brightness |
| 91 | Reverb | Reverb send level |
Working with Events
Reading Values
neuroscript
# Filter by note range
keep note where note >= 60 and note <= 72
# Check velocity
keep note where vel > 80Modifying Values
neuroscript
# Transpose notes
transpose +12
# Clamp velocity
vel clamp 40..100
# Change channel
ch -> 2State Access
neuroscript
# Read last CC value (from MIDI state)
when cc(7) > 100 {
# Boost notes when volume is high
vel + 20 -> vel
}Next Steps
- NeuroScript Language Reference — Complete language guide
- Lua API — Alternative scripting option
