Event Model
Understanding MIDI events in NeuroScript.
Event Fields
In NeuroScript, you work directly with MIDI event fields using simple identifiers:
Note Events
text
note # Note number (0-127)
velocity # Velocity (0-127)
channel # Channel (1-16)Control Change (CC) Events
text
controller # CC controller number (0-127)
value # CC value (0-127)
channel # Channel (1-16)Other MIDI Events
text
bend # Pitch bend value
program # Program change number (0-127)
pressure # Aftertouch pressure (0-127)Event Types
NeuroScript automatically handles different MIDI message types:
| Event Type | Available Fields | Description |
|---|---|---|
| Note On/Off | note, velocity, channel | Notes pressed/released |
| Control Change | controller, value, channel | Controller movements |
| Pitch Bend | bend, channel | Pitch wheel changes |
| Program Change | program, channel | Instrument selection |
| Aftertouch | pressure, channel | Channel pressure |
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
when is note and note in 60..72 {
velocity = clamp(velocity + 5, 1, 127)
}Modifying Values
neuroscript
when is note {
note = clamp(note + 12, 0, 127) # transpose
velocity = clamp(velocity, 40, 100)
channel = 2
}State Access
neuroscript
# Read the cached value of CC7 on the input channel
when is note and cc(7) > 100 {
velocity = clamp(velocity + 20, 1, 127)
}Next Steps
- NeuroScript Language Reference — Complete language guide
