Duke4.net Forums: What real life units do .VOC pitch variation correspond to? - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

What real life units do .VOC pitch variation correspond to?

#1

I'm trying to make a .wav version of the Freezethrower/Devastator fire sound (catfire.voc) to sound the way it does in the game. From what I understand, the game dynamically pitches the sound up to be +512 to +768 of its original pitch as defined in USERDEFS.CON

definesound CAT_FIRE            catfire.voc       512   768   4   0   0


but what exactly do the 512 and 768 equate to in terms of multiplier and percentage (eg 1.5x, 150%)? I've used both Change Pitch and Change Speed And Pitch in Audacity but just couldn't get it to sound like it does in the game.
0

User is offline   Reaper_Man 

  • Once and Future King

#2

Oh man, what a question.

The short answer is: Yes it's a multiplier, but not really directly. The scale is cents (the audio one, not the money one).

I am pretty sure the part of code that handles this way down in the engine is as follows:

/*---------------------------------------------------------------------
   Function: PITCH_GetScale

   Returns a fixed-point value to scale number the specified amount.
---------------------------------------------------------------------*/

uint32_t PITCH_GetScale(int const pitchoffset)
{
    static bool bInitialized;

    if (!bInitialized)
    {
        PITCH_Init();
        bInitialized = true;
    }

    if (pitchoffset == 0)
        return PitchTable[0][0];

    int noteshift = pitchoffset % 1200;

    if (noteshift < 0)
        noteshift += 1200;

    int const   note   = noteshift / 100;
    int const   detune = (noteshift % 100) / (100 / MAXDETUNE);
    int const   oshift = (pitchoffset - noteshift) / 1200;
    auto const &scale  = PitchTable[note][detune];

    return (oshift < 0) ? (scale >> -oshift) : (scale << oshift);
}


To determine the pitch multiplier, you calculate 2^(pitch/1200). The game simply picks a value randomly between the min and max ranges. However, because of how the pitch offset value here is modulus'd and clamped to the note and detune, there are actually fixed amount of "steps", which is the PitchTable. This is apparently precomputed at runtime. In other words - the pitch output of 510 is unique, but the output of 511, 512, and 513 is the same, then 514 is unique, and so on. The pattern is basically 1, 3, 1, 3, so on.

I think. Maybe. I've never looked at this code before, I just learned what "cents" are, and as I've been told, the sound engine is, in technical terms, "fucked". Hope this helps tho.
0

User is offline   Mark 

#3

I played around for a couple minutes with the original sound file in Audacity. By seperately adjusting pitch, tempo and boosting treble a bit it can sound close to the version in the game. Unfortunately I misclicked and didn't save my result. But at least it showed its possible to get close.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options