1
0
Fork 0

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.
This commit is contained in:
curt 1998-11-11 00:24:00 +00:00
parent dd70057f84
commit 8aa30c3d30
2 changed files with 72 additions and 3 deletions

View file

@ -21,6 +21,7 @@
// $Id$ // $Id$
// (Log is kept at end of this file) // (Log is kept at end of this file)
#define MICHAEL_JOHNSON_EXPERIMENTAL_ENGINE_AUDIO
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -572,11 +573,65 @@ static void fgMainLoop( void ) {
// Run audio scheduler // Run audio scheduler
#ifdef ENABLE_AUDIO_SUPPORT #ifdef ENABLE_AUDIO_SUPPORT
if ( current_options.get_sound() && audio_sched->working() ) { if ( current_options.get_sound() && audio_sched->working() ) {
double param = controls.get_throttle( 0 ) * 2.0 + 1.0;
# 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 ); pitch_envelope.setStep ( 0, 0.01, param );
volume_envelope.setStep ( 0, 0.01, param ); volume_envelope.setStep ( 0, 0.01, param );
# endif // experimental throttle patch
audio_sched -> update(); audio_sched -> update();
} }
#endif #endif
@ -891,6 +946,11 @@ int main( int argc, char **argv ) {
// $Log$ // $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 // Revision 1.65 1998/11/09 23:39:22 curt
// Tweaks for the instrument panel. // Tweaks for the instrument panel.
// //

View file

@ -212,8 +212,12 @@ int fgInitSubsystems( void )
abs_view_pos = fgGeodToCart(geod_pos); abs_view_pos = fgGeodToCart(geod_pos);
// Calculate ground elevation at starting point // Calculate ground elevation at starting point
FG_LOG( FG_GENERAL, FG_DEBUG,
"Altitude before update " << scenery.cur_elev );
scenery.cur_elev = scenery.cur_elev =
fgTileMgrCurElev( FG_Longitude, FG_Latitude, abs_view_pos ); 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; FG_Runway_altitude = scenery.cur_elev * METER_TO_FEET;
// Reset our altitude if we are below ground // Reset our altitude if we are below ground
@ -377,6 +381,11 @@ int fgInitSubsystems( void )
// $Log$ // $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 // Revision 1.48 1998/11/07 19:07:10 curt
// Enable release builds using the --without-logging option to the configure // Enable release builds using the --without-logging option to the configure
// script. Also a couple log message cleanups, plus some C to C++ comment // script. Also a couple log message cleanups, plus some C to C++ comment