XAudio2 midi volume

This forum is currently in read-only mode.
  • When I play midi files, volume doesn't work. I can only pause and play. It works for mp3's, why not for mid's? I hope, it's not a bug and I'm just doing something wrong, I've spent whole day looking for midi music for my game

  • I would say that the volume not working for midi's is odd, but I'm more surprised that it does for mp3's

  • I'll be probably using just music, haven't found any suitable free sound effects. I've wanted to have music played and after a level finished, turn it down a bit while shopping and then up again, fade in/out. Looks like I'll have to use just pause/play or continuous play.

    Is it same problem for you? Have you tried it? I'd upload an example, but I'm not on my comp and I can't get to my dropbox account(forgot pass).

    + System: Start of layout -> XAudio2: Play music "guilty.mid"

    -> XAudio2: Set music volume to 100

    + MouseKeyboard: On any key pressed -> XAudio2: Set music volume to 80

    This is first time I'm using sounds, but when I replace the mid with mp3 it works.

    Edit:

    Here is the file

  • Wow, that's really odd, on my pc, the midi file changes volume correctly yet mp3 files do not

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wow, that's really odd, on my pc, the midi file changes volume correctly yet mp3 files do not

    That's strange, but that means it could be better not to pause the music and just let it play continuously and lower the volume, and on some systems it'll work and on some it won't, I'll have to probably live with that.

    Do you know how to make a playlist?

  • Do you know how to make a playlist?

    In XAudio2? Sadly I don't think it's possible. However, if you know the exact length of each song you can make a hard-coded one I think.

    In my game I just have it change to a random song when the player presses the M key.

  • I was trying to change that volume today, with resource plugin, tried to load it as sound, changed master channel (but on wiki is that this doesn't affect music), but nothing worked. I'd like to know if it'd be possible with python? Could someone from developers answer me, if it's sound card/ construct/plugin problem or anything else and if it's going to get fixed/not, so I could move on.

  • I gave up, on trying to make midi play without problem:

    XAudio2

    .mid files

    + Loads midi and pause/play them

    • volume doesn't work

    mp3's

    +load files and pause/play works

    + setting volume works

    • there is no way to get music volume level
    • that means, no way to find out when a song finished playing and queue next one

    Python (pygame)

    .mid files

    + volume works

    • pause doesn't work

    mp3's

    + load files and pause/play works

    + setting volume works

    + you can stop music channel (it doesn't work for XAudio2 - only pause or load new file)

    + checking the music channel if working - works

    • can't set start position (i.e. start playback from middle)
    • can't queue songs (but you can make your own)

    conclusion is basically, don't use midi's, use mp3 and Python for music. I wanted to use midi files, because of their size, now after conversion of all midi's to mp3's my exe file inflated to almost 25MB, compared to 2MB before

    Eventually, this whole day try/error procedure had some positive effect. It forced me to start and learn Python a bit.

  • Another format you could have looked at is Mod files (.xm, .it, .s3m, etc) which are like midi files with custom samples/instruments. They sound the same on any pc (unlike midis).

    However, to check if a mod file is stopped you need to use an inverted "Is Paused" and inverted "Is Playing" condition. When both return false (the inverted versions therefore both return true) the song is over.

    Check out some of the music you can play with the mod plugin here: http://modarchive.org/index.php

    Edit: I also just realised, the mod plugin doesn't support volume controls. Darn

  • I'll wait how R0J0's Audiere plugin will turn out. For now it's bit better than XAudio2, still I miss some features.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)