From 8aa30c3d3059fcff139d5a25d7488f68f24735e5 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 11 Nov 1998 00:24:00 +0000 Subject: [PATCH] Added Michael Johnson's audio patches for testing. Also did a few tweaks to avoid numerical problems when starting at a place with no (or bogus) scenery. --- Main/GLUTmain.cxx | 66 ++++++++++++++++++++++++++++++++++++++++++++--- Main/fg_init.cxx | 9 +++++++ 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index 4de2b3ad0..562753a99 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -21,6 +21,7 @@ // $Id$ // (Log is kept at end of this file) +#define MICHAEL_JOHNSON_EXPERIMENTAL_ENGINE_AUDIO #ifdef HAVE_CONFIG_H # include @@ -572,10 +573,64 @@ static void fgMainLoop( void ) { // Run audio scheduler #ifdef ENABLE_AUDIO_SUPPORT if ( current_options.get_sound() && audio_sched->working() ) { - double param = controls.get_throttle( 0 ) * 2.0 + 1.0; - pitch_envelope.setStep ( 0, 0.01, param ); - volume_envelope.setStep ( 0, 0.01, param ); +# ifdef MICHAEL_JOHNSON_EXPERIMENTAL_ENGINE_AUDIO + + // note: all these factors are relative to the sample. our + // sample format should really contain a conversion factor so + // that we can get prop speed right for arbitrary samples. + // Note that for normal-size props, there is a point at which + // the prop tips approach the speed of sound; that is a pretty + // strong limit to how fast the prop can go. + + // multiplication factor is prime pitch control; add some log + // component for verisimilitude + + double pitch = log((controls.get_throttle(0) * 14.0) + 1.0); + //fprintf(stderr, "pitch1: %f ", pitch); + if (controls.get_throttle(0) > 0.0 || f->v_rel_wind > 40.0) { + //fprintf(stderr, "rel_wind: %f ", f->v_rel_wind); + // only add relative wind and AoA if prop is moving + // or we're really flying at idle throttle + if (pitch < 5.4) { // this needs tuning + // prop tips not breaking sound barrier + pitch += log(f->v_rel_wind + 0.8)/2; + } else { + // prop tips breaking sound barrier + pitch += log(f->v_rel_wind + 0.8)/10; + } + //fprintf(stderr, "pitch2: %f ", pitch); + //fprintf(stderr, "AoA: %f ", FG_Gamma_vert_rad); + + // Angle of Attack next... -x^3(e^x) is my best guess Just + // need to calculate some reasonable scaling factor and + // then clamp it on the positive aoa (neg adj) side + double aoa = FG_Gamma_vert_rad * 2.2; + double aoa_adj = pow(-aoa, 3) * pow(M_E, aoa); + if (aoa_adj < -0.8) aoa_adj = -0.8; + pitch += aoa_adj; + //fprintf(stderr, "pitch3: %f ", pitch); + + // don't run at absurdly slow rates -- not realistic + // and sounds bad to boot. :-) + if (pitch < 0.8) pitch = 0.8; + } + //fprintf(stderr, "pitch4: %f\n", pitch); + + double volume = controls.get_throttle(0) * 1.15 + 0.3 + + log(f->v_rel_wind + 1.0)/14.0; + // fprintf(stderr, "volume: %f\n", volume); + + pitch_envelope.setStep ( 0, 0.01, pitch ); + volume_envelope.setStep ( 0, 0.01, volume ); + +# else + + double param = controls.get_throttle( 0 ) * 2.0 + 1.0; + pitch_envelope.setStep ( 0, 0.01, param ); + volume_envelope.setStep ( 0, 0.01, param ); + +# endif // experimental throttle patch audio_sched -> update(); } @@ -891,6 +946,11 @@ int main( int argc, char **argv ) { // $Log$ +// Revision 1.66 1998/11/11 00:24:00 curt +// Added Michael Johnson's audio patches for testing. +// Also did a few tweaks to avoid numerical problems when starting at a place +// with no (or bogus) scenery. +// // Revision 1.65 1998/11/09 23:39:22 curt // Tweaks for the instrument panel. // diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index 7d4f2f205..e9c090669 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -212,8 +212,12 @@ int fgInitSubsystems( void ) abs_view_pos = fgGeodToCart(geod_pos); // Calculate ground elevation at starting point + FG_LOG( FG_GENERAL, FG_DEBUG, + "Altitude before update " << scenery.cur_elev ); scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude, abs_view_pos ); + FG_LOG( FG_GENERAL, FG_DEBUG, + "Altitude after update " << scenery.cur_elev ); FG_Runway_altitude = scenery.cur_elev * METER_TO_FEET; // Reset our altitude if we are below ground @@ -377,6 +381,11 @@ int fgInitSubsystems( void ) // $Log$ +// Revision 1.49 1998/11/11 00:24:02 curt +// Added Michael Johnson's audio patches for testing. +// Also did a few tweaks to avoid numerical problems when starting at a place +// with no (or bogus) scenery. +// // Revision 1.48 1998/11/07 19:07:10 curt // Enable release builds using the --without-logging option to the configure // script. Also a couple log message cleanups, plus some C to C++ comment -- 2.39.2