Anyone who's attempted to implement the use of GaugeSound.dll in their projects compiled with anything other than MinGW has undoubtedly encountered the problem with "looped sounds" failing to "stop" when commanded with the (GaugeStopSound)("stop_flag"); function.
Here then is a slight modification that will overcome this limitation.
Change the LPTSTR in the 2nd param of "TGaugePlaySound" to an LPSTR, change the LPTSTR in "TGaugeStopSound" to an LPSTR, and
then explicitly create the necessary LPSTR buffers and initialize them with constants:
Then, in the gauge's function calls, use the named pointer instead of a "string":Code:// Sound declarations typedef VOID (*TGaugePlaySound)(LPTSTR,LPSTR,int); typedef VOID (*TGaugeStopSound)(LPSTR); typedef VOID (*TTerminateSounds)(); TGaugePlaySound GaugePlaySound; TGaugeStopSound GaugeStopSound; TTerminateSounds TerminateSounds; HMODULE MGaugeSound; LPSTR flap = "flap"; LPSTR gearhorn = "gearhorn"; LPSTR overspeed = "overspeed"; LPSTR firetest = "firetest"; LPSTR geartest = "geartest"; LPSTR speedtest = "speedtest"; LPSTR warning = "warning";
Note that in the actual function call, no "quote marks" are required, since we're now passing a pointer name, and not a literal string.Code:if ( *rotartest == 1 ) { (GaugePlaySound)("sound\\esdg\\fire.wav",firetest,1) ; } else { (GaugeStopSound)(firetest); }
NOTE: My thanks go to Dave Nunyez from the Freelight Design forums for pointing out that my earlier "kludge" using an int wasn't really "safe hex" and could lead to all sorts of problems down the road.





Bookmarks