Socket
Socket
Sign inDemoInstall

wav-audio-sprite

Package Overview
Dependencies
3
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wav-audio-sprite

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


Version published
Weekly downloads
12
decreased by-53.85%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 20 Oct 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc