Hocus Pocus SFX Format

From ModdingWiki
Jump to navigation Jump to search
Hocus Pocus SFX Format
Format typeSound
HardwarePC Speaker
Number of sounds1 per file
Sampling rate140 Hz
Channel count1
Bits per sample16
Compressed?No
Tags?None
Games

The SFX format is used by Hocus Pocus to store PC Speaker sound effects.

File format

The files have no header and consist entirely of INT16LE values. Each INT16LE value stores a sound frequency in Hertz, which is played through the PC Speaker by using the sound() function, which is present in many progamming tools, including Borland C and Turbo Pascal.

Sound playback

The sounds are played at a rate of 140 Hz, so the game sends a new frequency to the PC Speaker 140 times per second. But only every fourth frequency value is ever played.

The sound playback works pretty much like this:

140 times per second DO
BEGIN
   IF sound_is_active THEN
   BEGIN
      sound(frequencies[sound_index]);
      sound_index := sound_index + 4;
      IF (sound_index >= sound_length) THEN
      BEGIN
         nosound();
         sound_is_active := FALSE;
      END;
   END;
END;

Credits

This file format was reverse engineered by K1n9_Duk3. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)