shithub: choc

Download patch

ref: 47c0b5207ed5bc077f1d9d59f94c12c522f2a0b9
parent: 1a9f364f3fe08bc769b66f162edec4f1bdf22345
author: Simon Howard <[email protected]>
date: Wed Sep 17 15:10:54 EDT 2008

Split sound code out of Heretic's i_ibm.c into s_sound.c. Rename
soundst.h to s_sound.h to fit. Reformat sounds.c files to declare sounds
through macros and harmonise on the common sfxinfo_t. Fix up Heretic
sound code to use common sound API.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1236

--- a/src/doom/deh_sound.c
+++ b/src/doom/deh_sound.c
@@ -41,7 +41,7 @@
     DEH_MAPPING("Zero 1", link)
     DEH_MAPPING("Zero 2", pitch)
     DEH_MAPPING("Zero 3", volume)
-    DEH_MAPPING("Zero 4", data)
+    DEH_UNSUPPORTED_MAPPING("Zero 4")
     DEH_MAPPING("Neg. One 1", usefulness)
     DEH_MAPPING("Neg. One 2", lumpnum)
 DEH_END_MAPPING
--- a/src/doom/sounds.c
+++ b/src/doom/sounds.c
@@ -36,76 +36,79 @@
 // Information about all the music
 //
 
+#define MUSIC(name) \
+    { name, 0, NULL, NULL }
+
 musicinfo_t S_music[] =
 {
-    { NULL, 0, 0, 0 },
-    { "e1m1", 0, 0, 0 },
-    { "e1m2", 0, 0, 0 },
-    { "e1m3", 0, 0, 0 },
-    { "e1m4", 0, 0, 0 },
-    { "e1m5", 0, 0, 0 },
-    { "e1m6", 0, 0, 0 },
-    { "e1m7", 0, 0, 0 },
-    { "e1m8", 0, 0, 0 },
-    { "e1m9", 0, 0, 0 },
-    { "e2m1", 0, 0, 0 },
-    { "e2m2", 0, 0, 0 },
-    { "e2m3", 0, 0, 0 },
-    { "e2m4", 0, 0, 0 },
-    { "e2m5", 0, 0, 0 },
-    { "e2m6", 0, 0, 0 },
-    { "e2m7", 0, 0, 0 },
-    { "e2m8", 0, 0, 0 },
-    { "e2m9", 0, 0, 0 },
-    { "e3m1", 0, 0, 0 },
-    { "e3m2", 0, 0, 0 },
-    { "e3m3", 0, 0, 0 },
-    { "e3m4", 0, 0, 0 },
-    { "e3m5", 0, 0, 0 },
-    { "e3m6", 0, 0, 0 },
-    { "e3m7", 0, 0, 0 },
-    { "e3m8", 0, 0, 0 },
-    { "e3m9", 0, 0, 0 },
-    { "inter", 0, 0, 0 },
-    { "intro", 0, 0, 0 },
-    { "bunny", 0, 0, 0 },
-    { "victor", 0, 0, 0 },
-    { "introa", 0, 0, 0 },
-    { "runnin", 0, 0, 0 },
-    { "stalks", 0, 0, 0 },
-    { "countd", 0, 0, 0 },
-    { "betwee", 0, 0, 0 },
-    { "doom", 0, 0, 0 },
-    { "the_da", 0, 0, 0 },
-    { "shawn", 0, 0, 0 },
-    { "ddtblu", 0, 0, 0 },
-    { "in_cit", 0, 0, 0 },
-    { "dead", 0, 0, 0 },
-    { "stlks2", 0, 0, 0 },
-    { "theda2", 0, 0, 0 },
-    { "doom2", 0, 0, 0 },
-    { "ddtbl2", 0, 0, 0 },
-    { "runni2", 0, 0, 0 },
-    { "dead2", 0, 0, 0 },
-    { "stlks3", 0, 0, 0 },
-    { "romero", 0, 0, 0 },
-    { "shawn2", 0, 0, 0 },
-    { "messag", 0, 0, 0 },
-    { "count2", 0, 0, 0 },
-    { "ddtbl3", 0, 0, 0 },
-    { "ampie", 0, 0, 0 },
-    { "theda3", 0, 0, 0 },
-    { "adrian", 0, 0, 0 },
-    { "messg2", 0, 0, 0 },
-    { "romer2", 0, 0, 0 },
-    { "tense", 0, 0, 0 },
-    { "shawn3", 0, 0, 0 },
-    { "openin", 0, 0, 0 },
-    { "evil", 0, 0, 0 },
-    { "ultima", 0, 0, 0 },
-    { "read_m", 0, 0, 0 },
-    { "dm2ttl", 0, 0, 0 },
-    { "dm2int", 0, 0, 0 } 
+    MUSIC(NULL),
+    MUSIC("e1m1"),
+    MUSIC("e1m2"),
+    MUSIC("e1m3"),
+    MUSIC("e1m4"),
+    MUSIC("e1m5"),
+    MUSIC("e1m6"),
+    MUSIC("e1m7"),
+    MUSIC("e1m8"),
+    MUSIC("e1m9"),
+    MUSIC("e2m1"),
+    MUSIC("e2m2"),
+    MUSIC("e2m3"),
+    MUSIC("e2m4"),
+    MUSIC("e2m5"),
+    MUSIC("e2m6"),
+    MUSIC("e2m7"),
+    MUSIC("e2m8"),
+    MUSIC("e2m9"),
+    MUSIC("e3m1"),
+    MUSIC("e3m2"),
+    MUSIC("e3m3"),
+    MUSIC("e3m4"),
+    MUSIC("e3m5"),
+    MUSIC("e3m6"),
+    MUSIC("e3m7"),
+    MUSIC("e3m8"),
+    MUSIC("e3m9"),
+    MUSIC("inter"),
+    MUSIC("intro"),
+    MUSIC("bunny"),
+    MUSIC("victor"),
+    MUSIC("introa"),
+    MUSIC("runnin"),
+    MUSIC("stalks"),
+    MUSIC("countd"),
+    MUSIC("betwee"),
+    MUSIC("doom"),
+    MUSIC("the_da"),
+    MUSIC("shawn"),
+    MUSIC("ddtblu"),
+    MUSIC("in_cit"),
+    MUSIC("dead"),
+    MUSIC("stlks2"),
+    MUSIC("theda2"),
+    MUSIC("doom2"),
+    MUSIC("ddtbl2"),
+    MUSIC("runni2"),
+    MUSIC("dead2"),
+    MUSIC("stlks3"),
+    MUSIC("romero"),
+    MUSIC("shawn2"),
+    MUSIC("messag"),
+    MUSIC("count2"),
+    MUSIC("ddtbl3"),
+    MUSIC("ampie"),
+    MUSIC("theda3"),
+    MUSIC("adrian"),
+    MUSIC("messg2"),
+    MUSIC("romer2"),
+    MUSIC("tense"),
+    MUSIC("shawn3"),
+    MUSIC("openin"),
+    MUSIC("evil"),
+    MUSIC("ultima"),
+    MUSIC("read_m"),
+    MUSIC("dm2ttl"),
+    MUSIC("dm2int") 
 };
 
 
@@ -113,117 +116,122 @@
 // Information about all the sfx
 //
 
