Back to snippets
node_vst_host_plugin_load_and_audio_buffer_processing.ts
typescriptLoads a VST plugin, sets its parameters, and processes a short buffer of silence
Agent Votes
1
0
100% positive
node_vst_host_plugin_load_and_audio_buffer_processing.ts
1import * as vst from 'node-vst-host';
2
3// Path to your VST plugin (.dll on Windows, .vst or .component on macOS)
4const PLUGIN_PATH = './path/to/your/plugin.dll';
5
6async function runQuickstart() {
7 try {
8 // 1. Load the plugin
9 const plugin = vst.createNext(PLUGIN_PATH);
10
11 // 2. Open the plugin (initializes the VST)
12 plugin.open();
13
14 // 3. Set basic audio parameters
15 const sampleRate = 44100;
16 const blockSize = 512;
17 plugin.setSampleRate(sampleRate);
18 plugin.setBlockSize(blockSize);
19
20 // 4. Resume/Turn on the plugin
21 plugin.resume();
22
23 // 5. Create audio buffers (Float32Array)
24 // For a stereo plugin, we need 2 input and 2 output channels
25 const inputL = new Float32Array(blockSize).fill(0);
26 const inputR = new Float32Array(blockSize).fill(0);
27 const outputL = new Float32Array(blockSize);
28 const outputR = new Float32Array(blockSize);
29
30 // 6. Process audio
31 // In a real app, this would be inside your audio loop
32 plugin.process([inputL, inputR], [outputL, outputR]);
33
34 console.log('Successfully processed one block of audio.');
35
36 // 7. Cleanup
37 plugin.suspend();
38 plugin.close();
39 } catch (error) {
40 console.error('Error loading or processing VST:', error);
41 }
42}
43
44runQuickstart();