GaugeSound.dll: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
(New page: {{Infobox-Applicable-FSVersion | FSXI = false | FSXA = true | FSX = true | FS2004 = true | FS2002 = false | FS2000 = false | FS98 = false }} If you wish to use the GaugeSound.dll in your ...) |
No edit summary |
||
| Line 32: | Line 32: | ||
case PANEL_SERVICE_PRE_INITIALIZE: | case PANEL_SERVICE_PRE_INITIALIZE: | ||
if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");} | if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");} | ||
GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound"); | GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound"); | ||
Latest revision as of 19:20, 5 April 2012
If you wish to use the GaugeSound.dll in your gauge(s), the first step is to declare the following in your main gauge (.cpp) file:
// Sound declarations typedef VOID (*TGaugePlaySound)(LPTSTR,LPSTR,int); typedef VOID (*TGaugeStopSound)(LPTSTR); typedef VOID (*TTerminateSounds)(); TGaugePlaySound GaugePlaySound; TGaugeStopSound GaugeStopSound; TTerminateSounds TerminateSounds; HMODULE MGaugeSound; // If you need to "loop" some sounds, define the "stop loop string names" LPSTR flap = "flap"; LPSTR gearhorn = "gearhorn"; LPSTR overspeed = "overspeed"; LPSTR firetest = "firetest"; LPSTR geartest = "geartest"; LPSTR speedtest = "speedtest"; LPSTR warning = "warning";
Next, initialize the following in the PANEL_SERVICE_PRE_INITIALIZE case:
case PANEL_SERVICE_PRE_INITIALIZE:
if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");
break;
Next, add the following to the PANEL_SERVICE_PRE_UPDATE case:
case PANEL_SERVICE_PRE_UPDATE:
MGaugeSound = GetModuleHandle("GaugeSound");
if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");
break;
Finally, add this to the PANEL_SERVICE_PRE_KILL case:
case PANEL_SERVICE_PRE_KILL:
MGaugeSound = GetModuleHandle("GaugeSound");
if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");
(TerminateSounds)();
FreeLibrary(MGaugeSound);
break;
To play a sound, use one of the following examples in a mouse callback. Note that "PathName" is the sub-folder name in the default FS ..\Sound folder, e.g., ..\Sound\Milviz. "SoundName" is for example push.wav:
Play once:
(GaugePlaySound)("sound\\PathName\\SoundName.wav","",0) ;
Loop Sound:
Looping a sound continuously require that you specify a "stop loop string name" and set the third parameter to 1 (0 = play once, 1 = loop continuously).
if ( *rotartest == 2 )
{ (GaugePlaySound)("soundesdggearhorn.wav",geartest,1) ; }
else { (GaugeStopSound)(geartest); }