+#define SOUND(name, priority) \
+  { name, priority, NULL, -1, -1, 0, 0, -1, NULL }
+#define SOUND_LINK(name, priority, link_id, pitch, volume) \
+  { name, priority, &S_sfx[link_id], pitch, volume, 0, 0, -1, NULL }
+
 sfxinfo_t S_sfx[] =
 {
   // S_sfx[0] needs to be a dummy for odd reasons.
-  { "none", 0, 0, -1, -1, 0, 0, 0, NULL },
-  { "pistol", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "shotgn", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "sgcock", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "dshtgn", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "dbopn", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "dbcls", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "dbload", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "plasma", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "bfg", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "sawup", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "sawidl", 118, 0, -1, -1, 0, 0, 0, NULL },
-  { "sawful", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "sawhit", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "rlaunc", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "rxplod", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "firsht", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "firxpl", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "pstart", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "pstop", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "doropn", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "dorcls", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "stnmov", 119, 0, -1, -1, 0, 0, 0, NULL },
-  { "swtchn", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "swtchx", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "plpain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "dmpain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "popain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "vipain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "mnpain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "pepain", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "slop", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "itemup", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "wpnup", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "oof", 96, 0, -1, -1, 0, 0, 0, NULL },
-  { "telept", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "posit1", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "posit2", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "posit3", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "bgsit1", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "bgsit2", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "sgtsit", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "cacsit", 98, 0, -1, -1, 0, 0, 0, NULL },
-  { "brssit", 94, 0, -1, -1, 0, 0, 0, NULL },
-  { "cybsit", 92, 0, -1, -1, 0, 0, 0, NULL },
-  { "spisit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "bspsit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "kntsit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "vilsit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "mansit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "pesit", 90, 0, -1, -1, 0, 0, 0, NULL },
-  { "sklatk", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "sgtatk", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skepch", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "vilatk", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "claw", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skeswg", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "pldeth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "pdiehi", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "podth1", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "podth2", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "podth3", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "bgdth1", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "bgdth2", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "sgtdth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "cacdth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skldth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "brsdth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "cybdth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "spidth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "bspdth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "vildth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "kntdth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "pedth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "skedth", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "posact", 120, 0, -1, -1, 0, 0, 0, NULL },
-  { "bgact", 120, 0, -1, -1, 0, 0, 0, NULL },
-  { "dmact", 120, 0, -1, -1, 0, 0, 0, NULL },
-  { "bspact", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "bspwlk", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "vilact", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "noway", 78, 0, -1, -1, 0, 0, 0, NULL },
-  { "barexp", 60, 0, -1, -1, 0, 0, 0, NULL },
-  { "punch", 64, 0, -1, -1, 0, 0, 0, NULL },
-  { "hoof", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "metal", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "chgun", 64, &S_sfx[sfx_pistol], 150, 0, 0, 0, 0, NULL },
-  { "tink", 60, 0, -1, -1, 0, 0, 0, NULL },
-  { "bdopn", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "bdcls", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "itmbk", 100, 0, -1, -1, 0, 0, 0, NULL },
-  { "flame", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "flamst", 32, 0, -1, -1, 0, 0, 0, NULL },
-  { "getpow", 60, 0, -1, -1, 0, 0, 0, NULL },
-  { "bospit", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "boscub", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "bossit", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "bospn", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "bosdth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "manatk", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "mandth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "sssit", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "ssdth", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "keenpn", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "keendt", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skeact", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skesit", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "skeatk", 70, 0, -1, -1, 0, 0, 0, NULL },
-  { "radio", 60, 0, -1, -1, 0, 0, 0, NULL } 
+  SOUND("none",   0),
+  SOUND("pistol", 64),
+  SOUND("shotgn", 64),
+  SOUND("sgcock", 64),
+  SOUND("dshtgn", 64),
+  SOUND("dbopn",  64),
+  SOUND("dbcls",  64),
+  SOUND("dbload", 64),
+  SOUND("plasma", 64),
+  SOUND("bfg",    64),
+  SOUND("sawup",  64),
+  SOUND("sawidl", 118),
+  SOUND("sawful", 64),
+  SOUND("sawhit", 64),
+  SOUND("rlaunc", 64),
+  SOUND("rxplod", 70),
+  SOUND("firsht", 70),
+  SOUND("firxpl", 70),
+  SOUND("pstart", 100),
+  SOUND("pstop",  100),
+  SOUND("doropn", 100),
+  SOUND("dorcls", 100),
+  SOUND("stnmov", 119),
+  SOUND("swtchn", 78),
+  SOUND("swtchx", 78),
+  SOUND("plpain", 96),
+  SOUND("dmpain", 96),
+  SOUND("popain", 96),
+  SOUND("vipain", 96),
+  SOUND("mnpain", 96),
+  SOUND("pepain", 96),
+  SOUND("slop",   78),
+  SOUND("itemup", 78),
+  SOUND("wpnup",  78),
+  SOUND("oof",    96),
+  SOUND("telept", 32),
+  SOUND("posit1", 98),
+  SOUND("posit2", 98),
+  SOUND("posit3", 98),
+  SOUND("bgsit1", 98),
+  SOUND("bgsit2", 98),
+  SOUND("sgtsit", 98),
+  SOUND("cacsit", 98),
+  SOUND("brssit", 94),
+  SOUND("cybsit", 92),
+  SOUND("spisit", 90),
+  SOUND("bspsit", 90),
+  SOUND("kntsit", 90),
+  SOUND("vilsit", 90),
+  SOUND("mansit", 90),
+  SOUND("pesit",  90),
+  SOUND("sklatk", 70),
+  SOUND("sgtatk", 70),
+  SOUND("skepch", 70),
+  SOUND("vilatk", 70),
+  SOUND("claw",   70),
+  SOUND("skeswg", 70),
+  SOUND("pldeth", 32),
+  SOUND("pdiehi", 32),
+  SOUND("podth1", 70),
+  SOUND("podth2", 70),
+  SOUND("podth3", 70),
+  SOUND("bgdth1", 70),
+  SOUND("bgdth2", 70),
+  SOUND("sgtdth", 70),
+  SOUND("cacdth", 70),
+  SOUND("skldth", 70),
+  SOUND("brsdth", 32),
+  SOUND("cybdth", 32),
+  SOUND("spidth", 32),
+  SOUND("bspdth", 32),
+  SOUND("vildth", 32),
+  SOUND("kntdth", 32),
+  SOUND("pedth",  32),
+  SOUND("skedth", 32),
+  SOUND("posact", 120),
+  SOUND("bgact",  120),
+  SOUND("dmact",  120),
+  SOUND("bspact", 100),
+  SOUND("bspwlk", 100),
+  SOUND("vilact", 100),
+  SOUND("noway",  78),
+  SOUND("barexp", 60),
+  SOUND("punch",  64),
+  SOUND("hoof",   70),
+  SOUND("metal",  70),
+  SOUND_LINK("chgun", 64, sfx_pistol, 150, 0),
+  SOUND("tink",   60),
+  SOUND("bdopn",  100),
+  SOUND("bdcls",  100),
+  SOUND("itmbk",  100),
+  SOUND("flame",  32),
+  SOUND("flamst", 32),
+  SOUND("getpow", 60),
+  SOUND("bospit", 70),
+  SOUND("boscub", 70),
+  SOUND("bossit", 70),
+  SOUND("bospn",  70),
+  SOUND("bosdth", 70),
+  SOUND("manatk", 70),
+  SOUND("mandth", 70),
+  SOUND("sssit",  70),
+  SOUND("ssdth",  70),
+  SOUND("keenpn", 70),
+  SOUND("keendt", 70),
+  SOUND("skeact", 70),
+  SOUND("skesit", 70),
+  SOUND("skeatk", 70),
+  SOUND("radio",  60),
 };
 
--- a/src/heretic/Makefile.am
+++ b/src/heretic/Makefile.am
@@ -1,4 +1,6 @@
 
+AM_CFLAGS=-I..
+
 noinst_LIBRARIES=libheretic.a
 
 SOURCE_FILES=                                        \
@@ -12,7 +14,6 @@
                        dstrings.h                    \
 f_finale.c                                           \
 g_game.c                                             \
-                       i_header.h                    \
 info.c                 info.h                        \
 in_lude.c                                            \
 m_misc.c                                             \
@@ -46,7 +47,7 @@
 r_things.c                                           \
 sb_bar.c                                             \
 sounds.c               sounds.h                      \
-                       soundst.h                     \
+s_sound.c              s_sound.h                     \
 v_video.c                                            
 
 EXTRA_DIST=                                          \
@@ -55,5 +56,4 @@
 i_ibm.c   
 
 libheretic_a_SOURCES=$(SOURCE_FILES)
-libheretic_a_CFLAGS=-I..
 
--- a/src/heretic/ct_chat.c
+++ b/src/heretic/ct_chat.c
@@ -28,7 +28,7 @@
 #include <ctype.h>
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 #define QUEUESIZE		128
 #define MESSAGESIZE	128
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -33,7 +33,7 @@
 #include <stdlib.h>
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 boolean shareware = false;      // true if only episode 1 present
 boolean ExtendedWAD = false;    // true if episodes 4 and 5 present
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -23,7 +23,7 @@
 // F_finale.c
 
 #include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
 #include <ctype.h>
 
 int finalestage;                // 0 = text, 1 = art screen
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/i_header.h
+++ /dev/null
@@ -1,99 +1,0 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-#ifndef __I_HEADER_H__
-#define __I_HEADER_H__
-
-#include "doomdef.h"
-
-//--------
-//SOUND IO
-//--------
-#define	FREQ_LOW		0x40
-#define FREQ_NORM		0x80
-#define FREQ_HIGH		0xff
-
-void I_SetMasterVolume(int volume);
-
-void I_TurnOffSfx(void);
-void I_TurnOnSfx(void);
-void I_TurnOffMusic(void);
-void I_TurnOnMusic(void);
-
-//  MUSIC I/O
-//
-
-int I_RegisterSong(void *songdata);
-// called by anything that wants to register a song lump with the sound lib
-// calls Paul's function of the similar name to register music only.
-// note that the song data is the same for any sound card and is paul's
-// MUS format.  Returns a handle which will be passed to all other music
-// functions.
-
-void I_UnregisterSong(int handle);
-// called by anything which is finished with a song and no longer needs
-// the sound library to be aware of it.  All songs should be stopped
-// before calling this, but it will double check and stop it if necessary.
-
-void I_LoopSong(int handle);
-// called by anything that wishes to start music.
-// plays a song, and when the song is done, starts playing it again in
-// an endless loop.  the start is faded in over three seconds.
-
-void I_FadeOutSong(int handle, int fotime);
-// called by anything that wishes to stop music.
-// fades out the song over <fotime> milliseconds.
-
-void I_StopSong(int handle);
-// called by anything that wishes to stop music.
-// stops a song abruptly.
-
-//  SFX I/O
-//
-
-void *I_GetSoundEffect(char *soundname);
-// called by routines which wish to play a sound effect at some later
-// time.  Pass it the lump name of a sound effect WITHOUT the sfx
-// prefix.  This means the maximum name length is 7 letters/digits.
-// The prefixes for different sound cards are 'S','M','A', and 'P'.
-// They refer to the card type.  The routine will cache in the
-// appropriate sound effect when it is played.
-
-void I_UngetSoundEffect(void *soundset);
-// called by routines which wish to no longer use the sounds at all
-// frees up the associated structure.  It stops any currently playing
-// sound effects.
-
-void I_StartSound(channel_t * c, int vol, int sep, int pitch, int priority);
-// Starts a sound in a particular sound channel
-
-void I_UpdateSoundParams(channel_t * c, int vol, int sep, int pitch);
-// Updates the volume, separation, and pitch of a sound channel
-
-void I_StopSound(channel_t * c);
-// Stops a sound channel
-
-int I_SoundIsPlaying(channel_t * c);
-// called by S_*()'s to see if a channel is still playing.  Returns 0
-// if no longer playing, 1 if playing.
-
-#endif
--- a/src/heretic/i_ibm.c
+++ b/src/heretic/i_ibm.c
@@ -30,8 +30,6 @@
 #include <graph.h>
 #include "doomdef.h"
 #include "r_local.h"
-#include "sounds.h"
-#include "i_sound.h"
 #include "dmx.h"
 
 // Macros
@@ -71,598 +69,6 @@
 extern int usemouse, usejoystick;
 
 extern void **lumpcache;
-
-/*
-===============================================================================
-
-		MUSIC & SFX API
-
-===============================================================================
-*/
-
-static channel_t channel[MAX_CHANNELS];
-
-static int rs;                  //the current registered song.
-int mus_song = -1;
-int mus_lumpnum;
-void *mus_sndptr;
-byte *soundCurve;
-
-extern sfxinfo_t S_sfx[];
-extern musicinfo_t S_music[];
-
-extern int snd_DesiredMusicDevice;
-extern int snd_DesiredSfxDevice;
-extern int snd_MaxVolume;
-extern int snd_MusicVolume;
-extern int snd_Channels;
-
-extern int startepisode;
-extern int startmap;
-
-int AmbChan;
-
-void S_Start(void)
-{
-    int i;
-
-    S_StartSong((gameepisode - 1) * 9 + gamemap - 1, true);
-
-    //stop all sounds
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (channel[i].handle)
-        {
-            S_StopSound(channel[i].mo);
-        }
-    }
-    memset(channel, 0, 8 * sizeof(channel_t));
-}
-
-void S_StartSong(int song, boolean loop)
-{
-    if (song == mus_song)
-    {                           // don't replay an old song
-        return;
-    }
-    if (rs)
-    {
-        I_StopSong(rs);
-        I_UnRegisterSong(rs);
-        Z_ChangeTag(lumpcache[mus_lumpnum], PU_CACHE);
-#ifdef __WATCOMC__
-        _dpmi_unlockregion(mus_sndptr, lumpinfo[mus_lumpnum].size);
-#endif
-    }
-    if (song < mus_e1m1 || song > NUMMUSIC)
-    {
-        return;
-    }
-    mus_lumpnum = W_GetNumForName(S_music[song].name);
-    mus_sndptr = W_CacheLumpNum(mus_lumpnum, PU_MUSIC);
-#ifdef __WATCOMC__
-    _dpmi_lockregion(mus_sndptr, lumpinfo[mus_lumpnum].size);
-#endif
-    rs = I_RegisterSong(mus_sndptr);
-    I_PlaySong(rs, loop);       //'true' denotes endless looping.
-    mus_song = song;
-}
-
-void S_StartSound(mobj_t * origin, int sound_id)
-{
-    int dist, vol;
-    int i;
-    int sound;
-    int priority;
-    int sep;
-    int angle;
-    int absx;
-    int absy;
-
-    static int sndcount = 0;
-    int chan;
-
-    if (sound_id == 0 || snd_MaxVolume == 0)
-        return;
-    if (origin == NULL)
-    {
-        origin = players[consoleplayer].mo;
-    }
-
-// calculate the distance before other stuff so that we can throw out
-// sounds that are beyond the hearing range.
-    absx = abs(origin->x - players[consoleplayer].mo->x);
-    absy = abs(origin->y - players[consoleplayer].mo->y);
-    dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
-    dist >>= FRACBITS;
-//  dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS;
-
-    if (dist >= MAX_SND_DIST)
-    {
-//      dist = MAX_SND_DIST - 1;
-        return;                 //sound is beyond the hearing range...
-    }
-    if (dist < 0)
-    {
-        dist = 0;
-    }
-    priority = S_sfx[sound_id].priority;
-    priority *= (10 - (dist / 160));
-    if (!S_StopSoundID(sound_id, priority))
-    {
-        return;                 // other sounds have greater priority
-    }
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (origin->player)
-        {
-            i = snd_Channels;
-            break;              // let the player have more than one sound.
-        }
-        if (origin == channel[i].mo)
-        {                       // only allow other mobjs one sound
-            S_StopSound(channel[i].mo);
-            break;
-        }
-    }
-    if (i >= snd_Channels)
-    {
-        if (sound_id >= sfx_wind)
-        {
-            if (AmbChan != -1 && S_sfx[sound_id].priority <=
-                S_sfx[channel[AmbChan].sound_id].priority)
-            {
-                return;         //ambient channel already in use
-            }
-            else
-            {
-                AmbChan = -1;
-            }
-        }
-        for (i = 0; i < snd_Channels; i++)
-        {
-            if (channel[i].mo == NULL)
-            {
-                break;
-            }
-        }
-        if (i >= snd_Channels)
-        {
-            //look for a lower priority sound to replace.
-            sndcount++;
-            if (sndcount >= snd_Channels)
-            {
-                sndcount = 0;
-            }
-            for (chan = 0; chan < snd_Channels; chan++)
-            {
-                i = (sndcount + chan) % snd_Channels;
-                if (priority >= channel[i].priority)
-                {
-                    chan = -1;  //denote that sound should be replaced.
-                    break;
-                }
-            }
-            if (chan != -1)
-            {
-                return;         //no free channels.
-            }
-            else                //replace the lower priority sound.
-            {
-                if (channel[i].handle)
-                {
-                    if (I_SoundIsPlaying(channel[i].handle))
-                    {
-                        I_StopSound(channel[i].handle);
-                    }
-                    if (S_sfx[channel[i].sound_id].usefulness > 0)
-                    {
-                        S_sfx[channel[i].sound_id].usefulness--;
-                    }
-
-                    if (AmbChan == i)
-                    {
-                        AmbChan = -1;
-                    }
-                }
-            }
-        }
-    }
-    if (S_sfx[sound_id].lumpnum == 0)
-    {
-        S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
-    }
-    if (S_sfx[sound_id].snd_ptr == NULL)
-    {
-        S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum,
-                                                 PU_SOUND);
-#ifdef __WATCOMC__
-        _dpmi_lockregion(S_sfx[sound_id].snd_ptr,
-                         lumpinfo[S_sfx[sound_id].lumpnum].size);
-#endif
-    }
-
-    // calculate the volume based upon the distance from the sound origin.
-//      vol = (snd_MaxVolume*16 + dist*(-snd_MaxVolume*16)/MAX_SND_DIST)>>9;
-    vol = soundCurve[dist];
-
-    if (origin == players[consoleplayer].mo)
-    {
-        sep = 128;
-    }
-    else
-    {
-        angle = R_PointToAngle2(players[consoleplayer].mo->x,
-                                players[consoleplayer].mo->y,
-                                channel[i].mo->x, channel[i].mo->y);
-        angle = (angle - viewangle) >> 24;
-        sep = angle * 2 - 128;
-        if (sep < 64)
-            sep = -sep;
-        if (sep > 192)
-            sep = 512 - sep;
-    }
-
-    channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
-    channel[i].handle =
-        I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, vol, sep,
-                     channel[i].pitch, 0);
-    channel[i].mo = origin;
-    channel[i].sound_id = sound_id;
-    channel[i].priority = priority;
-    if (sound_id >= sfx_wind)
-    {
-        AmbChan = i;
-    }
-    if (S_sfx[sound_id].usefulness == -1)
-    {
-        S_sfx[sound_id].usefulness = 1;
-    }
-    else
-    {
-        S_sfx[sound_id].usefulness++;
-    }
-}
-
-void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
-{
-    int dist;
-    int i;
-    int sep;
-
-    static int sndcount;
-    int chan;
-
-    if (sound_id == 0 || snd_MaxVolume == 0)
-        return;
-    if (origin == NULL)
-    {
-        origin = players[consoleplayer].mo;
-    }
-
-    if (volume == 0)
-    {
-        return;
-    }
-    volume = (volume * (snd_MaxVolume + 1) * 8) >> 7;
-
-// no priority checking, as ambient sounds would be the LOWEST.
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (channel[i].mo == NULL)
-        {
-            break;
-        }
-    }
-    if (i >= snd_Channels)
-    {
-        return;
-    }
-    if (S_sfx[sound_id].lumpnum == 0)
-    {
-        S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
-    }
-    if (S_sfx[sound_id].snd_ptr == NULL)
-    {
-        S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum,
-                                                 PU_SOUND);
-#ifdef __WATCOMC__
-        _dpmi_lockregion(S_sfx[sound_id].snd_ptr,
-                         lumpinfo[S_sfx[sound_id].lumpnum].size);
-#endif
-    }
-    channel[i].pitch = (byte) (127 - (M_Random() & 3) + (M_Random() & 3));
-    channel[i].handle =
-        I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, volume, 128,
-                     channel[i].pitch, 0);
-    channel[i].mo = origin;
-    channel[i].sound_id = sound_id;
-    channel[i].priority = 1;    //super low priority.
-    if (S_sfx[sound_id].usefulness == -1)
-    {
-        S_sfx[sound_id].usefulness = 1;
-    }
-    else
-    {
-        S_sfx[sound_id].usefulness++;
-    }
-}
-
-boolean S_StopSoundID(int sound_id, int priority)
-{
-    int i;
-    int lp;                     //least priority
-    int found;
-
-    if (S_sfx[sound_id].numchannels == -1)
-    {
-        return (true);
-    }
-    lp = -1;                    //denote the argument sound_id
-    found = 0;
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (channel[i].sound_id == sound_id && channel[i].mo)
-        {
-            found++;            //found one.  Now, should we replace it??
-            if (priority >= channel[i].priority)
-            {                   // if we're gonna kill one, then this'll be it
-                lp = i;
-                priority = channel[i].priority;
-            }
-        }
-    }
-    if (found < S_sfx[sound_id].numchannels)
-    {
-        return (true);
-    }
-    else if (lp == -1)
-    {
-        return (false);         // don't replace any sounds
-    }
-    if (channel[lp].handle)
-    {
-        if (I_SoundIsPlaying(channel[lp].handle))
-        {
-            I_StopSound(channel[lp].handle);
-        }
-        if (S_sfx[channel[i].sound_id].usefulness > 0)
-        {
-            S_sfx[channel[i].sound_id].usefulness--;
-        }
-        channel[lp].mo = NULL;
-    }
-    return (true);
-}
-
-void S_StopSound(mobj_t * origin)
-{
-    int i;
-
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (channel[i].mo == origin)
-        {
-            I_StopSound(channel[i].handle);
-            if (S_sfx[channel[i].sound_id].usefulness > 0)
-            {
-                S_sfx[channel[i].sound_id].usefulness--;
-            }
-            channel[i].handle = 0;
-            channel[i].mo = NULL;
-            if (AmbChan == i)
-            {
-                AmbChan = -1;
-            }
-        }
-    }
-}
-
-void S_SoundLink(mobj_t * oldactor, mobj_t * newactor)
-{
-    int i;
-
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (channel[i].mo == oldactor)
-            channel[i].mo = newactor;
-    }
-}
-
-void S_PauseSound(void)
-{
-    I_PauseSong(rs);
-}
-
-void S_ResumeSound(void)
-{
-    I_ResumeSong(rs);
-}
-
-static int nextcleanup;
-
-void S_UpdateSounds(mobj_t * listener)
-{
-    int i, dist, vol;
-    int angle;
-    int sep;
-    int priority;
-    int absx;
-    int absy;
-
-    listener = players[consoleplayer].mo;
-    if (snd_MaxVolume == 0)
-    {
-        return;
-    }
-    if (nextcleanup < gametic)
-    {
-        for (i = 0; i < NUMSFX; i++)
-        {
-            if (S_sfx[i].usefulness == 0 && S_sfx[i].snd_ptr)
-            {
-                if (lumpcache[S_sfx[i].lumpnum])
-                {
-                    if (((memblock_t
-                          *) ((byte *) (lumpcache[S_sfx[i].lumpnum]) -
-                              sizeof(memblock_t)))->id == 0x1d4a11)
-                    {           // taken directly from the Z_ChangeTag macro
-                        Z_ChangeTag2(lumpcache[S_sfx[i].lumpnum], PU_CACHE);
-#ifdef __WATCOMC__
-                        _dpmi_unlockregion(S_sfx[i].snd_ptr,
-                                           lumpinfo[S_sfx[i].lumpnum].size);
-#endif
-                    }
-                }
-                S_sfx[i].usefulness = -1;
-                S_sfx[i].snd_ptr = NULL;
-            }
-        }
-        nextcleanup = gametic + 35;     //CLEANUP DEBUG cleans every second
-    }
-    for (i = 0; i < snd_Channels; i++)
-    {
-        if (!channel[i].handle || S_sfx[channel[i].sound_id].usefulness == -1)
-        {
-            continue;
-        }
-        if (!I_SoundIsPlaying(channel[i].handle))
-        {
-            if (S_sfx[channel[i].sound_id].usefulness > 0)
-            {
-                S_sfx[channel[i].sound_id].usefulness--;
-            }
-            channel[i].handle = 0;
-            channel[i].mo = NULL;
-            channel[i].sound_id = 0;
-            if (AmbChan == i)
-            {
-                AmbChan = -1;
-            }
-        }
-        if (channel[i].mo == NULL || channel[i].sound_id == 0
-            || channel[i].mo == players[consoleplayer].mo)
-        {
-            continue;
-        }
-        else
-        {
-            absx = abs(channel[i].mo->x - players[consoleplayer].mo->x);
-            absy = abs(channel[i].mo->y - players[consoleplayer].mo->y);
-            dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
-            dist >>= FRACBITS;
-//          dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS;
-
-            if (dist >= MAX_SND_DIST)
-            {
-                S_StopSound(channel[i].mo);
-                continue;
-            }
-            if (dist < 0)
-                dist = 0;
-
-// calculate the volume based upon the distance from the sound origin.
-//          vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7;
-            vol = soundCurve[dist];
-
-            angle = R_PointToAngle2(players[consoleplayer].mo->x,
-                                    players[consoleplayer].mo->y,
-                                    channel[i].mo->x, channel[i].mo->y);
-            angle = (angle - viewangle) >> 24;
-            sep = angle * 2 - 128;
-            if (sep < 64)
-                sep = -sep;
-            if (sep > 192)
-                sep = 512 - sep;
-            I_UpdateSoundParams(channel[i].handle, vol, sep,
-                                channel[i].pitch);
-            priority = S_sfx[channel[i].sound_id].priority;
-            priority *= (10 - (dist >> 8));
-            channel[i].priority = priority;
-        }
-    }
-}
-
-void S_Init(void)
-{
-    soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
-    I_StartupSound();
-    if (snd_Channels > 8)
-    {
-        snd_Channels = 8;
-    }
-    I_SetChannels(snd_Channels);
-    I_SetMusicVolume(snd_MusicVolume);
-    S_SetMaxVolume(true);
-}
-
-void S_GetChannelInfo(SoundInfo_t * s)
-{
-    int i;
-    ChanInfo_t *c;
-
-    s->channelCount = snd_Channels;
-    s->musicVolume = snd_MusicVolume;
-    s->soundVolume = snd_MaxVolume;
-    for (i = 0; i < snd_Channels; i++)
-    {
-        c = &s->chan[i];
-        c->id = channel[i].sound_id;
-        c->priority = channel[i].priority;
-        c->name = S_sfx[c->id].name;
-        c->mo = channel[i].mo;
-        c->distance = P_AproxDistance(c->mo->x - viewx, c->mo->y - viewy)
-            >> FRACBITS;
-    }
-}
-
-void S_SetMaxVolume(boolean fullprocess)
-{
-    int i;
-
-    if (!fullprocess)
-    {
-        soundCurve[0] =
-            (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE)) *
-             (snd_MaxVolume * 8)) >> 7;
-    }
-    else
-    {
-        for (i = 0; i < MAX_SND_DIST; i++)
-        {
-            soundCurve[i] =
-                (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE) + i) *
-                 (snd_MaxVolume * 8)) >> 7;
-        }
-    }
-}
-
-static boolean musicPaused;
-void S_SetMusicVolume(void)
-{
-    I_SetMusicVolume(snd_MusicVolume);
-    if (snd_MusicVolume == 0)
-    {
-        I_PauseSong(rs);
-        musicPaused = true;
-    }
-    else if (musicPaused)
-    {
-        musicPaused = false;
-        I_ResumeSong(rs);
-    }
-}
-
-void S_ShutDown(void)
-{
-    extern int tsm_ID;
-    if (tsm_ID != -1)
-    {
-        I_StopSong(rs);
-        I_UnRegisterSong(rs);
-        I_ShutdownSound();
-    }
-}
 
 /*
 =============================================================================
--- a/src/heretic/i_sound.h
+++ /dev/null
@@ -1,45 +1,0 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-#ifndef __SOUND__
-#define __SOUND__
-
-#define SND_TICRATE             140     // tic rate for updating sound
-#define SND_MAXSONGS    40      // max number of songs in game
-#define SND_SAMPLERATE  11025   // sample rate of sound effects
-
-typedef enum
-{
-    snd_none,
-    snd_PC,
-    snd_Adlib,
-    snd_SB,
-    snd_PAS,
-    snd_GUS,
-    snd_MPU,
-    snd_MPU2,
-    snd_MPU3,
-    snd_AWE,
-    NUM_SCARDS
-} cardenum_t;
-
-#endif
--- a/src/heretic/in_lude.c
+++ b/src/heretic/in_lude.c
@@ -29,7 +29,7 @@
 */
 
 #include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 typedef enum
 {
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -35,7 +35,7 @@
 #include <ctype.h>
 
 #include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 int myargc;
 char **myargv;
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -27,7 +27,7 @@
 #include "doomdef.h"
 #include "p_local.h"
 #include "r_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/p_ceilng.c
+++ b/src/heretic/p_ceilng.c
@@ -23,7 +23,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 //==================================================================
 //==================================================================
--- a/src/heretic/p_doors.c
+++ b/src/heretic/p_doors.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 //==================================================================
 //==================================================================
--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/p_floor.c
+++ b/src/heretic/p_floor.c
@@ -22,7 +22,7 @@
 //-----------------------------------------------------------------------------
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 //==================================================================
 //==================================================================
--- a/src/heretic/p_inter.c
+++ b/src/heretic/p_inter.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 #define BONUSADD 6
 
--- a/src/heretic/p_map.c
+++ b/src/heretic/p_map.c
@@ -26,7 +26,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 /*
 ===============================================================================
--- a/src/heretic/p_mobj.c
+++ b/src/heretic/p_mobj.c
@@ -26,7 +26,7 @@
 #include "doomdef.h"
 #include "p_local.h"
 #include "sounds.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 void G_PlayerReborn(int player);
 void P_SpawnMapThing(mapthing_t * mthing);
--- a/src/heretic/p_plats.c
+++ b/src/heretic/p_plats.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 plat_t *activeplats[MAXPLATS];
 
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -27,7 +27,7 @@
 #include <stdlib.h>
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 void P_SpawnMapThing(mapthing_t * mthing);
 
--- a/src/heretic/p_spec.c
+++ b/src/heretic/p_spec.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/p_switch.c
+++ b/src/heretic/p_switch.c
@@ -23,7 +23,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 //==================================================================
 //
--- a/src/heretic/p_telept.c
+++ b/src/heretic/p_telept.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 //----------------------------------------------------------------------------
 //
--- a/src/heretic/p_user.c
+++ b/src/heretic/p_user.c
@@ -27,7 +27,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 void P_PlayerNextArtifact(player_t * player);
 
--- /dev/null
+++ b/src/heretic/s_sound.c
@@ -1,0 +1,576 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+
+#include <stdlib.h>
+
+#include "doomdef.h"
+#include "sounds.h"
+#include "s_sound.h"
+#include "i_sound.h"
+#include "r_local.h"
+#include "p_local.h"
+
+#include "w_wad.h"
+#include "z_zone.h"
+
+/*
+===============================================================================
+
+		MUSIC & SFX API
+
+===============================================================================
+*/
+
+boolean S_StopSoundID(int sound_id, int priority);
+
+static channel_t channel[MAX_CHANNELS];
+
+static void *rs;          // Handle for the registered song
+int mus_song = -1;
+int mus_lumpnum;
+void *mus_sndptr;
+byte *soundCurve;
+
+extern sfxinfo_t S_sfx[];
+extern musicinfo_t S_music[];
+
+extern int snd_DesiredMusicDevice;
+extern int snd_DesiredSfxDevice;
+extern int snd_MaxVolume;
+extern int snd_MusicVolume;
+extern int snd_Channels;
+
+extern int startepisode;
+extern int startmap;
+
+int AmbChan;
+
+void S_Start(void)
+{
+    int i;
+
+    S_StartSong((gameepisode - 1) * 9 + gamemap - 1, true);
+
+    //stop all sounds
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (channel[i].handle)
+        {
+            S_StopSound(channel[i].mo);
+        }
+    }
+    memset(channel, 0, 8 * sizeof(channel_t));
+}
+
+void S_StartSong(int song, boolean loop)
+{
+    int mus_len;
+
+    if (song == mus_song)
+    {                           // don't replay an old song
+        return;
+    }
+
+    if (rs != NULL)
+    {
+        I_StopSong();
+        I_UnRegisterSong(rs);
+    }
+
+    if (song < mus_e1m1 || song > NUMMUSIC)
+    {
+        return;
+    }
+    mus_lumpnum = W_GetNumForName(S_music[song].name);
+    mus_sndptr = W_CacheLumpNum(mus_lumpnum, PU_MUSIC);
+    mus_len = W_LumpLength(mus_lumpnum);
+    rs = I_RegisterSong(mus_sndptr, mus_len);
+    I_PlaySong(rs, loop);       //'true' denotes endless looping.
+    mus_song = song;
+}
+
+void S_StartSound(mobj_t * origin, int sound_id)
+{
+    int dist, vol;
+    int i;
+    int priority;
+    int sep;
+    int angle;
+    int absx;
+    int absy;
+
+    static int sndcount = 0;
+    int chan;
+
+    if (sound_id == 0 || snd_MaxVolume == 0)
+        return;
+    if (origin == NULL)
+    {
+        origin = players[consoleplayer].mo;
+    }
+
+// calculate the distance before other stuff so that we can throw out
+// sounds that are beyond the hearing range.
+    absx = abs(origin->x - players[consoleplayer].mo->x);
+    absy = abs(origin->y - players[consoleplayer].mo->y);
+    dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
+    dist >>= FRACBITS;
+//  dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS;
+
+    if (dist >= MAX_SND_DIST)
+    {
+//      dist = MAX_SND_DIST - 1;
+        return;                 //sound is beyond the hearing range...
+    }
+    if (dist < 0)
+    {
+        dist = 0;
+    }
+    priority = S_sfx[sound_id].priority;
+    priority *= (10 - (dist / 160));
+    if (!S_StopSoundID(sound_id, priority))
+    {
+        return;                 // other sounds have greater priority
+    }
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (origin->player)
+        {
+            i = snd_Channels;
+            break;              // let the player have more than one sound.
+        }
+        if (origin == channel[i].mo)
+        {                       // only allow other mobjs one sound
+            S_StopSound(channel[i].mo);
+            break;
+        }
+    }
+    if (i >= snd_Channels)
+    {
+        if (sound_id >= sfx_wind)
+        {
+            if (AmbChan != -1 && S_sfx[sound_id].priority <=
+                S_sfx[channel[AmbChan].sound_id].priority)
+            {
+                return;         //ambient channel already in use
+            }
+            else
+            {
+                AmbChan = -1;
+            }
+        }
+        for (i = 0; i < snd_Channels; i++)
+        {
+            if (channel[i].mo == NULL)
+            {
+                break;
+            }
+        }
+        if (i >= snd_Channels)
+        {
+            //look for a lower priority sound to replace.
+            sndcount++;
+            if (sndcount >= snd_Channels)
+            {
+                sndcount = 0;
+            }
+            for (chan = 0; chan < snd_Channels; chan++)
+            {
+                i = (sndcount + chan) % snd_Channels;
+                if (priority >= channel[i].priority)
+                {
+                    chan = -1;  //denote that sound should be replaced.
+                    break;
+                }
+            }
+            if (chan != -1)
+            {
+                return;         //no free channels.
+            }
+            else                //replace the lower priority sound.
+            {
+                if (channel[i].handle)
+                {
+                    if (I_SoundIsPlaying(channel[i].handle))
+                    {
+                        I_StopSound(channel[i].handle);
+                    }
+                    if (S_sfx[channel[i].sound_id].usefulness > 0)
+                    {
+                        S_sfx[channel[i].sound_id].usefulness--;
+                    }
+
+                    if (AmbChan == i)
+                    {
+                        AmbChan = -1;
+                    }
+                }
+            }
+        }
+    }
+    if (S_sfx[sound_id].lumpnum == 0)
+    {
+        S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
+    }
+
+    // calculate the volume based upon the distance from the sound origin.
+//      vol = (snd_MaxVolume*16 + dist*(-snd_MaxVolume*16)/MAX_SND_DIST)>>9;
+    vol = soundCurve[dist];
+
+    if (origin == players[consoleplayer].mo)
+    {
+        sep = 128;
+    }
+    else
+    {
+        angle = R_PointToAngle2(players[consoleplayer].mo->x,
+                                players[consoleplayer].mo->y,
+                                channel[i].mo->x, channel[i].mo->y);
+        angle = (angle - viewangle) >> 24;
+        sep = angle * 2 - 128;
+        if (sep < 64)
+            sep = -sep;
+        if (sep > 192)
+            sep = 512 - sep;
+    }
+
+    // TODO: Play pitch-shifted sounds as in Vanilla Heretic
+
+    channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
+    channel[i].handle = I_StartSound(&S_sfx[sound_id], i, vol, sep);
+    channel[i].mo = origin;
+    channel[i].sound_id = sound_id;
+    channel[i].priority = priority;
+    if (sound_id >= sfx_wind)
+    {
+        AmbChan = i;
+    }
+    if (S_sfx[sound_id].usefulness == -1)
+    {
+        S_sfx[sound_id].usefulness = 1;
+    }
+    else
+    {
+        S_sfx[sound_id].usefulness++;
+    }
+}
+
+void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
+{
+    int i;
+
+    if (sound_id == 0 || snd_MaxVolume == 0)
+        return;
+    if (origin == NULL)
+    {
+        origin = players[consoleplayer].mo;
+    }
+
+    if (volume == 0)
+    {
+        return;
+    }
+    volume = (volume * (snd_MaxVolume + 1) * 8) >> 7;
+
+// no priority checking, as ambient sounds would be the LOWEST.
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (channel[i].mo == NULL)
+        {
+            break;
+        }
+    }
+    if (i >= snd_Channels)
+    {
+        return;
+    }
+    if (S_sfx[sound_id].lumpnum == 0)
+    {
+        S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
+    }
+
+    // TODO: Pitch shifting.
+    channel[i].pitch = (byte) (127 - (M_Random() & 3) + (M_Random() & 3));
+    channel[i].handle = I_StartSound(&S_sfx[sound_id], i, volume, 128);
+    channel[i].mo = origin;
+    channel[i].sound_id = sound_id;
+    channel[i].priority = 1;    //super low priority.
+    if (S_sfx[sound_id].usefulness == -1)
+    {
+        S_sfx[sound_id].usefulness = 1;
+    }
+    else
+    {
+        S_sfx[sound_id].usefulness++;
+    }
+}
+
+boolean S_StopSoundID(int sound_id, int priority)
+{
+    int i;
+    int lp;                     //least priority
+    int found;
+
+    if (S_sfx[sound_id].numchannels == -1)
+    {
+        return (true);
+    }
+    lp = -1;                    //denote the argument sound_id
+    found = 0;
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (channel[i].sound_id == sound_id && channel[i].mo)
+        {
+            found++;            //found one.  Now, should we replace it??
+            if (priority >= channel[i].priority)
+            {                   // if we're gonna kill one, then this'll be it
+                lp = i;
+                priority = channel[i].priority;
+            }
+        }
+    }
+    if (found < S_sfx[sound_id].numchannels)
+    {
+        return (true);
+    }
+    else if (lp == -1)
+    {
+        return (false);         // don't replace any sounds
+    }
+    if (channel[lp].handle)
+    {
+        if (I_SoundIsPlaying(channel[lp].handle))
+        {
+            I_StopSound(channel[lp].handle);
+        }
+        if (S_sfx[channel[i].sound_id].usefulness > 0)
+        {
+            S_sfx[channel[i].sound_id].usefulness--;
+        }
+        channel[lp].mo = NULL;
+    }
+    return (true);
+}
+
+void S_StopSound(mobj_t * origin)
+{
+    int i;
+
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (channel[i].mo == origin)
+        {
+            I_StopSound(channel[i].handle);
+            if (S_sfx[channel[i].sound_id].usefulness > 0)
+            {
+                S_sfx[channel[i].sound_id].usefulness--;
+            }
+            channel[i].handle = 0;
+            channel[i].mo = NULL;
+            if (AmbChan == i)
+            {
+                AmbChan = -1;
+            }
+        }
+    }
+}
+
+void S_SoundLink(mobj_t * oldactor, mobj_t * newactor)
+{
+    int i;
+
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (channel[i].mo == oldactor)
+            channel[i].mo = newactor;
+    }
+}
+
+void S_PauseSound(void)
+{
+    I_PauseSong();
+}
+
+void S_ResumeSound(void)
+{
+    I_ResumeSong();
+}
+
+void S_UpdateSounds(mobj_t * listener)
+{
+    int i, dist, vol;
+    int angle;
+    int sep;
+    int priority;
+    int absx;
+    int absy;
+
+    listener = players[consoleplayer].mo;
+    if (snd_MaxVolume == 0)
+    {
+        return;
+    }
+
+    for (i = 0; i < snd_Channels; i++)
+    {
+        if (!channel[i].handle || S_sfx[channel[i].sound_id].usefulness == -1)
+        {
+            continue;
+        }
+        if (!I_SoundIsPlaying(channel[i].handle))
+        {
+            if (S_sfx[channel[i].sound_id].usefulness > 0)
+            {
+                S_sfx[channel[i].sound_id].usefulness--;
+            }
+            channel[i].handle = 0;
+            channel[i].mo = NULL;
+            channel[i].sound_id = 0;
+            if (AmbChan == i)
+            {
+                AmbChan = -1;
+            }
+        }
+        if (channel[i].mo == NULL || channel[i].sound_id == 0
+            || channel[i].mo == players[consoleplayer].mo)
+        {
+            continue;
+        }
+        else
+        {
+            absx = abs(channel[i].mo->x - players[consoleplayer].mo->x);
+            absy = abs(channel[i].mo->y - players[consoleplayer].mo->y);
+            dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
+            dist >>= FRACBITS;
+//          dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS;
+
+            if (dist >= MAX_SND_DIST)
+            {
+                S_StopSound(channel[i].mo);
+                continue;
+            }
+            if (dist < 0)
+                dist = 0;
+
+// calculate the volume based upon the distance from the sound origin.
+//          vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7;
+            vol = soundCurve[dist];
+
+            angle = R_PointToAngle2(players[consoleplayer].mo->x,
+                                    players[consoleplayer].mo->y,
+                                    channel[i].mo->x, channel[i].mo->y);
+            angle = (angle - viewangle) >> 24;
+            sep = angle * 2 - 128;
+            if (sep < 64)
+                sep = -sep;
+            if (sep > 192)
+                sep = 512 - sep;
+            // TODO: Pitch shifting.
+            I_UpdateSoundParams(channel[i].handle, vol, sep);
+            priority = S_sfx[channel[i].sound_id].priority;
+            priority *= (10 - (dist >> 8));
+            channel[i].priority = priority;
+        }
+    }
+}
+
+void S_Init(void)
+{
+    soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
+    I_InitSound();
+    if (snd_Channels > 8)
+    {
+        snd_Channels = 8;
+    }
+    I_SetMusicVolume(snd_MusicVolume);
+    S_SetMaxVolume(true);
+}
+
+void S_GetChannelInfo(SoundInfo_t * s)
+{
+    int i;
+    ChanInfo_t *c;
+
+    s->channelCount = snd_Channels;
+    s->musicVolume = snd_MusicVolume;
+    s->soundVolume = snd_MaxVolume;
+    for (i = 0; i < snd_Channels; i++)
+    {
+        c = &s->chan[i];
+        c->id = channel[i].sound_id;
+        c->priority = channel[i].priority;
+        c->name = S_sfx[c->id].name;
+        c->mo = channel[i].mo;
+        c->distance = P_AproxDistance(c->mo->x - viewx, c->mo->y - viewy)
+            >> FRACBITS;
+    }
+}
+
+void S_SetMaxVolume(boolean fullprocess)
+{
+    int i;
+
+    if (!fullprocess)
+    {
+        soundCurve[0] =
+            (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE)) *
+             (snd_MaxVolume * 8)) >> 7;
+    }
+    else
+    {
+        for (i = 0; i < MAX_SND_DIST; i++)
+        {
+            soundCurve[i] =
+                (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE) + i) *
+                 (snd_MaxVolume * 8)) >> 7;
+        }
+    }
+}
+
+static boolean musicPaused;
+void S_SetMusicVolume(void)
+{
+    I_SetMusicVolume(snd_MusicVolume);
+    if (snd_MusicVolume == 0)
+    {
+        I_PauseSong();
+        musicPaused = true;
+    }
+    else if (musicPaused)
+    {
+        musicPaused = false;
+        I_ResumeSong();
+    }
+}
+
+void S_ShutDown(void)
+{
+    extern int tsm_ID;
+    if (tsm_ID != -1)
+    {
+        I_StopSong();
+        I_UnRegisterSong(rs);
+        I_ShutdownSound();
+    }
+}
+
--- /dev/null
+++ b/src/heretic/s_sound.h
@@ -1,0 +1,45 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+
+// soundst.h
+
+#ifndef __SOUNDSTH__
+#define __SOUNDSTH__
+
+extern int snd_MaxVolume;
+extern int snd_MusicVolume;
+
+void S_Start(void);
+void S_StartSound(mobj_t * origin, int sound_id);
+void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume);
+void S_StopSound(mobj_t * origin);
+void S_PauseSound(void);
+void S_ResumeSound(void);
+void S_UpdateSounds(mobj_t * listener);
+void S_StartSong(int song, boolean loop);
+void S_Init(void);
+void S_GetChannelInfo(SoundInfo_t * s);
+void S_SetMaxVolume(boolean fullprocess);
+void S_SetMusicVolume(void);
+
+#endif
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -25,7 +25,7 @@
 
 #include "doomdef.h"
 #include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
 
 // Macros
 
--- a/src/heretic/sounds.c
+++ b/src/heretic/sounds.c
@@ -25,216 +25,232 @@
 // sounds.c
 
 #include "doomdef.h"
+#include "i_sound.h"
 #include "sounds.h"
 
 // Music info
 
+#define MUSIC(name) \
+    { name, 0, NULL, NULL }
+
 musicinfo_t S_music[] = {
-    {"MUS_E1M1", 0},            // 1-1
-    {"MUS_E1M2", 0},
-    {"MUS_E1M3", 0},
-    {"MUS_E1M4", 0},
-    {"MUS_E1M5", 0},
-    {"MUS_E1M6", 0},
-    {"MUS_E1M7", 0},
-    {"MUS_E1M8", 0},
-    {"MUS_E1M9", 0},
+    MUSIC("MUS_E1M1"),            // 1-1
+    MUSIC("MUS_E1M2"),
+    MUSIC("MUS_E1M3"),
+    MUSIC("MUS_E1M4"),
+    MUSIC("MUS_E1M5"),
+    MUSIC("MUS_E1M6"),
+    MUSIC("MUS_E1M7"),
+    MUSIC("MUS_E1M8"),
+    MUSIC("MUS_E1M9"),
 
-    {"MUS_E2M1", 0},            // 2-1
-    {"MUS_E2M2", 0},
-    {"MUS_E2M3", 0},
-    {"MUS_E2M4", 0},
-    {"MUS_E1M4", 0},
-    {"MUS_E2M6", 0},
-    {"MUS_E2M7", 0},
-    {"MUS_E2M8", 0},
-    {"MUS_E2M9", 0},
+    MUSIC("MUS_E2M1"),            // 2-1
+    MUSIC("MUS_E2M2"),
+    MUSIC("MUS_E2M3"),
+    MUSIC("MUS_E2M4"),
+    MUSIC("MUS_E1M4"),
+    MUSIC("MUS_E2M6"),
+    MUSIC("MUS_E2M7"),
+    MUSIC("MUS_E2M8"),
+    MUSIC("MUS_E2M9"),
 
-    {"MUS_E1M1", 0},            // 3-1
-    {"MUS_E3M2", 0},
-    {"MUS_E3M3", 0},
-    {"MUS_E1M6", 0},
-    {"MUS_E1M3", 0},
-    {"MUS_E1M2", 0},
-    {"MUS_E1M5", 0},
-    {"MUS_E1M9", 0},
-    {"MUS_E2M6", 0},
+    MUSIC("MUS_E1M1"),            // 3-1
+    MUSIC("MUS_E3M2"),
+    MUSIC("MUS_E3M3"),
+    MUSIC("MUS_E1M6"),
+    MUSIC("MUS_E1M3"),
+    MUSIC("MUS_E1M2"),
+    MUSIC("MUS_E1M5"),
+    MUSIC("MUS_E1M9"),
+    MUSIC("MUS_E2M6"),
 
-    {"MUS_E1M6", 0},            // 4-1
-    {"MUS_E1M2", 0},
-    {"MUS_E1M3", 0},
-    {"MUS_E1M4", 0},
-    {"MUS_E1M5", 0},
-    {"MUS_E1M1", 0},
-    {"MUS_E1M7", 0},
-    {"MUS_E1M8", 0},
-    {"MUS_E1M9", 0},
+    MUSIC("MUS_E1M6"),            // 4-1
+    MUSIC("MUS_E1M2"),
+    MUSIC("MUS_E1M3"),
+    MUSIC("MUS_E1M4"),
+    MUSIC("MUS_E1M5"),
+    MUSIC("MUS_E1M1"),
+    MUSIC("MUS_E1M7"),
+    MUSIC("MUS_E1M8"),
+    MUSIC("MUS_E1M9"),
 
-    {"MUS_E2M1", 0},            // 5-1
-    {"MUS_E2M2", 0},
-    {"MUS_E2M3", 0},
-    {"MUS_E2M4", 0},
-    {"MUS_E1M4", 0},
-    {"MUS_E2M6", 0},
-    {"MUS_E2M7", 0},
-    {"MUS_E2M8", 0},
-    {"MUS_E2M9", 0},
+    MUSIC("MUS_E2M1"),            // 5-1
+    MUSIC("MUS_E2M2"),
+    MUSIC("MUS_E2M3"),
+    MUSIC("MUS_E2M4"),
+    MUSIC("MUS_E1M4"),
+    MUSIC("MUS_E2M6"),
+    MUSIC("MUS_E2M7"),
+    MUSIC("MUS_E2M8"),
+    MUSIC("MUS_E2M9"),
 
-    {"MUS_E3M2", 0},            // 6-1
-    {"MUS_E3M3", 0},            // 6-2
-    {"MUS_E1M6", 0},            // 6-3
+    MUSIC("MUS_E3M2"),            // 6-1
+    MUSIC("MUS_E3M3"),            // 6-2
+    MUSIC("MUS_E1M6"),            // 6-3
 
-    {"MUS_TITL", 0},
-    {"MUS_INTR", 0},
-    {"MUS_CPTD", 0}
+    MUSIC("MUS_TITL"),
+    MUSIC("MUS_INTR"),
+    MUSIC("MUS_CPTD")
 };
 
 // Sound info
 
+    /* Macro for original heretic sfxinfo_t 
+#define SOUND(name, priority, numchannels) \
+    { name, NULL, priority, -1, NULL, 0, numchannels }
+#define SOUND_LINK(name, link_id, priority, numchannels) \
+    { name, &S_sfx[link_id], priority, -1, NULL, 0, numchannels }
+    */
+
+#define SOUND(name, priority, numchannels) \
+    { name, priority, NULL, -1, -1, -1, 0, numchannels, NULL }
+#define SOUND_LINK(name, link_id, priority, numchannels) \
+    { name, priority, &S_sfx[link_id], 0, 0, -1, 0, numchannels, NULL }
+
 sfxinfo_t S_sfx[] = {
-    {{0, 0, 0, 0, 0, 0, 0, 0}, NULL, 0, -1, NULL, 0, 0},
-    {"gldhit", NULL, 32, -1, NULL, 0, 2},
-    {"gntful", NULL, 32, -1, NULL, 0, -1},
-    {"gnthit", NULL, 32, -1, NULL, 0, -1},
-    {"gntpow", NULL, 32, -1, NULL, 0, -1},
-    {"gntact", NULL, 32, -1, NULL, 0, -1},
-    {"gntuse", NULL, 32, -1, NULL, 0, -1},
-    {"phosht", NULL, 32, -1, NULL, 0, 2},
-    {"phohit", NULL, 32, -1, NULL, 0, -1},
-    {"-phopow", &S_sfx[sfx_hedat1], 32, -1, NULL, 0, 1},
-    {"lobsht", NULL, 20, -1, NULL, 0, 2},
-    {"lobhit", NULL, 20, -1, NULL, 0, 2},
-    {"lobpow", NULL, 20, -1, NULL, 0, 2},
-    {"hrnsht", NULL, 32, -1, NULL, 0, 2},
-    {"hrnhit", NULL, 32, -1, NULL, 0, 2},
-    {"hrnpow", NULL, 32, -1, NULL, 0, 2},
-    {"ramphit", NULL, 32, -1, NULL, 0, 2},
-    {"ramrain", NULL, 10, -1, NULL, 0, 2},
-    {"bowsht", NULL, 32, -1, NULL, 0, 2},
-    {"stfhit", NULL, 32, -1, NULL, 0, 2},
-    {"stfpow", NULL, 32, -1, NULL, 0, 2},
-    {"stfcrk", NULL, 32, -1, NULL, 0, 2},
-    {"impsit", NULL, 32, -1, NULL, 0, 2},
-    {"impat1", NULL, 32, -1, NULL, 0, 2},
-    {"impat2", NULL, 32, -1, NULL, 0, 2},
-    {"impdth", NULL, 80, -1, NULL, 0, 2},
-    {"-impact", &S_sfx[sfx_impsit], 20, -1, NULL, 0, 2},
-    {"imppai", NULL, 32, -1, NULL, 0, 2},
-    {"mumsit", NULL, 32, -1, NULL, 0, 2},
-    {"mumat1", NULL, 32, -1, NULL, 0, 2},
-    {"mumat2", NULL, 32, -1, NULL, 0, 2},
-    {"mumdth", NULL, 80, -1, NULL, 0, 2},
-    {"-mumact", &S_sfx[sfx_mumsit], 20, -1, NULL, 0, 2},
-    {"mumpai", NULL, 32, -1, NULL, 0, 2},
-    {"mumhed", NULL, 32, -1, NULL, 0, 2},
-    {"bstsit", NULL, 32, -1, NULL, 0, 2},
-    {"bstatk", NULL, 32, -1, NULL, 0, 2},
-    {"bstdth", NULL, 80, -1, NULL, 0, 2},
-    {"bstact", NULL, 20, -1, NULL, 0, 2},
-    {"bstpai", NULL, 32, -1, NULL, 0, 2},
-    {"clksit", NULL, 32, -1, NULL, 0, 2},
-    {"clkatk", NULL, 32, -1, NULL, 0, 2},
-    {"clkdth", NULL, 80, -1, NULL, 0, 2},
-    {"clkact", NULL, 20, -1, NULL, 0, 2},
-    {"clkpai", NULL, 32, -1, NULL, 0, 2},
-    {"snksit", NULL, 32, -1, NULL, 0, 2},
-    {"snkatk", NULL, 32, -1, NULL, 0, 2},
-    {"snkdth", NULL, 80, -1, NULL, 0, 2},
-    {"snkact", NULL, 20, -1, NULL, 0, 2},
-    {"snkpai", NULL, 32, -1, NULL, 0, 2},
-    {"kgtsit", NULL, 32, -1, NULL, 0, 2},
-    {"kgtatk", NULL, 32, -1, NULL, 0, 2},
-    {"kgtat2", NULL, 32, -1, NULL, 0, 2},
-    {"kgtdth", NULL, 80, -1, NULL, 0, 2},
-    {"-kgtact", &S_sfx[sfx_kgtsit], 20, -1, NULL, 0, 2},
-    {"kgtpai", NULL, 32, -1, NULL, 0, 2},
-    {"wizsit", NULL, 32, -1, NULL, 0, 2},
-    {"wizatk", NULL, 32, -1, NULL, 0, 2},
-    {"wizdth", NULL, 80, -1, NULL, 0, 2},
-    {"wizact", NULL, 20, -1, NULL, 0, 2},
-    {"wizpai", NULL, 32, -1, NULL, 0, 2},
-    {"minsit", NULL, 32, -1, NULL, 0, 2},
-    {"minat1", NULL, 32, -1, NULL, 0, 2},
-    {"minat2", NULL, 32, -1, NULL, 0, 2},
-    {"minat3", NULL, 32, -1, NULL, 0, 2},
-    {"mindth", NULL, 80, -1, NULL, 0, 2},
-    {"minact", NULL, 20, -1, NULL, 0, 2},
-    {"minpai", NULL, 32, -1, NULL, 0, 2},
-    {"hedsit", NULL, 32, -1, NULL, 0, 2},
-    {"hedat1", NULL, 32, -1, NULL, 0, 2},
-    {"hedat2", NULL, 32, -1, NULL, 0, 2},
-    {"hedat3", NULL, 32, -1, NULL, 0, 2},
-    {"heddth", NULL, 80, -1, NULL, 0, 2},
-    {"hedact", NULL, 20, -1, NULL, 0, 2},
-    {"hedpai", NULL, 32, -1, NULL, 0, 2},
-    {"sorzap", NULL, 32, -1, NULL, 0, 2},
-    {"sorrise", NULL, 32, -1, NULL, 0, 2},
-    {"sorsit", NULL, 200, -1, NULL, 0, 2},
-    {"soratk", NULL, 32, -1, NULL, 0, 2},
-    {"soract", NULL, 200, -1, NULL, 0, 2},
-    {"sorpai", NULL, 200, -1, NULL, 0, 2},
-    {"sordsph", NULL, 200, -1, NULL, 0, 2},
-    {"sordexp", NULL, 200, -1, NULL, 0, 2},
-    {"sordbon", NULL, 200, -1, NULL, 0, 2},
-    {"-sbtsit", &S_sfx[sfx_bstsit], 32, -1, NULL, 0, 2},
-    {"-sbtatk", &S_sfx[sfx_bstatk], 32, -1, NULL, 0, 2},
-    {"sbtdth", NULL, 80, -1, NULL, 0, 2},
-    {"sbtact", NULL, 20, -1, NULL, 0, 2},
-    {"sbtpai", NULL, 32, -1, NULL, 0, 2},
-    {"plroof", NULL, 32, -1, NULL, 0, 2},
-    {"plrpai", NULL, 32, -1, NULL, 0, 2},
-    {"plrdth", NULL, 80, -1, NULL, 0, 2},
-    {"gibdth", NULL, 100, -1, NULL, 0, 2},
-    {"plrwdth", NULL, 80, -1, NULL, 0, 2},
-    {"plrcdth", NULL, 100, -1, NULL, 0, 2},
-    {"itemup", NULL, 32, -1, NULL, 0, 2},
-    {"wpnup", NULL, 32, -1, NULL, 0, 2},
-    {"telept", NULL, 50, -1, NULL, 0, 2},
-    {"doropn", NULL, 40, -1, NULL, 0, 2},
-    {"dorcls", NULL, 40, -1, NULL, 0, 2},
-    {"dormov", NULL, 40, -1, NULL, 0, 2},
-    {"artiup", NULL, 32, -1, NULL, 0, 2},
-    {"switch", NULL, 40, -1, NULL, 0, 2},
-    {"pstart", NULL, 40, -1, NULL, 0, 2},
-    {"pstop", NULL, 40, -1, NULL, 0, 2},
-    {"stnmov", NULL, 40, -1, NULL, 0, 2},
-    {"chicpai", NULL, 32, -1, NULL, 0, 2},
-    {"chicatk", NULL, 32, -1, NULL, 0, 2},
-    {"chicdth", NULL, 40, -1, NULL, 0, 2},
-    {"chicact", NULL, 32, -1, NULL, 0, 2},
-    {"chicpk1", NULL, 32, -1, NULL, 0, 2},
-    {"chicpk2", NULL, 32, -1, NULL, 0, 2},
-    {"chicpk3", NULL, 32, -1, NULL, 0, 2},
-    {"keyup", NULL, 50, -1, NULL, 0, 2},
-    {"ripslop", NULL, 16, -1, NULL, 0, 2},
-    {"newpod", NULL, 16, -1, NULL, 0, -1},
-    {"podexp", NULL, 40, -1, NULL, 0, -1},
-    {"bounce", NULL, 16, -1, NULL, 0, 2},
-    {"-volsht", &S_sfx[sfx_bstatk], 16, -1, NULL, 0, 2},
-    {"-volhit", &S_sfx[sfx_lobhit], 16, -1, NULL, 0, 2},
-    {"burn", NULL, 10, -1, NULL, 0, 2},
-    {"splash", NULL, 10, -1, NULL, 0, 1},
-    {"gloop", NULL, 10, -1, NULL, 0, 2},
-    {"respawn", NULL, 10, -1, NULL, 0, 1},
-    {"blssht", NULL, 32, -1, NULL, 0, 2},
-    {"blshit", NULL, 32, -1, NULL, 0, 2},
-    {"chat", NULL, 100, -1, NULL, 0, 1},
-    {"artiuse", NULL, 32, -1, NULL, 0, 1},
-    {"gfrag", NULL, 100, -1, NULL, 0, 1},
-    {"waterfl", NULL, 16, -1, NULL, 0, 2},
+    SOUND("",        0,   0),
+    SOUND("gldhit",  32,  2),
+    SOUND("gntful",  32,  -1),
+    SOUND("gnthit",  32,  -1),
+    SOUND("gntpow",  32,  -1),
+    SOUND("gntact",  32,  -1),
+    SOUND("gntuse",  32,  -1),
+    SOUND("phosht",  32,  2),
+    SOUND("phohit",  32,  -1),
+    SOUND_LINK("-phopow", sfx_hedat1, 32, 1),
+    SOUND("lobsht",  20,  2),
+    SOUND("lobhit",  20,  2),
+    SOUND("lobpow",  20,  2),
+    SOUND("hrnsht",  32,  2),
+    SOUND("hrnhit",  32,  2),
+    SOUND("hrnpow",  32,  2),
+    SOUND("ramphit", 32,  2),
+    SOUND("ramrain", 10,  2),
+    SOUND("bowsht",  32,  2),
+    SOUND("stfhit",  32,  2),
+    SOUND("stfpow",  32,  2),
+    SOUND("stfcrk",  32,  2),
+    SOUND("impsit",  32,  2),
+    SOUND("impat1",  32,  2),
+    SOUND("impat2",  32,  2),
+    SOUND("impdth",  80,  2),
+    SOUND_LINK("-impact", sfx_impsit, 20, 2),
+    SOUND("imppai",  32,  2),
+    SOUND("mumsit",  32,  2),
+    SOUND("mumat1",  32,  2),
+    SOUND("mumat2",  32,  2),
+    SOUND("mumdth",  80,  2),
+    SOUND_LINK("-mumact", sfx_mumsit, 20, 2),
+    SOUND("mumpai",  32,  2),
+    SOUND("mumhed",  32,  2),
+    SOUND("bstsit",  32,  2),
+    SOUND("bstatk",  32,  2),
+    SOUND("bstdth",  80,  2),
+    SOUND("bstact",  20,  2),
+    SOUND("bstpai",  32,  2),
+    SOUND("clksit",  32,  2),
+    SOUND("clkatk",  32,  2),
+    SOUND("clkdth",  80,  2),
+    SOUND("clkact",  20,  2),
+    SOUND("clkpai",  32,  2),
+    SOUND("snksit",  32,  2),
+    SOUND("snkatk",  32,  2),
+    SOUND("snkdth",  80,  2),
+    SOUND("snkact",  20,  2),
+    SOUND("snkpai",  32,  2),
+    SOUND("kgtsit",  32,  2),
+    SOUND("kgtatk",  32,  2),
+    SOUND("kgtat2",  32,  2),
+    SOUND("kgtdth",  80,  2),
+    SOUND_LINK("-kgtact", sfx_kgtsit, 20, 2),
+    SOUND("kgtpai",  32,  2),
+    SOUND("wizsit",  32,  2),
+    SOUND("wizatk",  32,  2),
+    SOUND("wizdth",  80,  2),
+    SOUND("wizact",  20,  2),
+    SOUND("wizpai",  32,  2),
+    SOUND("minsit",  32,  2),
+    SOUND("minat1",  32,  2),
+    SOUND("minat2",  32,  2),
+    SOUND("minat3",  32,  2),
+    SOUND("mindth",  80,  2),
+    SOUND("minact",  20,  2),
+    SOUND("minpai",  32,  2),
+    SOUND("hedsit",  32,  2),
+    SOUND("hedat1",  32,  2),
+    SOUND("hedat2",  32,  2),
+    SOUND("hedat3",  32,  2),
+    SOUND("heddth",  80,  2),
+    SOUND("hedact",  20,  2),
+    SOUND("hedpai",  32,  2),
+    SOUND("sorzap",  32,  2),
+    SOUND("sorrise", 32,  2),
+    SOUND("sorsit",  200, 2),
+    SOUND("soratk",  32,  2),
+    SOUND("soract",  200, 2),
+    SOUND("sorpai",  200, 2),
+    SOUND("sordsph", 200, 2),
+    SOUND("sordexp", 200, 2),
+    SOUND("sordbon", 200, 2),
+    SOUND_LINK("-sbtsit", sfx_bstsit, 32, 2),
+    SOUND_LINK("-sbtatk", sfx_bstatk, 32, 2),
+    SOUND("sbtdth",  80,  2),
+    SOUND("sbtact",  20,  2),
+    SOUND("sbtpai",  32,  2),
+    SOUND("plroof",  32,  2),
+    SOUND("plrpai",  32,  2),
+    SOUND("plrdth",  80,  2),
+    SOUND("gibdth",  100, 2),
+    SOUND("plrwdth", 80,  2),
+    SOUND("plrcdth", 100, 2),
+    SOUND("itemup",  32,  2),
+    SOUND("wpnup",   32,  2),
+    SOUND("telept",  50,  2),
+    SOUND("doropn",  40,  2),
+    SOUND("dorcls",  40,  2),
+    SOUND("dormov",  40,  2),
+    SOUND("artiup",  32,  2),
+    SOUND("switch",  40,  2),
+    SOUND("pstart",  40,  2),
+    SOUND("pstop",   40,  2),
+    SOUND("stnmov",  40,  2),
+    SOUND("chicpai", 32,  2),
+    SOUND("chicatk", 32,  2),
+    SOUND("chicdth", 40,  2),
+    SOUND("chicact", 32,  2),
+    SOUND("chicpk1", 32,  2),
+    SOUND("chicpk2", 32,  2),
+    SOUND("chicpk3", 32,  2),
+    SOUND("keyup",   50,  2),
+    SOUND("ripslop", 16,  2),
+    SOUND("newpod",  16,  -1),
+    SOUND("podexp",  40,  -1),
+    SOUND("bounce",  16,  2),
+    SOUND_LINK("-volsht", sfx_bstatk, 16, 2),
+    SOUND_LINK("-volhit", sfx_lobhit, 16, 2),
+    SOUND("burn",    10,  2),
+    SOUND("splash",  10,  1),
+    SOUND("gloop",   10,  2),
+    SOUND("respawn", 10,  1),
+    SOUND("blssht",  32,  2),
+    SOUND("blshit",  32,  2),
+    SOUND("chat",    100, 1),
+    SOUND("artiuse", 32,  1),
+    SOUND("gfrag",   100, 1),
+    SOUND("waterfl", 16,  2),
 
     // Monophonic sounds
 
-    {"wind", NULL, 16, -1, NULL, 0, 1},
-    {"amb1", NULL, 1, -1, NULL, 0, 1},
-    {"amb2", NULL, 1, -1, NULL, 0, 1},
-    {"amb3", NULL, 1, -1, NULL, 0, 1},
-    {"amb4", NULL, 1, -1, NULL, 0, 1},
-    {"amb5", NULL, 1, -1, NULL, 0, 1},
-    {"amb6", NULL, 1, -1, NULL, 0, 1},
-    {"amb7", NULL, 1, -1, NULL, 0, 1},
-    {"amb8", NULL, 1, -1, NULL, 0, 1},
-    {"amb9", NULL, 1, -1, NULL, 0, 1},
-    {"amb10", NULL, 1, -1, NULL, 0, 1},
-    {"amb11", NULL, 1, -1, NULL, 0, 0}
+    SOUND("wind",    16,  1),
+    SOUND("amb1",    1,   1),
+    SOUND("amb2",    1,   1),
+    SOUND("amb3",    1,   1),
+    SOUND("amb4",    1,   1),
+    SOUND("amb5",    1,   1),
+    SOUND("amb6",    1,   1),
+    SOUND("amb7",    1,   1),
+    SOUND("amb8",    1,   1),
+    SOUND("amb9",    1,   1),
+    SOUND("amb10",   1,   1),
+    SOUND("amb11",   1,   0)
 };
--- a/src/heretic/sounds.h
+++ b/src/heretic/sounds.h
@@ -93,10 +93,10 @@
     NUMMUSIC
 } musicenum_t;
 
+#if 0
 typedef struct
 {
     char name[8];
-    int p1;
 } musicinfo_t;
 
 typedef struct sfxinfo_s
@@ -109,6 +109,8 @@
     int lumpnum;
     int numchannels;            // total number of channels a sound type may occupy
 } sfxinfo_t;
+
+#endif
 
 typedef struct
 {
--- a/src/heretic/soundst.h
+++ /dev/null
@@ -1,45 +1,0 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-
-// soundst.h
-
-#ifndef __SOUNDSTH__
-#define __SOUNDSTH__
-
-extern int snd_MaxVolume;
-extern int snd_MusicVolume;
-
-void S_Start(void);
-void S_StartSound(mobj_t * origin, int sound_id);
-void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume);
-void S_StopSound(mobj_t * origin);
-void S_PauseSound(void);
-void S_ResumeSound(void);
-void S_UpdateSounds(mobj_t * listener);
-void S_StartSong(int song, boolean loop);
-void S_Init(void);
-void S_GetChannelInfo(SoundInfo_t * s);
-void S_SetMaxVolume(boolean fullprocess);
-void S_SetMusicVolume(void);
-
-#endif
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -53,9 +53,6 @@
     // volume if a link
     int volume;
 
-    // sound data
-    void *data;
-
     // this is checked every second to see if sound
     // can be thrown out (if 0, then decrement, if -1,
     // then throw out, if > 0, then it is in use)
@@ -63,6 +60,10 @@
 
     // lump number of sfx
     int lumpnum;		
+
+    // Maximum number of channels that the sound can be played on 
+    // (Heretic)
+    int numchannels;
 
     // data used by the low level code
     void *driver_data;