npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vita-node

v1.1.0

Published

Node.js bindings for Vital

Readme

Vita for Node.js (vita-node)

npm version CI

Node.js bindings for Vital. It was directly inspired by and leveraged the work of David Braun's Vita, a Python module for interacting with Vital. This is not an official product related to Vital or the original Vita project.

Installation

npm install vita-node

Example

The API is designed to be very similar to the original Python version.

const fs = require('fs');
const wav = require('node-wav'); // Run: npm install node-wav
const vita = require('vita-node');

const SAMPLE_RATE = 44100;

const bpm = 120.0;
const noteDur = 1.0;
const renderDur = 3.0;
const pitch = 36;   // integer
const velocity = 0.7; // [0.0 to 1.0]

const synth = new vita.Synth();
// The initial preset is loaded by default.

synth.setBpm(bpm);

// Let's make a custom modulation using
// the available modulation sources and destinations.
// These lists are constant.
console.log("Potential sources:", vita.getModulationSources());
console.log("Potential destinations:", vita.getModulationDestinations());

// "lfo_1" is a potential source,
// and "filter_1_cutoff" is a potential destination.
console.assert(synth.connectModulation("lfo_1", "filter_1_cutoff"));

const controls = synth.getControls();
controls.modulation_1_amount.set(1.0);
controls.filter_1_on.set(1.0);
const val = controls.filter_1_on.value();
controls.lfo_1_tempo.set(vita.constants.SyncedFrequency.k1_16);

// Use normalized parameter control (0-1 range, VST-style)
controls.filter_1_cutoff.setNormalized(0.5); // Set knob to 50%
console.log(controls.filter_1_cutoff.getNormalized()); // Get normalized value

// Get parameter details and display text
const info = synth.getControlDetails("delay_style");
console.log(`Options: ${info.options}`); // ["Mono", "Stereo", "Ping Pong", "Mid Ping Pong"]
console.log(`Current: ${synth.getControlText('delay_style')}`); // e.g., "Stereo"

// Render audio directly to a WAV file
// renderFile(filename, pitch, velocity, noteDuration, renderDuration)
synth.renderFile("generated_preset.wav", pitch, velocity, noteDur, renderDur);

// Or use render() which returns a Buffer with raw audio data
// const audioBuffer = synth.render(pitch, velocity, noteDur, renderDur);

// Dump current state to JSON text
const presetPath = "generated_preset.vital";
const jsonText = synth.toJson();
fs.writeFileSync(presetPath, jsonText);

// Load JSON text from a string
const loadedJson = fs.readFileSync(presetPath, 'utf8');
console.assert(synth.loadJson(loadedJson));

// Or load directly from file
console.assert(synth.loadPreset(presetPath));

// Load the initial preset, which also clears modulations
synth.loadInitPreset();
// Or just clear modulations.
synth.clearModulations();

API Notes

Controls Object

The getControls() method returns an object with all synthesizer parameters as properties. Each control is a ControlValue object with these methods:

  • set(value) - Set the control value
  • value() - Get the current value
  • setNormalized(value) - Set using normalized 0-1 range
  • getNormalized() - Get normalized value
  • getText() - Get display text for the current value

Example:

const controls = synth.getControls();
controls.filter_1_cutoff.set(0.5);  // Direct property access
console.log(controls.filter_1_cutoff.value());

Audio Rendering

  • renderFile(filename, pitch, velocity, noteDuration, renderDuration) - Render directly to WAV file
  • render(pitch, velocity, noteDuration, renderDuration) - Returns a Buffer with raw audio data

Batch Rendering (High Performance)

For rendering thousands of presets efficiently using multiple CPU cores:

const { BatchRenderer } = require('vita-node');

// Create batch renderer with 8 workers
const renderer = new BatchRenderer({ workers: 8 });

// Example 1: Render to output directory (preserves filenames)
const presets = ['preset1.vital', 'preset2.vital', ...];
await renderer.renderBatch(presets, './output');
// Creates: ./output/preset1.wav, ./output/preset2.wav, ...

// Example 2: Specify individual output paths
const outputPaths = ['bass.wav', 'lead.wav', ...];
await renderer.renderBatch(presets, outputPaths);

// Example 3: With progress tracking
await renderer.renderBatchWithProgress(
    presets,
    './output',
    { note: 48, velocity: 0.9 },
    (progress) => {
        console.log(`${progress.percentage.toFixed(1)}% complete`);
    }
);

Preset Management

Working with Vital presets (.vital files):

// Load a preset from file
if (synth.loadPreset('/path/to/preset.vital')) {
    console.log('Preset loaded successfully');
}

// Save current state as preset
const presetJson = synth.toJson();
fs.writeFileSync('my_preset.vital', presetJson);

// Load from JSON string
synth.loadJson(presetJson);

// Reset to initial preset
synth.loadInitPreset();

// Clear all modulations
synth.clearModulations();

Documentation

The API is not yet formally documented. Please browse bindings.cpp in this repository to see the full list of available functions and classes exposed to Node.js.

Issues

If you find any issues with the Node.js bindings, please report them at: https://github.com/rtavasso/vita-node/issues.


A Note on Licensing

The following sections are from the original Vital source code repository and apply to the C++ source code included in this project. Because vita-node is a derivative work licensed under GPLv3, all users must comply with these terms.

Code Licensing

If you are making a proprietary or closed source app and would like to use Vital's source code, contact [email protected] for non GPLv3 licensing options.

What can you do with the source

The source code is licensed under the GPLv3. If you download the source or create builds you must comply with that license.

Things you can't do with this source

  • Do not create an app and distribute it on the iOS app store. The app store is not comptabile with GPLv3 and you'll only get an exception for this if you're paying for a GPLv3 exception for Vital's source (see Code Licensing above).
  • Do not use the name "Vital", "Vital Audio", "Tytel" or "Matt Tytel" for marketing or to name any distribution of binaries built with this source. This source code does not give you rights to infringe on trademarks.
  • Do not connect to any web service at https://vital.audio, https://account.vital.audio or https://store.vital.audio from your own builds. This is against the terms of using those sites.
  • Do not distribute the presets that come with the free version of Vital. They're under a separate license that does not allow redistribution.