Sound effects affected by 'set music volume (n)'

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Only One In All
Metal Slime
Posts: 356
Joined: Tue Oct 16, 2007 5:56 am
Contact:

Sound effects affected by 'set music volume (n)'

Post by Only One In All »

It used to be that sound effects were not affected by the plotscript, 'set music volume' (around pre-2011 I'd say) but now both sound effects and music is affected by the command, which screws up the parts of Kitty House where the music is muted but sound effects are still needed to play.

Any way to get the old way back, or even a plot script that will affect music and sound effects separately?
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Re: Sound effects affected by 'set music volume (n)'

Post by Bob the Hamster »

Only One In All wrote:It used to be that sound effects were not affected by the plotscript, 'set music volume' (around pre-2011 I'd say) but now both sound effects and music is affected by the command, which screws up the parts of Kitty House where the music is muted but sound effects are still needed to play.

Any way to get the old way back, or even a plot script that will affect music and sound effects separately?
This is really a problem with our music backends.

the music_sdl backend keeps separate volume mixers for MIDI and for everything else. We used to only set the midi mixer, which meant that the volume commands were broken for sound effects and for ogg music. In 2010 we changed the music_sdl backend to change the overall volume, so it would work for both types of music. If we change it back to get the old sound effect behaviour, it will break volume support for ogg music.

Meanwhile, the music_native backend has no support for adjusting midi volume at all, so on that backend, volume adjusting commands will adjust ogg music and sound effects, but will have no effect on midi

It sucks, and we need a new music backend, but that is a whole lot of hard work, which is why we have not gotten around to it yet :(

It might be better to mute the song with "stop song", and then re-start it with "play song" after the sound effect.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

We do NOT set the volume for sound effects in music_sdl ever. I've just looked through the SDL_mixer source and confirmed that setting the music volume does not affect the sound effects volume.

It turns out that this is actually a bug or purposeful anti-feature in Windows Vista and 7 (and 8 I assume). Other people have devised elaborate workarounds for this bug, or ditched the Windows MIDI synth entirely:
http://www.doomworld.com/vb/source-port ... di-volume/

There is a not-hacky solution, which is to modify the volume on a MIDI note-by-note basis instead of setting the global volume. This requires modifying SDL_mixer (which I'd rather dump instead)

Strangely enough any time we have a problem with SDL_mixer I google it, and some thread at doomworld.com is always the best result. They really know what they're doing, and I'd like to look into borrowing some of their code.
Last edited by TMC on Wed Jul 31, 2013 4:59 pm, edited 1 time in total.
User avatar
Only One In All
Metal Slime
Posts: 356
Joined: Tue Oct 16, 2007 5:56 am
Contact:

Post by Only One In All »

Yeah, I was thinking about the possibility I might have to resort to just using stop song. :v: It would just make the cinematic events more awkward. Would a 'pause song' command of some sort, similar to 'pause sound' work?
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Ah! I stand corrected! I should have tested sound effect volumes myself before I misspoke :)
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Well funnily enough SDL_mixer's function to pause the song didn't work last time we tried it. That's why we can't have nice things.
Last edited by TMC on Thu Aug 01, 2013 5:15 am, edited 1 time in total.
User avatar
Only One In All
Metal Slime
Posts: 356
Joined: Tue Oct 16, 2007 5:56 am
Contact:

Post by Only One In All »

Just wanted to add, if you change the volume with the command, then play an OGG, the volume change does NOT take effect. You need to play a MIDI in order for it to do so.

I just had a problem with my volume being at 4 when there was a clear plotscript command indicating it should be 255. The OGG played at 4, but when I swapped it out for a MIDI, it played it at 255.
Post Reply