Jose Serodio
Jose Serodio

Reputation: 1439

How to find music position and duration for sound 'sprites'?

I'm making a videogame and I have an audio file called "sounds.mp3" where all my sounds are.

I'm using Howler.js, and I need to know where exactly the sound is positioned, and what is its duration.

sound = new Howl({
    urls: ['assets/sounds.mp3'],
    volume: 0.2,
    sprite: {
        point: [0, 700],
        blast: [0, 2000], // start , duration
        laser: [3000, 700], // sound.play('laser');
        winner: [5000, 9000]
    },
    onload: function() {
        init(); // when every music or sound is loaded
    }
});

Here, laser sound would start at second 3, and its duration would be one 0,7 seconds.

I know there are tools for image sprites like GetSpriteXY or Sprite Cow, would be awesome if someone knows a similar tool for this.

The actual code works, I just need a better way to pinpoint the sound whitin the file than just listening carefully.

Thank you in advance.

Upvotes: 1

Views: 810

Answers (1)

James Simpson
James Simpson

Reputation: 13688

There are a few options for this:

  1. You can load the sound into Audacity (http://www.audacityteam.org/), then simply double-click on each section of audio to select it and the bottom row will show you the info such as start and end position.

  2. If you have the individual audio tracks separate from the compiled sound sprite, you might consider using something like soundsprite (https://github.com/realbluesky/soundsprite) to generate the sprite file. It is compatible with the howler.js format and will output everything you need.

Upvotes: 1

Related Questions