README.sound 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. README: sound in DOOM
  2. 1) DOS/Win32 sound
  3. id licensed a third party sound library called
  4. DMX for DOS DOOM. The situation exhibited
  5. many symptons of serious NIH "Not Invented Here"),
  6. and one of the consequences is that the original
  7. DOOM sound code does not work without DMX. As
  8. DMX is not publicly available, the original DOOM
  9. sound support is removed.
  10. Win32 was not supported in the source dump I got.
  11. I have no knowledge how the WinDOOM port did the
  12. sound handling. A Win32 port should probaly rely on
  13. DirectSound. So far, the Win32 glDOOM port Jim Dose
  14. is working on has no sound support.
  15. In consequence, the only target with a working sound
  16. code is UNIX, which I could only verify with Linux
  17. on Intel586.
  18. 2) Linux sound
  19. DOOM for Linux used a separate process, sndserver.
  20. Quoting Dave Taylor:
  21. "Sound drivers should be an asychronous model, either
  22. a seperate thread or a seperate process. This is
  23. because sound should always be fed to the card without
  24. interruption or else you get pops and with low latency
  25. or else you get angry players.
  26. Now it turns out that this kind of code isn't too fun
  27. to write. In the days of Linux Doom, threads were not a
  28. happnin thing in Linux. In fact, they still largely
  29. aren't. You can use them these days if you have gnu's
  30. libc installed, but you still can't debug them because
  31. gdb doesn't support them properly yet. I believe the
  32. original seperate process had a bad latency delay
  33. because of the time it took for commands to be flushed
  34. through the pipe used to communicate with the seperate
  35. process. I should have looked into this more thoroughly.
  36. In Quake, I discovered that I could feed multiple
  37. acknowledgements to a SoundBlaster or compatible without
  38. any side-effects such as pops or other malfunctions.
  39. This discovery led me to switch to a completely synchronous
  40. model, much much easier to debug and understand, so I
  41. think this was fairly intelligent. Although we had to
  42. populate the game with calls in the right places to keep
  43. the sound buffers fed, and although it wasn't gauranteed to
  44. be always fed, well over 99% of the time, it was fed, and
  45. your the latency was never worse than the frequency of your
  46. refills (several times per frame) plus a small lead time
  47. (40th of a second?)."
  48. The separate sndserver code base introduced some redundancy
  49. (WAD access for sound lumps) for each UNIX target (Sun, SGI,
  50. Linux) and more differences between DOS and UNIX version.
  51. However, I kept the IPC based parts in the source, and
  52. separated the sndserver target in another directory to avoid
  53. further redundancy. There seem to be a few bug-like things
  54. going on in the sndserver that do not receive penalty as
  55. the program has to do only a simple task. One example would
  56. be a libc realloc mixed with zone memory allocation.
  57. Ungraceful and untimely demise of Linuxdoom (core instead
  58. of I_Error) will leave idle sndserver processes in your
  59. system, blocking /dev/bsp. Kill them manually.
  60. I put the non-redundant parts of the sndserver program
  61. into the i_sound module of doom, and with the SND_SERV
  62. compiler switch you can choose to use the internal sound
  63. support. However, there is a problem with e.g. the
  64. double shotgun and the plasma gun - walk up to a wall,
  65. face it straight, and fire. The sound output is crappy.
  66. This vanishes with decreasing screen size. A similar
  67. problem occurs with trimer driven asynchronous output
  68. enabled by SNDINTR.
  69. I agree with Dave that threads would be preferable.
  70. With respect to Linux ports of John Carmack's next
  71. Trinity engine, this one will rely on Win32
  72. multithreading e.g. for input sampling. So the Linux
  73. community will have to sort out threads anyway :-).
  74. To improve the current sound server, other means of
  75. IPC should take care of the latency. The mixing
  76. buffer/command buffer as shared memory comes to mind.
  77. 3) Music support
  78. There is, and was, no music support in Linuxdoom. Fine with
  79. me - I wouldn't give a bat's tail feathers for DOOM music.
  80. Your mileage may vary. There are a few leftovers of the DOS
  81. music support also interfacing DMX, so there is a place
  82. to start. However, in the age of CDROM based music, I
  83. recommend getting e.g. Workman to cooperate with DOOM
  84. (currently, DOOM accessing the soundcard SpekerOut
  85. interferes with Workman controlling the CD drives
  86. SpeakerOut), so musci could be chosen and run completely
  87. independend of the game. You could try Linuxdoom with
  88. Q2 music that way.