The Music Editor opens when you create or double-click a .vmus file. It provides a piano roll interface for composing music for the Vectrex's AY-3-8910 PSG sound chip, which has three tone channels (A, B, C) and one noise channel.

AY-3-8910 basics
The PSG has three independent tone oscillators (channels A, B, C) and one noise generator. Each channel can play one note at a time. Notes are specified as MIDI note numbers; the compiler converts them to PSG register values at build time.
Tools
| Tool | Shortcut | Use |
|---|---|---|
| Draw | D | Click and drag to create a note; drag right to set duration |
| Select | S | Click or shift-click to select notes; drag to move |
| Erase | E | Click a note to delete it |
| Pan | P / Middle-mouse | Scroll the view |
Piano roll
Notes appear as rounded rectangles on the grid. The vertical axis is pitch (A0 at the bottom, C8 at the top); the horizontal axis is time in ticks (24 ticks = 1 beat).
- Zoom: scroll wheel adjusts horizontal zoom (0.5×–3×).
- Channel colours: each channel (A, B, C) has a distinct colour. Switch the channel view filter in the toolbar to focus on one channel at a time.

Noise track
The noise track is a horizontal strip at the bottom of the grid. Draw events here to activate the noise generator. Each event has:
| Field | Range | Description |
|---|---|---|
| Period | 0–31 | Controls the noise pitch/colour. Lower = higher pitch. |
| Velocity | 0–15 | Volume of the noise burst. |
Playback
| Control | Action |
|---|---|
| Play / Stop | Start or stop playback |
| Speed | Playback rate: 25%–200% |
| Auto-scroll | Keep the playhead centred while playing |
| BPM | Tempo setting |
| Loop | Set loop start and end points |
Keyboard shortcuts:
Space— Play/Stop1/2/3— Switch active channelDelete— Remove selected notes
MIDI import
File → Import MIDI opens the MIDI import dialog. Select a .mid file and choose a mapping mode:
| Mode | Description |
|---|---|
| Merge | All MIDI tracks mapped dynamically to channels A, B, C as notes fit. |
| Separate | First three MIDI tracks mapped to A, B, C respectively. |
| Multiplex | Tim Follin-style: up to 6 virtual voices rapidly switched across the 3 channels. |
The dialog previews the result with audio playback before you commit. Percussion (MIDI channel 10, low notes) is detected automatically and mapped to the noise track.
Channel instruments
Each channel can reference a .vinstr instrument from assets/instruments/. The editor's playback uses it to preview that channel, and the MIDI import can generate .vinstr instruments from the General MIDI programs of the file. Leave a channel unset to hear the plain square wave.
The game itself plays a .vmus as PSG tones and noise. To play an instrument from code, call PLAY_NOTE (see Instrument Editor).
File format
{
"version": "1.0",
"name": "theme",
"author": "",
"tempo": 120,
"ticksPerBeat": 24,
"totalTicks": 96,
"notes": [
{ "id": "n1", "note": 69, "start": 0, "duration": 24, "velocity": 12, "channel": 0 },
{ "id": "n2", "note": 57, "start": 0, "duration": 48, "velocity": 10, "channel": 1 },
{ "id": "n3", "note": 71, "start": 24, "duration": 24, "velocity": 12, "channel": 0 }
],
"noise": [
{ "id": "h1", "start": 0, "duration": 6, "period": 8, "channels": 2, "velocity": 5 }
],
"loopStart": 0,
"loopEnd": 96
}- Every note and noise event needs an
id. noteis a MIDI number (60 is C4),velocityruns 0–15, andchannelis 0, 1 or 2 (PSG A, B or C).- For noise events,
periodruns 0–31 (0 is the highest pitch) andchannelsis a bitmask: 1 for A, 2 for B, 4 for C. - With
ticksPerBeat24, a quarter note is 24 ticks and a 4/4 bar is 96. - Notes on one channel must not overlap.
Using it from VPy and C
Music lives in assets/music/<name>.vmus and loops. Write music on channels A and B: sound effects play on channel C.
| Language | How to play it | Targets |
|---|---|---|
| VPy | PLAY_MUSIC("theme"), STOP_MUSIC() | m6809, rp2350, uvm2, pitrex. On m6809, STOP_MUSIC() only builds when the program also calls PLAY_MUSIC |
| C | #include "theme.h", then PLAY_MUSIC(THEME_music) | WASM simulator, rp2350, uvm2 |
The music update and the frame sync are injected for you: do not call AUDIO_UPDATE(), MUSIC_UPDATE() or WAIT_RECAL() in VPy, and in C vpy_run() advances the music every frame.