Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
nukeykt

Doom/Strife with random pitched sound

Recommended Posts

A version of DMX used in Doom/Strife "with broken pitched sound" actually supports pitched sound. Instead Doom has some bugs in the sound code. The first bug was in I_StartSound function, where Id swapped separation and pitch parameters, which cause neutral pitch for player sounds. The sound code also updates non player sounds every tic, and always calls SFX_SetOrigin function with neutral pitch value. As a result DMX plays every sound with neutral pitch.

Then i developed a small hack for strife binary which fixes I_StartSound function, and modifies DMX code to ignore new pitch value. Results:



Doom 2 v1.9:


VCDIFF patch download
Strife v1.31:
https://www.dropbox.com/s/vi33v6m7gedk4mo/strifepitch.vcdiff?dl=0

Doom 1 1.666:
https://www.dropbox.com/s/f39t6n05488a1ew/doom1_1666pitch.vcdiff?dl=0

Doom 2 1.666:
https://www.dropbox.com/s/z2uzfocf4300v7s/doom2_1666pitch.vcdiff?dl=0

Doom 1.7a:
https://www.dropbox.com/s/z6a14numo1c27eg/doom17a_pitch.vcdiff?dl=0

Doom 1.8:
https://www.dropbox.com/s/hrj1jqpgm8t4mrq/doom18pitch.vcdiff?dl=0

Doom 1.9:
https://www.dropbox.com/s/l6vsgq41n51l7gu/doom19pitch.vcdiff?dl=0

Ultimate Doom:
https://www.dropbox.com/s/vc49cy1yocvevru/doomultpitch.vcdiff?dl=0

Final Doom:
https://www.dropbox.com/s/4gp9yckacdnfu8v/doomfinpitch.vcdiff?dl=0

Share this post


Link to post

I've looked at your videos and the sound is pitched like it is in Doom v1.1. Sounds were less pitched in Doom v1.2. Do you know if the sound pitch was somewhat already broken in Doom v1.2?

Share this post


Link to post

I appreciate your research into this, and it's of historical interest to learn that it wasn't the DMX library that randomly broke pitch shifting but actually id itself who somehow did it. Nevertheless random-pitched sound effects must be destroyed.

Share this post


Link to post

After I took a look at older Doom versions (Doom 0.99 through Doom 1.3), I realized that the fixed Doom v1.9 changes the pitch too much. That's not how it was meant to be. The pitch effect of Doom v1.1 is different from v1.9.

I believe Id Software didn't realize where the bug was, so they tried to increase the maximum pitch difference in their source code to see if it would change something, when they realized it didn't fix the bug, they didn't change the values back to what it was before.

Share this post


Link to post
axdoom1 said:

After I took a look at older Doom versions (Doom 0.99 through Doom 1.3), I realized that the fixed Doom v1.9 changes the pitch too much. That's not how it was meant to be. The pitch effect of Doom v1.1 is different from v1.9.

I believe Id Software didn't realize where the bug was, so they tried to increase the maximum pitch difference in their source code to see if it would change something, when they realized it didn't fix the bug, they didn't change the values back to what it was before.


Pitch value calculation formula in Doom 1.9 exacts to 1.2. It could be due to changes in DMX code.

Share this post


Link to post
nukeykt said:

The first bug was in I_StartSound function, where Id swapped separation and pitch parameters, which cause neutral pitch for player sounds. The sound code also updates non player sounds every tic, and always calls SFX_SetOrigin function with neutral pitch value. As a result DMX plays every sound with neutral pitch.

Could it be a change in the DMX API, where the pitch and separation parameters used to be the other way around and they didn't update the code?

Share this post


Link to post
Gez said:

Could it be a change in the DMX API, where the pitch and separation parameters used to be the other way around and they didn't update the code?


API of DMX used in Doom 1.9:

SFX_PlayPatch(
 void *patch,           // INPUT : Patch to play
 int  pitch,            // INPUT : 0..128..255  -1Oct..C..+1Oct
 int  x,                // INPUT : Left-Right Positioning
 int  volume,           // INPUT : Volume Level 1..127
 int  flags,            // INPUT : Flags 
 int  priority          // INPUT : Priority, 0=Lowest
 );

