openmusic-sample-player
Provides an abstraction on top of BufferSourceNodes so samples can be played without regenerating the node when ended
Usage
Install first: npm install openmusic-sample-player
.
Then you can use it in your code:
var SamplePlayer = ; var audioContext = ;var player = ; // suppose you have a BufferSource in `buffer` already playerbuffer = buffer; // if you want to make it loopplayerloop = true; // and start playing!playerstart;
Multiple plays can be scheduled:
var now = audioContextcurrentTime;playerstartnow + 1; // play in 1 secondplayerstartnow + 2; // play in 2 secondsplayerstartnow + 3; // play in 3 seconds// ...player; // stop all scheduled plays
Demo
Run npm install
so it installs stuff for the demo. Then gulp build
, and then you can open build/index.html
for the demo.
If you do changes in the code, you'll need to rebuild the demo. Use gulp build
or gulp
only for running build
and setting up a watch
loop that automatically rebuilds the demo as you change its files.