Overview
A plugin can carry four kinds of files:
| Kind | For | Loaded with | In the built plugin |
|---|---|---|---|
| Sample banks | Audio that plays: a drum kit, a multisampled instrument, one-shots. | api.samples | One library file per bank, inside the plugin. |
| Asset folders | Files read as data: wavetables, impulse responses, presets, MIDI. | api.assets | The files themselves, inside the plugin. |
| Artwork | Images for the plugin's window: panels, knob film strips. | <img src> and Knob layers | Compiled into the plugin's code. |
| Live content | Files under content/ that you publish after release. | api.assets | Not built in: installed plugins download each release. |
The path is the same for each: upload the files, declare them in static assets, load them in the editor, and hand them to the audio thread.
In the builder
- Save the plugin. Until it is saved, the tab says "Save the plugin first to upload assets."
- Open the Assets tab, beside the code tabs above the editor. Your code files stay in the list on the left and the Live Preview on the right.
- Use "+ Files" for single files, or "+ Folder" to upload a whole folder with its layout kept. "Storage used" shows how much you have uploaded.
- Declare the folders in static assets (below). Until you do, a folder is marked "not reachable from code", with a button that copies an entry for it.
- On each file, the badge shows the ids your code uses. "Copy the call that loads this file" copies the exact line: api.samples.loadSample for a sample, or loadWavetable, loadImpulseResponse or loadAsset for an asset, by the folder's type.
Uploads take audio (wav, mp3, flac, ogg, aiff), images (png, jpg, jpeg, webp), and json, mid and midi. Each file can be renamed, moved and downloaded from its row. The content/ folder is pinned at the top with a cloud icon: what you put there is published to installed plugins instead of built into them (Live content).
Give samples as WAV files. A sample in another format is marked "not a WAV — will not load", and a build on daplug.in stops on it. A file the build will leave out is marked "left out".
Declaring them
static assets says which folders are sample banks and which are asset folders. Write it with plain values: the build reads it without running your code. satisfies PluginAssetConfig checks it as you type.
import { SynthPlugin } from '@the-plug/core';
import type { PluginAssetConfig } from '@the-plug/core';
type Params = { volume: number };
export default class Drums extends SynthPlugin<Params> {
static id = 'com.example.drums';
static pluginName = 'Drums';
static parameters = [{ id: 'volume', name: 'Volume', default: 0.8 }];
static assets = {
// Every audio file under kits/acoustic is a sample of the bank "acoustic".
sampleBanks: ['kits/acoustic'],
assetFolders: [
{ id: 'cabs', name: 'Cabinets', path: 'irs/cabs', type: 'impulse-response' },
{ id: 'tables', name: 'Wavetables', path: 'tables', type: 'wavetable' },
],
} satisfies PluginAssetConfig;
process() {}
render() {
return <div />;
}
}| Field | What it holds |
|---|---|
sampleBanks | A list of banks. A bank written as its folder, such as 'kits/acoustic', gets the id 'acoustic' and the name 'Acoustic'; every audio file below it, at any depth, is a sample. Write it as { id, name, path } to choose the id and name. |
assetFolders | A list of { id, name, path, type }, where type is 'wavetable', 'impulse-response', 'preset', 'midi' or 'custom'. Every file below the folder is an asset. A folder id starts with a letter or digit, then letters, digits, dots, dashes or underscores. |
defaults | What is loaded before the editor ever opens: audioData: 'bank/sample' fills the playback slots, and '<slot>_ir': 'folder/asset' a convolver. |
basePath | A folder every path above is under. Without it, paths start at the plugin's root. |
A bank finds wav, mp3, flac, ogg, aiff files by itself. A samples list written into a bank is used only with autoDiscover: false; otherwise the folder decides. An unknown key in an asset folder is refused at build time.
How files get ids
Code names a file by its folder's id and the file's own id. Files and folders whose names start with a dot are skipped.
In an asset folder
An asset's id is its file name without the extension, with its case kept: in the folder cabs (irs/cabs), the file irs/cabs/Greenback_4x12.wav is Greenback_4x12, shown as "Greenback 4x12". Two files with the same name in one folder are refused.
In a sample bank
A sample's id is its path inside the bank, lower-cased, with every run of other characters turned into a dash. Its root note comes from the file name: note or midi followed by a number, or else a note name such as C1 or A#3, where C4 is 60. A name with neither plays at 60. The first folder inside the bank is the sample's category.
| File in the bank | id | name | Root note | Category |
|---|---|---|---|---|
Kicks/Kick_C1.wav | kicks-kick-c1 | Kick C1 | 24 | Kicks |
Pads/warm_pad_A#3.wav | pads-warm-pad-a-3 | Warm Pad A#3 | 58 | Pads |
bell_note72.wav | bell-note72 | Bell Note72 | 72 | — |
snare.wav | snare | Snare | 60 | — |
The editor completes these ids as you type, from your plugin's own files (typed ids).
Loading in the editor
Files are loaded by the plugin's window, never by process(), and a load that fails does not throw. api.samples.loadSample resolves with an empty bufferId, and api.assets resolves empty, with the reason in the log, so check the result as the examples below do. Listing is immediate, so render() can draw a browser straight from api.samples.getSamples or api.assets.listAssets.
Every call is in the reference: api.samples and api.assets.
Reaching the audio thread
The audio thread cannot open files, so whatever the window loads is handed over. A sample goes into the playback slots: declare audioDataL, audioDataR and dspInfo in static dspState, call api.copyBufferToDsp(bufferId), and play it with frame.samplePlayer. A mono sample fills both slots.
import { SynthPlugin } from '@the-plug/core';
import type { AudioFrame, PluginAPI } from '@the-plug/core';
type Params = { volume: number };
export default class OneShot extends SynthPlugin<Params> {
static id = 'com.example.oneshot';
static pluginName = 'One Shot';
static parameters = [{ id: 'volume', name: 'Volume', default: 0.8 }];
static assets = { sampleBanks: ['kits/acoustic'] };
// The playback slots. process() plays only what the editor copied in here.
static dspState = {
audioDataL: new Float32Array(480000),
audioDataR: new Float32Array(480000),
dspInfo: new Float32Array(4),
voice: new Float32Array(2), // [playing, position]
};
state = { status: 'Pick a sound' };
async choose(api: PluginAPI<Params>, sampleId: string) {
const loaded = await api.samples.loadSample('acoustic', sampleId);
if (loaded.bufferId === '') {
this.setState({ status: `Could not load ${sampleId}` });
return;
}
api.copyBufferToDsp(loaded.bufferId);
this.setState({ status: sampleId });
}
process(frame: AudioFrame<Params>) {
const voice = frame.dspState.voice;
for (let m = 0; m < frame.midiCount; m++) {
const e = frame.getMidiEvent(m);
if (e.type === 0x90 && e.velocity > 0) {
voice[0] = 1;
voice[1] = 0;
}
}
if (voice[0] === 0) {
frame.outL = 0;
frame.outR = 0;
return;
}
const gain = frame.getParam('volume');
frame.outL = frame.samplePlayer.readSampleInterp(0, voice[1]) * gain;
frame.outR = frame.samplePlayer.readSampleInterp(1, voice[1]) * gain;
// Step by the file's rate over the session's, so it plays at its own pitch.
voice[1] += frame.samplePlayer.getSampleRate() / frame.sampleRate;
if (voice[1] >= frame.samplePlayer.getSampleFrames()) voice[0] = 0;
}
render(api: PluginAPI<Params>) {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, padding: 12 }}>
{api.samples.getSamples('acoustic').map((s) => (
<button onClick={() => this.choose(api, s.id)}>{s.name}</button>
))}
<span>{this.state.status}</span>
</div>
);
}
} An impulse response goes into a convolver slot: load it with api.assets.loadImpulseResponse and pass the id to this.setAudioState('<slot>_ir', id).
import { EffectPlugin } from '@the-plug/core';
import type { AudioFrame, PluginAPI, PluginAssetConfig } from '@the-plug/core';
import { convolver } from '@the-plug/dsp';
type Params = { mix: number };
export default class CabSim extends EffectPlugin<Params> {
static id = 'com.example.cabsim';
static pluginName = 'Cab Sim';
static parameters = [{ id: 'mix', name: 'Mix', default: 1 }];
static assets = {
assetFolders: [{ id: 'cabs', name: 'Cabinets', path: 'irs/cabs', type: 'impulse-response' }],
// In place before the editor is ever opened, so a session that never shows it still sounds right.
defaults: { cabL_ir: 'cabs/greenback', cabR_ir: 'cabs/greenback' },
} satisfies PluginAssetConfig;
// One convolver per channel. Each sample costs the whole length, so keep it short.
static dsp = { cabL: convolver(256), cabR: convolver(256) };
state = { cab: 'greenback' };
async pick(api: PluginAPI<Params>, id: string) {
const ir = await api.assets.loadImpulseResponse('cabs', id);
if (ir === '') return; // the log says why
this.setAudioState('cabL_ir', ir);
this.setAudioState('cabR_ir', ir);
this.setState({ cab: id });
}
process(frame: AudioFrame<Params>) {
const mix = frame.getParam('mix');
frame.outL = frame.inL + (frame.dsp.cabL(frame.inL) - frame.inL) * mix;
frame.outR = frame.inR + (frame.dsp.cabR(frame.inR) - frame.inR) * mix;
}
render(api: PluginAPI<Params>) {
return (
<div style={{ display: 'flex', gap: 6, padding: 12 }}>
{api.assets.listAssets('cabs').map((a) => (
<button onClick={() => this.pick(api, a.id)}>{a.name}</button>
))}
</div>
);
}
} A host can run a plugin without ever opening its window, as when a project is bounced. List what has to be in place from the start in defaults; the build checks that each file it names is in the plugin. A sample or impulse response the window loads later is remembered in the project.
Images in your UI
<img src> takes a path written out in full, to a png, jpg or webp of 2 MiB or less among your plugin's files, or a data URI. A web address or a path worked out in code stops the build. A Knob's Image layer takes a film strip, cut by frames and strip. For vector art, draw with an <svg> element.
import { Knob } from '@the-plug/ui';
<div style={{ position: 'relative', width: 400, height: 240 }}>
<img src="./art/panel.png" alt="" style={{ width: 400, height: 240, objectFit: 'cover' }} />
<Knob
value={this.getParam('drive')}
onChange={(v) => this.setParam('drive', v)}
size={96}
layers={[{ primitive: { type: 'Image', src: './art/knob-strip.png', width: 96, height: 96, frames: 64, strip: 'vertical' } }]}
/>
</div> Artwork is compiled into the plugin itself, so it needs no folder declaration. The builder looks an image path up in your plugin's files first, then in the components it imports, then, for a path under assets/, in your library, copying it into the plugin when you save.
Live content
Files under content/ are not built into the plugin. Publish them from the bar under the content/ folder in the Assets tab: Publish, check what changed, then Publish v2, v3 and so on. Installed plugins pick up each release the next time they open, and api.assets.getContentStatus() reports the download.
import { EffectPlugin } from '@the-plug/core';
import type { AudioFrame, PluginAPI, PluginAssetConfig } from '@the-plug/core';
type Params = { mix: number };
export default class Rooms extends EffectPlugin<Params> {
static id = 'com.example.rooms';
static pluginName = 'Rooms';
static parameters = [{ id: 'mix', name: 'Mix', default: 0.3 }];
static assets = {
// Under content/: published from the builder's Assets tab, downloaded by every installed copy.
assetFolders: [{ id: 'rooms', name: 'Rooms', path: 'content/rooms', type: 'impulse-response' }],
} satisfies PluginAssetConfig;
process(frame: AudioFrame<Params>) {
frame.outL = frame.inL;
frame.outR = frame.inR;
}
render(api: PluginAPI<Params>) {
const content = api.assets.getContentStatus();
const rooms = api.assets.listAssets('rooms');
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 4, padding: 12 }}>
{content.state === 'downloading' ? (
<span>Downloading new rooms: {Math.round((100 * content.receivedBytes) / content.totalBytes)}%</span>
) : null}
{rooms.map((r) => (
<span>{r.name}</span>
))}
</div>
);
}
} Two things are refused because they must work before anything downloads: a sample bank under content/, and a defaults entry that names a live folder.
What ships
A built plugin carries its assets inside its bundle. Each asset folder becomes a folder under Contents/Resources/Assets/, with an index.json that api.assets reads, and each sample bank becomes one library file under SampleLibraries/. Live folders are left out, and artwork is already in the code.
Drums.vst3/Contents/Resources/
Assets/
index.json the folders and their files, as api.assets lists them
cabs/greenback.wav
tables/saw-stack.wav
SampleLibraries/
acoustic.db the bank "acoustic", every sample in one fileA build on daplug.in stops on a sample bank with no samples in it, so a plugin never ships an empty instrument.