All docs

Instrument Editor

Design reusable AY-3-8910 instrument presets (.vinstr) with arpeggio, pitch sweep, noise, and an audio analyzer that maps real sounds to PSG parameters.

The Instrument Editor opens when you create or double-click a .vinstr file. It defines a reusable instrument preset for the AY-3-8910 PSG — a set of timbral parameters (arpeggio, pitch sweep, noise) that the Music Editor can assign to a channel. The editor has two tabs: Edit for manual parameter control and Analyze for deriving parameters automatically from a real audio file.

Instrument Editor — two-column Edit tab: left column has Basic, Presets and Piano keyboard; right column has Arpeggio, Effects and Pitch Sweep


Edit tab

The Edit tab is split into two columns.

Left column — Basic, Presets, Piano

FieldRangeDescription
Duration1–255 framesHow many frames (@50 Hz) the note plays before cutting off.
Volume0–15Peak amplitude.

Presets — four built-in starting points:

PresetCharacter
PluckShort attack, downward pitch sweep — guitar/harp-like
BellSlow arpeggio through harmonics — metallic bell
BassLong sustain, upward pitch sweep — deep bass note
LeadTwo-step arpeggio — bright lead tone

Right column — Arpeggio, Effects, Pitch Sweep

Arpeggio

Arpeggio cycles through up to 4 semitone intervals rapidly, simulating chords or harmonics on the AY-3-8910's single-oscillator channels.

FieldRangeDescription
Count0–4Number of arpeggio steps. 0 = no arpeggio.
Speed1–16 framesHow many frames per arpeggio step. Lower = faster cycling.
Intervals−12 to +12 stSemitone offset for each step. Step 0 is always the root note.

Arpeggio section — Count set to 3, intervals sliders showing 0, +7, +12

Effects

Noise — toggle on to mix the PSG noise generator into the note. Set the Noise period (0–31) to control the noise colour: 0 is the brightest, 31 the darkest.

Pitch Sweep

Makes the oscillator pitch change over the note's duration, adding movement to leads and bass sounds.

FieldRangeDescription
Delta−127 to +127AY period increment per frame. Positive = pitch falls; negative = pitch rises.
Duration0–255 framesHow many frames the sweep lasts. 0 = no sweep.

Piano keyboard

The bottom of the left column has a two-octave keyboard (C3–B4). Click any key to audition the instrument at that pitch through the Web Audio API. The preview accurately simulates the arpeggio, pitch sweep, and duration as they would sound on real Vectrex hardware.

Piano keyboard in the left column — two white octaves, one key highlighted


Analyze tab

The Analyze tab listens to a real audio file and derives AY-3-8910 parameters that approximate its timbre. This is a fast way to get a plausible starting point when you want a sound to resemble a specific real instrument.

Analyze tab — waveform display with yellow selection region, analysis results panel below

Loading audio

Drag a .wav, .mp3, .ogg, or .flac file onto the drop zone, or click it to browse. The waveform appears in the display.

Selecting a region

Click and drag on the waveform to select the region to analyze. Drag the yellow handle markers to resize the selection. For best results, select a short stable section (a single note attack, not silence or a long decay).

  • Scroll wheel — zoom in/out on the waveform
  • Shift + scroll — pan left/right
  • Fit selection — zoom to show only the selected region
  • Full view — zoom out to show the whole file

Use ▶ Play selection to audition the selected region before analyzing. ↺ Loop repeats it continuously for careful listening.

Analysis

Click Analyze selection to run the spectral analysis. The editor computes:

PropertyMethod
Fundamental pitchDFT peak in 40–5000 Hz range → MIDI note
DurationRMS decay time (first point below 20% of peak) → frames
VolumeRMS peak → 0–15 scale
ArpeggioHarmonic partials at 2×, 3×, 4× fundamental → semitone intervals
NoiseSpectral flatness of mid-high range → noise period
Pitch sweepPitch drift between first and last quarter of region → sweep delta

The results panel shows the detected values and any harmonics found. Click ▶ .vinstr to preview how the instrument sounds at the detected note before committing.

Click Apply all to Instrument to copy all detected parameters into the Edit tab. The editor switches back to Edit automatically so you can fine-tune from there.

The AY-3-8910 can only produce square waves. Arpeggio approximates complex timbres by cycling through harmonics rapidly. The result is always an approximation — use the piano keyboard to judge whether it needs further manual adjustment.


File format

{
  "version": "1.0",
  "name": "bell",
  "duration_frames": 20,
  "volume": 12,
  "arpeggio_count": 3,
  "arpeggio_speed_frames": 3,
  "arpeggio_intervals": [0, 7, 12, 0],
  "noise_enabled": false,
  "noise_period": 15,
  "pitch_sweep_delta": 0,
  "pitch_sweep_duration_frames": 0
}

In the Music Editor, assign a .vinstr preset to a channel via the Channel instruments section. The compiler reads the preset at build time and bakes the parameters into the ROM's sound tables.