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

soundsprite

v0.2.7

Published

Concat small audio files into single file and export in many formats.

Downloads

4

Readme

What?

Forked from [tonistiigi/audiosprite] (https://github.com/tonistiigi/audiosprite) to target other frameworks - all credit to original author

This is a ffmpeg wrapper that will take in multiple audio files and combines them into a single file. The final file will be exported in mp3, webm, opus, m4a and caf(IMA-ADPCM) to support as many devices as possible. This tool will also generate a JSON file that is compatible with goldfire/howler.js framework.

This project is also targeting [bp74/StageXL] (https://github.com/bp74/StageXL) - implementation pending.

Why?

iOS, Windows Phone and some Android phones have very limited HTML5 audio support. They only support playing single file at a time and loading in new files requires user interaction and has a big latency. To overcome this there is a technique to combine all audio into single file and only play/loop certain parts of that file. goldfire/howler.js is a audio framework that uses this technique.

###Installation

npm install -g soundsprite

Hints for Windows users

  • You need to install Node.js
  • Use Git Bash instead of Command Line or Powershell
  • Download ffmpeg and include it in your path export PATH=$PATH:path/to/ffmpeg/bin
  • IMA-ADPCM(the fastest iPhone format) will only be generated if you are using OSX.

###Usage

> soundsprite --help
info: Usage: soundsprite [options] file1.mp3 file2.mp3 *.wav
info: Options:
  --output, -o      Name for the output file.                                    [default: "output"]
  --export, -e      Limit exported file types. Comma separated extension list.   [default: ""]
  --log, -l         Log level (debug, info, notice, warning, error).             [default: "info"]
  --autoplay, -a    Autoplay sprite name                                         [default: null]
  --silence, -s     Add special "silence" track with specified duration.         [default: 0]
  --samplerate, -r  Sample rate.                                                 [default: 44100]
  --channels, -c    Number of channels (1=mono, 2=stereo).                       [default: 1]
  --rawparts, -p    Include raw slices(for Web Audio API) in specified formats.  [default: ""]
  --help, -h        Show this help message.


> soundsprite --autoplay bg_loop --output mygameaudio bg_loop.wav *.mp3
info: File added OK file=bg_loop.wav
info: 1.25s silence gap added OK
info: File added OK file=click.mp3
info: 1.70s silence gap added OK
info: Exported caf OK file=mygameaudio.caf
info: Exported ac3 OK file=mygameaudio.opus
info: Exported mp3 OK file=mygameaudio.mp3
info: Exported m4a OK file=mygameaudio.m4a
info: Exported ogg OK file=mygameaudio.webm
info: Exported json OK file=mygameaudio.json
info: All done


> cat mygameaudio.json
{
  "urls": [
    "mygameaudio.caf",
    "mygameaudio.opus",
    "mygameaudio.mp3",
    "mygameaudio.m4a",
    "mygameaudio.webm"
  ],
  "sprite": {
    "bg_loop": [0, 3.75, true],
    "click": [4, 0.3]
  }
}

####Custom silent track

On some cases starting and pausing a file has bigger latency than just setting playhead position. You may get better results if your file is always playing. --silence <duration> option will generate extra track named silence that you can play instead of pausing the file.

####Usage with goldfire/howler.js framework.

Generated JSON file can be passed straight into Howl constructor. Check out [Howler.js documentation] (http://goldfirestudios.com/blog/104/howler.js-Modern-Web-Audio-Javascript-Library) for more info.

var settings = /* JSON generated by audiosprite*/;
var sound = new Howl(settings);