Added support for pitch and volume envelopes and tied them to the
throttle setting.
This commit is contained in:
parent
cc0d582e26
commit
be2f27bd66
1 changed files with 24 additions and 4 deletions
|
@ -53,11 +53,8 @@
|
||||||
#include <Include/general.h>
|
#include <Include/general.h>
|
||||||
|
|
||||||
#include <Aircraft/aircraft.h>
|
#include <Aircraft/aircraft.h>
|
||||||
//#include <Astro/moon.hxx>
|
|
||||||
//#include <Astro/planets.hxx>
|
|
||||||
#include <Astro/sky.hxx>
|
#include <Astro/sky.hxx>
|
||||||
#include <Astro/stars.hxx>
|
#include <Astro/stars.hxx>
|
||||||
//#include <Astro/sun.hxx>
|
|
||||||
#include <Astro/solarsystem.hxx>
|
#include <Astro/solarsystem.hxx>
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
|
@ -104,6 +101,8 @@ int panel_hist = 0;
|
||||||
|
|
||||||
// Global structures for the Audio library
|
// Global structures for the Audio library
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
|
slEnvelope pitch_envelope ( 1, SL_SAMPLE_ONE_SHOT ) ;
|
||||||
|
slEnvelope volume_envelope ( 1, SL_SAMPLE_ONE_SHOT ) ;
|
||||||
slScheduler *audio_sched;
|
slScheduler *audio_sched;
|
||||||
smMixer *audio_mixer;
|
smMixer *audio_mixer;
|
||||||
slSample *s1;
|
slSample *s1;
|
||||||
|
@ -455,6 +454,7 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
|
||||||
// What should we do when we have nothing else to do? Let's get ready
|
// What should we do when we have nothing else to do? Let's get ready
|
||||||
// for the next move and update the display?
|
// for the next move and update the display?
|
||||||
static void fgMainLoop( void ) {
|
static void fgMainLoop( void ) {
|
||||||
|
fgCONTROLS *c;
|
||||||
fgFLIGHT *f;
|
fgFLIGHT *f;
|
||||||
fgGENERAL *g;
|
fgGENERAL *g;
|
||||||
fgTIME *t;
|
fgTIME *t;
|
||||||
|
@ -465,6 +465,7 @@ static void fgMainLoop( void ) {
|
||||||
// double joy_x, joy_y;
|
// double joy_x, joy_y;
|
||||||
// int joy_b1, joy_b2;
|
// int joy_b1, joy_b2;
|
||||||
|
|
||||||
|
c = &cur_control_params;
|
||||||
f = current_aircraft.flight;
|
f = current_aircraft.flight;
|
||||||
g = &general;
|
g = &general;
|
||||||
t = &cur_time_params;
|
t = &cur_time_params;
|
||||||
|
@ -572,6 +573,11 @@ static void fgMainLoop( void ) {
|
||||||
// Run audio scheduler
|
// Run audio scheduler
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
if ( current_options.get_sound() ) {
|
if ( current_options.get_sound() ) {
|
||||||
|
double param = c->throttle[0] * 2.0 + 1.0;
|
||||||
|
|
||||||
|
pitch_envelope.setStep ( 0, 0.01, param );
|
||||||
|
volume_envelope.setStep ( 0, 0.01, param );
|
||||||
|
|
||||||
audio_sched -> update();
|
audio_sched -> update();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -679,7 +685,7 @@ static void fgIdleFunction ( void ) {
|
||||||
|
|
||||||
audio_sched = new slScheduler ( 8000 );
|
audio_sched = new slScheduler ( 8000 );
|
||||||
audio_mixer = new smMixer;
|
audio_mixer = new smMixer;
|
||||||
audio_mixer -> setMasterVolume ( 80 ) ; /* 80% of max volume. */
|
audio_mixer -> setMasterVolume ( 50 ) ; /* 80% of max volume. */
|
||||||
audio_sched -> setSafetyMargin ( 1.0 ) ;
|
audio_sched -> setSafetyMargin ( 1.0 ) ;
|
||||||
string slfile = current_options.get_fg_root() + "/Sounds/wasp.wav";
|
string slfile = current_options.get_fg_root() + "/Sounds/wasp.wav";
|
||||||
|
|
||||||
|
@ -688,6 +694,16 @@ static void fgIdleFunction ( void ) {
|
||||||
s1 -> getRate(), s1 -> getBps(), s1 -> getStereo());
|
s1 -> getRate(), s1 -> getBps(), s1 -> getStereo());
|
||||||
audio_sched -> loopSample ( s1 );
|
audio_sched -> loopSample ( s1 );
|
||||||
|
|
||||||
|
pitch_envelope.setStep ( 0, 0.01, 0.6 );
|
||||||
|
volume_envelope.setStep ( 0, 0.01, 0.6 );
|
||||||
|
|
||||||
|
audio_sched -> addSampleEnvelope( s1, 0, 0, &
|
||||||
|
pitch_envelope,
|
||||||
|
SL_PITCH_ENVELOPE );
|
||||||
|
audio_sched -> addSampleEnvelope( s1, 0, 1,
|
||||||
|
&volume_envelope,
|
||||||
|
SL_VOLUME_ENVELOPE );
|
||||||
|
|
||||||
// strcpy(slfile, path);
|
// strcpy(slfile, path);
|
||||||
// strcat(slfile, "thunder.wav");
|
// strcat(slfile, "thunder.wav");
|
||||||
// s2 -> loadFile ( slfile );
|
// s2 -> loadFile ( slfile );
|
||||||
|
@ -872,6 +888,10 @@ int main( int argc, char **argv ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.52 1998/09/25 16:02:07 curt
|
||||||
|
// Added support for pitch and volume envelopes and tied them to the
|
||||||
|
// throttle setting.
|
||||||
|
//
|
||||||
// Revision 1.51 1998/09/15 04:27:28 curt
|
// Revision 1.51 1998/09/15 04:27:28 curt
|
||||||
// Changes for new Astro code.
|
// Changes for new Astro code.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue