Skip to content

Commit

Permalink
MixStream: properly clamp samples that clip
Browse files Browse the repository at this point in the history
  • Loading branch information
stump committed Jan 9, 2013
1 parent c815c52 commit bfafd3e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/MixStream/MixStream.c
Expand Up @@ -228,6 +228,7 @@ static gboolean _mix_stream_nextchunk(MixStream* stream, gsize size)
/* If we're converting stereo to mono, average this sample with the other channel's. */
if (stream->channels == 2 && stream->out_channels == 1)
current_sample = (float)(0.5 * (current_sample + *(floatbuf++)));
current_sample = CLAMP(current_sample, -1.0, 1.0);

#define OUTPUT_SAMPLE(type, value) { *(type*)out_buf = (type)(value); out_buf += sizeof(type); size -= sizeof(type); }

Expand Down

0 comments on commit bfafd3e

Please sign in to comment.