An audio playback library for Node.js

Related tags

Video symphonia
Overview

symphonia.js

A "way too simple" cross-platform zero dependency audio playback library for Node.js

Supported Platforms

  • Windows (x64)
  • macOS (x64)
  • macOS (ARM64)
  • Linux (x64)

Supported Audio Formats

  • MP3
  • WAV
  • Vorbis
  • FLAC
  • MP4
  • AAC

Note

Take note that the node_modules generated by npm when installing this package is non-portable across platforms in order to save space. Thus, you'll need to run npm install when transferring your project between platforms in order for this package to work correctly (you should not be committing your node_modules anyway so for most use cases this shouldn't be a problem).

Lastly, when you call the functions for the first time it might take a few seconds for the computer to respond. This is perfectly normal behaviour as it might be caused by Windows Defender.

Credits

Usage

const axios = require('axios')
const fs = require('fs')
const symphonia = require('@tropicbliss/symphonia')

try {
  const buf = fs.readFileSync('chime.ogg') // Gets a Buffer
  symphonia.playFromBuf(buf, { speed: 1.0, volume: 1.0, isBlocking: true }) // The option object is optional. The speed and volume is both set to 1.0 and `isBlocking` is set to `true` by default.

  // You can also obtain buffers from a web request
  axios
    .get(URL)
    .then((res) => Buffer.from(res.data, 'binary'))
    .then((buf) => {
      symphonia.playFromBuf(buf)
    })

  // Play a sine wave at the frequency of 440Hz for 250ms
  symphonia.playFromSine(440.0, 250)
} catch (e) {
  console.log('Error playing audio: ', e)
}

Note that calling playFromX() without setting the isBlocking option parameter blocks the main thread by default, so pass false to isBlocking to make the methods non-blocking.

const fs = require('fs')
const symphonia = require('@tropicbliss/symphonia')

async function playStuff() {
  const buf = fs.readFileSync('chime.ogg')
  const data = symphonia.playFromBuf(buf, { isBlocking: false })
  console.log("I'm not done yet, do something else to prevent this program from exiting!")
  if (data.totalDuration) {
    console.log(`This audio will be played for ${data.totalDuration} seconds.`)
    await new Promise((resolve) => setTimeout(resolve, data.totalDuration * 1000))
  }
}

try {
  playStuff()
} catch (e) {
  console.log('Error playing audio: ', e)
}
You might also like...
Swish - The powerful little audio node for Discord
Swish - The powerful little audio node for Discord

Swish - The powerful little audio node for Discord. Swish is a standalone server that allows you to connect multiple bots and play audio across all yo

A minimal library for building compiled Node.js add-ons in Rust via Node-API
A minimal library for building compiled Node.js add-ons in Rust via Node-API

A minimal library for building compiled Node.js add-ons in Rust via Node-API

Egui node graph is a featureful, customizable library to create node graph applications using egui
Egui node graph is a featureful, customizable library to create node graph applications using egui

Egui node graph is a featureful, customizable library to create node graph applications using egui. The library takes care of presenting a node graph to your users, and allows customizing many aspects of the interaction, creating the semantics you want for your specific application.

A node and runtime configuration for polkadot node.
A node and runtime configuration for polkadot node.

MANTA NODE This repo is a fresh FRAME-based Substrate node, forked from substrate-developer-hub/substrate-node-templte 🚀 It links to pallet-manta-dap

Nvm - Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Node Version Manager Table of Contents Intro About Installing and Updating Install & Update Script Additional Notes Troubleshooting on Linux Troublesh

Abuse the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code.
Abuse the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code.

jscythe abuses the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code, even if t

Simple node and rust script to achieve an easy to use bridge between rust and node.js

Node-Rust Bridge Simple rust and node.js script to achieve a bridge between them. Only 1 bridge can be initialized per rust program. But node.js can h

Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample).

ldk-node-sample Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample ). Installation git clone https://github.com/op

Cross-platform audio I/O library in pure Rust

CPAL - Cross-Platform Audio Library Low-level library for audio input and output in pure Rust. This library currently supports the following: Enumerat

Rust bindings for the soloud audio engine library

