Visualizers

Want AI to make you a visualizer scene?

Start a chat with this prompt and describe your idea. The assistant checks it's possible, writes both files and tells you where they go.

Show prompt
You're going to help me make a custom visualizer scene for Opal Music, a desktop Apple Music player. The full reference is at https://opalmusic.app/docs/visualizers.md; read it if you can browse. The essentials are below.

How we'll work:
1. Start by asking me what I'd like to see, unless I've already said.
2. Check the idea against the limits below. If part of it isn't possible (imported 3D models, file-loaded images, text, video, custom shaders, internet access, more detail than the vertex budget allows), say so plainly and suggest the closest thing that works. Agree on the idea with me before writing code.
3. Write two complete files: manifest.json and main.js. No placeholders.
4. Tell me how to install it: in the visualizer window, click the folder button, make a new folder inside the one that opens (for example "my-scene"), save both files in it, then close and reopen the visualizer and pick the scene from the dropdown. Saving main.js again reloads it live.
5. Offer to tune it: speed, colors, how strongly it reacts to the music.

The API (version 2; version 1 scenes still work):
- manifest.json has exactly these fields: {"api": 2, "name": "...", "description": "...", "author": "...", "entry": "main.js"}
- main.js defines a synchronous function render(frame, draw), called every display refresh. Variables outside render persist between frames. The screen is cleared to black before each frame. It is plain JavaScript (QuickJS): no DOM, canvas, WebGL, Node.js, fetch, timers, async or modules.
- frame: time (seconds), dt (seconds since last frame, max 0.1), width, height (logical pixels), intensity (user setting 0.2 to 2.0; multiply reactions by it), theme.accent and theme.background ([r,g,b,a]), and audio: spectrum (64 bands, 30 Hz to 20 kHz, each 0 to 1, already smoothed), waveform (256 samples, about -1 to 1), bass, mid, treble (0 to 1), rms and peak ([left, right]), playing (bool). Real music mostly sits between 0.1 and 0.6.
- draw (origin top left, later shapes cover earlier ones): circle(x, y, r, color); rect(cx, cy, w, h, color, rotation = 0) positioned by its center; line(x1, y1, x2, y2, width, color); polyline([[x, y], ...], width, color); triangle(x1, y1, x2, y2, x3, y3, color); quad(x1, y1, x2, y2, x3, y3, x4, y4, color); polygon([[x, y], ...], color) for convex shapes only.
- Colors are linear [r, g, b, alpha]: alpha 0 to 1, RGB 0 to 8. Values above 1 glow with bloom.
- Helpers: opal.clamp(v, lo = 0, hi = 1), opal.lerp(a, b, t), opal.smooth(prev, target, speed, dt) for frame-rate-independent easing (4 gentle, 20 snappy), opal.hsv(h, s = 1, v = 1, a = 1) with hue wrapping over 0 to 1, opal.rgb("#rrggbb", a = 1).
- Limits: 262144 submitted triangle corners per frame, including instances (triangle 3, rect/quad 6, circle 72); excess is dropped with a warning; about 50 ms per frame, so aim for under 5 ms; 32 MiB of memory; coordinates within plus or minus 32768.

API 2 additions:
- draw.mesh(Float32Array xy, Float32Array rgba per vertex, optional Uint16Array/Uint32Array triangle indices, optional {texture, uvs: Float32Array uv per vertex}). Gradients and soft alpha are interpolated by the GPU. Reuse arrays each frame.
- opal.mesh(same arguments) returns an immutable retained mesh handle; draw.instances(handle, Float32Array tuples x,y,scale,rotation,r,g,b,a) transforms and tints it on the GPU.
- draw.blend("normal"|"add"|"multiply"|"screen") changes subsequent drawing; settings reset each frame.
- opal.mesh3d and draw.mesh3d take xyz triples. draw.instances3d tuples are x,y,z,scale,yaw,pitch,roll,r,g,b,a. draw.camera({position:[x,y,z],yaw,pitch,roll,fov:60,near:0.1}); camera looks down -Z, Y up, angles radians, FOV vertical degrees. draw.fog([r,g,b,a],near,far). Normal 3D writes depth; translucent normal geometry still needs sorting. Other blend modes test depth without writing it.
- opal.texture(width,height,Uint8Array RGBA) creates a texture once; RGB bytes are sRGB. Use mesh options {texture,uvs}; max 2048 per dimension, 16 MiB total.
- opal.noise2/noise3 return native deterministic gradient noise -1..1. const random=opal.random(seed) creates a seeded generator in [0,1).
- Optional synchronous init(frame), resize(frame), trackChange(audio). audio also has loudness, loudnessShort (3s), loudnessLong (20s), spectralFlux, onset, onsetCount and track generation. Compare onsetCount across frames, not a repeated onset boolean. Onsets are a heuristic, not BPM detection.
- Press D for timing, sampled explicit GC, memory and vertex overlay. Types: https://opalmusic.app/opal-visualizer.d.ts. Recorded-audio checks and deterministic PNG capture are documented in the full reference.

Good practice: smooth audio with opal.smooth (fast while rising, slow while falling), scale reactions by frame.intensity, draw back to front for depth, and stay well under the vertex budget. Keep instance counts stable. For normal translucent 3D, draw back to front; add/screen are useful for particles.

This page as Markdown. Index for AI tools: llms.txt.