We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 477 - mono->stereo and other upsampling conversions produce poor sound
Summary: mono->stereo and other upsampling conversions produce poor sound
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: 1.2.13
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-11 20:14 UTC by Jacob Meuser
Modified: 2009-09-20 23:19 UTC (History)
2 users (show)

See Also:


Attachments
updated patch against 1.2.13 (535 bytes, patch)
2008-04-16 03:02 UTC, Jacob Meuser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Meuser 2007-08-11 20:14:54 UTC
when SDL converts audio, it often degrades the overall sound quality.  This is noticeable even when doing just mono->stereo, and just 22050 Hz -> 44100 Hz.  these are the simplest upsampling conversions.

bug #298 hits on this and suggests that the fix isn't complete.  I believe the correct fix is below.  desired->size is of no consequence, audio->spec.size is the real buffer size.

this patch is against 1.2.9

--- src/audio/SDL_audio.c.orig	Fri Sep 17 06:20:10 2004
+++ src/audio/SDL_audio.c	Fri Aug 10 02:19:27 2007
@@ -481,7 +481,8 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
 			return(-1);
 		}
 		if ( audio->convert.needed ) {
-			audio->convert.len = desired->size;
+			audio->convert.len = (int) ( ((double) audio->spec.size) /
+                                          audio->convert.len_ratio );
 			audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
 			   audio->convert.len*audio->convert.len_mult);
 			if ( audio->convert.buf == NULL ) {
Comment 1 Sam Lantinga 2007-12-29 11:56:07 UTC
This change appears to already be in SDL 1.2.12.
Comment 2 Jacob Meuser 2008-01-03 00:50:42 UTC
no.  1.2.12 is using desired->size, this patch uses audio->spec.size.
Comment 3 Jacob Meuser 2008-04-16 03:02:50 UTC
Created attachment 251 [details]
updated patch against 1.2.13
Comment 4 Brad Smith 2009-01-19 03:54:32 UTC
Could a developer please take a look at the updated patch for 1.2.13?
Comment 5 Ryan C. Gordon 2009-09-20 23:19:34 UTC

Fixed in svn revision #4763 (and will be included in the 1.2.14 release).

--ryan.