Default MUS channel volume is incorrect

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Yarn366
Posts: 61
Joined: Fri Mar 02, 2018 11:48 pm
Preferred Pronouns: He/Him

Default MUS channel volume is incorrect

Post by Yarn366 »

When playing MUS files, GZDoom initially sets the volume of each MIDI channel to 127. This is incorrect; they should be set to 100, the same as the General MIDI default and the same default value that's used by vanilla Doom.

An example of a song affected by this issue is Doom's D_E1M3. This song sets the volume of MIDI channels 1 and 2 to 100 but does not set the volume of channel 10. Because of this, the drums are played a bit louder than they should be in GZDoom due to channel 10's volume being 127 instead of 100.

(All my testing with both GZDoom and vanilla Doom was done the in-game music volume set to maximum, by the way.)

The culprit is this line:

https://github.com/ZDoom/ZMusic/blob/1d ... s.cpp#L138

That should be set to 100, not 127.
User avatar
Rachael
Posts: 13793
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Default MUS channel volume is incorrect

Post by Rachael »

Do you have a reference (source) for this? It's an easy enough change, but not one that I will make without having the proper data easily available.

Seeing as how this is a shared library, I am also concerned this may break the music in the Raze games - if it's possible to look up what volume those musics start at, it would be extremely helpful.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Default MUS channel volume is incorrect

Post by Graf Zahl »

No worry about Raze. All the Build games use MID format, not MUS. And for MID the volume is indeed defaulted to 100, although there's an interesting comment about ASS (which is what at least Duke used) in there, saying it defaulted to 90.
Yarn366
Posts: 61
Joined: Fri Mar 02, 2018 11:48 pm
Preferred Pronouns: He/Him

Re: Default MUS channel volume is incorrect

Post by Yarn366 »

The attached initial_volume_test.zip contains a MUS file that can be used to test for this issue. In it, a note plays for 6 seconds on channel 1 without the channel volume having been set. Midway through the note, the channel volume is set to 100; in vanilla Doom, there is no volume change. Then, a series of short notes play alternately on channels 2 and 3, with channel 2 having no volume set and channel 3 having the volume set to 100; in vanilla Doom, all the notes are the same volume. After that, the tests repeat two more times, this time on different channels. This is then followed by 5 minutes of silence.

If you play this in vanilla Doom, make sure the music volume is set to maximum.

This technically isn't part of the issue that I reported, but I have noticed that vanilla Doom resets the channel volumes to 100 every time a song loops and not just when the song begins. In case you're interested, the attached loop_volume_test.zip tests this. It plays a 4-second note without a prior volume change command, and sets the volume to 70 halfway through. In vanilla Doom, the note starts louder and then suddenly gets quieter every time it's played; in GZDoom, this happens only the first time, with subsequent loops just playing the note at the lower volume with no further volume change.
You do not have the required permissions to view the files attached to this post.
Gez
 
 
Posts: 17934
Joined: Fri Jul 06, 2007 3:22 pm

Re: Default MUS channel volume is incorrect

Post by Gez »

Yarn366 wrote: Sun Dec 25, 2022 9:35 pm When playing MUS files, GZDoom initially sets the volume of each MIDI channel to 127. This is incorrect; they should be set to 100, the same as the General MIDI default and the same default value that's used by vanilla Doom.
We don't have the full vanilla Doom code (the code released had had its sound system excised because the DMX library remained proprietary and closed source), but the next best thing is Chocolate Doom.
https://github.com/chocolate-doom/choco ... /mus2mid.c
And I see this:

Code: Select all

// Cached channel velocities
	static byte channelvelocities[] =
	{
	127, 127, 127, 127, 127, 127, 127, 127,
	127, 127, 127, 127, 127, 127, 127, 127
	};
This sets all velocities to 127. Volume is not affected anywhere and presumably retain its default value of 100.

ZMusic seems to do the opposite: set velocity to 100 and volume to 127.
User avatar
Rachael
Posts: 13793
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Default MUS channel volume is incorrect

Post by Rachael »

Gone ahead and did the change, then:
https://github.com/ZDoom/ZMusic/commit/ ... b81945e9ec
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Default MUS channel volume is incorrect

Post by Graf Zahl »

And it took just a bit less than 20 years to discover the problem. The code in question was added in early February 2003 with ZDoom 2.0.40. Interestingly, the original had velocity at 64, it later got changed to 100.

Return to “Closed Bugs [GZDoom]”