diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-29 17:48:53 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-29 17:48:53 +0000 |
commit | 7e407086954ee6cc4c1188cae1bbaa2bae34a7e3 (patch) | |
tree | 85221803645bb11ed2decf26029733057e4de7d3 /src/audio.c | |
parent | eada55f61163e5fe06f69175b1cb8c4172345d75 (diff) |
Fast ramp-up of volume on starting, to avoid 'click'
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@117 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/audio.c')
-rw-r--r-- | src/audio.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/audio.c b/src/audio.c index 6735665..31646f0 100644 --- a/src/audio.c +++ b/src/audio.c @@ -70,6 +70,20 @@ static void audio_mix(void *data, Uint8 *stream8, int len) { } + /* Fast ramp-up of volume when starting program, avoids 'click' */ + if ( a->startup ) { + for ( j=0; j<len; j++ ) { + stream[j] *= a->startup_volume; + a->startup_volume += 0.001; + if ( a->startup_volume > 1.0 ) { + if ( a->startup ) printf("AU: Finished startup ramp.\n"); + a->startup = 0; + a->startup_volume = 1.0; + } + } + + } + if ( a->debug && (clip_count > 0) ) printf("AU: Clipped %i samples.\n", clip_count); } @@ -132,6 +146,8 @@ AudioContext *audio_setup(int debug) { /* Initialise audio context */ a->debug = debug; + a->startup = 1; + a->startup_volume = 0.0; for ( i=0; i<AUDIO_MAX_SOUNDS; i++ ) { a->sounds[i].inuse = 0; } |