Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

beepbox-lite

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beepbox-lite

A simple beepbox player!

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Beepbox

Note: This package was originally called beepbox, but I've renamed it as beepbox-lite to give access to the rightful owner of Beepbox!

A simple library for playing beepbox songs. This library is a more polished version of what I made for my 2018 JS13kGames entry!

This is an open source project under the MIT license, see LICENSE.md for additional information.

Usage

Create an audio context and load a song

import Audio from 'beepbox';
import song from './song.json';
const player = new Audio(song);

Play a beepbox song (once)

/**
 * Play the loaded clip once.
 *
 * @returns {Object}
 *   The generic node from Audio.generateNode() for this sequence.
 */
player.play();

Loop a beepbox song (infinitely)

/**
 * Play the loaded clip infinitely.
 *
 * @returns {Object}
 *   The generic node from Audio.generateNode() for this sequence.
 */
player.loop();

Play a single note

/**
 * Play a single note with the given params.
 *
 * @param {Number} freq
 *   The note frequency to play.
 * @param {Number} len
 *   The duration to play the note (seconds).
 * @param {Number} off
 *   The time offset to play the note (seconds).
 * @param {String} type
 *   The OscillatorNode type to use; https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/type
 * @param {Number} gain
 *   The gain (volume) to play the note at (0.0 - 1.0).
 *
 * @returns {Object}
 *   The generic node from Audio.generateNode() for this sequence.
 */
player.note(freq, len, off, type, gain);

Example

'use strict';

import Audio from 'beepbox';
import song from './song.json';

const player = new Audio(song);
player.play();

Contact

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc