0.0.3 • Published 12 months ago

sound-deck v0.0.3

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

sound-deck-core

The SoundDeck class presents a convenient API for producing sounds in your client-side JS / TS projects. The SoundDeck uses the AudioContext interface and abstracts some of the complexity of managining an audio graph.

Current features:

  • load audio files from a URL then play and stop them on demand
  • generate white noise of a given frequency using randomly generated sample buffers
  • generate tones using Oscillator node
  • set the master volume of the whole SoundDeck and/or set the volume of individual sounds when playing them
  • Promise - based API for knowing when a sound has finished
  • ability to play sounds on a loop until programatically stoped.

This library was generated with Nx.

installation

npm npm i sound-deck

yarn yarn add sound-deck`

Usage

Basic example:

const mySoundDeck = new SoundDeck();

console.log('starting 5 second tone');
const tone = mySoundDeck.playTone(
  { type: 'sawtooth', frequency: 600, duration: 5 },
  { volume: 0.5 }
);

if (tone) {
    tone.whenEnded.then(() => {
        console.log('tone now finished.')
    })
}

See more examples at:

compatability

Most modern browsers are compatible with AudioContext. The methods for loading and playing audio file have fallbacks to work partially in envirornements where the AudioContext is not available.

Running unit tests

Run nx test sound-deck-core to execute the unit tests via Jest.

Releases

  • From sound-deck\packages\sound-deck-core : Use npm version {patch|minor|major} to update version number
  • From sound-deck\ : nx build sound-deck-core to build the library.
  • From sound-deck\dist\packages\sound-deck-core: npm publish
0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago