Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@dr.pogodin/audio-loader
Advanced tools
It used to be a patched fork of
audio-loader
library,
but starting from v1.2.0
it has been refactored to drop NodeJS support,
and thanks to that to use the minimum of dependencies (many of which were
not actively maintained).
There are also some changes in the API.
ORIGINAL README BELOW, IT IS PENDING AN UPDATE
An simple and flexible audio buffer loader for browser.
var load = require('@dr.pogodin/audio-loader')
// load one file
load('http://example.net/audio/file.mp3').then(function (buffer) {
console.log(buffer) // => <AudioBuffer>
})
// load a collection of files
load({ snare: 'samples/snare.wav', kick: 'samples/kick.wav' },
{ from: 'http://example.net/'} ).then(function (audio) {
console.log(audio) // => { snare: <AudioBuffer>, kick: <AudioBuffer> }
})
Npm
npm i --save audio-loader
Yarn
yarn add audio-loader
Browser
Download the minified distribution which exports loadAudio
as window global:
<script src="audio-loader.min.js"></script>
<script>
loadAudio({ snare: 'snare.wav' }, { from: 'oramics.github.io/sampled/' }).then(..)
</script>
You can load individual or collection of files:
load('http://path/to/file.mp3').then(function (buffer) {
// buffer is an AudioBuffer
play(buffer)
})
// apply a prefix using options.from
load(['snare.mp3', 'kick.mp3'], { from: 'http://server.com/audio/' }).then(function (buffers) {
// buffers is an array of AudioBuffers
play(buffers[0])
})
// the options.from can be a function
function toUrl (name) { return 'http://server.com/samples' + name + '?key=secret' }
load({ snare: 'snare.mp3', kick: 'kick.mp3' }, { from: toUrl }).then(function (buffers) {
// buffers is a hash of names to AudioBuffers
play(buffers['snare'])
})
audio-loader
will detect if some of the values of an object is an audio file name and try to fetch it:
var inst = { name: 'piano', gain: 0.2, audio: 'samples/piano.mp3' }
load(inst).then(function (piano) {
console.log(piano.name) // => 'piano' (it's not an audio file)
console.log(piano.gain) // => 0.2 (it's not an audio file)
console.log(piano.audio) // => <AudioBuffer> (it loaded the file)
})
If you provide a .js
file, audio-loader
will interpret it as a midi.js soundfont file and try to load it:
load('acoustic_grand_piano-ogg.js').then(function (buffers) {
buffers['C2'] // => <AudioBuffer>
})
This is a repository of them: https://github.com/gleitz/midi-js-soundfonts
load(source, options)
Param | Type | Description |
---|---|---|
source | Object | the object to be loaded: can be an URL string, ArrayBuffer with encoded data or an array/map of sources |
options | Object | (Optional) the load options for that source |
Possible options
keys are:
from?: function|string
– Optional. A function or string to convert
from file names to urls.
If is a string it will be prefixed to the name:
load('snare.mp3', { from: 'http://audio.net/samples/' })
If it's a function it receives the file name and should return the url as
string.only?: {Array} - Optional. When loading objects, if provided, only the given keys will be included in the decoded object:
load('piano.json', { only: ['C2', 'D2'] })`To run the test, clone this repo and:
npm install
npm test
To run the browser example:
npm i -g budo
npm run browser-example
MIT License
FAQs
A flexible web audio sample loader for browser and node
The npm package @dr.pogodin/audio-loader receives a total of 19 weekly downloads. As such, @dr.pogodin/audio-loader popularity was classified as not popular.
We found that @dr.pogodin/audio-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.