soloud-rs A crossplatform Rust bindings for the soloud audio engine library. Supported formats: wav, mp3, ogg, flac. The library also comes with a spe

Symphonia is a pure Rust audio decoding and media demuxing library supporting AAC, FLAC, MP3, MP4, OGG, Vorbis, and WAV.

Pure Rust multimedia format demuxing, tag reading, and audio decoding library

A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.
A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.

OptiVorbis A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without alter

TinyAudio is a cross-platform audio output library

TinyAudio TinyAudio is a cross-platform audio output library. Its main goal to provide unified access to a default sound output device of your operati

Rust library for A-law and μ-law (mu-law) audio encoding.

law-encoder ⚖️️‍️law-encoder👨‍⚖ is a Rust library for A-law and μ-law (mu-law) audio encoding. These encoding schemes are defined in ITU-T standards

Playwright is a rust library to automate Chromium, Firefox and WebKit built on top of Node.js library.

🎭 Playwright for Rust Playwright is a rust library to automate Chromium, Firefox and WebKit built on top of Node.js library. Installation [dependenci

A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

A graphical user interface toolkit for audio plugins.

HexoTK - A graphic user interface toolkit for audio plugins State of Development Super early! Building cargo run --example demo TODO / Features Every

A collection of filters for real-time audio processing

Audio Filters A collection of filters for real-time audio processing Feature Progress #![no_std] (via libm) f32 & f64 capable (via num-traits) SIMD Do

A discord.py experimental extension for audio recording

discord-ext-audiorec This project is currently under development. We do not guarantee it works.

Comments
  • Pause and

    Pause and "stop"?

    Can you pause or even stop (resetting position to start) something that's playing? I've been looking at a way to do something like a sound board (a silly hobby project) in node.

    If the same button is pushed quickly, it should interrupt the previous sound that might still be playing and immediately play the sound from the start again. Most libraries seem to just fire & forget when playing a sound (with no way of stopping it once it started).

    opened by tiagosiebler 0
Releases(v0.2.8)
Owner
tropicbliss
I like big bits and I cannot lie.
tropicbliss
A library for calculating simple moving averages

simple_moving_average This crate provides several algorithms for calculating the simple moving average (SMA) of a series of data samples. SMAs are com

Oskar Gustafsson 5 Oct 9, 2021
Media Cleaner is a simple CLI tool to clean up your media library based on your Overseerr requests and Tautulli history, written in Rust.

Media Cleaner Media Cleaner is a simple CLI tool to clean up your media library based on your Overseerr requests and Tautulli history, written in Rust

Felix Bjerhem Aronsson 21 Mar 22, 2023
Rust audio playback library

Audio playback library Rust playback library. Playback is handled by cpal. MP3 decoding is handled by minimp3. WAV decoding is handled by hound. Vorbi

null 1.2k Jan 1, 2023
Flutter crossplatform audio playback library powered by golang beep & oto

Rowdy Pure Rust based Dart/Flutter audio playback library Installation $ flutter pub add rowdy Configuration You'll need the Rust toolchain installed

Kingkor Roy Tirtho 3 Aug 31, 2022
A low-overhead and adaptable audio playback library for Rust

Awedio   A low-overhead and adaptable audio playback library for Rust. Examples Play a single sound file: let (mut manager, backend) = awedio::start()

10 Buttons 20 May 25, 2023
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
A tool that switch default audio playback device on windows.

AudioSwitch A tool built by Rust that can switch default audio playback device on windows. How to use specify which device you want to use Execute it

null 2 Aug 28, 2022
Estratto is a powerful and user-friendly Rust library designed for extracting rich audio features from digital audio signals.

estratto 〜 An Audio Feature Extraction Library estratto is a powerful and user-friendly Rust library designed for extracting rich audio features from

Amber J Blue 5 Aug 25, 2023
Media player with Youtube search, download, and playback functionality.

Pomelo 0.2.0 Pomelo is a desktop media player with Youtube search, playback, and download functionality. Current features Play videos locally from the

null 3 Sep 29, 2024
A node based audio effects thing

DSP Stuff A node based audio effects thing. Usage Run with cargo run --release --features gpl_effects (customize the feature flags as you wish) If you

Ben Simms 37 Dec 21, 2022