2.2.3 • Published 7 years ago

sound-board v2.2.3

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Sound board

Build Status

A simple abstraction around web audio apis to make interactions easier for loading files and playing them.

Install

npm i sound-board --save

Usage

Loading sound

import soundBoard from 'sound-board'

soundBoard.downloadSound('waterbowl', 'http://example.com/waterbowl.mp3')
  .then(() => soundBoard.play('waterbowl'))
  .catch(err => console.error(err)) // if something happens on download

// or
soundBoard.loadSounds({
  waterbowl: 'http://example.com/waterbowl.mp3',
  gong: 'http://example.com/gong.mp3'
})
  .then(() => /* do stuff with sounds */)
  .catch(err => console.error(err)) // if something happens on a download

// or a local buffer
soundBoard.loadBuffer('chime', arrbuffer)
  .then(() => /* do stuff with sounds */)
  .catch(err => console.error(err)) // if something happens on a download

Playing sound

// to play a sound at a certain time
soundBoard.play('waterbowl', 1.337) // starts at 1.337 seconds

// to pause the sound
soundBoard.pause('waterbowl')

// to stop the sound
soundBoard.stop('waterbowl')

Events

soundBoard.on('play', (soundName) => {}) // when starting to play the sound
soundBoard.on('pause', (soundName) => {}) // when pausing the sound
soundBoard.on('end', (soundName) => {}) // when the sound ends
soundBoard.on('frequencyData', (soundName, bufferLength, dataArray) => {}) // some data when song is playing
2.2.3

7 years ago

2.1.3

7 years ago

2.0.3

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago