Sign in to follow this  
Guest ptwaugh

Looping sound in C gauge.

Recommended Posts

Ok... this has officially driven me crazy.The announciator gauge works fine, with the light going off when RRPM falls below 90%, and back on when the RPM comes back up, but the sound no longer starts. Before it was starting, but then I couldn't stop it without stopping all sounds.I've tried everything I can think of. I know the dll is sound (pun intended), and realize I must be doing something wrong.If you can help please do. Here's the code:#include "incsound.h"// Set up gauge headerchar lrrpm_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER lrrpm_list;extern MOUSERECT lrrpm_mouse_rect[];GAUGE_CALLBACK lrrpm_gcb;GAUGE_HEADER_FS700(GAUGE_W, lrrpm_gauge_name, &lrrpm_list, lrrpm_mouse_rect, lrrpm_gcb, 0,0,0 );BOOL32 low_rrpm = 0; // Warn when RRPM falls below 90%.BOOL32 WARNING_LRRPM_PLAYING = 0; // True when sound loop playing.FLOAT64 FSAPI lrrpm_cb( PELEMENT_ICON pelement ){ // LOW ROTOR ANUNCIATOR ON // Determine RRPM, set flag, & reset mute. double rrpm = pelement->source_var.var_value.n; MODULE_VAR r_rpm = {TURB_ENGINE_1_N2}; lookup_var(&r_rpm); rrpm = r_rpm.var_value.n; if (rrpm < 90) { low_rrpm = 1; }else{ // RRPM Normal (turn off Icon) low_rrpm = 0; // Reset audio mute audio_warning_muted = 0; } return FALSE;}// Low Rotor RPM Warning ON bitmap as an icon.// This icon must be invisible when loadingMAKE_ICON( lrrpm_on_icon, BMP_LOW_ROTOR_ON, NULL, NULL, IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | IMAGE_USE_BRIGHT | IMAGE_HIDDEN, 0, 0,0, TURB_ENGINE_1_N2, lrrpm_cb, ICON_SWITCH_TYPE_SET_CUR_ICON, 1, 0, 0 )PELEMENT_HEADER lrrpm_on_icon_plist[] ={ &lrrpm_on_icon.header, NULL};// Low Rotor RPM Warning OFF bitmap is the background.MAKE_STATIC ( lrrpm_off_icon, BMP_LOW_ROTOR_OFF, &lrrpm_on_icon_plist, NULL, IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | IMAGE_USE_BRIGHT, 0, 0,0 )PELEMENT_HEADER lrrpm_list = &lrrpm_off_icon.header;MOUSE_TOOLTIP_ARGS (LowRotor_Args) MOUSE_TOOLTIP_ARG (TURB_ENGINE_1_N2, 1, NULL, NULL, NULL, NULL, NULL, NULL)MOUSE_TOOLTIP_ARGS_ENDMOUSE_FUNCTION LOWROTOR_mcb; //Mouse click to turn switch on and offMOUSE_BEGIN( lrrpm_mouse_rect, HELP_NONE, 0, 0 ) MOUSE_TOOLTIP_TEXT_STRING ("Rotor RPM (%1!d! RPM)", LowRotor_Args) MOUSE_CHILD_FUNCT( 0, 0, 90, 90, CURSOR_HAND, MOUSE_LEFTSINGLE, LOWROTOR_mcb )MOUSE_END// I click on the low rotor annunciator, and I can terminate the sound.BOOL FSAPI LOWROTOR_mcb( PPIXPOINT relative_point, FLAGS32 mouse_flags ){ //(TerminateSounds)(); if ( WARNING_LRRPM_PLAYING == 1 ) { WARNING_LRRPM_PLAYING = 0; (GaugeStopSound)("EO"); }else{ WARNING_LRRPM_PLAYING = 1; (GaugePlaySound)("soundBenchmark.B206B3EngOut.Loop.wav", "EO", 1); } return FALSE;}void FSAPI lrrpm_gcb (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_CONNECT_TO_WINDOW: // Load GaugeSound Services DLL 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; case PANEL_SERVICE_PRE_INSTALL: break; case PANEL_SERVICE_PRE_INITIALIZE: break; case PANEL_SERVICE_PRE_UPDATE: //Now show and hide the switch bitmaps by showing and hiding the icons MGaugeSound = GetModuleHandle("GaugeSound"); if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");} GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound"); GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound"); TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds"); if ( low_rrpm ) { // LOW ROTOR WARNING LIGHT ON SHOW_LISTELEMENT(pgauge->elements_list[0],1); // Audio warning on (if not active) if (low_rrpm && WARNING_LRRPM_PLAYING) { (GaugePlaySound)("soundBenchmark.B206B3LowRotor.Loop.wav", "LRRPM", 1); WARNING_LRRPM_PLAYING = 1; } }else{ // LOW ROTOR WARNING LIGHT OFF HIDE_LISTELEMENT(pgauge->elements_list[0],1); // Audio warning off (GaugeStopSound)("LRRPM"); //(TerminateSounds)(); WARNING_LRRPM_PLAYING = 0; } case PANEL_SERVICE_PRE_DRAW: break; case PANEL_SERVICE_PRE_KILL: //Unregister the sound when unloading the panel 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; }}/////////////////////////////////////////////////////////////////////////////#undef GAUGE_NAME#undef GAUGEHDR_VAR_NAME#undef GAUGE_W

Share this post

Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this