Growler

.wav files loaded as .mp3 from game engine

Recommended Posts

Using MelonJS 5.1, I'm trying to load a .wav audio file named data/bgm/Spywatch_Music_Overworld_v3_Spanish.wav but it's reading it as a .mp3.

modules.js:30156 GET http://127.0.0.1:3000/data/bgm/Spywatch_Music_Overworld_v3_Spanish.mp3 404 (Not Found)

My resources object is loaded via Grunt:

        files: [
          {
            src: ['build/data/bgm/**/*', 'build/data/sfx/**/*'],
            type: 'audio'
          },

Which results in

game.resources = [
    {
        "name": "Spywatch_Music_Overworld_v3_Spanish",
        "type": "audio",
        "src": "build/data/bgm/"
    },

https://melonjs.github.io/melonJS/docs/me.audio.html states "melonJS supports a wide array of audio codecs that have varying browser support : ("mp3", "mpeg", opus", "ogg", "oga", "wav", "aac", "caf", "m4a", "mp4", "weba", "webm", "dolby", "flac")."

so in game.js I initialize the sound engine as me.audio.init('mp3,ogg,wav');

Why is the engine defaulting to .mp3? Do I have to manually specify the audio file extension?

@obiot  @Parasyte

Share this post


Link to post
Share on other sites

Hi, the list of extensions is also a list of priority, which means that in this case melonjs will check if mp3 is supported, and if yes try to load the corresponding mp3 assets.

 

if you need .wav, just put it first, or only that extension.

Share this post


Link to post
Share on other sites

Hi, well this is just not how the current implementation works, the engine will just pick up one that is supported by the target broswer based on the given priority, and if you want to provide the 3 formats, you cannot therefore mix&match them.

Keep in mind also that not all browsers will support ogg for example. I would personnaly recommend to stick to mp3 amd webm (wav files are just to big), and it’s pretty simple to convert them (some website even provide some online converter).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.