Jump to content

Using GaugeSound.dll with MSVC++ .NET (all editions)


n4gix

Recommended Posts

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:

 

// Sound declarations
   typedef VOID (*TGaugePlaySound)(LPTSTR,[color=Red]LPSTR[/color],int);
   typedef VOID (*TGaugeStopSound)([color=Red]LPSTR[/color]);
   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";

Then, in the gauge's function calls, use the named pointer instead of a "string":

 

           if ( *rotartest == 1 ) 
               { (GaugePlaySound)("sound\\esdg\\fire.wav",firetest,1) ; }
           else { (GaugeStopSound)(firetest); } 

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.

 

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.

Bill Leaming http://smileys.sur-la-toile.com/repository/Combat/0054.gif

Gauge Programming - 3d Modeling Military Visualizations

Flightsim.com Panels & Gauges Forum Moderator

Flightsim Rig: Intel Core i7-2600K - 8GB DDR3 1333 - EVGA GTX770 4GB - Win7 64bit Home Premium

Development Rig1: Intel Core i7-3770k - 16GB DDR3 - Dual Radeon HD7770 SLI 1GB - Win7 64bit Professional

Development Rig2: Intel Core i7-860 - 8GB DDR3 Corsair - GeForce GTS240 1GB - Win7 64bit Home Premium

NOTE: Unless explicitly stated in the post, everything written by my hand is MY opinion. I do NOT speak for any company, real or imagined...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...