XAudio2 midi volume

For questions about using Classic.

Post » Wed May 18, 2011 4:28 pm

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 :lol: .... :x
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Wed May 18, 2011 6:08 pm

I would say that the volume not working for midi's is odd, but I'm more surprised that it does for mp3's :o Not sure why this is, but a temporary solution is just to boost the sound effects volume instead (to give the effect that music is decreasing). Sadly this means users will need to turn their system volume down just for your game :(
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu May 19, 2011 7:40 am

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
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Thu May 19, 2011 9:20 pm

Wow, that's really odd, on my pc, the midi file changes volume correctly yet mp3 files do not :shock: Weird stuff :?
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri May 20, 2011 9:35 am

[quote="Jayjay":2d1unksy]Wow, that's really odd, on my pc, the midi file changes volume correctly yet mp3 files do not :shock: Weird stuff :?[/quote:2d1unksy]

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?
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Fri May 20, 2011 2:26 pm

[quote="Noga":wrd8covl]Do you know how to make a playlist?[/quote:wrd8covl]

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.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri May 20, 2011 3:43 pm

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.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Mon May 23, 2011 11:14 pm

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 :( . I didn't use wav's because all converted wav files were even bigger than mp3. I'll report all these to bugs tracker. I don't know how would it work if I played wav music file as sound or if I used ogg's, but getting music volume level would be great and stopping music, and maybe setting song position and... :)
Eventually, this whole day try/error procedure had some positive effect. It forced me to start and learn Python a bit.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue May 24, 2011 5:13 pm

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: [url:2utltt17]http://modarchive.org/index.php[/url:2utltt17]

Edit: I also just realised, the mod plugin doesn't support volume controls. Darn :(
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed May 25, 2011 5:03 pm

I'll wait how R0J0's Audiere plugin will turn out. For now it's bit better than XAudio2, still I miss some features.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests