Mercurial > sdl-ios-xcode
changeset 2655:b8e736c8a5a8 gsoc2008_audio_resampling
Added beginnings of resampling code.
author | Aaron Wishnick <schnarf@gmail.com> |
---|---|
date | Wed, 18 Jun 2008 04:51:10 +0000 |
parents | 2e14bdaaff18 |
children | dd74182b3c3c |
files | Xcode/SDL/SDL.xcodeproj/project.pbxproj include/SDL_audio.h src/audio/SDL_audiocvt.c |
diffstat | 3 files changed, 302 insertions(+), 330 deletions(-) [+] |
line wrap: on
line diff
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj Wed Apr 23 06:26:21 2008 +0000 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj Wed Jun 18 04:51:10 2008 +0000 @@ -512,35 +512,6 @@ BECDF6B70761BA81005FE872 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EECDF2E0086C3A07F000001 /* SDLMain.m */; }; /* End PBXBuildFile section */ -/* Begin PBXBuildStyle section */ - F512D95E02A6E0AB01D28762 /* Development */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEBUGGING_SYMBOLS = YES; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - OPTIMIZATION_CFLAGS = "-O0"; - ZERO_LINK = YES; - }; - name = Development; - }; - F512D95F02A6E0AB01D28762 /* Deployment */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUGGING_SYMBOLS = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - ZERO_LINK = NO; - }; - name = Deployment; - }; -/* End PBXBuildStyle section */ - /* Begin PBXContainerItemProxy section */ BECDF6C50761BA81005FE872 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -742,8 +713,8 @@ BECDF66C0761BA81005FE872 /* SDL.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDL.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BECDF6B30761BA81005FE872 /* libSDL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL.a; sourceTree = BUILT_PRODUCTS_DIR; }; BECDF6BA0761BA81005FE872 /* libSDLmain.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDLmain.a; sourceTree = BUILT_PRODUCTS_DIR; }; - BECDF6BE0761BA81005FE872 /* Standard DMG */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = "Standard DMG"; sourceTree = BUILT_PRODUCTS_DIR; }; - BECDF6C30761BA81005FE872 /* Developer Extras Package */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = "Developer Extras Package"; sourceTree = BUILT_PRODUCTS_DIR; }; + BECDF6BE0761BA81005FE872 /* Standard DMG */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Standard DMG"; sourceTree = BUILT_PRODUCTS_DIR; }; + BECDF6C30761BA81005FE872 /* Developer Extras Package */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Developer Extras Package"; sourceTree = BUILT_PRODUCTS_DIR; }; F51789D101769A2401D3D55B /* SDL_sysjoystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_sysjoystick.c; sourceTree = "<group>"; }; F59C70FF00D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = "<group>"; }; F59C710000D5CB5801000001 /* Welcome.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Welcome.txt; sourceTree = "<group>"; }; @@ -1609,73 +1580,6 @@ ); buildRules = ( ); - buildSettings = { - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXPORTED_SYMBOLS_FILE = ../../src/main/macosx/exports/SDL.x; - FRAMEWORK_SEARCH_PATHS = ""; - FRAMEWORK_VERSION = A; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - ENABLE_QUARTZ, - PTHREAD_NO_RECURSIVE_MUTEX, - SDL_USE_PTHREADS, - TARGET_API_MAC_CARBON, - TARGET_API_MAC_OSX, - MACOSX, - HAVE_OPENGL, - ); - GCC_USE_GCC3_PFE_SUPPORT = YES; - HEADER_SEARCH_PATHS = ( - /System/Library/Frameworks/Carbon.framework/Headers, - ../../src, - ../../include, - ../../src/audio, - ../../src/cdrom, - ../../src/endian, - ../../src/events, - ../../src/file, - ../../src/hermes, - ../../src/joystick, - ../../src/main, - ../../src/thread, - ../../src/timer, - ../../src/video, - ); - INFOPLIST_FILE = "Info-Framework__Upgraded_.plist"; - INSTALL_PATH = "@executable_path/../Frameworks"; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ( - "-seg1addr", - 0x30000000, - "-framework", - IOKit, - "-framework", - Cocoa, - "-framework", - OpenGL, - "-framework", - Carbon, - "-framework", - QuickTime, - "-framework", - AudioToolbox, - "-framework", - AudioUnit, - "-framework", - CoreAudio, - ); - PRODUCT_NAME = SDL; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wall", - "-Wno-four-char-constants", - ); - WRAPPER_EXTENSION = framework; - }; comments = "We recommend installing to /Library/Frameworks\nAn alternative is $(HOME)/Library/Frameworks for per-user if permissions are an issue.\n\nAdd the framework to the Groups & Files panel (under Linked Frameworks is a good place) and enable the check box for the targets that need to link to it. You can also manually add \"-framework SDL\" to your linker flags if you don't like the check box system.\n\nAdd /Library/Frameworks/SDL.framework/Headers to your header search path\nAdd /Library/Frameworks to your library search path\n(Adjust the two above if installed in $(HOME)/Library/Frameworks. You can also list both paths if you want robustness.)\n\nWe used to use an exports file. It was becoming a maintenance issue we kept neglecting, so we have removed it. If you need it back, set the \"Exported Symbols File\" option to:\n../../src/main/macosx/exports/SDL.x\n(You may need to regenerate the exports list. There is a Makefile in that directory that you can run from the command line to rebuild it.)\nLong term, we want to utilize gcc 4.0's new visibility feature (analogous to declspec on Windows). Other platforms would benefit from this change too. The downside is that we still use gcc 3.3 for the PowerPC build here so only our x86 builds will cull the symbols if we go down this route (and don't use the exports file).\n\n"; dependencies = ( ); @@ -1697,50 +1601,6 @@ ); buildRules = ( ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - ENABLE_QUARTZ, - PTHREAD_NO_RECURSIVE_MUTEX, - SDL_USE_PTHREADS, - DISABLE_JOYSTICK, - DISABLE_CDROM, - TARGET_API_MAC_CARBON, - TARGET_API_MAC_OSX, - MACOSX, - HAVE_OPENGL, - ); - HEADER_SEARCH_PATHS = ( - /System/Library/Frameworks/Carbon.framework/Headers/, - ../../src, - ../../include, - ../../src/audio, - ../../src/cdrom, - ../../src/endian, - ../../src/events, - ../../src/file, - ../../src/joystick, - ../../src/thread, - ../../src/timer, - ../../src/video, - ); - LIBRARY_STYLE = STATIC; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = SDL; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; comments = "This produces libsdl.a, which is the static build of SDL. You will have to link to the Cocoa and OpenGL frameworks in your application."; dependencies = ( ); @@ -1763,73 +1623,6 @@ ); buildRules = ( ); - buildSettings = { - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXPORTED_SYMBOLS_FILE = ../../src/main/macosx/exports/SDL.x; - FRAMEWORK_SEARCH_PATHS = ""; - FRAMEWORK_VERSION = A; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - ENABLE_QUARTZ, - PTHREAD_NO_RECURSIVE_MUTEX, - SDL_USE_PTHREADS, - TARGET_API_MAC_CARBON, - TARGET_API_MAC_OSX, - MACOSX, - HAVE_OPENGL, - ); - GCC_USE_GCC3_PFE_SUPPORT = YES; - HEADER_SEARCH_PATHS = ( - /System/Library/Frameworks/Carbon.framework/Headers, - ../../src, - ../../include, - ../../src/audio, - ../../src/cdrom, - ../../src/endian, - ../../src/events, - ../../src/file, - ../../src/hermes, - ../../src/joystick, - ../../src/main, - ../../src/thread, - ../../src/timer, - ../../src/video, - ); - INFOPLIST_FILE = "Info-Framework__Upgraded_.plist"; - INSTALL_PATH = "@executable_path/../Frameworks"; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ( - "-seg1addr", - 0x30000000, - "-framework", - IOKit, - "-framework", - Cocoa, - "-framework", - OpenGL, - "-framework", - Carbon, - "-framework", - QuickTime, - "-framework", - AudioToolbox, - "-framework", - AudioUnit, - "-framework", - CoreAudio, - ); - PRODUCT_NAME = SDL; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wall", - "-Wno-four-char-constants", - ); - WRAPPER_EXTENSION = framework; - }; comments = "We recommend installing to /Library/Frameworks\nAn alternative is $(HOME)/Library/Frameworks for per-user if permissions are an issue.\n\nAdd the framework to the Groups & Files panel (under Linked Frameworks is a good place) and enable the check box for the targets that need to link to it. You can also manually add \"-framework SDL\" to your linker flags if you don't like the check box system.\n\nAdd /Library/Frameworks/SDL.framework/Headers to your header search path\nAdd /Library/Frameworks to your library search path\n(Adjust the two above if installed in $(HOME)/Library/Frameworks. You can also list both paths if you want robustness.)\n\nWe used to use an exports file. It was becoming a maintenance issue we kept neglecting, so we have removed it. If you need it back, set the \"Exported Symbols File\" option to:\n../../src/main/macosx/exports/SDL.x\n(You may need to regenerate the exports list. There is a Makefile in that directory that you can run from the command line to rebuild it.)\nLong term, we want to utilize gcc 4.0's new visibility feature (analogous to declspec on Windows). Other platforms would benefit from this change too. The downside is that we still use gcc 3.3 for the PowerPC build here so only our x86 builds will cull the symbols if we go down this route (and don't use the exports file).\n\n"; dependencies = ( ); @@ -1851,50 +1644,6 @@ ); buildRules = ( ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - ENABLE_QUARTZ, - PTHREAD_NO_RECURSIVE_MUTEX, - SDL_USE_PTHREADS, - DISABLE_JOYSTICK, - DISABLE_CDROM, - TARGET_API_MAC_CARBON, - TARGET_API_MAC_OSX, - MACOSX, - HAVE_OPENGL, - ); - HEADER_SEARCH_PATHS = ( - /System/Library/Frameworks/Carbon.framework/Headers/, - ../../src, - ../../include, - ../../src/audio, - ../../src/cdrom, - ../../src/endian, - ../../src/events, - ../../src/file, - ../../src/joystick, - ../../src/thread, - ../../src/timer, - ../../src/video, - ); - LIBRARY_STYLE = STATIC; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = SDL; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; comments = "This produces libsdl.a, which is the static build of SDL. You will have to link to the Cocoa and OpenGL frameworks in your application."; dependencies = ( ); @@ -1915,25 +1664,6 @@ ); buildRules = ( ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - LIBRARY_STYLE = STATIC; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = SDLmain; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; comments = "This produces libSDLmain.a, which contains only SDL_main.m, the hook to get the app running correctly before your SDL code executes."; dependencies = ( ); @@ -1951,19 +1681,6 @@ ); buildRules = ( ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "Standard Package"; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; dependencies = ( BECDF6C60761BA81005FE872 /* PBXTargetDependency */, ); @@ -1981,19 +1698,6 @@ ); buildRules = ( ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "Devel Package"; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; dependencies = ( ); name = "Developer Extras Package"; @@ -2008,13 +1712,7 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 0073178E0858DB0500B2BC32 /* Build configuration list for PBXProject "SDL" */; - buildSettings = { - MACOSX_DEPLOYMENT_TARGET = 10.1; - }; - buildStyles = ( - F512D95E02A6E0AB01D28762 /* Development */, - F512D95F02A6E0AB01D28762 /* Deployment */, - ); + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 0867D691FE84028FC02AAC07 /* SDLFramework */; productRefGroup = 034768DDFF38A45A11DB9C8B /* Products */; @@ -2634,16 +2332,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; GCC_SYMBOLS_PRIVATE_EXTERN = YES; INFOPLIST_FILE = "Info-Framework.plist"; INSTALL_PATH = "@executable_path/../Frameworks"; @@ -2670,16 +2372,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; GCC_SYMBOLS_PRIVATE_EXTERN = YES; INFOPLIST_FILE = "Info-Framework.plist"; INSTALL_PATH = "@executable_path/../Frameworks"; @@ -2706,16 +2412,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; GCC_SYMBOLS_PRIVATE_EXTERN = YES; INFOPLIST_FILE = "Info-Framework.plist"; INSTALL_PATH = "@executable_path/../Frameworks"; @@ -2739,16 +2449,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_FOR_TARGET_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; OTHER_CFLAGS = "$(OTHER_CFLAGS_$(CURRENT_ARCH))"; OTHER_CFLAGS_i386 = ""; OTHER_CFLAGS_ppc = ""; @@ -2764,16 +2478,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; OTHER_CFLAGS = "$(OTHER_CFLAGS_$(CURRENT_ARCH))"; OTHER_CFLAGS_i386 = ""; OTHER_CFLAGS_ppc = ""; @@ -2789,16 +2507,20 @@ "SDL_VIDEO_DRIVER_DGA=1", "SDL_VIDEO_DRIVER_X11=1", "SDL_VIDEO_DRIVER_X11_DGAMOUSE=1", - "SDL_VIDEO_DRIVER_X11_DYNAMIC=\"/usr/X11R6/lib/libX11.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\"/usr/X11R6/lib/libXext.6.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\"/usr/X11R6/lib/libXrandr.2.dylib\"", - "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\"/usr/X11R6/lib/libXrender.1.dylib\"", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3)", + "$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)", "SDL_VIDEO_DRIVER_X11_VIDMODE=1", "SDL_VIDEO_DRIVER_X11_XINERAMA=1", "SDL_VIDEO_DRIVER_X11_XME=1", "SDL_VIDEO_DRIVER_X11_XRANDR=1", "SDL_VIDEO_DRIVER_X11_XV=1", ); + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_1 = "SDL_VIDEO_DRIVER_X11_DYNAMIC=\\\"/usr/X11R6/lib/libX11.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_2 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT=\\\"/usr/X11R6/lib/libXext.6.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_3 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR=\\\"/usr/X11R6/lib/libXrandr.2.dylib\\\""; + GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4 = "SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER=\\\"/usr/X11R6/lib/libXrender.1.dylib\\\""; OTHER_CFLAGS = "$(OTHER_CFLAGS_$(CURRENT_ARCH))"; OTHER_CFLAGS_i386 = ""; OTHER_CFLAGS_ppc = "";
--- a/include/SDL_audio.h Wed Apr 23 06:26:21 2008 +0000 +++ b/include/SDL_audio.h Wed Jun 18 04:51:10 2008 +0000 @@ -142,10 +142,15 @@ SDL_AudioFormat dst_format; /* Target audio format */ double rate_incr; /* Rate conversion increment */ Uint8 *buf; /* Buffer to hold entire audio data */ + Uint8 *sinc; /* Windowed sinc filter */ + Uint8 *state_buf; /* Sample history for either the FIR or IIR filter */ + int state_pos; /* Position in the state */ + int len_sinc; /* Length of windowed sinc filter, in appropriate units (not necessarily bytes) */ int len; /* Length of original audio buffer */ int len_cvt; /* Length of converted audio buffer */ int len_mult; /* buffer must be len*len_mult big */ - double len_ratio; /* Given len, final size is len*len_ratio */ + int len_div; /* desination length = len_mult / len_div * src length */ + double len_ratio; /* Given len, final size is len*len_ratio ( len_ratio = len_mult / len_div ) */ SDL_AudioFilter filters[10]; /* Filter list */ int filter_index; /* Current audio conversion function */ } SDL_AudioCVT;
--- a/src/audio/SDL_audiocvt.c Wed Apr 23 06:26:21 2008 +0000 +++ b/src/audio/SDL_audiocvt.c Wed Jun 18 04:51:10 2008 +0000 @@ -20,6 +20,7 @@ slouken@libsdl.org */ #include "SDL_config.h" +#include <math.h> /* Functions for audio drivers to perform runtime conversion of audio format */ @@ -1229,6 +1230,79 @@ } } +/* Perform proper resampling */ +static void SDLCALL +SDL_Resample(SDL_AudioCVT * cvt, SDL_AudioFormat format) +{ + int i, j; + +#ifdef DEBUG_CONVERT + fprintf(stderr, "Converting audio rate via proper resampling (mono)\n"); +#endif + +#define zerostuff_mono(type) { \ + const type *src = (const type *) (cvt->buf + cvt->len_cvt); \ + type *dst = (type *) (cvt->buf + (cvt->len_cvt * cvt->len_mult)); \ + for (i = cvt->len_cvt / sizeof (type); i; --i) { \ + src--; \ + dst[-1] = src[0]; \ + for( j = -cvt->len_mult; j < -1; ++j ) { \ + dst[j] = 0; \ + } \ + dst -= cvt->len_mult; \ + } \ + } + +#define discard_mono(type) { \ + const type *src = (const type *) (cvt->buf); \ + type *dst = (type *) (cvt->buf); \ + for (i = 0; i < cvt->len_cvt / sizeof (type); ++i) { \ + dst[0] = src[0]; \ + src += cvt->len_div; \ + ++dst; \ + } \ + } + + // Step 1: Zero stuff the conversion buffer + switch (SDL_AUDIO_BITSIZE(format)) { + case 8: + zerostuff_mono(Uint8); + break; + case 16: + zerostuff_mono(Uint16); + break; + case 32: + zerostuff_mono(Uint32); + break; + } + + cvt->len_cvt *= cvt->len_mult; + + // Step 2: Use either a windowed sinc FIR filter or IIR lowpass filter to remove all alias frequencies + + // Step 3: Discard unnecessary samples + switch (SDL_AUDIO_BITSIZE(format)) { + case 8: + discard_mono(Uint8); + break; + case 16: + discard_mono(Uint16); + break; + case 32: + discard_mono(Uint32); + break; + } + +#undef zerostuff_mono +#undef discard_mono + + cvt->len_cvt /= cvt->len_div; + + if (cvt->filters[++cvt->filter_index]) { + cvt->filters[cvt->filter_index] (cvt, format); + } +} + int SDL_ConvertAudio(SDL_AudioCVT * cvt) { @@ -1309,6 +1383,177 @@ return 0; /* no conversion necessary. */ } +/* Generate the necessary IIR lowpass coefficients for resampling. + Assume that the SDL_AudioCVT struct is already set up with + the correct values for len_mult and len_div, and use the + type of dst_format. Also assume the buffer is allocated. + Note the buffer needs to be 6 units long. + For now, use RBJ's cookbook coefficients. It might be more + optimal to create a Butterworth filter, but this is more difficult. +*/ +int SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format) { + float fc; /* cutoff frequency */ + float coeff[6]; /* floating point iir coefficients b0, b1, b2, a0, a1, a2 */ + float scale; + float w0, alpha, cosw0; + + /* The higher Q is, the higher CUTOFF can be. Need to find a good balance to avoid aliasing */ + static const float Q = 5.0f; + static const float CUTOFF = 0.4f; + + fc = (cvt->len_mult > cvt->len_div) ? CUTOFF / (float)cvt->len_mult : CUTOFF / (float)cvt->len_div; + + w0 = 2.0f * M_PI * fc; + cosw0 = cosf(w0); + alpha = sin(w0) / (2.0f * Q); + + /* Compute coefficients, normalizing by a0 */ + scale = 1.0f / (1.0f + alpha); + + coeff[0] = (1.0f - cosw0) / 2.0f * scale; + coeff[1] = (1.0f - cosw0) * scale; + coeff[2] = coeff[0]; + + coeff[3] = 1.0f; /* a0 is normalized to 1 */ + coeff[4] = -2.0f * cosw0 * scale; + coeff[5] = (1.0f - alpha) * scale; + + /* Convert coefficients to fixed point, using the range (-2.0, 2.0) */ + + /* Initialize the state buffer to all zeroes, and set initial position */ + memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4); + cvt->state_pos = 0; +} + +/* Apply the windowed sinc FIR filter to the given SDL_AudioCVT struct */ +int SDL_FilterFIR(SDL_AudioCVT * cvt, SDL_AudioFormat format) { + int n = cvt->len_cvt / (SDL_AUDIO_BITSIZE(format) / 4); + int m = cvt->len_sinc; + int i, j; + + /* Note: this makes use of the symmetry of the sinc filter. + We can also make a big optimization here by taking advantage + of the fact that the signal is zero stuffed, so we can do + significantly fewer multiplications and additions. + */ +#define filter_sinc(type, shift_bits) { \ + type *sinc = (type *)cvt->sinc; \ + type *state = (type *)cvt->state_buf; \ + type *buf = (type *)cvt->buf; \ + for(i = 0; i < n; ++i) { \ + state[cvt->state_pos++] = buf[i] >> shift_bits; \ + if(cvt->state_pos == m) cvt->state_pos = 0; \ + buf[i] = 0; \ + for(j = 0; j < m; ++j) { \ + buf[i] += state[j] * sinc[j]; \ + } \ + } \ + } + + switch (SDL_AUDIO_BITSIZE(format)) { + case 8: + filter_sinc(Uint8, 4); + break; + case 16: + filter_sinc(Uint16, 8); + break; + case 32: + filter_sinc(Uint32, 16); + break; + } + +#undef filter_sinc + +} + +/* Generate the necessary windowed sinc filter for resampling. + Assume that the SDL_AudioCVT struct is already set up with + the correct values for len_mult and len_div, and use the + type of dst_format. Also assume the buffer is allocated. + Note the buffer needs to be m+1 units long. +*/ +int +SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format, unsigned int m) { + float fScale; /* scale factor for fixed point */ + float *fSinc; /* floating point sinc buffer, to be converted to fixed point */ + float fc; /* cutoff frequency */ + float two_pi_fc, two_pi_over_m, four_pi_over_m, m_over_two; + float norm_sum, norm_fact; + unsigned int i; + + /* Check that the buffer is allocated */ + if( cvt->sinc == NULL ) { + return -1; + } + + /* Set the length */ + cvt->len_sinc = m; + + /* Allocate the floating point windowed sinc. */ + fSinc = (float *)malloc(m * sizeof(float)); + if( fSinc == NULL ) { + return -1; + } + + /* Set up the filter parameters */ + fc = (cvt->len_mult > cvt->len_div) ? 0.5f / (float)cvt->len_mult : 0.5f / (float)cvt->len_div; + two_pi_fc = 2.0f * M_PI * fc; + two_pi_over_m = 2.0f * M_PI / (float)m; + four_pi_over_m = 2.0f * two_pi_over_m; + m_over_two = (float)m / 2.0f; + norm_sum = 0.0f; + + for(i = 0; i <= m; ++i ) { + if( i == m/2 ) { + fSinc[i] = two_pi_fc; + } else { + fSinc[i] = sinf(two_pi_fc * ((float)i - m_over_two)) / ((float)i - m_over_two); + /* Apply blackman window */ + fSinc[i] *= 0.42f - 0.5f * cosf(two_pi_over_m * (float)i) + 0.08f * cosf(four_pi_over_m * (float)i); + } + norm_sum += abs(fSinc[i]); + } + + /* Now normalize and convert to fixed point. We scale everything to half the precision + of whatever datatype we're using, for example, 16 bit data means we use 8 bits */ + +#define convert_fixed(type, size) { \ + norm_fact = size / norm_sum; \ + type *dst = (type *)cvt->sinc; \ + for( i = 0; i <= m; ++i ) { \ + dst[i] = (type)(fSinc[i] * norm_fact); \ + } \ + } + + /* If we're using floating point, we only need to normalize */ + if(SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) { + float *fDest = (float *)cvt->sinc; + norm_fact = 1.0f / norm_sum; + for(i = 0; i <= m; ++i) { + fDest[i] = fSinc[i] * norm_fact; + } + } else { + switch (SDL_AUDIO_BITSIZE(format)) { + case 8: + convert_fixed(Uint8, 0x0e); + break; + case 16: + convert_fixed(Uint16, 0xfe); + break; + case 32: + convert_fixed(Uint32, 0xfffe); + break; + } + } + + /* Initialize the state buffer to all zeroes, and set initial position */ + memset(cvt->state_buf, 0, cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4); + cvt->state_pos = 0; + + /* Clean up */ +#undef convert_fixed + free(fSinc); +} /* Creates a set of audio filters to convert from one format to another.