SFX_SetOrigin(
 SFX_HANDLE handle,     // INPUT : Handle received from play
 int        pitch,      // INPUT : 0..127..255
 int        x,          // INPUT : Left-Right Positioning
 int        volume      // INPUT : Volume Level 1..127
 );
API of DMX in Doom 1.2, based on disassembly:
SFX_PlayPatch(
 void *patch,           // INPUT : Patch to play
 int  x,                // INPUT : Left-Right Positioning
 int  pitch,            // INPUT : 0..128..255  -1Oct..C..+1Oct
 int  volume,           // INPUT : Volume Level 1..127
 int  priority          // INPUT : Priority, 0=Lowest
 );

SFX_SetOrigin(
 SFX_HANDLE handle,     // INPUT : Handle received from play
 int        x,          // INPUT : Left-Right Positioning
 int        volume      // INPUT : Volume Level 1..127
 );
So, you was partially right.

Share this post


Link to post
nukeykt said:

Pitch value calculation formula in Doom 1.9 exacts to 1.2. It could be due to changes in DMX code.


If you want to compare Doom v1.2 with Doom v1.3...
(you can listen to the sound online without downloading the file)

Plasma gun:
http://www.mediafire.com/listen/m5r4pp34qvf0xrp/Doom_v1.2_vs_Doom_v1.3_plasmagun_sound.mp3

Chaingun:
http://www.mediafire.com/listen/qk76n5nnptx2xk7/Doom_v1.2_vs_Doom_v1.3_chaingun_sound.mp3

The pitches may be the same, but in the exact same conditions, shooting with these weapons produce different results.

Share this post


Link to post

Questions:

Wiki article">
The Wiki article said:

"Sound effects are always played at a neutral pitch in later versions of DOS Doom, despite the fact that the DMX API calls are still passed a randomized pitch value."

"Two DMX functions are relevant for this bug: SFX_PlayPatch() and SFX_SetOrigin().
The order in which parameters are passed was modified, and as a result Doom started sending the channel separation value (stereo positioning for the sound) as the pitch value."


Why is the sound always played as a neutral pitch even though a integer that could be of any value is sent as the Pitch Change?

Why didn't the Left-Right Positioning of sounds broke like the sound pitch did?

Share this post


Link to post
Brewtal_Legend said:

How is this supposed to be used exactly?


It's not. Pitch shifted sounds are an atrocity.

Share this post


Link to post

Really interesting stuff, thanks! I thought I'd seen the last of the pitch stuff when I finished up the code for chocolate-doom, and since then we had the DMX leak and now this... there's no bottom to the well ;)

Share this post


Link to post
Linguica said:

So the DMX guy effectively broke his own API?

The number of parameters changed, so compilation was impossible until the code was updated to reflect the API change, and Id Software half-assed their update.

Share this post


Link to post
Gez said:

The number of parameters changed, so compilation was impossible until the code was updated to reflect the API change, and Id Software half-assed their update.

You could split the blame I suppose.

Share this post


Link to post
nukeykt said:

I just verified that, Doom 1.9 has random panned player sound.

I wish you would be a little more in-depth in your descriptions / explanations.

Share this post


Link to post
nukeykt said:

I just verified that, Doom 1.9 has random panned player sound.

What do you mean by 'panned'? There's no pitch variation in Chocolate 1.9, and I'm sure its not present in the 1.9 dos exes either.. Unless my ears are broken or something.

Share this post


Link to post

I tried loading doom2.exe in DOSBox and pushing a wall a bunch of times while recording it in OBS. Then I exported the audio to Audacity, split the stereo stream into left / right streams, and overlaid them. In the following GIF I flip between the left channel and right channel. If they were perfectly equivalent then there would be no apparent movement. But it does look like there's a little bit of random difference between the left and right channels when you flip them back and forth:



The engine also says

#define NORM_SEP	128

...

    if ( origin->x == players[consoleplayer].mo->x
	 && origin->y == players[consoleplayer].mo->y)
    {	
      sep 	= NORM_SEP;
    }
So since the pitch-shifting value is also centered around 128, that suggests that player sounds were shifted left or right by up to 16.

The game then takes the square of the separation in order to determine the final left- and right-channel volumes, so I dunno what that ends up being in terms of real world volume difference per channel.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×