Sign in to follow this  
  • entries
    177
  • comments
    531
  • views
    163635

The Number of the Beast

Sign in to follow this  
Scet

68 views

Well it's 6/6/6 so go play DooM or I'll have to hurt you. I know where you live, Rav told me.

Also in case you missed it, DOOM.Net is the IOTD.

I've added a header to the journal(like anyone could miss it). I figure this is a better way to show screenshots, mabye the 56k slowpokes won't be afraid to visit although I have always tried to keep image sizes low.

On to actual development news I finally figured out how to load sound effects. DOOM sounds are just 8-bit mono 11Khz PCM, but loading them into DirectSound directly has proved to be a complete pain in the ass. I tried FMODEx, but that was an even bigger pain and the C# API was nauseating. My solution is rather simple, just add a minimal WAV header onto the PCM data.


namespace Doom
{

public class Sound
{

private DirectSound.SecondaryBuffer Buffer = null;

private static DirectSound.Device Device = null;

private static byte[] WaveHeader = new byte[]{ 0x52, 0x49, 0x46, 0x46, 0xE8, 0x4F, 0x04, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x64, 0x61, 0x74, 0x61 };

public Sound( Lump SoundLump )
{
SoundLump.Position = 0;
int ID = SoundLump.ReadUInt16();
int Frequency = SoundLump.ReadUInt16();
int Samples = SoundLump.ReadUInt16();
SoundLump.ReadUInt16();
IO.MemoryStream MemoryStream = new IO.MemoryStream();
IO.BinaryWriter BinaryWriter = new IO.BinaryWriter( MemoryStream );
BinaryWriter.Write( WaveHeader, 0, 16 );
BinaryWriter.Write( (int)16 ); // Chunk Size
BinaryWriter.Write( (short)1 ); // Format Tag
BinaryWriter.Write( (ushort)1 ); // Channels
BinaryWriter.Write( (uint)Frequency ); // Samples Per Second
BinaryWriter.Write( (uint)Frequency ); // Bytes Per Second
BinaryWriter.Write( (ushort)1 ); // Block Align
BinaryWriter.Write( (ushort)8 ); // Bits Per Sample
BinaryWriter.Write( WaveHeader, 16, 4 );
BinaryWriter.Write( (int)Samples ); // Samples
BinaryWriter.Write( SoundLump.ReadBytes( Samples ) ); // Data
MemoryStream.Position = 0;
try
{
Buffer = new DirectSound.SecondaryBuffer( MemoryStream, Device );
}
catch
{
Buffer = null;
}
BinaryWriter.Close();
MemoryStream.Close();
return;
}

static Sound()
{
Device = new DirectSound.Device();
Device.SetCooperativeLevel( Video.Form, DirectSound.CooperativeLevel.Normal );
return;
}

~Sound()
{
return;
}

public void Play()
{
if( Buffer != null )
{
Buffer.Play( 0, DirectSound.BufferPlayFlags.Default );
}
return;
}

}

}



There are two sounds that cause an exception because they're too small, but since I've never heard them I'm not really worried about it.

I'm going to work on wall collision now since I have some segment-segment collision code lying around from the subsector stuff. After that's in I can start added things like switches, doors and teleporters.

Oh and who rigged the "Featured Book"? [grin].



Sign in to follow this  


2 Comments


Recommended Comments

I no longer control MacMan. He says that he loves the Santa hat and that those against the hat will suffer.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now