
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
sample-loader
Advanced tools
A powerful and easy audio buffer loader for browser:
var ac = new AudioContext()
var load = require('sample-loader')(ac)
// a simple audio buffer player (use `sample-player` instead)
function play(buffer) {
var source = ac.createBufferSource()
source.buffer = buffer
source.connect(ac.destinaton)
source.start(ac.currentTime)
}
load('@drum-machines/maestro').then(function (buffers) {
play(buffers['snare'])
})
## Install
Via npm: npm i --save sample-loader or grab the browser ready file (4kb) which exports loader as window globals.
sample-loader is a flexible function to load samples from server. You can create a loader with an AudioContext instance and an (optional) options hash map:
var loader = require('sample-loader')
var ac = new AudioContext()
var load = loader(ac, { /* options (can be null) */ })
The returned load function receives only one parameter: the samples to load and returns always a Promise.
You can load individual or collection of files:
load('http://path/to/file.mp3').then(function (buffer) {
// buffer is an AudioBuffer
play(buffer)
})
load(['samples/snare.mp3', 'samples/kick.mp3']).then(function (buffers) {
// buffers is an array of AudioBuffers
play(buffers[0])
})
load({ snare: 'samples/snare.mp3', kick: 'samples/kick.mp3' }).then(function (buffers) {
// buffers is a hash of names to AudioBuffers
play(buffers['snare'])
})
You can load midi.js soundfont files, and works out of the box with Benjamin Gleitzman's package of
pre-rendered sound fonts. No server setup, just prepend @soundfont before the instrument name:
load('@soundfont/acoustic_grand_piano').then(function(buffers) {
play(buffers['C2'])
})
Can load drum-machines by prepending @drum-machines before the instrument name:
load('@drum-machines/CR-78').then(function (buffers) {
play(buffers['snare'])
})
You can add you own server samples repositories with the options parameter:
var load = loader(ac, { repositories: {
'@my-repo': 'http://myserver.com/samples'
}})
and then:
load('@my-repo/file.mp3')
MIT License
FAQs
A web audio sample loader
We found that sample-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.