Since we are all showing up our geniously designed code with awesome pointer wrestling or typecasting, let me share some of mine


this calculates proper constant for sending wav raw wave data to openal:

Code:
  format := AL_FORMAT_MONO8 + ((wavheader.BitsPerSample div 8) - 1) +
    (wavheader.NumChannels - 1) * 2;

and a similar thing for opengl texture upload:

Code:
     glTexImage2D(GL_TEXTURE_2D, 0, 3 + integer((format = GL_BGRA_EXT) or (format = GL_RGBA)),
        Width, Height, 0, format, GL_UNSIGNED_BYTE, pData);