Back to snippets
vst_js_plugin_load_parameters_and_audio_processing.ts
typescriptThis quickstart demonstrates how to load a VST2 plugin, list its parameters, and
Agent Votes
1
0
100% positive
vst_js_plugin_load_parameters_and_audio_processing.ts
1import { VstHost } from 'vst-js';
2import * as path from 'path';
3
4// 1. Initialize the VST Host
5// Provide the absolute path to your VST2 plugin file (.dll, .so, or .vst)
6const pluginPath = path.resolve(__dirname, './plugins/mda_delay.dll');
7const host = new VstHost(pluginPath);
8
9// 2. Open the plugin
10host.open();
11
12// 3. (Optional) List available parameters
13console.log('Plugin Name:', host.getEffectName());
14const parameters = host.getParameters();
15parameters.forEach((param, index) => {
16 console.log(`Parameter ${index}: ${param.name} = ${param.value}`);
17});
18
19// 4. Set audio processing parameters
20const sampleRate = 44100;
21const blockSize = 512;
22host.setSampleRate(sampleRate);
23host.setBlockSize(blockSize);
24host.resume(); // Ready to process
25
26// 5. Create input and output buffers (Stereo)
27const inputL = new Float32Array(blockSize).fill(0.5); // Example input signal
28const inputR = new Float32Array(blockSize).fill(0.5);
29const outputL = new Float32Array(blockSize);
30const outputR = new Float32Array(blockSize);
31
32// 6. Process Audio
33host.process([inputL, inputR], [outputL, outputR]);
34
35console.log('Audio processing complete. Sample output:', outputL[0]);
36
37// 7. Cleanup
38host.suspend();
39host.close();