[Bug] Unable to manually play sample using Sample_Play when using SB driver and targetting DOS
Hi!
At this point it seems like I have have encountered an issue where the combination of Sample_Play and the SB-driver refuses to work, but WAV output produces the expected results.
My setup is as follows:
*) Using Open Watcom V2 under linux
*) Compiling libmikmod-3.3.13 DOS library using included Makefile.wat without modifications (thank you for this!)
*) Targetting 32-bit DOS using DOS32A or PMODEW (DOS4GW seems to crash out for me)
*) Modifying and using included libmikmod-3.3.13/examples/soundeffects/soundeffects.c
*) Compiled using wcl386 -cc++ -oi+ -l=dos32a -5s -bt=dos -fp5 -fpi87 -mf -oeatxh -w4 -ei -zp8 -zq -dMIKMOD_STATIC=1 -i=./libmikmod-3.3.13/include soundfx.c ./libmikmod-3.3.13/dos/mikmod.lib
*) Running the resulting EXE under Dosbox and real hardware
Playing a module seems to work just fine, however I cannot get manual sound effects to play either in combination with a module or using the standalone example.
However using WAV writer output the resulting music.wav does contain sound effects!
So the issue seems t be the combination of Sample_Play / Voice_Play and SB driver, but module playback works. I am not getting any loading or playback errors, it simply does not play the sample at all.
My samples does not seem to be the issue (since WAV output works and they are all mono and PCM) nor does the SB output seem to be an issue since module playback works and I'm afraid this is a little over my head.
I will try to test this using a PicoGUS as soon as I can to see if I can further narrow it down.
Indeed, soundeffects.c is silent for me too under dosbox using djgpp or watcom, but splay.c just works and plsys modules under dosbox using either of the compilers.
Unfortunately I can't debug this for the moment, so if you get any progress I'd like to hear and accept well-tested patches.
Thanks.
BTW, example programs need a simple patch for usleep() replacement: See the following patch. I'll push it to git later.
diff --git a/libmikmod/examples/simpleplay/splay.c b/libmikmod/examples/simpleplay/splay.c
index a56dfcb..6764a87 100644
--- a/libmikmod/examples/simpleplay/splay.c
+++ b/libmikmod/examples/simpleplay/splay.c
@@ -17,6 +17,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
diff --git a/libmikmod/examples/simpleplayFP/splayFP.c b/libmikmod/examples/simpleplayFP/splayFP.c
index ab615c5..497e870 100644
--- a/libmikmod/examples/simpleplayFP/splayFP.c
+++ b/libmikmod/examples/simpleplayFP/splayFP.c
@@ -18,6 +18,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
diff --git a/libmikmod/examples/simpleplayMEM/splayMEM.c b/libmikmod/examples/simpleplayMEM/splayMEM.c
index 9c608e8..a36d790 100644
--- a/libmikmod/examples/simpleplayMEM/splayMEM.c
+++ b/libmikmod/examples/simpleplayMEM/splayMEM.c
@@ -20,6 +20,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
diff --git a/libmikmod/examples/simpleplayMEM2/splayMEM2.c b/libmikmod/examples/simpleplayMEM2/splayMEM2.c
index f215763..d87da42 100644
--- a/libmikmod/examples/simpleplayMEM2/splayMEM2.c
+++ b/libmikmod/examples/simpleplayMEM2/splayMEM2.c
@@ -20,6 +20,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
diff --git a/libmikmod/examples/soundeffects/soundeffects.c b/libmikmod/examples/soundeffects/soundeffects.c
index dca0ea5..de9af68 100644
--- a/libmikmod/examples/soundeffects/soundeffects.c
+++ b/libmikmod/examples/soundeffects/soundeffects.c
@@ -18,6 +18,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
diff --git a/libmikmod/examples/umxplay/umxplay.c b/libmikmod/examples/umxplay/umxplay.c
index 95443b6..2f8acaa 100644
--- a/libmikmod/examples/umxplay/umxplay.c
+++ b/libmikmod/examples/umxplay/umxplay.c
@@ -20,6 +20,9 @@
void amiga_sysinit (void);
void amiga_usleep (unsigned long timeout);
#define MikMod_Sleep(ns) amiga_usleep(ns)
+#elif defined(__WATCOMC__) && defined(_DOS)
+#include <dos.h>
+#define MikMod_Sleep(ns) delay(ns / 1000)
#else
#include <unistd.h> /* for usleep() */
#define MikMod_Sleep(ns) usleep(ns)
Thank you for the super quick verification of the issue!
I did make a quick usleep to sleep fix myself to get it running.
I will update here if I manage to get any more tests done!
I can now confirm that sound effect playback does not really work with the GUS driver either.
Tested with PicoGUS on an Intel 200MMX system.
PicoGUS works as expected with random demos and a module playback example
Sound effect sample produces no sound and does not seem to attempt playback.
But if I force wav writer it works as expected.
Edit: On a side note, the resulting music.wav is in stereo and the sounds only play in the left channel (in all cases), but I've assumed that's default behavior.
So the gus driver actually works, that's good to know. I never had the hardware, therefore never tested since I took over the project.
Q: soundeffects play doesn't work, but does playing modules work properly with gus driver?
Understandable, GUS cards are not cheap these days.
Yes, as far as I can tell module playback works as expected.
Yes, as far as I can tell module playback works as expected.
Thanks for re-confirming -- and for putting up with my blindness.. (You actually noted that it plays modules properly in your first gus message, I guess I was half-asleep..)
No worries, I know how it is. Also just having the issue confirmed feels like a christmas present seeing how much of an incredible edge case "I want to play tracked modules AND play samples for a possible DOS-project" is 2025 =D