npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wav-audio-sprite

v0.1.5

Published

Concatenate WAV files and pads with silence to whole seconds, for use in audio sprites.

Downloads

13

Readme

wav-audio-sprite

Concatenate WAV files and pads with silence to whole seconds, for use in audio sprites.

Meant to be instantly useful during development and later part of a larger tool-chain.

This process is really fast, compared to also encoding to a compressed format, which makes it extra suitable for local development.

Notes on usage

Only concatenates and pads + records information for use by a suitable player later. Does not convert to MP3, OGG, or other format. As such, there are no external dependencies such as FFMEPG or SOX that can sometimes trip up people. It is also very fast, so during development, you can do this on the fly for every request.

Use the WAVs during development and do final conversion for release builds in a separate part of the tool-chain - or even manually by the sound guy to get the most out of desktop/mobile and different formats.

Padding is by default at minimum one second silence between each sample, but if options.padding is set in milliseconds, that gap will be used instead, without aligning to each whole second.

API usage

npm install --save-dev wav-audio-sprite

const wavAudioSprite = require('wav-audio-sprite');

const files = ['sound-a.wav', 'sound-b.wav'];
const options = {
    padding: 200
};
wavAudioSprite(files, options)
    .then(result => {
        const {buffer, timings} = result;
        saveAudioSprite(buffer);
        postProcessTimings(timings);
    })
    .catch(e => console.error(e));

timings contains each filename, with start, end and durations - different tools wants different data and this is meant to be further processed if needs be:

{
  "sound-a.wav": {
    "start": 0,
    "end": 29538.73015873016,
    "duration": 29538.73015873016
  },
  "sound-b.wav": {
    "start": 31000,
    "end": 88600.23,
    "duration": 57600.23
  }
}

CLI usage

npm install -g wav-audio-sprite

howler-sprite

Barely more than an example, but outputs audiosprite and json in Howler.js format:

howler-sprite *.wav

howler-sprite --name mysprite *.wav

howler-sprite --path build *.wav

howler-sprite --path build --name mysprite *.wav

Add -q or --quiet to silence the output.

audio-sprite.json:

{
  "src": [
    "audio-sprite.wav"
  ],
  "sprite": {
    "sound-a": [0, 29538],
    "sound-b": [31000, 88600]
  }
}

See also

Uses node-wav for decoding/encoding.