diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.c | 16 | ||||
-rw-r--r-- | src/types.h | 2 |
2 files changed, 18 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; } diff --git a/src/types.h b/src/types.h index b163075..959a205 100644 --- a/src/types.h +++ b/src/types.h @@ -156,6 +156,8 @@ typedef struct { } sounds[AUDIO_MAX_SOUNDS]; int debug; + int startup; + float startup_volume; } AudioContext; |