Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-sound-spritesheet with all npm packages installed. Try it out:

grunt-sound-spritesheet lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

require("grunt/package.json"); // grunt is a peer dependency. // require("grunt-sound-spritesheet/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-sound-spritesheet v0.1.2

Combines audio files into one audio file and creates json data for cue points.

grunt-sound-spritesheet

Combines audio files into one audio file and creates json data for cue points.

supported formats

* mp3
* ogg

Compatabile with Howlerjs

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-sound-spritesheet --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-sound-spritesheet');

The "soundSpritesheet" task

Overview

In your project's Gruntfile, add a section named soundSpritesheet to the data object passed into grunt.initConfig().

grunt.initConfig({
  soundSpritesheet: {
    options: {
      audioDir: './audioFiles',
      outputDir: 'output',
      outputFileName:'big.mp3',
      outputFormat:'mp3'
    }
  },
});

Options

options.audioDir

Type: String required

Path to audio files

options.outputDir

Type: String required

options.outputFileName

Type: String required

options.outputFormat

Type: String required

file format . Either mp3 or ogg for now.

Usage Examples

grunt.initConfig({
  soundSpritesheet: {
    options: {
      audioDir: './audioFiles',
      outputDir: 'output',
      outputFileName:'bingo.ogg',
      outputFormat:'ogg'
    }
  },
});

Sample generated Json data file

each entry starts with the file name in spriteSheet and have start point and end points in an array

{
    "1": [
        0,
        2116.8999999999996
    ],
    "2": [
        6740.81723356009,
        2430.4
    ],
    "laser": [
        9171.21723356009,
        2221.4
    ],
    "test": [
        11392.61723356009,
        2848.3
    ]
}

Usage with Howler

var sound = new Howl({
  urls: ['bingo.mp3'],
  sprite: path-to-json-object-file
});

// shoot the laser!
sound.play('laser');

Release History

(0.1.0) (0.1.2)

Todo

  • more audio formats
  • ability to add silence gap between audio files

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free