synched with trunk at revision 32129

This commit is contained in:
Nick Samarin 2010-10-03 16:28:28 +00:00
commit 90ab716cd5
1278 changed files with 44751 additions and 36586 deletions

@ -70,6 +70,7 @@ OPTION(WITH_LCMS "Enable color correction with lcms" OFF)
OPTION(WITH_PYTHON "Enable Embedded Python API" ON)
OPTION(WITH_BUILDINFO "Include extra build details" ON)
OPTION(WITH_FLUID "Enable Elbeem (Fluid Simulation)" ON)
OPTION(WITH_IK_ITASC "Enable ITASC IK solver" ON)
OPTION(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
OPTION(WITH_GAMEENGINE "Enable Game Engine" ON)
@ -294,13 +295,13 @@ IF(UNIX AND NOT APPLE)
SET(EXPAT_LIB expat)
ENDIF (WITH_OPENCOLLADA)
FIND_PACKAGE(X11 REQUIRED)
# Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# BSD's dont use libdl.so
SET(LLIBS "${LLIBS} -ldl")
LIST(APPEND LLIBS -ldl)
# binreloc is linux only
SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
@ -308,19 +309,13 @@ IF(UNIX AND NOT APPLE)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(WITH_OPENMP)
SET(LLIBS "${LLIBS} -lgomp")
LIST(APPEND LLIBS -lgomp)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
ENDIF(WITH_OPENMP)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts")
IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
ADD_DEFINITIONS(-D__SSE__)
ADD_DEFINITIONS(-D__MMX__)
ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
SET(PLATFORM_LINKFLAGS "-pthread")
@ -369,15 +364,6 @@ IF(WIN32)
SET(WINTAB_INC ${LIBDIR}/wintab/include)
IF(WITH_PYTHON)
SET(PYTHON ${LIBDIR}/python)
SET(PYTHON_VERSION 3.1)
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
# SET(PYTHON_BINARY python) # not used yet
SET(PYTHON_LIB python31)
SET(PYTHON_LIBPATH ${PYTHON}/lib)
ENDIF(WITH_PYTHON)
IF(WITH_OPENAL)
SET(OPENAL ${LIBDIR}/openal)
SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
@ -407,8 +393,7 @@ IF(WIN32)
ENDIF(WITH_QUICKTIME)
IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
ADD_DEFINITIONS(-D__SSE__)
ADD_DEFINITIONS(-D__MMX__)
ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
IF(MSVC)
@ -421,11 +406,19 @@ IF(WIN32)
SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
SET(CMAKE_C_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
IF(CMAKE_CL_64)
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
ELSE(CMAKE_CL_64)
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
ENDIF(CMAKE_CL_64)
SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
IF(CMAKE_CL_64)
SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
ELSE(CMAKE_CL_64)
SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
ENDIF(CMAKE_CL_64)
SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
@ -527,6 +520,15 @@ IF(WIN32)
SET(JACK_LIBPATH ${JACK}/lib)
ENDIF(WITH_JACK)
IF(WITH_PYTHON)
SET(PYTHON ${LIBDIR}/python)
SET(PYTHON_VERSION 3.1)
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
# SET(PYTHON_BINARY python) # not used yet
SET(PYTHON_LIB python31)
SET(PYTHON_LIBPATH ${PYTHON}/lib)
ENDIF(WITH_PYTHON)
# MSVC only, Mingw doesnt need
IF(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
@ -538,19 +540,12 @@ IF(WIN32)
ELSE(MSVC) # MINGW
SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
SET(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
SET(CMAKE_CXX_FLAGS "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C++ flags ")
SET(CMAKE_C_FLAGS "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C flags ")
# Better warnings
SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Mingw debug C++ flags ")
SET(CMAKE_CXX_FLAGS_RELEASE " -O2" CACHE STRING "Mingw release C++ flags ")
SET(CMAKE_CXX_FLAGS_MINSIZEREL " -Os" CACHE STRING "Mingw minsize release C++ flags ")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Mingw debug C flags ")
SET(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Mingw release C flags ")
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os" CACHE STRING "Mingw minsize release C flags ")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
ADD_DEFINITIONS(-DFREE_WINDOWS)
IF(WITH_OPENMP)
@ -614,6 +609,9 @@ IF(WIN32)
SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
# TODO, gives linking errors, force off
SET(WITH_IMAGE_OPENEXR OFF)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_IMAGE_TIFF)
@ -633,11 +631,14 @@ IF(WIN32)
SET(WITH_JACK OFF)
ENDIF(WITH_JACK)
IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
ADD_DEFINITIONS(-D__SSE__)
ADD_DEFINITIONS(-D__MMX__)
ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
IF(WITH_PYTHON)
SET(PYTHON ${LIBDIR}/python)
SET(PYTHON_VERSION 3.1)
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
# SET(PYTHON_BINARY python) # not used yet
SET(PYTHON_LIB python31mw)
SET(PYTHON_LIBPATH ${PYTHON}/lib)
ENDIF(WITH_PYTHON)
ENDIF(MSVC)
@ -819,12 +820,6 @@ IF(APPLE)
SET(TIFF_LIBPATH ${TIFF}/lib)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
ADD_DEFINITIONS(-D__SSE__)
ADD_DEFINITIONS(-D__MMX__)
ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(EXETYPE MACOSX_BUNDLE)
SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
@ -868,13 +863,29 @@ IF(WITH_BUILDINFO)
ENDIF(BUILD_REV_RETURN)
ENDIF(WIN32)
ENDIF(WITH_BUILDINFO)
#-----------------------------------------------------------------------------
# Common.
IF(WITH_RAYOPTIMIZATION)
IF(CMAKE_COMPILER_IS_GNUCC)
IF(SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
ENDIF(SUPPORT_SSE_BUILD)
IF(SUPPORT_SSE2_BUILD)
SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
ADD_DEFINITIONS(-D__SSE2__)
IF(NOT SUPPORT_SSE_BUILD) # dont double up
ADD_DEFINITIONS(-D__MMX__)
ENDIF(NOT SUPPORT_SSE_BUILD)
ENDIF(SUPPORT_SSE2_BUILD)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ENDIF(WITH_RAYOPTIMIZATION)
IF(WITH_IMAGE_OPENJPEG)
set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
set(OPENJPEG_INC ${OPENJPEG})
set(OPENJPEG_LIb extern_libopenjpeg)
set(OPENJPEG_LIb extern_openjpeg)
ENDIF(WITH_IMAGE_OPENJPEG)
#-----------------------------------------------------------------------------

@ -33,9 +33,9 @@ import platform as pltfrm
# Need a better way to do this. Automagical maybe is not the best thing, maybe it is.
if pltfrm.architecture()[0] == '64bit':
bitness = 64
bitness = 64
else:
bitness = 32
bitness = 32
import sys
import os
@ -79,15 +79,15 @@ B.binarykind = ['blender' , 'blenderplayer']
# XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
use_color = ARGUMENTS.get('BF_FANCY', '1')
if platform=='win32':
use_color = None
use_color = None
if not use_color=='1':
B.bc.disable()
B.bc.disable()
#on defaut white Os X terminal, some colors are totally unlegible
if platform=='darwin':
B.bc.OKGREEN = '\033[34m'
B.bc.WARNING = '\033[36m'
B.bc.OKGREEN = '\033[34m'
B.bc.WARNING = '\033[36m'
# arguments
print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
@ -110,100 +110,100 @@ quickie = B.arguments.get('BF_QUICK', None)
quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
if quickdebug:
B.quickdebug=string.split(quickdebug, ',')
B.quickdebug=string.split(quickdebug, ',')
else:
B.quickdebug=[]
B.quickdebug=[]
if quickie:
B.quickie=string.split(quickie,',')
B.quickie=string.split(quickie,',')
else:
B.quickie=[]
B.quickie=[]
toolset = B.arguments.get('BF_TOOLSET', None)
if toolset:
print "Using " + toolset
if toolset=='mstoolkit':
env = BlenderEnvironment(ENV = os.environ)
env.Tool('mstoolkit', [toolpath])
else:
env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
# xxx commented out, as was supressing warnings under mingw..
#if env:
# btools.SetupSpawn(env)
print "Using " + toolset
if toolset=='mstoolkit':
env = BlenderEnvironment(ENV = os.environ)
env.Tool('mstoolkit', [toolpath])
else:
env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
# xxx commented out, as was supressing warnings under mingw..
#if env:
# btools.SetupSpawn(env)
else:
if bitness==64 and platform=='win32':
env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
else:
env = BlenderEnvironment(ENV = os.environ)
if bitness==64 and platform=='win32':
env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
else:
env = BlenderEnvironment(ENV = os.environ)
if not env:
print "Could not create a build environment"
Exit()
print "Could not create a build environment"
Exit()
cc = B.arguments.get('CC', None)
cxx = B.arguments.get('CXX', None)
if cc:
env['CC'] = cc
env['CC'] = cc
if cxx:
env['CXX'] = cxx
env['CXX'] = cxx
if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
if bitness == 64:
platform = 'win64-vc'
else:
platform = 'win32-vc'
if bitness == 64:
platform = 'win64-vc'
else:
platform = 'win32-vc'
elif env['CC'] in ['gcc'] and sys.platform=='win32':
platform = 'win32-mingw'
platform = 'win32-mingw'
env.SConscriptChdir(0)
crossbuild = B.arguments.get('BF_CROSS', None)
if crossbuild and platform not in ('win32-vc', 'win64-vc'):
platform = 'linuxcross'
platform = 'linuxcross'
env['OURPLATFORM'] = platform
configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
if os.path.exists(configfile):
print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
else:
print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
if crossbuild and env['PLATFORM'] != 'win32':
print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
env.Tool('crossmingw', [toolpath])
# todo: determine proper libs/includes etc.
# Needed for gui programs, console programs should do without it
print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
env.Tool('crossmingw', [toolpath])
# todo: determine proper libs/includes etc.
# Needed for gui programs, console programs should do without it
# Now we don't need this option to have console window
# env.Append(LINKFLAGS=['-mwindows'])
# Now we don't need this option to have console window
# env.Append(LINKFLAGS=['-mwindows'])
userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
# first read platform config. B.arguments will override
optfiles = [configfile]
if os.path.exists(userconfig):
print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
optfiles += [userconfig]
print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
optfiles += [userconfig]
else:
print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
opts = btools.read_opts(env, optfiles, B.arguments)
opts.Update(env)
if not env['BF_FANCY']:
B.bc.disable()
B.bc.disable()
# remove install dir so old and new files are not mixed.
# NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
# TODO: perhaps we need an option (off by default) to not do this altogether...
if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
if os.path.isdir(scriptsDir):
print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
shutil.rmtree(scriptsDir)
scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
if os.path.isdir(scriptsDir):
print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
shutil.rmtree(scriptsDir)
SetOption('num_jobs', int(env['BF_NUMJOBS']))
@ -211,158 +211,158 @@ print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('n
print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
if 'blenderlite' in B.targets:
target_env_defs = {}
target_env_defs['WITH_BF_GAMEENGINE'] = False
target_env_defs['WITH_BF_OPENAL'] = False
target_env_defs['WITH_BF_OPENEXR'] = False
target_env_defs['WITH_BF_OPENMP'] = False
target_env_defs['WITH_BF_ICONV'] = False
target_env_defs['WITH_BF_INTERNATIONAL'] = False
target_env_defs['WITH_BF_OPENJPEG'] = False
target_env_defs['WITH_BF_FFMPEG'] = False
target_env_defs['WITH_BF_QUICKTIME'] = False
target_env_defs['WITH_BF_REDCODE'] = False
target_env_defs['WITH_BF_DDS'] = False
target_env_defs['WITH_BF_CINEON'] = False
target_env_defs['WITH_BF_HDR'] = False
target_env_defs['WITH_BF_ZLIB'] = False
target_env_defs['WITH_BF_SDL'] = False
target_env_defs['WITH_BF_JPEG'] = False
target_env_defs['WITH_BF_PNG'] = False
target_env_defs['WITH_BF_BULLET'] = False
target_env_defs['WITH_BF_BINRELOC'] = False
target_env_defs['BF_BUILDINFO'] = False
target_env_defs['BF_NO_ELBEEM'] = True
target_env_defs['WITH_BF_PYTHON'] = False
# Merge blenderlite, let command line to override
for k,v in target_env_defs.iteritems():
if k not in B.arguments:
env[k] = v
target_env_defs = {}
target_env_defs['WITH_BF_GAMEENGINE'] = False
target_env_defs['WITH_BF_OPENAL'] = False
target_env_defs['WITH_BF_OPENEXR'] = False
target_env_defs['WITH_BF_OPENMP'] = False
target_env_defs['WITH_BF_ICONV'] = False
target_env_defs['WITH_BF_INTERNATIONAL'] = False
target_env_defs['WITH_BF_OPENJPEG'] = False
target_env_defs['WITH_BF_FFMPEG'] = False
target_env_defs['WITH_BF_QUICKTIME'] = False
target_env_defs['WITH_BF_REDCODE'] = False
target_env_defs['WITH_BF_DDS'] = False
target_env_defs['WITH_BF_CINEON'] = False
target_env_defs['WITH_BF_HDR'] = False
target_env_defs['WITH_BF_ZLIB'] = False
target_env_defs['WITH_BF_SDL'] = False
target_env_defs['WITH_BF_JPEG'] = False
target_env_defs['WITH_BF_PNG'] = False
target_env_defs['WITH_BF_BULLET'] = False
target_env_defs['WITH_BF_BINRELOC'] = False
target_env_defs['BF_BUILDINFO'] = False
target_env_defs['BF_NO_ELBEEM'] = True
target_env_defs['WITH_BF_PYTHON'] = False
# Merge blenderlite, let command line to override
for k,v in target_env_defs.iteritems():
if k not in B.arguments:
env[k] = v
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env['CCFLAGS'].append('/openmp')
env['CPPFLAGS'].append('/openmp')
env['CXXFLAGS'].append('/openmp')
else:
if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
env.Append(LINKFLAGS=['-openmp', '-static-intel'])
env['CCFLAGS'].append('-openmp')
env['CPPFLAGS'].append('-openmp')
env['CXXFLAGS'].append('-openmp')
else:
env.Append(CCFLAGS=['-fopenmp'])
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(CXXFLAGS=['-fopenmp'])
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env['CCFLAGS'].append('/openmp')
env['CPPFLAGS'].append('/openmp')
env['CXXFLAGS'].append('/openmp')
else:
if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
env.Append(LINKFLAGS=['-openmp', '-static-intel'])
env['CCFLAGS'].append('-openmp')
env['CPPFLAGS'].append('-openmp')
env['CXXFLAGS'].append('-openmp')
else:
env.Append(CCFLAGS=['-fopenmp'])
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(CXXFLAGS=['-fopenmp'])
if env['WITH_GHOST_COCOA'] == True:
env.Append(CFLAGS=['-DGHOST_COCOA'])
env.Append(CXXFLAGS=['-DGHOST_COCOA'])
env.Append(CPPFLAGS=['-DGHOST_COCOA'])
env.Append(CFLAGS=['-DGHOST_COCOA'])
env.Append(CXXFLAGS=['-DGHOST_COCOA'])
env.Append(CPPFLAGS=['-DGHOST_COCOA'])
if env['USE_QTKIT'] == True:
env.Append(CFLAGS=['-DUSE_QTKIT'])
env.Append(CXXFLAGS=['-DUSE_QTKIT'])
env.Append(CPPFLAGS=['-DUSE_QTKIT'])
env.Append(CFLAGS=['-DUSE_QTKIT'])
env.Append(CXXFLAGS=['-DUSE_QTKIT'])
env.Append(CPPFLAGS=['-DUSE_QTKIT'])
#check for additional debug libnames
if env.has_key('BF_DEBUG_LIBS'):
B.quickdebug += env['BF_DEBUG_LIBS']
B.quickdebug += env['BF_DEBUG_LIBS']
printdebug = B.arguments.get('BF_LISTDEBUG', 0)
if len(B.quickdebug) > 0 and printdebug != 0:
print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
for l in B.quickdebug:
print "\t" + l
print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
for l in B.quickdebug:
print "\t" + l
# remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
if env['WITH_BF_STATICCXX']:
if 'stdc++' in env['LLIBS']:
env['LLIBS'].remove('stdc++')
else:
print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
if 'stdc++' in env['LLIBS']:
env['LLIBS'].remove('stdc++')
else:
print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
# check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
if 'blenderplayer' in B.targets:
env['WITH_BF_PLAYER'] = True
env['WITH_BF_PLAYER'] = True
if 'blendernogame' in B.targets:
env['WITH_BF_GAMEENGINE'] = False
env['WITH_BF_GAMEENGINE'] = False
# disable elbeem (fluidsim) compilation?
if env['BF_NO_ELBEEM'] == 1:
env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
env['CCFLAGS'].append('-DDISABLE_ELBEEM')
env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
env['CCFLAGS'].append('-DDISABLE_ELBEEM')
if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
B.root_build_dir = env['BF_BUILDDIR']
B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
if not B.root_build_dir[-1]==os.sep:
B.root_build_dir += os.sep
B.root_build_dir += os.sep
if not B.doc_build_dir[-1]==os.sep:
B.doc_build_dir += os.sep
B.doc_build_dir += os.sep
# We do a shortcut for clean when no quicklist is given: just delete
# builddir without reading in SConscripts
do_clean = None
if 'clean' in B.targets:
do_clean = True
do_clean = True
if not quickie and do_clean:
if os.path.exists(B.doc_build_dir):
print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
dirs = os.listdir(B.doc_build_dir)
for entry in dirs:
if os.path.isdir(B.doc_build_dir + entry) == 1:
print "clean dir %s"%(B.doc_build_dir+entry)
shutil.rmtree(B.doc_build_dir+entry)
else: # remove file
print "remove file %s"%(B.doc_build_dir+entry)
os.remove(B.root_build_dir+entry)
if os.path.exists(B.root_build_dir):
print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
dirs = os.listdir(B.root_build_dir)
for entry in dirs:
if os.path.isdir(B.root_build_dir + entry) == 1:
print "clean dir %s"%(B.root_build_dir+entry)
shutil.rmtree(B.root_build_dir+entry)
else: # remove file
print "remove file %s"%(B.root_build_dir+entry)
os.remove(B.root_build_dir+entry)
for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
if os.path.exists(confile):
print "clean file %s"%confile
if os.path.isdir(confile):
for root, dirs, files in os.walk(confile):
for name in files:
os.remove(os.path.join(root, name))
else:
os.remove(confile)
print B.bc.OKGREEN+'...done'+B.bc.ENDC
else:
print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
Exit()
if os.path.exists(B.doc_build_dir):
print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
dirs = os.listdir(B.doc_build_dir)
for entry in dirs:
if os.path.isdir(B.doc_build_dir + entry) == 1:
print "clean dir %s"%(B.doc_build_dir+entry)
shutil.rmtree(B.doc_build_dir+entry)
else: # remove file
print "remove file %s"%(B.doc_build_dir+entry)
os.remove(B.root_build_dir+entry)
if os.path.exists(B.root_build_dir):
print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
dirs = os.listdir(B.root_build_dir)
for entry in dirs:
if os.path.isdir(B.root_build_dir + entry) == 1:
print "clean dir %s"%(B.root_build_dir+entry)
shutil.rmtree(B.root_build_dir+entry)
else: # remove file
print "remove file %s"%(B.root_build_dir+entry)
os.remove(B.root_build_dir+entry)
for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
if os.path.exists(confile):
print "clean file %s"%confile
if os.path.isdir(confile):
for root, dirs, files in os.walk(confile):
for name in files:
os.remove(os.path.join(root, name))
else:
os.remove(confile)
print B.bc.OKGREEN+'...done'+B.bc.ENDC
else:
print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
Exit()
if not os.path.isdir ( B.root_build_dir):
os.makedirs ( B.root_build_dir )
os.makedirs ( B.root_build_dir + 'source' )
os.makedirs ( B.root_build_dir + 'intern' )
os.makedirs ( B.root_build_dir + 'extern' )
os.makedirs ( B.root_build_dir + 'lib' )
os.makedirs ( B.root_build_dir + 'bin' )
os.makedirs ( B.root_build_dir )
os.makedirs ( B.root_build_dir + 'source' )
os.makedirs ( B.root_build_dir + 'intern' )
os.makedirs ( B.root_build_dir + 'extern' )
os.makedirs ( B.root_build_dir + 'lib' )
os.makedirs ( B.root_build_dir + 'bin' )
# # Docs not working with epy anymore
# if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
# os.makedirs ( B.doc_build_dir )
# os.makedirs ( B.doc_build_dir )
Help(opts.GenerateHelpText(env))
@ -370,10 +370,10 @@ Help(opts.GenerateHelpText(env))
# commands, do 'scons BF_QUIET=0'
bf_quietoutput = B.arguments.get('BF_QUIET', '1')
if env['BF_QUIET']:
B.set_quiet_output(env)
B.set_quiet_output(env)
else:
if toolset=='msvc':
B.msvc_hack(env)
if toolset=='msvc':
B.msvc_hack(env)
print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
env.SConsignFile(B.root_build_dir+'scons-signatures')
@ -395,23 +395,23 @@ SConscript(B.root_build_dir+'/source/SConscript')
# libraries to give as objects to linking phase
mainlist = []
for tp in B.possible_types:
if not tp == 'player':
mainlist += B.create_blender_liblist(env, tp)
if not tp == 'player':
mainlist += B.create_blender_liblist(env, tp)
if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
B.propose_priorities()
B.propose_priorities()
dobj = B.buildinfo(env, "dynamic") + B.resources
thestatlibs, thelibincs = B.setup_staticlibs(env)
thesyslibs = B.setup_syslibs(env)
if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
env.BlenderProg(B.root_build_dir, "blender", mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
if env['WITH_BF_PLAYER']:
playerlist = B.create_blender_liblist(env, 'player')
playerlist += B.create_blender_liblist(env, 'intern')
playerlist += B.create_blender_liblist(env, 'extern')
env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
playerlist = B.create_blender_liblist(env, 'player')
playerlist += B.create_blender_liblist(env, 'intern')
playerlist += B.create_blender_liblist(env, 'extern')
env.BlenderProg(B.root_build_dir, "blenderplayer", playerlist, thestatlibs + dobj + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
##### Now define some targets
@ -421,17 +421,19 @@ if env['WITH_BF_PLAYER']:
#-- binaries
blenderinstall = []
if env['OURPLATFORM']=='darwin':
for prg in B.program_list:
bundle = '%s.app' % prg[0]
bundledir = os.path.dirname(bundle)
for dp, dn, df in os.walk(bundle):
if '.svn' in dn:
dn.remove('.svn')
dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source))
for prg in B.program_list:
bundle = '%s.app' % prg[0]
bundledir = os.path.dirname(bundle)
for dp, dn, df in os.walk(bundle):
if '.svn' in dn:
dn.remove('.svn')
if '_svn' in dn:
dn.remove('_svn')
dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source))
else:
blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
#-- local path = config files in install dir: installdir\VERSION
#- dont do config and scripts for darwin, it is already in the bundle
@ -442,90 +444,101 @@ dottargetlist = []
scriptinstall = []
if env['OURPLATFORM']!='darwin':
for dp, dn, df in os.walk('bin/.blender'):
if '.svn' in dn:
dn.remove('.svn')
for f in df:
if not env['WITH_BF_INTERNATIONAL']:
if 'locale' in dp:
continue
if f == '.Blanguages':
continue
if not env['WITH_BF_FREETYPE']:
if f.endswith('.ttf'):
continue
if 'locale' in dp:
datafileslist.append(os.path.join(dp,f))
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:])) # skip bin
datafilestargetlist.append(dir + os.sep + f)
for dp, dn, df in os.walk('bin/.blender'):
if '.svn' in dn:
dn.remove('.svn')
if '_svn' in dn:
dn.remove('_svn')
for f in df:
if not env['WITH_BF_INTERNATIONAL']:
if 'locale' in dp:
continue
if f == '.Blanguages':
continue
if not env['WITH_BF_FREETYPE']:
if f.endswith('.ttf'):
continue
if 'locale' in dp:
datafileslist.append(os.path.join(dp,f))
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:])) # skip bin
datafilestargetlist.append(dir + os.sep + f)
else:
dotblendlist.append(os.path.join(dp, f))
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['config'] + dp.split(os.sep)[1:])) # skip bin
dottargetlist.append(dir + os.sep + f)
dotblenderinstall = []
for targetdir,srcfile in zip(dottargetlist, dotblendlist):
td, tf = os.path.split(targetdir)
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
td, tf = os.path.split(targetdir)
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
if env['WITH_BF_PYTHON']:
#-- local/VERSION/scripts
scriptpaths=['release/scripts']
for scriptpath in scriptpaths:
for dp, dn, df in os.walk(scriptpath):
if '.svn' in dn:
dn.remove('.svn')
dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
scriptinstall.append(env.Install(dir=dir,source=source))
else:
dotblendlist.append(os.path.join(dp, f))
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['config'] + dp.split(os.sep)[1:])) # skip bin
dottargetlist.append(dir + os.sep + f)
dotblenderinstall = []
for targetdir,srcfile in zip(dottargetlist, dotblendlist):
td, tf = os.path.split(targetdir)
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
td, tf = os.path.split(targetdir)
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
if env['WITH_BF_PYTHON']:
#-- local/VERSION/scripts
scriptpaths=['release/scripts']
for scriptpath in scriptpaths:
for dp, dn, df in os.walk(scriptpath):
if '.svn' in dn:
dn.remove('.svn')
if '_svn' in dn:
dn.remove('_svn')
dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
# To ensure empty dirs are created too
if len(source)==0:
env.Execute(Mkdir(dir))
scriptinstall.append(env.Install(dir=dir,source=source))
#-- icons
if env['OURPLATFORM']=='linux2':
iconlist = []
icontargetlist = []
iconlist = []
icontargetlist = []
for tp, tn, tf in os.walk('release/freedesktop/icons'):
if '.svn' in tn:
tn.remove('.svn')
for f in tf:
iconlist.append(os.path.join(tp, f))
icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
for tp, tn, tf in os.walk('release/freedesktop/icons'):
if '.svn' in tn:
tn.remove('.svn')
if '_svn' in tn:
tn.remove('_svn')
for f in tf:
iconlist.append(os.path.join(tp, f))
icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
iconinstall = []
for targetdir,srcfile in zip(icontargetlist, iconlist):
td, tf = os.path.split(targetdir)
iconinstall.append(env.Install(dir=td, source=srcfile))
iconinstall = []
for targetdir,srcfile in zip(icontargetlist, iconlist):
td, tf = os.path.split(targetdir)
iconinstall.append(env.Install(dir=td, source=srcfile))
# dlls for linuxcross
# TODO - add more libs, for now this lets blenderlite run
if env['OURPLATFORM']=='linuxcross':
dir=env['BF_INSTALLDIR']
source = []
dir=env['BF_INSTALLDIR']
source = []
if env['WITH_BF_OPENMP']:
source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
if env['WITH_BF_OPENMP']:
source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
scriptinstall.append(env.Install(dir=dir, source=source))
scriptinstall.append(env.Install(dir=dir, source=source))
#-- plugins
pluglist = []
plugtargetlist = []
for tp, tn, tf in os.walk('release/plugins'):
if '.svn' in tn:
tn.remove('.svn')
df = tp[8:] # remove 'release/'
for f in tf:
pluglist.append(os.path.join(tp, f))
plugtargetlist.append( os.path.join(env['BF_INSTALLDIR'], df, f) )
if '.svn' in tn:
tn.remove('.svn')
if '_svn' in tn:
tn.remove('_svn')
df = tp[8:] # remove 'release/'
for f in tf:
pluglist.append(os.path.join(tp, f))
plugtargetlist.append( os.path.join(env['BF_INSTALLDIR'], df, f) )
# header files for plugins
@ -546,80 +559,82 @@ plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', '
plugininstall = []
for targetdir,srcfile in zip(plugtargetlist, pluglist):
td, tf = os.path.split(targetdir)
plugininstall.append(env.Install(dir=td, source=srcfile))
td, tf = os.path.split(targetdir)
plugininstall.append(env.Install(dir=td, source=srcfile))
textlist = []
texttargetlist = []
for tp, tn, tf in os.walk('release/text'):
if '.svn' in tn:
tn.remove('.svn')
for f in tf:
textlist.append(tp+os.sep+f)
if '.svn' in tn:
tn.remove('.svn')
if '_svn' in tn:
tn.remove('_svn')
for f in tf:
textlist.append(tp+os.sep+f)
textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
if env['OURPLATFORM']=='darwin':
allinstall = [blenderinstall, plugininstall, textinstall]
allinstall = [blenderinstall, plugininstall, textinstall]
elif env['OURPLATFORM']=='linux2':
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
else:
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
dllsources = []
dllsources = []
if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
# For MinGW and linuxcross static linking will be used
dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
# For MinGW and linuxcross static linking will be used
dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
#currently win64-vc doesn't appear to have libpng.dll
if env['OURPLATFORM'] != 'win64-vc':
dllsources += ['${BF_PNG_LIBPATH}/libpng.dll']
#currently win64-vc doesn't appear to have libpng.dll
if env['OURPLATFORM'] != 'win64-vc':
dllsources += ['${BF_PNG_LIBPATH}/libpng.dll']
dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
# Used when linking to libtiff was dynamic
# keep it here until compilation on all platform would be ok
# dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
# Used when linking to libtiff was dynamic
# keep it here until compilation on all platform would be ok
# dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
if env['OURPLATFORM'] != 'linuxcross':
# pthreads library is already added
dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
if env['OURPLATFORM'] != 'linuxcross':
# pthreads library is already added
dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
if env['WITH_BF_SDL']:
if env['OURPLATFORM'] == 'win64-vc':
pass # we link statically already to SDL on win64
else:
dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
if env['WITH_BF_SDL']:
if env['OURPLATFORM'] == 'win64-vc':
pass # we link statically already to SDL on win64
else:
dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
if env['WITH_BF_PYTHON']:
if env['BF_DEBUG']:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
else:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
if env['WITH_BF_PYTHON']:
if env['BF_DEBUG']:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
else:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
if env['WITH_BF_ICONV']:
if env['OURPLATFORM'] == 'win64-vc':
pass # we link statically to iconv on win64
elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
#gettext for MinGW and cross-compilation is compiled staticly
dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
if env['WITH_BF_ICONV']:
if env['OURPLATFORM'] == 'win64-vc':
pass # we link statically to iconv on win64
elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
#gettext for MinGW and cross-compilation is compiled staticly
dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
if env['WITH_BF_OPENAL']:
dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
if env['WITH_BF_OPENAL']:
dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
if env['WITH_BF_SNDFILE']:
dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
if env['WITH_BF_SNDFILE']:
dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
if env['WITH_BF_FFMPEG']:
dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
'${BF_FFMPEG_LIBPATH}/avformat-52.dll',
'${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
'${BF_FFMPEG_LIBPATH}/avutil-50.dll',
'${BF_FFMPEG_LIBPATH}/swscale-0.dll']
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
allinstall += windlls
if env['WITH_BF_FFMPEG']:
dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
'${BF_FFMPEG_LIBPATH}/avformat-52.dll',
'${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
'${BF_FFMPEG_LIBPATH}/avutil-50.dll',
'${BF_FFMPEG_LIBPATH}/swscale-0.dll']
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
allinstall += windlls
installtarget = env.Alias('install', allinstall)
bininstalltarget = env.Alias('install-bin', blenderinstall)
@ -629,24 +644,24 @@ nsiscmd = env.Command('nsisinstaller', None, nsisaction)
nsisalias = env.Alias('nsis', nsiscmd)
if 'blender' in B.targets:
blenderexe= env.Alias('blender', B.program_list)
Depends(blenderexe,installtarget)
blenderexe= env.Alias('blender', B.program_list)
Depends(blenderexe,installtarget)
if env['WITH_BF_PLAYER']:
blenderplayer = env.Alias('blenderplayer', B.program_list)
Depends(blenderplayer,installtarget)
blenderplayer = env.Alias('blenderplayer', B.program_list)
Depends(blenderplayer,installtarget)
if not env['WITH_BF_GAMEENGINE']:
blendernogame = env.Alias('blendernogame', B.program_list)
Depends(blendernogame,installtarget)
blendernogame = env.Alias('blendernogame', B.program_list)
Depends(blendernogame,installtarget)
if 'blenderlite' in B.targets:
blenderlite = env.Alias('blenderlite', B.program_list)
Depends(blenderlite,installtarget)
blenderlite = env.Alias('blenderlite', B.program_list)
Depends(blenderlite,installtarget)
Depends(nsiscmd, allinstall)
Default(B.program_list)
if not env['WITHOUT_BF_INSTALL']:
Default(installtarget)
Default(installtarget)

@ -0,0 +1,118 @@
#! /usr/bin/env python
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
def print_help(targets):
print("CMake quicky wrapper, no valid targets given.")
print(" * targets can contain a subset of the full target name.")
print(" * arguments with a '-' prefix are passed onto make.")
print(" * this must run from the cmake build dir")
print(" * alias this with a short command for speedy access, in bash:")
print(" alias mk='../blender/build_files/cmake/example_scripts/make_quicky.py'")
print("")
print(" eg: make_quicky.py -j3 extern python")
print(" ...will execute")
print(" make -j3 extern_binreloc extern_glew bf_python bf_python_ext blender/fast")
print("")
print("Target List:")
for t in targets:
print(" %s" % t)
print("...exiting")
def main():
targets = set()
# collect targets
file = open("Makefile", "r")
for line in file:
line = line.rstrip()
if not line or line[0] in ". \t@$#":
continue
line = line.split("#", 1)[0]
if ":" not in line:
continue
line = line.split(":", 1)[0]
if "/" in line: # cmake terget options, dont need these
continue
targets.add(line)
file.close()
# remove cmake targets
bad = set([
"help",
"clean",
"all",
"preinstall",
"install",
"default_target",
"edit_cache",
"cmake_force",
"rebuild_cache",
"depend",
"cmake_check_build_system",
])
targets -= set(bad)
# parse args
targets = list(targets)
targets.sort()
import sys
if len(sys.argv) == 1:
print_help(targets)
return
targets_new = []
args = []
for arg in sys.argv[1:]:
if arg[0] in "/-":
args.append(arg)
else:
found = False
for t in targets:
if arg in t and t not in targets_new:
targets_new.append(t)
found = True
if not found:
print("Error '%s' not found in...")
for t in targets:
print(" %s" % t)
print("...aborting.")
return
# execute
cmd = "make %s %s blender/fast" % (" ".join(args), " ".join(targets_new))
print("cmake building with targets: %s" % " ".join(targets_new))
print("executing: %s" % cmd)
import os
os.system(cmd)
if __name__ == "__main__":
main()

@ -183,19 +183,38 @@ MACRO(SETUP_LIBLINKS
ENDMACRO(SETUP_LIBLINKS)
MACRO(TEST_SSE_SUPPORT)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckCSourceRuns)
MESSAGE(STATUS "Detecting SSE support")
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_REQUIRED_FLAGS "-msse -msse2")
ELSEIF(MSVC)
SET(CMAKE_REQUIRED_FLAGS "/arch:SSE2")
SET(CMAKE_REQUIRED_FLAGS "/arch:SSE2") # TODO, SSE 1 ?
ENDIF()
CHECK_CXX_SOURCE_COMPILES("
CHECK_C_SOURCE_RUNS("
#include <xmmintrin.h>
int main() { __m128 v = _mm_setzero_ps(); return 0; }"
SUPPORT_SSE_BUILD)
CHECK_C_SOURCE_RUNS("
#include <emmintrin.h>
int main() { __m128d v = _mm_setzero_pd(); return 0; }"
SUPPORT_SSE2_BUILD)
MESSAGE(STATUS "Detecting SSE support")
IF(SUPPORT_SSE_BUILD)
MESSAGE(STATUS " ...SSE support found.")
ELSE(SUPPORT_SSE_BUILD)
MESSAGE(STATUS " ...SSE support missing.")
ENDIF(SUPPORT_SSE_BUILD)
IF(SUPPORT_SSE2_BUILD)
MESSAGE(STATUS " ...SSE2 support found.")
ELSE(SUPPORT_SSE2_BUILD)
MESSAGE(STATUS " ...SSE2 support missing.")
ENDIF(SUPPORT_SSE2_BUILD)
ENDMACRO(TEST_SSE_SUPPORT)

@ -176,6 +176,9 @@ ifeq ($(OS),linux)
REL_CFLAGS += -O2
REL_CCFLAGS += -O2
NAN_DEPEND = true
ifeq ($(WITH_BF_RAYOPTIMIZATION), true)
CCFLAGS += -msse
endif
ifeq ($(CPU),alpha)
CFLAGS += -mieee
endif

@ -161,7 +161,11 @@ ifndef CONFIG_GUESS
export WITH_TIFF ?= true
#enable raytracing optimization (currently only for i386 and x86_64)
export WITH_BF_RAYOPTIMIZATION ?= true
ifeq ($(CPU),powerpc)
export WITH_BF_RAYOPTIMIZATION ?= false
else
export WITH_BF_RAYOPTIMIZATION ?= true
endif
export WITH_LCMS ?= false
export WITH_CINEON ?= true

@ -0,0 +1,48 @@
# Maintainer: Campbell Barton <ideasman42 at gmail dot com>
# custom blender vars
blender_srcdir=$srcdir/../../../..
blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
blender_ver_string=$(expr $blender_version / 100).$(expr $blender_version % 100).$blender_subversion
pkgname=blender-beta
pkgver=$blender_ver_string
pkgrel=1
pkgdesc="A fully integrated 3D graphics creation suite"
arch=('i686' 'x86_64')
url="www.blender.org"
license=('GPL')
groups=()
depends=('libjpeg' 'libpng' 'openexr' 'python3>=3.1' 'gettext' 'libxi' 'libxmu' 'mesa' 'freetype2' 'openal' 'sdl' 'libsndfile' 'libsamplerate' 'ffmpeg')
makedepends=('cmake' 'svn')
optdepends=()
provides=('blender')
conflicts=('blender')
replaces=()
backup=()
options=()
install=blender.install
# use current svn to make the package.
# source=(http://download.blender.org/source/$pkgname-$pkgver.tar.gz)
# md5sums=('27edb80c82c25252d43d6a01980d953a') #generate with 'makepkg -g'
source=()
md5sums=()
noextract=()
build() {
mkdir -p $srcdir/build
cd $srcdir/build
cmake $blender_srcdir \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DWITH_PYTHON_INSTALL:BOOL=OFF \
-DWITH_OPENCOLLADA:BOOL=OFF
make
}
package() {
cd $srcdir/build
make DESTDIR="$pkgdir" install
}

@ -0,0 +1,29 @@
post_install() {
cat << EOF
NOTE
----
Happy blending!
EOF
echo "update desktop mime database..."
update-desktop-database
}
post_upgrade() {
post_install $1
}
pre_remove() {
/bin/true
}
post_remove() {
echo "update desktop mime database..."
update-desktop-database
}
op=$1
shift
$op $*

@ -0,0 +1,213 @@
CC = 'gcc44'
CXX = 'g++44'
LCGDIR = '../lib/freebsd7'
LIBDIR = "${LCGDIR}"
BF_PYTHON = '/usr/local'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
BF_PYTHON_VERSION = '3.1'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = False
BF_OPENAL = '/usr/local'
BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
BF_CXX = '/usr/local'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
BF_LIBSAMPLERATE = '/usr/local'
BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include'
BF_LIBSAMPLERATE_LIB = 'samplerate'
BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib'
WITH_BF_JACK = True
BF_JACK = '/usr/local'
BF_JACK_INC = '${BF_JACK}/include/jack'
BF_JACK_LIB = 'jack'
BF_JACK_LIBPATH = '${BF_JACK}/lib'
WITH_BF_SNDFILE = True
BF_SNDFILE = '/usr/local'
BF_SNDFILE_INC = '${BF_SNDFILE}/include/sndfile'
BF_SNDFILE_LIB = 'sndfile'
BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
WITH_BF_SDL = True
BF_SDL = '/usr/local' #$(shell sdl-config --prefix)
BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
WITH_BF_OPENEXR = True
WITH_BF_STATICOPENEXR = False
BF_OPENEXR = '/usr/local'
# when compiling with your own openexr lib you might need to set...
# BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR ${BF_OPENEXR}/include'
BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '
BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
# BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
WITH_BF_DDS = True
WITH_BF_JPEG = True
BF_JPEG = '/usr/local'
BF_JPEG_INC = '${BF_JPEG}/include'
BF_JPEG_LIB = 'jpeg'
WITH_BF_PNG = True
BF_PNG = '/usr/local'
BF_PNG_INC = '${BF_PNG}/include'
BF_PNG_LIB = 'png'
WITH_BF_TIFF = True
BF_TIFF = '/usr/local'
BF_TIFF_INC = '${BF_TIFF}/include'
BF_TIFF_LIB = 'tiff'
WITH_BF_ZLIB = True
BF_ZLIB = '/usr'
BF_ZLIB_INC = '${BF_ZLIB}/include'
BF_ZLIB_LIB = 'z'
WITH_BF_INTERNATIONAL = True
BF_GETTEXT = '/usr/local'
BF_GETTEXT_INC = '${BF_GETTEXT}/include'
BF_GETTEXT_LIB = 'gettextlib'
BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
WITH_BF_GAMEENGINE = False
WITH_BF_PLAYER = True
WITH_BF_BULLET = True
BF_BULLET = '#extern/bullet2/src'
BF_BULLET_INC = '${BF_BULLET}'
BF_BULLET_LIB = 'extern_bullet'
# enable freetype2 support for text objects
BF_FREETYPE = '/usr/local'
BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
### XXX Find what this actually wants; it doesn't want libquicktime.
WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME
BF_QUICKTIME = '/usr/local'
BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
WITH_BF_ICONV = True
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'iconv'
BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
WITH_BF_BINRELOC = True
# enable ffmpeg support
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
BF_FFMPEG = '/usr/local'
BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
# enable ogg, vorbis and theora in ffmpeg
WITH_BF_OGG = True # -DWITH_OGG
BF_OGG = '/usr/local'
BF_OGG_INC = '${BF_OGG}/include'
BF_OGG_LIB = 'ogg vorbis vorbisenc theoraenc theoradec'
WITH_BF_OPENJPEG = True
BF_OPENJPEG = '#extern/libopenjpeg'
BF_OPENJPEG_LIB = ''
BF_OPENJPEG_INC = '${BF_OPENJPEG}'
BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
WITH_BF_FFTW3 = True
BF_FFTW3 = LIBDIR + '/usr/local'
BF_FFTW3_INC = '${BF_FFTW3}/include'
BF_FFTW3_LIB = 'fftw3'
BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
WITH_BF_REDCODE = True
BF_REDCODE = '#extern/libredcode'
BF_REDCODE_LIB = ''
# BF_REDCODE_INC = '${BF_REDCODE}/include'
BF_REDCODE_INC = '${BF_REDCODE}/../' #C files request "libredcode/format.h" which is in "#extern/libredcode/format.h", stupid but compiles for now.
BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
# Mesa Libs should go here if your using them as well....
WITH_BF_STATICOPENGL = False
BF_OPENGL = '/usr/local'
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIB = 'GL GLU X11 Xi'
BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = '/usr'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
BF_PCRE = '/usr/local'
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
BF_EXPAT = '/usr/local'
BF_EXPAT_LIB = 'expat'
BF_EXPAT_LIBPATH = '${BF_EXPAT}/lib'
WITH_BF_OPENMP = True
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
CPPFLAGS = []
CXXFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
if WITH_BF_FFMPEG:
# libavutil needs UINT64_C()
CXXFLAGS += ['-D__STDC_CONSTANT_MACROS', ]
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
##BF_DEPEND = True
##
##AR = ar
##ARFLAGS = ruv
##ARFLAGSQUIET = ru
##
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement']
CC_WARN = ['-Wall']
CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = ['util', 'c', 'm', 'pthread', 'stdc++']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/freebsd7'
BF_INSTALLDIR='../install/freebsd7'
#Link against pthread
PLATFORM_LINKFLAGS = ['-pthread']

@ -0,0 +1,213 @@
CC = 'gcc44'
CXX = 'g++44'
LCGDIR = '../lib/freebsd8'
LIBDIR = "${LCGDIR}"
BF_PYTHON = '/usr/local'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
BF_PYTHON_VERSION = '3.1'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = False
BF_OPENAL = '/usr/local'
BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
BF_CXX = '/usr/local'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
BF_LIBSAMPLERATE = '/usr/local'
BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include'
BF_LIBSAMPLERATE_LIB = 'samplerate'
BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib'
WITH_BF_JACK = True
BF_JACK = '/usr/local'
BF_JACK_INC = '${BF_JACK}/include/jack'
BF_JACK_LIB = 'jack'
BF_JACK_LIBPATH = '${BF_JACK}/lib'
WITH_BF_SNDFILE = True
BF_SNDFILE = '/usr/local'
BF_SNDFILE_INC = '${BF_SNDFILE}/include/sndfile'
BF_SNDFILE_LIB = 'sndfile'
BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
WITH_BF_SDL = True
BF_SDL = '/usr/local' #$(shell sdl-config --prefix)
BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
WITH_BF_OPENEXR = True
WITH_BF_STATICOPENEXR = False
BF_OPENEXR = '/usr/local'
# when compiling with your own openexr lib you might need to set...
# BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR ${BF_OPENEXR}/include'
BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '
BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
# BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
WITH_BF_DDS = True
WITH_BF_JPEG = True
BF_JPEG = '/usr/local'
BF_JPEG_INC = '${BF_JPEG}/include'
BF_JPEG_LIB = 'jpeg'
WITH_BF_PNG = True
BF_PNG = '/usr/local'
BF_PNG_INC = '${BF_PNG}/include'
BF_PNG_LIB = 'png'
WITH_BF_TIFF = True
BF_TIFF = '/usr/local'
BF_TIFF_INC = '${BF_TIFF}/include'
BF_TIFF_LIB = 'tiff'
WITH_BF_ZLIB = True
BF_ZLIB = '/usr'
BF_ZLIB_INC = '${BF_ZLIB}/include'
BF_ZLIB_LIB = 'z'
WITH_BF_INTERNATIONAL = True
BF_GETTEXT = '/usr/local'
BF_GETTEXT_INC = '${BF_GETTEXT}/include'
BF_GETTEXT_LIB = 'gettextlib'
BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
WITH_BF_GAMEENGINE = False
WITH_BF_PLAYER = True
WITH_BF_BULLET = True
BF_BULLET = '#extern/bullet2/src'
BF_BULLET_INC = '${BF_BULLET}'
BF_BULLET_LIB = 'extern_bullet'
# enable freetype2 support for text objects
BF_FREETYPE = '/usr/local'
BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
### XXX Find what this actually wants; it doesn't want libquicktime.
WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME
BF_QUICKTIME = '/usr/local'
BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
WITH_BF_ICONV = True
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'iconv'
BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
WITH_BF_BINRELOC = True
# enable ffmpeg support
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
BF_FFMPEG = '/usr/local'
BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
# enable ogg, vorbis and theora in ffmpeg
WITH_BF_OGG = True # -DWITH_OGG
BF_OGG = '/usr/local'
BF_OGG_INC = '${BF_OGG}/include'
BF_OGG_LIB = 'ogg vorbis vorbisenc theoraenc theoradec'
WITH_BF_OPENJPEG = True
BF_OPENJPEG = '#extern/libopenjpeg'
BF_OPENJPEG_LIB = ''
BF_OPENJPEG_INC = '${BF_OPENJPEG}'
BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
WITH_BF_FFTW3 = True
BF_FFTW3 = LIBDIR + '/usr/local'
BF_FFTW3_INC = '${BF_FFTW3}/include'
BF_FFTW3_LIB = 'fftw3'
BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
WITH_BF_REDCODE = True
BF_REDCODE = '#extern/libredcode'
BF_REDCODE_LIB = ''
# BF_REDCODE_INC = '${BF_REDCODE}/include'
BF_REDCODE_INC = '${BF_REDCODE}/../' #C files request "libredcode/format.h" which is in "#extern/libredcode/format.h", stupid but compiles for now.
BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
# Mesa Libs should go here if your using them as well....
WITH_BF_STATICOPENGL = False
BF_OPENGL = '/usr/local'
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIB = 'GL GLU X11 Xi'
BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = '/usr'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
BF_PCRE = '/usr/local'
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
BF_EXPAT = '/usr/local'
BF_EXPAT_LIB = 'expat'
BF_EXPAT_LIBPATH = '${BF_EXPAT}/lib'
WITH_BF_OPENMP = True
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
CPPFLAGS = []
CXXFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
if WITH_BF_FFMPEG:
# libavutil needs UINT64_C()
CXXFLAGS += ['-D__STDC_CONSTANT_MACROS', ]
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
##BF_DEPEND = True
##
##AR = ar
##ARFLAGS = ruv
##ARFLAGSQUIET = ru
##
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement']
CC_WARN = ['-Wall']
CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = ['util', 'c', 'm', 'pthread', 'stdc++']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/freebsd8'
BF_INSTALLDIR='../install/freebsd8'
#Link against pthread
PLATFORM_LINKFLAGS = ['-pthread']

@ -0,0 +1,213 @@
CC = 'gcc44'
CXX = 'g++44'
LCGDIR = '../lib/freebsd9'
LIBDIR = "${LCGDIR}"
BF_PYTHON = '/usr/local'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
BF_PYTHON_VERSION = '3.1'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}'
BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = False
BF_OPENAL = '/usr/local'
BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
BF_CXX = '/usr/local'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
BF_LIBSAMPLERATE = '/usr/local'
BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include'
BF_LIBSAMPLERATE_LIB = 'samplerate'
BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib'
WITH_BF_JACK = True
BF_JACK = '/usr/local'
BF_JACK_INC = '${BF_JACK}/include/jack'
BF_JACK_LIB = 'jack'
BF_JACK_LIBPATH = '${BF_JACK}/lib'
WITH_BF_SNDFILE = True
BF_SNDFILE = '/usr/local'
BF_SNDFILE_INC = '${BF_SNDFILE}/include/sndfile'
BF_SNDFILE_LIB = 'sndfile'
BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
WITH_BF_SDL = True
BF_SDL = '/usr/local' #$(shell sdl-config --prefix)
BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
WITH_BF_OPENEXR = True
WITH_BF_STATICOPENEXR = False
BF_OPENEXR = '/usr/local'
# when compiling with your own openexr lib you might need to set...
# BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR ${BF_OPENEXR}/include'
BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '
BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
# BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
WITH_BF_DDS = True
WITH_BF_JPEG = True
BF_JPEG = '/usr/local'
BF_JPEG_INC = '${BF_JPEG}/include'
BF_JPEG_LIB = 'jpeg'
WITH_BF_PNG = True
BF_PNG = '/usr/local'
BF_PNG_INC = '${BF_PNG}/include'
BF_PNG_LIB = 'png'
WITH_BF_TIFF = True
BF_TIFF = '/usr/local'
BF_TIFF_INC = '${BF_TIFF}/include'
BF_TIFF_LIB = 'tiff'
WITH_BF_ZLIB = True
BF_ZLIB = '/usr'
BF_ZLIB_INC = '${BF_ZLIB}/include'
BF_ZLIB_LIB = 'z'
WITH_BF_INTERNATIONAL = True
BF_GETTEXT = '/usr/local'
BF_GETTEXT_INC = '${BF_GETTEXT}/include'
BF_GETTEXT_LIB = 'gettextlib'
BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
WITH_BF_GAMEENGINE = False
WITH_BF_PLAYER = True
WITH_BF_BULLET = True
BF_BULLET = '#extern/bullet2/src'
BF_BULLET_INC = '${BF_BULLET}'
BF_BULLET_LIB = 'extern_bullet'
# enable freetype2 support for text objects
BF_FREETYPE = '/usr/local'
BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
### XXX Find what this actually wants; it doesn't want libquicktime.
WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME
BF_QUICKTIME = '/usr/local'
BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
WITH_BF_ICONV = True
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'iconv'
BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
WITH_BF_BINRELOC = True
# enable ffmpeg support
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
BF_FFMPEG = '/usr/local'
BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
# enable ogg, vorbis and theora in ffmpeg
WITH_BF_OGG = True # -DWITH_OGG
BF_OGG = '/usr/local'
BF_OGG_INC = '${BF_OGG}/include'
BF_OGG_LIB = 'ogg vorbis vorbisenc theoraenc theoradec'
WITH_BF_OPENJPEG = True
BF_OPENJPEG = '#extern/libopenjpeg'
BF_OPENJPEG_LIB = ''
BF_OPENJPEG_INC = '${BF_OPENJPEG}'
BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
WITH_BF_FFTW3 = True
BF_FFTW3 = LIBDIR + '/usr/local'
BF_FFTW3_INC = '${BF_FFTW3}/include'
BF_FFTW3_LIB = 'fftw3'
BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
WITH_BF_REDCODE = True
BF_REDCODE = '#extern/libredcode'
BF_REDCODE_LIB = ''
# BF_REDCODE_INC = '${BF_REDCODE}/include'
BF_REDCODE_INC = '${BF_REDCODE}/../' #C files request "libredcode/format.h" which is in "#extern/libredcode/format.h", stupid but compiles for now.
BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
# Mesa Libs should go here if your using them as well....
WITH_BF_STATICOPENGL = False
BF_OPENGL = '/usr/local'
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIB = 'GL GLU X11 Xi'
BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = '/usr'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
BF_PCRE = '/usr/local'
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
BF_EXPAT = '/usr/local'
BF_EXPAT_LIB = 'expat'
BF_EXPAT_LIBPATH = '${BF_EXPAT}/lib'
WITH_BF_OPENMP = True
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
CPPFLAGS = []
CXXFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']
if WITH_BF_FFMPEG:
# libavutil needs UINT64_C()
CXXFLAGS += ['-D__STDC_CONSTANT_MACROS', ]
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
##BF_DEPEND = True
##
##AR = ar
##ARFLAGS = ruv
##ARFLAGSQUIET = ru
##
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement']
CC_WARN = ['-Wall']
CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = ['util', 'c', 'm', 'pthread', 'stdc++']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/freebsd9'
BF_INSTALLDIR='../install/freebsd9'
#Link against pthread
PLATFORM_LINKFLAGS = ['-pthread']

@ -84,6 +84,8 @@ BF_GETTEXT = '/usr'
BF_GETTEXT_INC = '${BF_GETTEXT}/include'
BF_GETTEXT_LIB = 'gettextlib'
BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
#WITH_BF_GETTEXT_STATIC = True
#BF_GETTEXT_LIB_STATIC = '${BF_GETTEXT}/lib/libgettextlib.a'
WITH_BF_GAMEENGINE = True
WITH_BF_PLAYER = False
@ -97,6 +99,8 @@ BF_BULLET_LIB = 'extern_bullet'
BF_FREETYPE = '/usr'
BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
#WITH_BF_FREETYPE_STATIC = True
#BF_FREETYPE_LIB_STATIC = '${BF_FREETYPE}/lib/libfreetype.a'
WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME
BF_QUICKTIME = '/usr/local'
@ -116,6 +120,8 @@ BF_FFMPEG = '/usr'
BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
#WITH_BF_STATICFFMPEG = True
#BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH/libavcodec.a ${BF_FFMPEG_LIBPATH}/libswscale.a ${BF_FFMPEG_LIBPATH}/libavutil.a ${BF_FFMPEG_LIBPATH}/libavdevice.a'
# enable ogg, vorbis and theora in ffmpeg
WITH_BF_OGG = False # -DWITH_OGG

File diff suppressed because it is too large Load Diff

@ -15,7 +15,15 @@ import sys
Variables = SCons.Variables
BoolVariable = SCons.Variables.BoolVariable
VERSION = '2.53' # This is used in creating the local config directories
def get_version():
fname = os.path.join(os.path.dirname(__file__), "..", "..", "..", "source", "blender", "blenkernel", "BKE_blender.h")
for l in open(fname, "r"):
if "BLENDER_VERSION" in l:
ver = int(l.split()[-1])
return "%d.%d" % (ver / 100, ver % 100)
raise Exception("%s: missing version string" % fname)
VERSION = get_version() # This is used in creating the local config directories
def print_arguments(args, bc):
if len(args):
@ -38,19 +46,20 @@ def validate_arguments(args, bc):
'WITH_BF_OPENEXR', 'BF_OPENEXR', 'BF_OPENEXR_INC', 'BF_OPENEXR_LIB', 'BF_OPENEXR_LIBPATH', 'WITH_BF_STATICOPENEXR', 'BF_OPENEXR_LIB_STATIC',
'WITH_BF_DDS', 'WITH_BF_CINEON', 'WITH_BF_HDR',
'WITH_BF_FFMPEG', 'BF_FFMPEG_LIB','BF_FFMPEG_EXTRA', 'BF_FFMPEG', 'BF_FFMPEG_INC',
'WITH_BF_STATICFFMPEG', 'BF_FFMPEG_LIB_STATIC',
'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB',
'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH',
'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH',
'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH',
'WITH_BF_PNG', 'BF_PNG', 'BF_PNG_INC', 'BF_PNG_LIB', 'BF_PNG_LIBPATH',
'WITH_BF_TIFF', 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH',
'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH',
'WITH_BF_TIFF', 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH', 'WITH_BF_STATICTIFF', 'BF_TIFF_LIB_STATIC',
'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH', 'WITH_BF_STATICZLIB', 'BF_ZLIB_LIB_STATIC',
'WITH_BF_INTERNATIONAL',
'BF_GETTEXT', 'BF_GETTEXT_INC', 'BF_GETTEXT_LIB', 'BF_GETTEXT_LIBPATH',
'BF_GETTEXT', 'BF_GETTEXT_INC', 'BF_GETTEXT_LIB', 'WITH_BF_GETTEXT_STATIC', 'BF_GETTEXT_LIB_STATIC', 'BF_GETTEXT_LIBPATH',
'WITH_BF_ICONV', 'BF_ICONV', 'BF_ICONV_INC', 'BF_ICONV_LIB', 'BF_ICONV_LIBPATH',
'WITH_BF_GAMEENGINE', 'WITH_BF_BULLET', 'BF_BULLET', 'BF_BULLET_INC', 'BF_BULLET_LIB',
'BF_WINTAB', 'BF_WINTAB_INC',
'WITH_BF_FREETYPE', 'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH',
'WITH_BF_FREETYPE', 'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH', 'BF_FREETYPE_LIB_STATIC', 'WITH_BF_FREETYPE_STATIC',
'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
'WITH_BF_FFTW3', 'BF_FFTW3', 'BF_FFTW3_INC', 'BF_FFTW3_LIB', 'BF_FFTW3_LIBPATH',
'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC',
@ -236,6 +245,8 @@ def read_opts(env, cfg, args):
('BF_FFMPEG_INC', 'FFMPEG includes', ''),
('BF_FFMPEG_LIBPATH', 'FFMPEG library path', ''),
(BoolVariable('WITH_BF_STATICFFMPEG', 'Use static FFMPEG if true', False)),
('BF_FFMPEG_LIB_STATIC', 'Static FFMPEG libraries', ''),
(BoolVariable('WITH_BF_OGG', 'Use OGG, THEORA, VORBIS in FFMPEG if true',
False)),
@ -267,10 +278,12 @@ def read_opts(env, cfg, args):
('BF_PNG_LIBPATH', 'PNG library path', ''),
(BoolVariable('WITH_BF_TIFF', 'Use TIFF if true', True)),
(BoolVariable('WITH_BF_STATICTIFF', 'Staticly link to TIFF', False)),
('BF_TIFF', 'TIFF base path', ''),
('BF_TIFF_INC', 'TIFF include path', ''),
('BF_TIFF_LIB', 'TIFF library', ''),
('BF_TIFF_LIBPATH', 'TIFF library path', ''),
('BF_TIFF_LIB_STATIC', 'TIFF static library', ''),
(BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)),
('BF_LCMS', 'LCMS base path', ''),
@ -279,16 +292,20 @@ def read_opts(env, cfg, args):
('BF_LCMS_LIBPATH', 'LCMS library path', ''),
(BoolVariable('WITH_BF_ZLIB', 'Use ZLib if true', True)),
(BoolVariable('WITH_BF_STATICZLIB', 'Staticly link to ZLib', False)),
('BF_ZLIB', 'ZLib base path', ''),
('BF_ZLIB_INC', 'ZLib include path', ''),
('BF_ZLIB_LIB', 'ZLib library', ''),
('BF_ZLIB_LIBPATH', 'ZLib library path', ''),
('BF_ZLIB_LIB_STATIC', 'ZLib static library', ''),
(BoolVariable('WITH_BF_INTERNATIONAL', 'Use Gettext if true', True)),
('BF_GETTEXT', 'gettext base path', ''),
('BF_GETTEXT_INC', 'gettext include path', ''),
('BF_GETTEXT_LIB', 'gettext library', ''),
(BoolVariable('WITH_BF_GETTEXT_STATIC', 'Use static gettext library if true', False)),
('BF_GETTEXT_LIB_STATIC', 'static gettext library', ''),
('BF_GETTEXT_LIBPATH', 'gettext library path', ''),
(BoolVariable('WITH_BF_ICONV', 'Use iconv if true', True)),
@ -309,29 +326,14 @@ def read_opts(env, cfg, args):
('BF_CXX', 'c++ base path for libstdc++, only used when static linking', ''),
(BoolVariable('WITH_BF_STATICCXX', 'static link to stdc++', False)),
('BF_CXX_LIB_STATIC', 'static library path for stdc++', ''),
##
##WITH_BF_NSPR = True
##BF_NSPR = $(LCGDIR)/nspr
##BF_NSPR_INC = -I$(BF_NSPR)/include -I$(BF_NSPR)/include/nspr
##BF_NSPR_LIB =
### Uncomment the following line to use Mozilla inplace of netscape
##CPPFLAGS += -DMOZ_NOT_NET
### Location of MOZILLA/Netscape header files...
##BF_MOZILLA = $(LCGDIR)/mozilla
##BF_MOZILLA_INC = -I$(BF_MOZILLA)/include/mozilla/nspr -I$(BF_MOZILLA)/include/mozilla -I$(BF_MOZILLA)/include/mozilla/xpcom -I$(BF_MOZILLA)/include/mozilla/idl
##BF_MOZILLA_LIB =
### Will fall back to look in BF_MOZILLA_INC/nspr and BF_MOZILLA_LIB
### if this is not set.
##
### Be paranoid regarding library creation (do not update archives)
##BF_PARANOID = True
##
### enable freetype2 support for text objects
(BoolVariable('WITH_BF_FREETYPE', 'Use FreeType2 if true', True)),
('BF_FREETYPE', 'Freetype base path', ''),
('BF_FREETYPE_INC', 'Freetype include path', ''),
('BF_FREETYPE_LIB', 'Freetype library', ''),
('BF_FREETYPE_LIBPATH', 'Freetype library path', ''),
(BoolVariable('WITH_BF_FREETYPE_STATIC', 'Use Static Freetype if true', False)),
('BF_FREETYPE_LIB_STATIC', 'Static Freetype library', ''),
(BoolVariable('WITH_BF_OPENMP', 'Use OpenMP if true', False)),
('BF_OPENMP', 'Base path to OpenMP (used when cross-compiling with older versions of WinGW)', ''),

@ -32,4 +32,4 @@ license@blender.org for further information.
Ton Roosendaal
Chairman Blender Foundation.
June 2005
June 2005

@ -1390,4 +1390,4 @@ Radoslav Dejanovic
James H. Cloos, Jr.
Karl Erlandsen (LethalSideParting)
Kari Pulli
Dave Shemano
Dave Shemano

@ -91,25 +91,25 @@ while lines:
l = lines.pop(0)
if l.startswith("Environment Variables:"):
fw('.SH "ENVIRONMENT VARIABLES"\n')
elif l.endswith(":"): # one line
elif l.endswith(":"): # one line
fw('.SS "%s"\n\n' % l)
elif l.startswith("-") or l.startswith("/"): # can be multi line
elif l.startswith("-") or l.startswith("/"): # can be multi line
fw('.TP\n')
fw('.B %s\n' % man_format(l))
while lines:
# line with no
if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
break
if not l: # second blank line
if not l: # second blank line
fw('.IP\n')
else:
fw('.br\n')
l = lines.pop(0)
l = l[1:] # remove first whitespace (tab)
l = l[1:] # remove first whitespace (tab)
fw('%s\n' % man_format(l))

4
extern/SConscript vendored

@ -18,7 +18,7 @@ if env['OURPLATFORM'] == 'linux2':
SConscript(['binreloc/SConscript']);
if env['WITH_BF_LZO']:
SConscript(['lzo/SConscript'])
SConscript(['lzo/SConscript'])
if env['WITH_BF_LZMA']:
SConscript(['lzma/SConscript'])
SConscript(['lzma/SConscript'])

@ -18,9 +18,15 @@
# All rights reserved.
#
SET(INC ./include )
SET(SRC
binreloc.c
)
SET(INC
./include
)
ADD_DEFINITIONS(-DENABLE_BINRELOC)
FILE(GLOB SRC *.c)
BLENDERLIB(extern_binreloc "${SRC}" "${INC}")
#, libtype=['core','player'], priority = [25,15] )

@ -24,12 +24,13 @@ btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int
m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE;
m_unscaledPoints.resize(numPoints);
unsigned char* pointsBaseAddress = (unsigned char*)points;
unsigned char* pointsAddress = (unsigned char*)points;
for (int i=0;i<numPoints;i++)
{
btVector3* point = (btVector3*)(pointsBaseAddress + i*stride);
m_unscaledPoints[i] = point[0];
btScalar* point = (btScalar*)pointsAddress;
m_unscaledPoints[i] = btVector3(point[0], point[1], point[2]);
pointsAddress += stride;
}
recalcLocalAabb();

@ -24,10 +24,12 @@
#
# ***** END GPL LICENSE BLOCK *****
SET(INC include src)
SET(INC
./include
)
IF(UNIX)
SET(INC ${INC} ${X11_X11_INCLUDE_PATH})
LIST(APPEND INC ${X11_X11_INCLUDE_PATH})
ENDIF(UNIX)
SET(SRC
@ -37,4 +39,3 @@ SET(SRC
ADD_DEFINITIONS(-DGLEW_STATIC)
BLENDERLIB(extern_glew "${SRC}" "${INC}")

@ -24,9 +24,7 @@
#
# ***** END GPL LICENSE BLOCK *****
SET(INC . src)
SET(INC .)
FILE(GLOB SRC *.c except t1_generate_luts.c)
ADD_DEFINITIONS(-DWITH_OPENJPEG)
BLENDERLIB(extern_libopenjpeg "${SRC}" "${INC}")
#, libtype=['international','player'], priority=[5, 210])
FILE(GLOB SRC *.c)
BLENDERLIB(extern_openjpeg "${SRC}" "${INC}")

@ -11,15 +11,15 @@ flags = []
defs = []
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
flags = []
defs.append('OPJ_STATIC')
flags = []
defs.append('OPJ_STATIC')
else:
flags = ['-Wall', '-O3', '-ffast-math', '-std=c99']
flags = ['-Wall', '-O3', '-ffast-math', '-std=c99']
oj_env = env.Clone()
if not env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
oj_env.Replace(CCFLAGS = '')
oj_env.Replace(BF_DEBUG_FLAGS = '')
oj_env.Replace(CCFLAGS = '')
oj_env.Replace(BF_DEBUG_FLAGS = '')
oj_env.BlenderLib ( libname='extern_openjpeg',
sources=sources, includes=Split(incs),

@ -28,7 +28,4 @@ SET(INC . )
FILE(GLOB SRC ./*.c)
BLENDERLIB(bf_lzma "${SRC}" "${INC}")
#, libtype='blender', priority = 0 )
BLENDERLIB(extern_lzma "${SRC}" "${INC}")

@ -6,4 +6,4 @@ sources = env.Glob('./*.c')
defs = ''
incs = ' . '
env.BlenderLib ('bf_lzma', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] )
env.BlenderLib ('extern_lzma', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] )

@ -25,10 +25,6 @@
# ***** END GPL LICENSE BLOCK *****
SET(INC include)
SET(SRC minilzo/minilzo.c)
FILE(GLOB SRC minilzo/*.c)
BLENDERLIB(bf_minilzo "${SRC}" "${INC}")
#, libtype='blender', priority = 0 )
BLENDERLIB(extern_minilzo "${SRC}" "${INC}")

@ -6,4 +6,4 @@ sources = env.Glob('minilzo/*.c')
defs = ''
incs = ' include '
env.BlenderLib ('bf_minilzo', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] )
env.BlenderLib ('extern_minilzo', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] )

@ -33,7 +33,6 @@ ADD_SUBDIRECTORY(container)
ADD_SUBDIRECTORY(memutil)
ADD_SUBDIRECTORY(decimation)
ADD_SUBDIRECTORY(iksolver)
ADD_SUBDIRECTORY(itasc)
ADD_SUBDIRECTORY(boolop)
ADD_SUBDIRECTORY(opennl)
ADD_SUBDIRECTORY(smoke)
@ -42,4 +41,8 @@ IF(WITH_FLUID)
ADD_SUBDIRECTORY(elbeem)
ENDIF(WITH_FLUID)
IF(WITH_IK_ITASC)
ADD_SUBDIRECTORY(itasc)
ENDIF(WITH_IK_ITASC)
ADD_SUBDIRECTORY(bsp)

@ -20,46 +20,64 @@
#
# ***** END LGPL LICENSE BLOCK *****
SET(INC . intern FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC})
SET(INC
.
intern
FX SRC
${PTHREADS_INC}
${LIBSAMPLERATE_INC}
)
FILE(GLOB SRC intern/*.cpp intern/*.h FX/*.cpp SRC/*.cpp)
FILE(GLOB SRC
intern/*.cpp
intern/*.h
FX/*.cpp
SRC/*.cpp
)
IF(WITH_FFMPEG)
SET(INC ${INC} ffmpeg ${FFMPEG_INC})
LIST(APPEND INC ffmpeg ${FFMPEG_INC})
FILE(GLOB FFMPEGSRC ffmpeg/*.cpp)
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
IF(WITH_SDL)
SET(INC ${INC} SDL ${SDL_INCLUDE_DIR})
LIST(APPEND INC SDL ${SDL_INCLUDE_DIR})
FILE(GLOB SDLSRC SDL/*.cpp)
ADD_DEFINITIONS(-DWITH_SDL)
ENDIF(WITH_SDL)
IF(WITH_OPENAL)
SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR})
LIST(APPEND INC OpenAL ${OPENAL_INCLUDE_DIR})
FILE(GLOB OPENALSRC OpenAL/*.cpp)
ADD_DEFINITIONS(-DWITH_OPENAL)
ENDIF(WITH_OPENAL)
IF(WITH_JACK)
SET(INC ${INC} jack ${JACK_INC})
LIST(APPEND INC jack ${JACK_INC})
FILE(GLOB JACKSRC jack/*.cpp)
ADD_DEFINITIONS(-DWITH_JACK)
ENDIF(WITH_JACK)
IF(WITH_SNDFILE)
SET(INC ${INC} sndfile ${SNDFILE_INC})
LIST(APPEND INC sndfile ${SNDFILE_INC})
FILE(GLOB SNDFILESRC sndfile/*.cpp)
ADD_DEFINITIONS(-DWITH_SNDFILE)
ENDIF(WITH_SNDFILE)
IF(WITH_FFTW3)
SET(INC ${INC} fftw ${FFTW3_INC})
FILE(GLOB FFTW3SRC fftw/*.cpp)
ADD_DEFINITIONS(-DWITH_FFTW3)
ENDIF(WITH_FFTW3)
#IF(WITH_FFTW3)
# LIST(APPEND INC fftw ${FFTW3_INC})
# FILE(GLOB FFTW3SRC fftw/*.cpp)
# ADD_DEFINITIONS(-DWITH_FFTW3)
#ENDIF(WITH_FFTW3)
SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${FFTW3SRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC})
IF(WITH_PYTHON)
LIST(APPEND INC Python ${PYTHON_INC})
FILE(GLOB PYTHONSRC Python/*.cpp)
ELSE(WITH_PYTHON)
ADD_DEFINITIONS(-DDISABLE_PYTHON)
ENDIF(WITH_PYTHON)
BLENDERLIB(bf_audaspace "${SRC}" "${INC}")
SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${FFTW3SRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC} ${PYTHONSRC})
BLENDERLIB(bf_intern_audaspace "${SRC}" "${INC}")

@ -24,26 +24,37 @@
*/
#include "AUD_AccumulatorFactory.h"
#include "AUD_AccumulatorReader.h"
#include "AUD_CallbackIIRFilterReader.h"
sample_t accumulatorFilterAdditive(AUD_CallbackIIRFilterReader* reader, void* useless)
{
float in = reader->x(0);
float lastin = reader->x(-1);
float out = reader->y(-1) + in - lastin;
if(in > lastin)
out += in - lastin;
return out;
}
sample_t accumulatorFilter(AUD_CallbackIIRFilterReader* reader, void* useless)
{
float in = reader->x(0);
float lastin = reader->x(-1);
float out = reader->y(-1);
if(in > lastin)
out += in - lastin;
return out;
}
AUD_AccumulatorFactory::AUD_AccumulatorFactory(AUD_IFactory* factory,
bool additive) :
AUD_EffectFactory(factory),
m_additive(additive) {}
AUD_AccumulatorFactory::AUD_AccumulatorFactory(bool additive) :
AUD_EffectFactory(0),
m_additive(additive) {}
AUD_IReader* AUD_AccumulatorFactory::createReader()
m_additive(additive)
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_AccumulatorReader(reader, m_additive);
AUD_NEW("reader")
}
return reader;
}
AUD_IReader* AUD_AccumulatorFactory::createReader() const
{
return new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
m_additive ? accumulatorFilterAdditive : accumulatorFilter);
}

@ -37,7 +37,11 @@ private:
/**
* Whether the accumulator is additive.
*/
bool m_additive;
const bool m_additive;
// hide copy constructor and operator=
AUD_AccumulatorFactory(const AUD_AccumulatorFactory&);
AUD_AccumulatorFactory& operator=(const AUD_AccumulatorFactory&);
public:
/**
@ -47,13 +51,7 @@ public:
*/
AUD_AccumulatorFactory(AUD_IFactory* factory, bool additive = false);
/**
* Creates a new accumulator factory.
* \param additive Whether the accumulator is additive.
*/
AUD_AccumulatorFactory(bool additive = false);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_ACCUMULATORFACTORY

@ -1,99 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_AccumulatorReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#define CC specs.channels + channel
AUD_AccumulatorReader::AUD_AccumulatorReader(AUD_IReader* reader,
bool additive) :
AUD_EffectReader(reader),
m_additive(additive)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_sums = new AUD_Buffer(samplesize); AUD_NEW("buffer")
memset(m_sums->getBuffer(), 0, samplesize);
m_prevs = new AUD_Buffer(samplesize); AUD_NEW("buffer")
memset(m_prevs->getBuffer(), 0, samplesize);
}
AUD_AccumulatorReader::~AUD_AccumulatorReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_sums; AUD_DELETE("buffer")
delete m_prevs; AUD_DELETE("buffer")
}
void AUD_AccumulatorReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* sums;
sample_t* prevs;
sums = m_sums->getBuffer();
prevs = m_prevs->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
if(m_additive)
{
for(int channel = 0; channel < specs.channels; channel++)
{
for(int i = 0; i < length; i++)
{
if(buf[i * CC] > prevs[channel])
sums[channel] += buf[i * CC] - prevs[channel];
buffer[i * CC] = sums[channel] + buf[i * CC];
prevs[channel] = buf[i * CC];
}
}
}
else
{
for(int channel = 0; channel < specs.channels; channel++)
{
for(int i = 0; i < length * specs.channels; i++)
{
if(buf[i * CC] > prevs[channel])
sums[channel] += buf[i * CC] - prevs[channel];
buffer[i * CC] = sums[channel];
prevs[channel] = buf[i * CC];
}
}
}
}

@ -1,75 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_ACCUMULATORREADER
#define AUD_ACCUMULATORREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
/**
* This class represents an accumulator.
*/
class AUD_AccumulatorReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The sums of the specific channels.
*/
AUD_Buffer *m_sums;
/**
* The previous results of the specific channels.
*/
AUD_Buffer *m_prevs;
/**
* Whether the accumulator is additive.
*/
bool m_additive;
public:
/**
* Creates a new accumulator reader.
* \param reader The reader to read from.
* \param additive Whether the accumulator is additive.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_AccumulatorReader(AUD_IReader* reader, bool additive);
/**
* Destroys the reader.
*/
virtual ~AUD_AccumulatorReader();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_ACCUMULATORREADER

@ -0,0 +1,76 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_BaseIIRFilterReader.h"
#include <cstring>
#define CC m_channels + m_channel
AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_IReader* reader, int in,
int out) :
AUD_EffectReader(reader),
m_channels(reader->getSpecs().channels),
m_xlen(in), m_ylen(out),
m_xpos(0), m_ypos(0), m_channel(0)
{
m_x = new sample_t[in * m_channels];
m_y = new sample_t[out * m_channels];
memset(m_x, 0, sizeof(sample_t) * in * m_channels);
memset(m_y, 0, sizeof(sample_t) * out * m_channels);
}
AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
{
delete[] m_x;
delete[] m_y;
}
void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
m_reader->read(length, buf);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
buffer = m_buffer.getBuffer();
for(m_channel = 0; m_channel < m_channels; m_channel++)
{
for(int i = 0; i < length; i++)
{
m_x[m_xpos * CC] = buf[i * CC];
m_y[m_ypos * CC] = buffer[i * CC] = filter();
m_xpos = (m_xpos + 1) % m_xlen;
m_ypos = (m_ypos + 1) % m_ylen;
}
}
}

@ -0,0 +1,114 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_BASEIIRFILTERREADER
#define AUD_BASEIIRFILTERREADER
#include "AUD_EffectReader.h"
#include "AUD_Buffer.h"
/**
* This class is a base class for infinite impulse response filters.
*/
class AUD_BaseIIRFilterReader : public AUD_EffectReader
{
private:
/**
* Channel count.
*/
const int m_channels;
/**
* Length of input samples needed.
*/
const int m_xlen;
/**
* Length of output samples needed.
*/
const int m_ylen;
/**
* The playback buffer.
*/
AUD_Buffer m_buffer;
/**
* The last in samples array.
*/
sample_t* m_x;
/**
* The last out samples array.
*/
sample_t* m_y;
/**
* Position of the current input sample in the input array.
*/
int m_xpos;
/**
* Position of the current output sample in the output array.
*/
int m_ypos;
/**
* Current channel.
*/
int m_channel;
// hide copy constructor and operator=
AUD_BaseIIRFilterReader(const AUD_BaseIIRFilterReader&);
AUD_BaseIIRFilterReader& operator=(const AUD_BaseIIRFilterReader&);
protected:
/**
* Creates a new base IIR filter reader.
* \param reader The reader to read from.
* \param in The count of past input samples needed.
* \param out The count of past output samples needed.
*/
AUD_BaseIIRFilterReader(AUD_IReader* reader, int in, int out);
public:
inline sample_t x(int pos)
{
return m_x[(m_xpos + pos + m_xlen) % m_xlen * m_channels + m_channel];
}
inline sample_t y(int pos)
{
return m_y[(m_ypos + pos + m_ylen) % m_ylen * m_channels + m_channel];
}
virtual ~AUD_BaseIIRFilterReader();
virtual void read(int & length, sample_t* & buffer);
virtual sample_t filter()=0;
};
#endif //AUD_BASEIIRFILTERREADER

@ -24,26 +24,49 @@
*/
#include "AUD_ButterworthFactory.h"
#include "AUD_ButterworthReader.h"
#include "AUD_IIRFilterReader.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define BWPB41 0.76536686473
#define BWPB42 1.84775906502
AUD_ButterworthFactory::AUD_ButterworthFactory(AUD_IFactory* factory,
float frequency) :
AUD_EffectFactory(factory),
m_frequency(frequency) {}
m_frequency(frequency)
{
}
AUD_ButterworthFactory::AUD_ButterworthFactory(float frequency) :
AUD_EffectFactory(0),
m_frequency(frequency) {}
AUD_IReader* AUD_ButterworthFactory::createReader()
AUD_IReader* AUD_ButterworthFactory::createReader() const
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_ButterworthReader(reader, m_frequency);
AUD_NEW("reader")
}
// calculate coefficients
float omega = 2 * tan(m_frequency * M_PI / reader->getSpecs().rate);
float o2 = omega * omega;
float o4 = o2 * o2;
float x1 = o2 + 2 * BWPB41 * omega + 4;
float x2 = o2 + 2 * BWPB42 * omega + 4;
float y1 = o2 - 2 * BWPB41 * omega + 4;
float y2 = o2 - 2 * BWPB42 * omega + 4;
float o228 = 2 * o2 - 8;
float norm = x1 * x2;
std::vector<float> a, b;
a.push_back(1);
a.push_back((x1 + x2) * o228 / norm);
a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm);
a.push_back((y1 + y2) * o228 / norm);
a.push_back(y1 * y2 / norm);
b.push_back(o4 / norm);
b.push_back(4 * o4 / norm);
b.push_back(6 * o4 / norm);
b.push_back(b[1]);
b.push_back(b[0]);
return reader;
return new AUD_IIRFilterReader(reader, b, a);
}

@ -37,7 +37,11 @@ private:
/**
* The attack value in seconds.
*/
float m_frequency;
const float m_frequency;
// hide copy constructor and operator=
AUD_ButterworthFactory(const AUD_ButterworthFactory&);
AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&);
public:
/**
@ -47,13 +51,7 @@ public:
*/
AUD_ButterworthFactory(AUD_IFactory* factory, float frequency);
/**
* Creates a new butterworth factory.
* \param frequency The cutoff frequency.
*/
AUD_ButterworthFactory(float frequency);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_BUTTERWORTHFACTORY

@ -1,124 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_ButterworthReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define BWPB41 0.76536686473
#define BWPB42 1.84775906502
#define CC channels + channel
AUD_ButterworthReader::AUD_ButterworthReader(AUD_IReader* reader,
float frequency) :
AUD_EffectReader(reader)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_outvalues = new AUD_Buffer(samplesize * 5); AUD_NEW("buffer")
memset(m_outvalues->getBuffer(), 0, samplesize * 5);
m_invalues = new AUD_Buffer(samplesize * 5); AUD_NEW("buffer")
memset(m_invalues->getBuffer(), 0, samplesize * 5);
m_position = 0;
// calculate coefficients
float omega = 2 * tan(frequency * M_PI / specs.rate);
float o2 = omega * omega;
float o4 = o2 * o2;
float x1 = o2 + 2 * BWPB41 * omega + 4;
float x2 = o2 + 2 * BWPB42 * omega + 4;
float y1 = o2 - 2 * BWPB41 * omega + 4;
float y2 = o2 - 2 * BWPB42 * omega + 4;
float o228 = 2 * o2 - 8;
float norm = x1 * x2;
m_coeff[0][0] = 0;
m_coeff[0][1] = (x1 + x2) * o228 / norm;
m_coeff[0][2] = (x1 * y2 + x2 * y1 + o228 * o228) / norm;
m_coeff[0][3] = (y1 + y2) * o228 / norm;
m_coeff[0][4] = y1 * y2 / norm;
m_coeff[1][4] = m_coeff[1][0] = o4 / norm;
m_coeff[1][3] = m_coeff[1][1] = 4 * o4 / norm;
m_coeff[1][2] = 6 * o4 / norm;
}
AUD_ButterworthReader::~AUD_ButterworthReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_outvalues; AUD_DELETE("buffer")
delete m_invalues; AUD_DELETE("buffer");
}
void AUD_ButterworthReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* outvalues;
sample_t* invalues;
outvalues = m_outvalues->getBuffer();
invalues = m_invalues->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
int channels = specs.channels;
for(int channel = 0; channel < channels; channel++)
{
for(int i = 0; i < length; i++)
{
invalues[m_position * CC] = buf[i * CC];
outvalues[m_position * CC] = 0;
for(int j = 0; j < 4; j++)
{
outvalues[m_position * CC] += m_coeff[1][j] *
invalues[((m_position + j) % 5) * CC] -
m_coeff[0][j] *
outvalues[((m_position + j) % 5) * CC];
}
buffer[i * CC] = outvalues[m_position * CC];
m_position = (m_position + 4) % 5;
}
}
}

@ -1,83 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_BUTTERWORTHREADER
#define AUD_BUTTERWORTHREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
/**
* This class represents a butterworth filter.
*/
class AUD_ButterworthReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The last out values buffer.
*/
AUD_Buffer *m_outvalues;
/**
* The last in values buffer.
*/
AUD_Buffer *m_invalues;
/**
* The position for buffer cycling.
*/
int m_position;
/**
* Filter coefficients.
*/
float m_coeff[2][5];
public:
/**
* Creates a new butterworth reader.
* \param reader The reader to read from.
* \param attack The attack value in seconds.
* \param release The release value in seconds.
* \param threshold The threshold value.
* \param arthreshold The attack/release threshold value.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_ButterworthReader(AUD_IReader* reader, float frequency);
/**
* Destroys the reader.
*/
virtual ~AUD_ButterworthReader();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_BUTTERWORTHREADER

@ -23,33 +23,25 @@
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_RectifyReader.h"
#include "AUD_Buffer.h"
#include "AUD_CallbackIIRFilterReader.h"
#include <cmath>
AUD_RectifyReader::AUD_RectifyReader(AUD_IReader* reader) :
AUD_EffectReader(reader)
AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(AUD_IReader* reader,
int in, int out,
doFilterIIR doFilter,
endFilterIIR endFilter,
void* data) :
AUD_BaseIIRFilterReader(reader, in, out),
m_filter(doFilter), m_endFilter(endFilter), m_data(data)
{
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_RectifyReader::~AUD_RectifyReader()
AUD_CallbackIIRFilterReader::~AUD_CallbackIIRFilterReader()
{
delete m_buffer; AUD_DELETE("buffer")
if(m_endFilter)
m_endFilter(m_data);
}
void AUD_RectifyReader::read(int & length, sample_t* & buffer)
sample_t AUD_CallbackIIRFilterReader::filter()
{
sample_t* buf;
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
for(int i = 0; i < length * specs.channels; i++)
buffer[i] = fabs(buf[i]);
return m_filter(this, m_data);
}

@ -0,0 +1,83 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_CALLBACKIIRFILTERREADER
#define AUD_CALLBACKIIRFILTERREADER
#include "AUD_BaseIIRFilterReader.h"
#include "AUD_Buffer.h"
class AUD_CallbackIIRFilterReader;
typedef sample_t (*doFilterIIR)(AUD_CallbackIIRFilterReader*, void*);
typedef void (*endFilterIIR)(void*);
/**
* This class provides an interface for infinite impulse response filters via a
* callback filter function.
*/
class AUD_CallbackIIRFilterReader : public AUD_BaseIIRFilterReader
{
private:
/**
* Filter function.
*/
const doFilterIIR m_filter;
/**
* End filter function.
*/
const endFilterIIR m_endFilter;
/**
* Data pointer.
*/
void* m_data;
// hide copy constructor and operator=
AUD_CallbackIIRFilterReader(const AUD_CallbackIIRFilterReader&);
AUD_CallbackIIRFilterReader& operator=(const AUD_CallbackIIRFilterReader&);
public:
/**
* Creates a new callback IIR filter reader.
* \param reader The reader to read from.
* \param in The count of past input samples needed.
* \param out The count of past output samples needed.
* \param doFilter The filter callback.
* \param endFilter The finishing callback.
* \param data Data pointer for the callbacks.
*/
AUD_CallbackIIRFilterReader(AUD_IReader* reader, int in, int out,
doFilterIIR doFilter,
endFilterIIR endFilter = 0,
void* data = 0);
virtual ~AUD_CallbackIIRFilterReader();
virtual sample_t filter();
};
#endif //AUD_CALLBACKIIRFILTERREADER

@ -29,30 +29,16 @@
AUD_DelayFactory::AUD_DelayFactory(AUD_IFactory* factory, float delay) :
AUD_EffectFactory(factory),
m_delay(delay) {}
m_delay(delay)
{
}
AUD_DelayFactory::AUD_DelayFactory(float delay) :
AUD_EffectFactory(0),
m_delay(delay) {}
float AUD_DelayFactory::getDelay()
float AUD_DelayFactory::getDelay() const
{
return m_delay;
}
void AUD_DelayFactory::setDelay(float delay)
AUD_IReader* AUD_DelayFactory::createReader() const
{
m_delay = delay;
}
AUD_IReader* AUD_DelayFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_DelayReader(reader, m_delay); AUD_NEW("reader")
}
return reader;
return new AUD_DelayReader(getReader(), m_delay);
}

@ -37,7 +37,11 @@ private:
/**
* The delay in samples.
*/
float m_delay;
const float m_delay;
// hide copy constructor and operator=
AUD_DelayFactory(const AUD_DelayFactory&);
AUD_DelayFactory& operator=(const AUD_DelayFactory&);
public:
/**
@ -45,26 +49,14 @@ public:
* \param factory The input factory.
* \param delay The desired delay in seconds.
*/
AUD_DelayFactory(AUD_IFactory* factory = 0, float delay = 0);
/**
* Creates a new delay factory.
* \param delay The desired delay in seconds.
*/
AUD_DelayFactory(float delay);
AUD_DelayFactory(AUD_IFactory* factory, float delay = 0);
/**
* Returns the delay in seconds.
*/
float getDelay();
float getDelay() const;
/**
* Sets the delay.
* \param delay The new delay value in seconds.
*/
void setDelay(float delay);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_DELAYFACTORY

@ -24,28 +24,19 @@
*/
#include "AUD_DelayReader.h"
#include "AUD_Buffer.h"
#include <cstring>
AUD_DelayReader::AUD_DelayReader(AUD_IReader* reader, float delay) :
AUD_EffectReader(reader)
AUD_EffectReader(reader),
m_delay(int(delay * reader->getSpecs().rate)),
m_remdelay(int(delay * reader->getSpecs().rate)),
m_empty(true)
{
m_delay = (int)(delay * reader->getSpecs().rate);
m_remdelay = m_delay;
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_DelayReader::~AUD_DelayReader()
{
delete m_buffer; AUD_DELETE("buffer")
}
void AUD_DelayReader::seek(int position)
{
if(position < 0)
return;
if(position < m_delay)
{
m_remdelay = m_delay - position;
@ -58,18 +49,18 @@ void AUD_DelayReader::seek(int position)
}
}
int AUD_DelayReader::getLength()
int AUD_DelayReader::getLength() const
{
int len = m_reader->getLength();
if(len < 0)
return len;
return len+m_delay;
return len + m_delay;
}
int AUD_DelayReader::getPosition()
int AUD_DelayReader::getPosition() const
{
if(m_remdelay > 0)
return m_delay-m_remdelay;
return m_delay - m_remdelay;
return m_reader->getPosition() + m_delay;
}
@ -80,26 +71,41 @@ void AUD_DelayReader::read(int & length, sample_t* & buffer)
AUD_Specs specs = m_reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
if(m_buffer->getSize() < length * samplesize)
m_buffer->resize(length * samplesize);
if(m_buffer.getSize() < length * samplesize)
{
m_buffer.resize(length * samplesize);
m_empty = false;
}
buffer = m_buffer.getBuffer();
if(length > m_remdelay)
{
memset(m_buffer->getBuffer(), 0, m_remdelay * samplesize);
if(!m_empty)
memset(buffer, 0, m_remdelay * samplesize);
int len = length - m_remdelay;
m_reader->read(len, buffer);
memcpy(m_buffer->getBuffer() + m_remdelay * specs.channels,
buffer, len * samplesize);
sample_t* buf;
m_reader->read(len, buf);
memcpy(buffer + m_remdelay * specs.channels,
buf, len * samplesize);
if(len < length-m_remdelay)
length = m_remdelay + len;
m_remdelay = 0;
m_empty = false;
}
else
{
memset(m_buffer->getBuffer(), 0, length * samplesize);
if(!m_empty)
{
memset(buffer, 0, length * samplesize);
m_empty = true;
}
m_remdelay -= length;
}
buffer = m_buffer->getBuffer();
}
else
m_reader->read(length, buffer);

@ -27,7 +27,7 @@
#define AUD_DELAYREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_Buffer.h"
/**
* This class reads another reader and changes it's delay.
@ -38,35 +38,38 @@ private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
AUD_Buffer m_buffer;
/**
* The delay level.
*/
int m_delay;
const int m_delay;
/**
* The remaining delay for playback.
*/
int m_remdelay;
/**
* Whether the buffer is currently filled with zeros.
*/
bool m_empty;
// hide copy constructor and operator=
AUD_DelayReader(const AUD_DelayReader&);
AUD_DelayReader& operator=(const AUD_DelayReader&);
public:
/**
* Creates a new delay reader.
* \param reader The reader to read from.
* \param delay The delay in seconds.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_DelayReader(AUD_IReader* reader, float delay);
/**
* Destroys the reader.
*/
virtual ~AUD_DelayReader();
virtual void seek(int position);
virtual int getLength();
virtual int getPosition();
virtual int getLength() const;
virtual int getPosition() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -0,0 +1,50 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_DoubleFactory.h"
#include "AUD_DoubleReader.h"
AUD_DoubleFactory::AUD_DoubleFactory(AUD_IFactory* factory1, AUD_IFactory* factory2) :
m_factory1(factory1), m_factory2(factory2)
{
}
AUD_IReader* AUD_DoubleFactory::createReader() const
{
AUD_IReader* reader1 = m_factory1->createReader();
AUD_IReader* reader2;
try
{
reader2 = m_factory2->createReader();
}
catch(AUD_Exception&)
{
delete reader1;
throw;
}
return new AUD_DoubleReader(reader1, reader2);
}

@ -23,43 +23,41 @@
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_SQUAREREADER
#define AUD_SQUAREREADER
#ifndef AUD_DOUBLEFACTORY
#define AUD_DOUBLEFACTORY
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_IFactory.h"
/**
* This class changes another signal into a square signal.
* This factory plays two other factories behind each other.
* \note Readers from the underlying factories must have the same sample rate and channel count.
*/
class AUD_SquareReader : public AUD_EffectReader
class AUD_DoubleFactory : public AUD_IFactory
{
private:
/**
* The playback buffer.
* First played factory.
*/
AUD_Buffer *m_buffer;
AUD_IFactory* m_factory1;
/**
* The threshold level.
* Second played factory.
*/
float m_threshold;
AUD_IFactory* m_factory2;
// hide copy constructor and operator=
AUD_DoubleFactory(const AUD_DoubleFactory&);
AUD_DoubleFactory& operator=(const AUD_DoubleFactory&);
public:
/**
* Creates a new square reader.
* \param reader The reader to read from.
* \param threshold The size of the buffer.
* \exception AUD_Exception Thrown if the reader specified is NULL.
* Creates a new double factory.
* \param factory1 The first input factory.
* \param factory2 The second input factory.
*/
AUD_SquareReader(AUD_IReader* reader, float threshold);
AUD_DoubleFactory(AUD_IFactory* factory1, AUD_IFactory* factory2);
/**
* Destroys the reader.
*/
virtual ~AUD_SquareReader();
virtual void read(int & length, sample_t* & buffer);
virtual AUD_IReader* createReader() const;
};
#endif //AUD_SQUAREREADER
#endif //AUD_DOUBLEFACTORY

@ -24,80 +24,51 @@
*/
#include "AUD_DoubleReader.h"
#include "AUD_Buffer.h"
#include <cstring>
static const char* specs_error = "AUD_DoubleReader: Both readers have to have "
"the same specs.";
AUD_DoubleReader::AUD_DoubleReader(AUD_IReader* reader1,
AUD_IReader* reader2) :
m_reader1(reader1), m_reader2(reader2)
m_reader1(reader1), m_reader2(reader2), m_finished1(false)
{
try
AUD_Specs s1, s2;
s1 = reader1->getSpecs();
s2 = reader2->getSpecs();
if(memcmp(&s1, &s2, sizeof(AUD_Specs)) != 0)
{
if(!reader1)
AUD_THROW(AUD_ERROR_READER);
if(!reader2)
AUD_THROW(AUD_ERROR_READER);
AUD_Specs s1, s2;
s1 = reader1->getSpecs();
s2 = reader2->getSpecs();
if(memcmp(&s1, &s2, sizeof(AUD_Specs)) != 0)
AUD_THROW(AUD_ERROR_READER);
delete reader1;
delete reader2;
AUD_THROW(AUD_ERROR_SPECS, specs_error);
}
catch(AUD_Exception)
{
if(reader1)
{
delete reader1; AUD_DELETE("reader")
}
if(reader2)
{
delete reader2; AUD_DELETE("reader")
}
throw;
}
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_finished1 = false;
}
AUD_DoubleReader::~AUD_DoubleReader()
{
delete m_reader1; AUD_DELETE("reader")
delete m_reader2; AUD_DELETE("reader")
delete m_buffer; AUD_DELETE("buffer")
delete m_reader1;
delete m_reader2;
}
bool AUD_DoubleReader::isSeekable()
bool AUD_DoubleReader::isSeekable() const
{
return false;
return m_reader1->isSeekable() && m_reader2->isSeekable();
}
void AUD_DoubleReader::seek(int position)
{
int length1 = m_reader1->getLength();
m_reader1->seek(position);
if(position < 0)
position = 0;
int pos1 = m_reader1->getPosition();
if(position < length1)
{
m_reader1->seek(position);
m_reader2->seek(0);
m_finished1 = false;
}
if((m_finished1 = (pos1 < position)))
m_reader2->seek(position - pos1);
else
{
m_reader2->seek(position-length1);
m_finished1 = true;
}
m_reader2->seek(0);
}
int AUD_DoubleReader::getLength()
int AUD_DoubleReader::getLength() const
{
int len1 = m_reader1->getLength();
int len2 = m_reader2->getLength();
@ -106,49 +77,45 @@ int AUD_DoubleReader::getLength()
return len1 + len2;
}
int AUD_DoubleReader::getPosition()
int AUD_DoubleReader::getPosition() const
{
return m_reader1->getPosition() + m_reader2->getPosition();
}
AUD_Specs AUD_DoubleReader::getSpecs()
AUD_Specs AUD_DoubleReader::getSpecs() const
{
return m_reader1->getSpecs();
}
AUD_ReaderType AUD_DoubleReader::getType()
{
if(m_reader1->getType() == AUD_TYPE_BUFFER &&
m_reader2->getType() == AUD_TYPE_BUFFER)
return AUD_TYPE_BUFFER;
return AUD_TYPE_STREAM;
}
bool AUD_DoubleReader::notify(AUD_Message &message)
{
return m_reader1->notify(message) | m_reader2->notify(message);
}
void AUD_DoubleReader::read(int & length, sample_t* & buffer)
{
if(!m_finished1)
{
int len = length;
m_reader1->read(len, buffer);
if(len < length)
{
AUD_Specs specs = m_reader1->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
if(m_buffer->getSize() < length * samplesize)
m_buffer->resize(length * samplesize);
memcpy(m_buffer->getBuffer(), buffer, len * samplesize);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
sample_t* buf = buffer;
buffer = m_buffer.getBuffer();
memcpy(buffer, buf, len * samplesize);
len = length - len;
length -= len;
m_reader2->read(len, buffer);
memcpy(m_buffer->getBuffer() + length * specs.channels, buffer,
m_reader2->read(len, buf);
memcpy(buffer + length * specs.channels, buf,
len * samplesize);
length += len;
buffer = m_buffer->getBuffer();
m_finished1 = true;
}
}

@ -27,7 +27,7 @@
#define AUD_DOUBLEREADER
#include "AUD_IReader.h"
class AUD_Buffer;
#include "AUD_Buffer.h"
/**
* This reader plays two readers with the same specs sequently.
@ -53,15 +53,18 @@ private:
/**
* The playback buffer for the intersecting part.
*/
AUD_Buffer* m_buffer;
AUD_Buffer m_buffer;
// hide copy constructor and operator=
AUD_DoubleReader(const AUD_DoubleReader&);
AUD_DoubleReader& operator=(const AUD_DoubleReader&);
public:
/**
* Creates a new ping pong reader.
* \param reader1 The first reader to read from.
* \param reader2 The second reader to read from.
* \exception AUD_Exception Thrown if one of the reader specified is NULL
* or the specs from the readers differ.
* \exception AUD_Exception Thrown if the specs from the readers differ.
*/
AUD_DoubleReader(AUD_IReader* reader1, AUD_IReader* reader2);
@ -70,13 +73,11 @@ public:
*/
virtual ~AUD_DoubleReader();
virtual bool isSeekable();
virtual bool isSeekable() const;
virtual void seek(int position);
virtual int getLength();
virtual int getPosition();
virtual AUD_Specs getSpecs();
virtual AUD_ReaderType getType();
virtual bool notify(AUD_Message &message);
virtual int getLength() const;
virtual int getPosition() const;
virtual AUD_Specs getSpecs() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -26,25 +26,16 @@
#include "AUD_EffectFactory.h"
#include "AUD_IReader.h"
AUD_IReader* AUD_EffectFactory::getReader()
{
if(m_factory != 0)
return m_factory->createReader();
return 0;
}
AUD_EffectFactory::AUD_EffectFactory(AUD_IFactory* factory)
{
m_factory = factory;
}
void AUD_EffectFactory::setFactory(AUD_IFactory* factory)
AUD_EffectFactory::~AUD_EffectFactory()
{
m_factory = factory;
}
AUD_IFactory* AUD_EffectFactory::getFactory()
AUD_IFactory* AUD_EffectFactory::getFactory() const
{
return m_factory;
}

@ -34,6 +34,11 @@
*/
class AUD_EffectFactory : public AUD_IFactory
{
private:
// hide copy constructor and operator=
AUD_EffectFactory(const AUD_EffectFactory&);
AUD_EffectFactory& operator=(const AUD_EffectFactory&);
protected:
/**
* If there is no reader it is created out of this factory.
@ -44,9 +49,12 @@ protected:
* Returns the reader created out of the factory.
* This method can be used for the createReader function of the implementing
* classes.
* \return The reader created out of the factory or NULL if there is none.
* \return The reader created out of the factory.
*/
AUD_IReader* getReader();
inline AUD_IReader* getReader() const
{
return m_factory->createReader();
}
public:
/**
@ -58,19 +66,13 @@ public:
/**
* Destroys the factory.
*/
virtual ~AUD_EffectFactory() {}
/**
* Sets the input factory.
* \param factory The input factory.
*/
void setFactory(AUD_IFactory* factory);
virtual ~AUD_EffectFactory();
/**
* Returns the saved factory.
* \return The factory or NULL if there has no factory been saved.
*/
AUD_IFactory* getFactory();
AUD_IFactory* getFactory() const;
};
#endif //AUD_EFFECTFACTORY

@ -27,17 +27,15 @@
AUD_EffectReader::AUD_EffectReader(AUD_IReader* reader)
{
if(!reader)
AUD_THROW(AUD_ERROR_READER);
m_reader = reader;
}
AUD_EffectReader::~AUD_EffectReader()
{
delete m_reader; AUD_DELETE("reader")
delete m_reader;
}
bool AUD_EffectReader::isSeekable()
bool AUD_EffectReader::isSeekable() const
{
return m_reader->isSeekable();
}
@ -47,31 +45,21 @@ void AUD_EffectReader::seek(int position)
m_reader->seek(position);
}
int AUD_EffectReader::getLength()
int AUD_EffectReader::getLength() const
{
return m_reader->getLength();
}
int AUD_EffectReader::getPosition()
int AUD_EffectReader::getPosition() const
{
return m_reader->getPosition();
}
AUD_Specs AUD_EffectReader::getSpecs()
AUD_Specs AUD_EffectReader::getSpecs() const
{
return m_reader->getSpecs();
}
AUD_ReaderType AUD_EffectReader::getType()
{
return m_reader->getType();
}
bool AUD_EffectReader::notify(AUD_Message &message)
{
return m_reader->notify(message);
}
void AUD_EffectReader::read(int & length, sample_t* & buffer)
{
m_reader->read(length, buffer);

@ -34,6 +34,11 @@
*/
class AUD_EffectReader : public AUD_IReader
{
private:
// hide copy constructor and operator=
AUD_EffectReader(const AUD_EffectReader&);
AUD_EffectReader& operator=(const AUD_EffectReader&);
protected:
/**
* The reader to read from.
@ -44,7 +49,6 @@ public:
/**
* Creates a new effect reader.
* \param reader The reader to read from.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_EffectReader(AUD_IReader* reader);
@ -53,13 +57,11 @@ public:
*/
virtual ~AUD_EffectReader();
virtual bool isSeekable();
virtual bool isSeekable() const;
virtual void seek(int position);
virtual int getLength();
virtual int getPosition();
virtual AUD_Specs getSpecs();
virtual AUD_ReaderType getType();
virtual bool notify(AUD_Message &message);
virtual int getLength() const;
virtual int getPosition() const;
virtual AUD_Specs getSpecs() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -24,7 +24,31 @@
*/
#include "AUD_EnvelopeFactory.h"
#include "AUD_EnvelopeReader.h"
#include "AUD_CallbackIIRFilterReader.h"
#include <cmath>
struct EnvelopeParameters
{
float attack;
float release;
float threshold;
float arthreshold;
};
sample_t envelopeFilter(AUD_CallbackIIRFilterReader* reader, EnvelopeParameters* param)
{
float in = fabs(reader->x(0));
float out = reader->y(-1);
if(in < param->threshold)
in = 0.0f;
return (in > out ? param->attack : param->release) * (out - in) + in;
}
void endEnvelopeFilter(EnvelopeParameters* param)
{
delete param;
}
AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_IFactory* factory, float attack,
float release, float threshold,
@ -33,26 +57,22 @@ AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_IFactory* factory, float attack,
m_attack(attack),
m_release(release),
m_threshold(threshold),
m_arthreshold(arthreshold) {}
m_arthreshold(arthreshold)
{
}
AUD_EnvelopeFactory::AUD_EnvelopeFactory(float attack, float release,
float threshold, float arthreshold) :
AUD_EffectFactory(0),
m_attack(attack),
m_release(release),
m_threshold(threshold),
m_arthreshold(arthreshold) {}
AUD_IReader* AUD_EnvelopeFactory::createReader()
AUD_IReader* AUD_EnvelopeFactory::createReader() const
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_EnvelopeReader(reader, m_attack, m_release,
m_threshold, m_arthreshold);
AUD_NEW("reader")
}
EnvelopeParameters* param = new EnvelopeParameters();
param->arthreshold = m_arthreshold;
param->attack = pow(m_arthreshold, 1.0f/(reader->getSpecs().rate * m_attack));
param->release = pow(m_arthreshold, 1.0f/(reader->getSpecs().rate * m_release));
param->threshold = m_threshold;
return reader;
return new AUD_CallbackIIRFilterReader(reader, 1, 2,
(doFilterIIR) envelopeFilter,
(endFilterIIR) endEnvelopeFilter,
param);
}

@ -37,22 +37,26 @@ private:
/**
* The attack value in seconds.
*/
float m_attack;
const float m_attack;
/**
* The release value in seconds.
*/
float m_release;
const float m_release;
/**
* The threshold value.
*/
float m_threshold;
const float m_threshold;
/**
* The attack/release threshold value.
*/
float m_arthreshold;
const float m_arthreshold;
// hide copy constructor and operator=
AUD_EnvelopeFactory(const AUD_EnvelopeFactory&);
AUD_EnvelopeFactory& operator=(const AUD_EnvelopeFactory&);
public:
/**
@ -66,17 +70,7 @@ public:
AUD_EnvelopeFactory(AUD_IFactory* factory, float attack, float release,
float threshold, float arthreshold);
/**
* Creates a new envelope factory.
* \param attack The attack value in seconds.
* \param release The release value in seconds.
* \param threshold The threshold value.
* \param arthreshold The attack/release threshold value.
*/
AUD_EnvelopeFactory(float attack, float release, float threshold,
float arthreshold);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_ENVELOPEFACTORY

@ -1,86 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_EnvelopeReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#include <cmath>
AUD_EnvelopeReader::AUD_EnvelopeReader(AUD_IReader* reader, float attack,
float release, float threshold,
float arthreshold) :
AUD_EffectReader(reader),
m_threshold(threshold)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_envelopes = new AUD_Buffer(samplesize);
AUD_NEW("buffer")
memset(m_envelopes->getBuffer(), 0, samplesize);
m_bAttack = pow(arthreshold, 1.0f/(specs.rate * attack));
m_bRelease = pow(arthreshold, 1.0f/(specs.rate * release));
}
AUD_EnvelopeReader::~AUD_EnvelopeReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_envelopes; AUD_DELETE("buffer")
}
void AUD_EnvelopeReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* envelopes;
envelopes = m_envelopes->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
sample_t value;
for(int channel = 0; channel < specs.channels; channel++)
{
for(int i = 0; i < length; i++)
{
value = fabs(buf[i * specs.channels + channel]);
if(value < m_threshold)
value = 0.0f;
buffer[i * specs.channels + channel] = envelopes[channel] =
((value > envelopes[channel]) ? m_bAttack : m_bRelease) *
(envelopes[channel] - value) + value;
}
}
}

@ -1,84 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_ENVELOPEREADER
#define AUD_ENVELOPEREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
/**
* This class represents an envelope follower.
*/
class AUD_EnvelopeReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The last envelopes buffer.
*/
AUD_Buffer *m_envelopes;
/**
* Attack b value.
*/
float m_bAttack;
/**
* Release b value.
*/
float m_bRelease;
/**
* Threshold value.
*/
float m_threshold;
public:
/**
* Creates a new envelope reader.
* \param reader The reader to read from.
* \param attack The attack value in seconds.
* \param release The release value in seconds.
* \param threshold The threshold value.
* \param arthreshold The attack/release threshold value.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_EnvelopeReader(AUD_IReader* reader, float attack, float release,
float threshold, float arthreshold);
/**
* Destroys the reader.
*/
virtual ~AUD_EnvelopeReader();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_ENVELOPEREADER

@ -31,54 +31,26 @@ AUD_FaderFactory::AUD_FaderFactory(AUD_IFactory* factory, AUD_FadeType type,
AUD_EffectFactory(factory),
m_type(type),
m_start(start),
m_length(length) {}
m_length(length)
{
}
AUD_FaderFactory::AUD_FaderFactory(AUD_FadeType type,
float start, float length) :
AUD_EffectFactory(0),
m_type(type),
m_start(start),
m_length(length) {}
AUD_FadeType AUD_FaderFactory::getType()
AUD_FadeType AUD_FaderFactory::getType() const
{
return m_type;
}
void AUD_FaderFactory::setType(AUD_FadeType type)
{
m_type = type;
}
float AUD_FaderFactory::getStart()
float AUD_FaderFactory::getStart() const
{
return m_start;
}
void AUD_FaderFactory::setStart(float start)
{
m_start = start;
}
float AUD_FaderFactory::getLength()
float AUD_FaderFactory::getLength() const
{
return m_length;
}
void AUD_FaderFactory::setLength(float length)
AUD_IReader* AUD_FaderFactory::createReader() const
{
m_length = length;
}
AUD_IReader* AUD_FaderFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_FaderReader(reader, m_type, m_start, m_length);
AUD_NEW("reader")
}
return reader;
return new AUD_FaderReader(getReader(), m_type, m_start, m_length);
}

@ -39,17 +39,21 @@ private:
/**
* The fading type.
*/
AUD_FadeType m_type;
const AUD_FadeType m_type;
/**
* The fading start.
*/
float m_start;
const float m_start;
/**
* The fading length.
*/
float m_length;
const float m_length;
// hide copy constructor and operator=
AUD_FaderFactory(const AUD_FaderFactory&);
AUD_FaderFactory& operator=(const AUD_FaderFactory&);
public:
/**
@ -59,53 +63,26 @@ public:
* \param start The time where fading should start in seconds.
* \param length How long fading should last in seconds.
*/
AUD_FaderFactory(AUD_IFactory* factory = 0,
AUD_FaderFactory(AUD_IFactory* factory,
AUD_FadeType type = AUD_FADE_IN,
float start = 0.0f, float length = 1.0f);
/**
* Creates a new fader factory.
* \param type The fading type.
* \param start The time where fading should start in seconds.
* \param length How long fading should last in seconds.
*/
AUD_FaderFactory(AUD_FadeType type = AUD_FADE_IN,
float start = 0.0f, float length = 1.0f);
/**
* Returns the fading type.
*/
AUD_FadeType getType();
/**
* Sets the fading type.
* \param type The new fading type: AUD_FADE_IN or AUD_FADE_OUT.
*/
void setType(AUD_FadeType type);
AUD_FadeType getType() const;
/**
* Returns the fading start.
*/
float getStart();
/**
* Sets the fading start.
* \param start The new fading start.
*/
void setStart(float start);
float getStart() const;
/**
* Returns the fading length.
*/
float getLength();
float getLength() const;
/**
* Sets the fading length.
* \param start The new fading length.
*/
void setLength(float length);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_FADERFACTORY

@ -24,7 +24,6 @@
*/
#include "AUD_FaderReader.h"
#include "AUD_Buffer.h"
#include <cstring>
@ -33,19 +32,9 @@ AUD_FaderReader::AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type,
AUD_EffectReader(reader),
m_type(type),
m_start(start),
m_length(length)
m_length(length),
m_empty(true)
{
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_FaderReader::~AUD_FaderReader()
{
delete m_buffer; AUD_DELETE("buffer")
}
bool AUD_FaderReader::notify(AUD_Message &message)
{
return m_reader->notify(message);
}
void AUD_FaderReader::read(int & length, sample_t* & buffer)
@ -56,28 +45,50 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer)
m_reader->read(length, buffer);
if(m_buffer->getSize() < length * samplesize)
m_buffer->resize(length * samplesize);
if((position + length) / (float)specs.rate <= m_start)
{
if(m_type != AUD_FADE_OUT)
{
buffer = m_buffer->getBuffer();
memset(buffer, 0, length * samplesize);
if(m_buffer.getSize() < length * samplesize)
{
m_buffer.resize(length * samplesize);
m_empty = false;
}
buffer = m_buffer.getBuffer();
if(!m_empty)
{
memset(buffer, 0, length * samplesize);
m_empty = true;
}
}
}
else if(position / (float)specs.rate >= m_start+m_length)
{
if(m_type == AUD_FADE_OUT)
{
buffer = m_buffer->getBuffer();
memset(buffer, 0, length * samplesize);
if(m_buffer.getSize() < length * samplesize)
{
m_buffer.resize(length * samplesize);
m_empty = false;
}
buffer = m_buffer.getBuffer();
if(!m_empty)
{
memset(buffer, 0, length * samplesize);
m_empty = true;
}
}
}
else
{
sample_t* buf = m_buffer->getBuffer();
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
sample_t* buf = m_buffer.getBuffer();
float volume = 1.0f;
for(int i = 0; i < length * specs.channels; i++)
@ -98,5 +109,6 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer)
}
buffer = buf;
m_empty = false;
}
}

@ -27,7 +27,7 @@
#define AUD_FADERREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_Buffer.h"
/**
* This class fades another reader.
@ -37,25 +37,34 @@ class AUD_Buffer;
class AUD_FaderReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The fading type.
*/
AUD_FadeType m_type;
const AUD_FadeType m_type;
/**
* The fading start.
*/
float m_start;
const float m_start;
/**
* The fading length.
*/
float m_length;
const float m_length;
/**
* The playback buffer.
*/
AUD_Buffer m_buffer;
/**
* Whether the buffer is empty.
*/
bool m_empty;
// hide copy constructor and operator=
AUD_FaderReader(const AUD_FaderReader&);
AUD_FaderReader& operator=(const AUD_FaderReader&);
public:
/**
@ -63,17 +72,10 @@ public:
* \param type The fading type.
* \param start The time where fading should start in seconds.
* \param length How long fading should last in seconds.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type,
float start,float length);
/**
* Destroys the reader.
*/
virtual ~AUD_FaderReader();
virtual bool notify(AUD_Message &message);
virtual void read(int & length, sample_t* & buffer);
};

@ -24,28 +24,38 @@
*/
#include "AUD_HighpassFactory.h"
#include "AUD_HighpassReader.h"
#include "AUD_IIRFilterReader.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
AUD_HighpassFactory::AUD_HighpassFactory(AUD_IFactory* factory, float frequency,
float Q) :
AUD_EffectFactory(factory),
m_frequency(frequency),
m_Q(Q) {}
m_Q(Q)
{
}
AUD_HighpassFactory::AUD_HighpassFactory(float frequency, float Q) :
AUD_EffectFactory(0),
m_frequency(frequency),
m_Q(Q) {}
AUD_IReader* AUD_HighpassFactory::createReader()
AUD_IReader* AUD_HighpassFactory::createReader() const
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_HighpassReader(reader, m_frequency, m_Q);
AUD_NEW("reader")
}
// calculate coefficients
float w0 = 2 * M_PI * m_frequency / reader->getSpecs().rate;
float alpha = sin(w0) / (2 * m_Q);
float norm = 1 + alpha;
float c = cos(w0);
std::vector<float> a, b;
a.push_back(1);
a.push_back(-2 * c / norm);
a.push_back((1 - alpha) / norm);
b.push_back((1 + c) / (2 * norm));
b.push_back((-1 - c) / norm);
b.push_back(b[0]);
return reader;
return new AUD_IIRFilterReader(reader, b, a);
}

@ -37,12 +37,16 @@ private:
/**
* The attack value in seconds.
*/
float m_frequency;
const float m_frequency;
/**
* The Q factor.
*/
float m_Q;
const float m_Q;
// hide copy constructor and operator=
AUD_HighpassFactory(const AUD_HighpassFactory&);
AUD_HighpassFactory& operator=(const AUD_HighpassFactory&);
public:
/**
@ -53,14 +57,7 @@ public:
*/
AUD_HighpassFactory(AUD_IFactory* factory, float frequency, float Q = 1.0f);
/**
* Creates a new highpass factory.
* \param frequency The cutoff frequency.
* \param Q The Q factor.
*/
AUD_HighpassFactory(float frequency, float Q = 1.0f);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_HIGHPASSFACTORY

@ -1,116 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_HighpassReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define CC channels + channel
AUD_HighpassReader::AUD_HighpassReader(AUD_IReader* reader, float frequency,
float Q) :
AUD_EffectReader(reader)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_outvalues = new AUD_Buffer(samplesize * AUD_HIGHPASS_ORDER);
AUD_NEW("buffer")
memset(m_outvalues->getBuffer(), 0, samplesize * AUD_HIGHPASS_ORDER);
m_invalues = new AUD_Buffer(samplesize * AUD_HIGHPASS_ORDER);
AUD_NEW("buffer")
memset(m_invalues->getBuffer(), 0, samplesize * AUD_HIGHPASS_ORDER);
m_position = 0;
// calculate coefficients
float w0 = 2 * M_PI * frequency / specs.rate;
float alpha = sin(w0) / (2 * Q);
float norm = 1 + alpha;
m_coeff[0][0] = 0;
m_coeff[0][1] = -2 * cos(w0) / norm;
m_coeff[0][2] = (1 - alpha) / norm;
m_coeff[1][2] = m_coeff[1][0] = (1 + cos(w0)) / (2 * norm);
m_coeff[1][1] = (-1 - cos(w0)) / norm;
}
AUD_HighpassReader::~AUD_HighpassReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_outvalues; AUD_DELETE("buffer")
delete m_invalues; AUD_DELETE("buffer");
}
void AUD_HighpassReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* outvalues;
sample_t* invalues;
outvalues = m_outvalues->getBuffer();
invalues = m_invalues->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
int channels = specs.channels;
for(int channel = 0; channel < channels; channel++)
{
for(int i = 0; i < length; i++)
{
invalues[m_position * CC] = buf[i * CC];
outvalues[m_position * CC] = 0;
for(int j = 0; j < AUD_HIGHPASS_ORDER; j++)
{
outvalues[m_position * CC] += m_coeff[1][j] *
invalues[((m_position + j) % AUD_HIGHPASS_ORDER) * CC] -
m_coeff[0][j] *
outvalues[((m_position + j) % AUD_HIGHPASS_ORDER) * CC];
}
buffer[i * CC] = outvalues[m_position * CC];
m_position = (m_position + AUD_HIGHPASS_ORDER-1) %
AUD_HIGHPASS_ORDER;
}
}
}

@ -1,83 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_HIGHPASSREADER
#define AUD_HIGHPASSREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#define AUD_HIGHPASS_ORDER 3
/**
* This class represents a highpass filter.
*/
class AUD_HighpassReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The last out values buffer.
*/
AUD_Buffer *m_outvalues;
/**
* The last in values buffer.
*/
AUD_Buffer *m_invalues;
/**
* The position for buffer cycling.
*/
int m_position;
/**
* Filter coefficients.
*/
float m_coeff[2][AUD_HIGHPASS_ORDER];
public:
/**
* Creates a new highpass reader.
* \param reader The reader to read from.
* \param frequency The cutoff frequency.
* \param Q The Q factor.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_HighpassReader(AUD_IReader* reader, float frequency, float Q);
/**
* Destroys the reader.
*/
virtual ~AUD_HighpassReader();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_HIGHPASSREADER

@ -0,0 +1,39 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_IIRFilterFactory.h"
#include "AUD_IIRFilterReader.h"
AUD_IIRFilterFactory::AUD_IIRFilterFactory(AUD_IFactory* factory,
std::vector<float> b,
std::vector<float> a) :
AUD_EffectFactory(factory), m_a(a), m_b(b)
{
}
AUD_IReader* AUD_IIRFilterFactory::createReader() const
{
return new AUD_IIRFilterReader(getReader(), m_b, m_a);
}

@ -0,0 +1,66 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_IIRFILTERFACTORY
#define AUD_IIRFILTERFACTORY
#include "AUD_EffectFactory.h"
#include <vector>
/**
* This factory creates a IIR filter reader.
*/
class AUD_IIRFilterFactory : public AUD_EffectFactory
{
private:
/**
* Output filter coefficients.
*/
std::vector<float> m_a;
/**
* Input filter coefficients.
*/
std::vector<float> m_b;
// hide copy constructor and operator=
AUD_IIRFilterFactory(const AUD_IIRFilterFactory&);
AUD_IIRFilterFactory& operator=(const AUD_IIRFilterFactory&);
public:
/**
* Creates a new IIR filter factory.
* \param factory The input factory.
* \param b The input filter coefficients.
* \param a The output filter coefficients.
*/
AUD_IIRFilterFactory(AUD_IFactory* factory, std::vector<float> b,
std::vector<float> a);
virtual AUD_IReader* createReader() const;
};
#endif //AUD_IIRFILTERFACTORY

@ -0,0 +1,50 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_IIRFilterReader.h"
AUD_IIRFilterReader::AUD_IIRFilterReader(AUD_IReader* reader,
std::vector<float> b,
std::vector<float> a) :
AUD_BaseIIRFilterReader(reader, b.size(), a.size()), m_a(a), m_b(b)
{
for(int i = 1; i < m_a.size(); i++)
m_a[i] /= m_a[0];
for(int i = 0; i < m_b.size(); i++)
m_b[i] /= m_a[0];
m_a[0] = 1;
}
sample_t AUD_IIRFilterReader::filter()
{
sample_t out = 0;
for(int i = 1; i < m_a.size(); i++)
out -= y(-i) * m_a[i];
for(int i = 0; i < m_b.size(); i++)
out += x(-i) * m_b[i];
return out;
}

@ -23,44 +23,44 @@
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_VOLUMEREADER
#define AUD_VOLUMEREADER
#ifndef AUD_IIRFILTERREADER
#define AUD_IIRFILTERREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_BaseIIRFilterReader.h"
#include <vector>
/**
* This class reads another reader and changes it's volume.
* This class is for infinite impulse response filters with simple coefficients.
*/
class AUD_VolumeReader : public AUD_EffectReader
class AUD_IIRFilterReader : public AUD_BaseIIRFilterReader
{
private:
/**
* The playback buffer.
* Output filter coefficients.
*/
AUD_Buffer *m_buffer;
std::vector<float> m_a;
/**
* The volume level.
* Input filter coefficients.
*/
float m_volume;
std::vector<float> m_b;
// hide copy constructor and operator=
AUD_IIRFilterReader(const AUD_IIRFilterReader&);
AUD_IIRFilterReader& operator=(const AUD_IIRFilterReader&);
public:
/**
* Creates a new volume reader.
* Creates a new IIR filter reader.
* \param reader The reader to read from.
* \param volume The size of the buffer.
* \exception AUD_Exception Thrown if the reader specified is NULL.
* \param b The input filter coefficients.
* \param a The output filter coefficients.
*/
AUD_VolumeReader(AUD_IReader* reader, float volume);
AUD_IIRFilterReader(AUD_IReader* reader, std::vector<float> b,
std::vector<float> a);
/**
* Destroys the reader.
*/
virtual ~AUD_VolumeReader();
virtual bool notify(AUD_Message &message);
virtual void read(int & length, sample_t* & buffer);
virtual sample_t filter();
};
#endif //AUD_VOLUMEREADER
#endif //AUD_IIRFILTERREADER

@ -31,37 +31,21 @@ AUD_LimiterFactory::AUD_LimiterFactory(AUD_IFactory* factory,
float start, float end) :
AUD_EffectFactory(factory),
m_start(start),
m_end(end) {}
m_end(end)
{
}
float AUD_LimiterFactory::getStart()
float AUD_LimiterFactory::getStart() const
{
return m_start;
}
void AUD_LimiterFactory::setStart(float start)
{
m_start = start;
}
float AUD_LimiterFactory::getEnd()
float AUD_LimiterFactory::getEnd() const
{
return m_end;
}
void AUD_LimiterFactory::setEnd(float end)
AUD_IReader* AUD_LimiterFactory::createReader() const
{
m_end = end;
}
AUD_IReader* AUD_LimiterFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_LimiterReader(reader, m_start, m_end);
AUD_NEW("reader")
}
return reader;
return new AUD_LimiterReader(getReader(), m_start, m_end);
}

@ -37,12 +37,16 @@ private:
/**
* The start time.
*/
float m_start;
const float m_start;
/**
* The end time.
*/
float m_end;
const float m_end;
// hide copy constructor and operator=
AUD_LimiterFactory(const AUD_LimiterFactory&);
AUD_LimiterFactory& operator=(const AUD_LimiterFactory&);
public:
/**
@ -52,33 +56,20 @@ public:
* \param end The desired end time, a negative value signals that it should
* play to the end.
*/
AUD_LimiterFactory(AUD_IFactory* factory = 0,
AUD_LimiterFactory(AUD_IFactory* factory,
float start = 0, float end = -1);
/**
* Returns the start time.
*/
float getStart();
/**
* Sets the start time.
* \param start The new start time.
*/
void setStart(float start);
float getStart() const;
/**
* Returns the end time.
*/
float getEnd();
float getEnd() const;
/**
* Sets the end time.
* \param end The new end time, a negative value signals that it should play
* to the end.
*/
void setEnd(float end);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_LIMITERFACTORY

@ -30,31 +30,27 @@
AUD_LimiterReader::AUD_LimiterReader(AUD_IReader* reader,
float start, float end) :
AUD_EffectReader(reader)
AUD_EffectReader(reader),
m_start(int(start * reader->getSpecs().rate)),
m_end(int(end * reader->getSpecs().rate))
{
m_end = (int)(end * reader->getSpecs().rate);
if(start <= 0)
m_start = 0;
else
if(m_start > 0)
{
m_start = (int)(start * reader->getSpecs().rate);
if(m_reader->isSeekable())
m_reader->seek(m_start);
else
{
// skip first m_start samples by reading them
int length;
int length = AUD_DEFAULT_BUFFER_SIZE;
sample_t* buffer;
for(int i = m_start;
i >= AUD_DEFAULT_BUFFER_SIZE;
i -= AUD_DEFAULT_BUFFER_SIZE)
for(int len = m_start;
length == AUD_DEFAULT_BUFFER_SIZE;
len -= AUD_DEFAULT_BUFFER_SIZE)
{
length = AUD_DEFAULT_BUFFER_SIZE;
if(len < AUD_DEFAULT_BUFFER_SIZE)
length = len;
m_reader->read(length, buffer);
length = i;
}
m_reader->read(length, buffer);
}
}
}
@ -64,18 +60,18 @@ void AUD_LimiterReader::seek(int position)
m_reader->seek(position + m_start);
}
int AUD_LimiterReader::getLength()
int AUD_LimiterReader::getLength() const
{
int len = m_reader->getLength();
if(m_reader->getType() != AUD_TYPE_BUFFER || len < 0 ||
(len > m_end && m_end >= 0))
if(len < 0 || (len > m_end && m_end >= 0))
len = m_end;
return len - m_start;
}
int AUD_LimiterReader::getPosition()
int AUD_LimiterReader::getPosition() const
{
return m_reader->getPosition() - m_start;
int pos = m_reader->getPosition();
return AUD_MIN(pos, m_end) - m_start;
}
void AUD_LimiterReader::read(int & length, sample_t* & buffer)
@ -83,7 +79,7 @@ void AUD_LimiterReader::read(int & length, sample_t* & buffer)
if(m_end >= 0)
{
int position = m_reader->getPosition();
if(position+length > m_end)
if(position + length > m_end)
length = m_end - position;
if(length < 0)
{

@ -37,12 +37,16 @@ private:
/**
* The start sample: inclusive.
*/
int m_start;
const int m_start;
/**
* The end sample: exlusive.
*/
int m_end;
const int m_end;
// hide copy constructor and operator=
AUD_LimiterReader(const AUD_LimiterReader&);
AUD_LimiterReader& operator=(const AUD_LimiterReader&);
public:
/**
@ -51,13 +55,12 @@ public:
* \param start The desired start sample (inclusive).
* \param end The desired end sample (exklusive), a negative value signals
* that it should play to the end.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_LimiterReader(AUD_IReader* reader, float start = 0, float end = -1);
virtual void seek(int position);
virtual int getLength();
virtual int getPosition();
virtual int getLength() const;
virtual int getPosition() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -28,30 +28,16 @@
AUD_LoopFactory::AUD_LoopFactory(AUD_IFactory* factory, int loop) :
AUD_EffectFactory(factory),
m_loop(loop) {}
m_loop(loop)
{
}
AUD_LoopFactory::AUD_LoopFactory(int loop) :
AUD_EffectFactory(0),
m_loop(loop) {}
int AUD_LoopFactory::getLoop()
int AUD_LoopFactory::getLoop() const
{
return m_loop;
}
void AUD_LoopFactory::setLoop(int loop)
AUD_IReader* AUD_LoopFactory::createReader() const
{
m_loop = loop;
}
AUD_IReader* AUD_LoopFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_LoopReader(reader, m_loop); AUD_NEW("reader")
}
return reader;
return new AUD_LoopReader(getReader(), m_loop);
}

@ -38,7 +38,11 @@ private:
/**
* The loop count.
*/
int m_loop;
const int m_loop;
// hide copy constructor and operator=
AUD_LoopFactory(const AUD_LoopFactory&);
AUD_LoopFactory& operator=(const AUD_LoopFactory&);
public:
/**
@ -47,28 +51,14 @@ public:
* \param loop The desired loop count, negative values result in endless
* looping.
*/
AUD_LoopFactory(AUD_IFactory* factory = 0, int loop = -1);
/**
* Creates a new loop factory.
* \param loop The desired loop count, negative values result in endless
* looping.
*/
AUD_LoopFactory(int loop);
AUD_LoopFactory(AUD_IFactory* factory, int loop = -1);
/**
* Returns the loop count.
*/
int getLoop();
int getLoop() const;
/**
* Sets the loop count.
* \param loop The desired loop count, negative values result in endless
* looping.
*/
void setLoop(int loop);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_LOOPFACTORY

@ -29,36 +29,37 @@
#include <cstring>
AUD_LoopReader::AUD_LoopReader(AUD_IReader* reader, int loop) :
AUD_EffectReader(reader), m_loop(loop)
AUD_EffectReader(reader), m_count(loop), m_left(loop)
{
m_samples = -1;
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_LoopReader::~AUD_LoopReader()
void AUD_LoopReader::seek(int position)
{
delete m_buffer; AUD_DELETE("buffer")
}
AUD_ReaderType AUD_LoopReader::getType()
{
if(m_loop < 0)
return AUD_TYPE_STREAM;
return m_reader->getType();
}
bool AUD_LoopReader::notify(AUD_Message &message)
{
if(message.type == AUD_MSG_LOOP)
int len = m_reader->getLength();
if(len < 0)
m_reader->seek(position);
else
{
m_loop = message.loopcount;
m_samples = message.time * m_reader->getSpecs().rate;
m_reader->notify(message);
return true;
if(m_count >= 0)
{
m_left = m_count - (position / len);
if(m_left < 0)
m_left = 0;
}
m_reader->seek(position % len);
}
return m_reader->notify(message);
}
int AUD_LoopReader::getLength() const
{
if(m_count < 0)
return -1;
return m_reader->getLength() * m_count;
}
int AUD_LoopReader::getPosition() const
{
return m_reader->getPosition() * (m_count < 0 ? 1 : m_count);
}
void AUD_LoopReader::read(int & length, sample_t* & buffer)
@ -66,50 +67,44 @@ void AUD_LoopReader::read(int & length, sample_t* & buffer)
AUD_Specs specs = m_reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
if(m_samples >= 0)
{
if(length > m_samples)
length = m_samples;
m_samples -= length;
}
int len = length;
m_reader->read(len, buffer);
if(len < length && m_loop != 0)
if(len < length && m_left)
{
int pos = 0;
if(m_buffer->getSize() < length * samplesize)
m_buffer->resize(length * samplesize);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
memcpy(m_buffer->getBuffer() + pos * specs.channels,
buffer, len * samplesize);
sample_t* buf = m_buffer.getBuffer();
memcpy(buf + pos * specs.channels, buffer, len * samplesize);
pos += len;
while(pos < length && m_loop != 0)
while(pos < length && m_left)
{
if(m_loop > 0)
m_loop--;
if(m_left > 0)
m_left--;
m_reader->seek(0);
len = length - pos;
m_reader->read(len, buffer);
// prevent endless loop
if(!len)
break;
memcpy(m_buffer->getBuffer() + pos * specs.channels,
buffer, len * samplesize);
memcpy(buf + pos * specs.channels, buffer, len * samplesize);
pos += len;
}
length = pos;
buffer = m_buffer->getBuffer();
buffer = buf;
}
else
length = len;

@ -27,7 +27,7 @@
#define AUD_LOOPREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_Buffer.h"
/**
* This class reads another reader and loops it.
@ -39,17 +39,21 @@ private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
AUD_Buffer m_buffer;
/**
* The loop count.
*/
const int m_count;
/**
* The left loop count.
*/
int m_loop;
int m_left;
/**
* The left samples.
*/
int m_samples;
// hide copy constructor and operator=
AUD_LoopReader(const AUD_LoopReader&);
AUD_LoopReader& operator=(const AUD_LoopReader&);
public:
/**
@ -57,17 +61,12 @@ public:
* \param reader The reader to read from.
* \param loop The desired loop count, negative values result in endless
* looping.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_LoopReader(AUD_IReader* reader, int loop);
/**
* Destroys the reader.
*/
virtual ~AUD_LoopReader();
virtual AUD_ReaderType getType();
virtual bool notify(AUD_Message &message);
virtual void seek(int position);
virtual int getLength() const;
virtual int getPosition() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -24,28 +24,38 @@
*/
#include "AUD_LowpassFactory.h"
#include "AUD_LowpassReader.h"
#include "AUD_IIRFilterReader.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
AUD_LowpassFactory::AUD_LowpassFactory(AUD_IFactory* factory, float frequency,
float Q) :
AUD_EffectFactory(factory),
m_frequency(frequency),
m_Q(Q) {}
m_Q(Q)
{
}
AUD_LowpassFactory::AUD_LowpassFactory(float frequency, float Q) :
AUD_EffectFactory(0),
m_frequency(frequency),
m_Q(Q) {}
AUD_IReader* AUD_LowpassFactory::createReader()
AUD_IReader* AUD_LowpassFactory::createReader() const
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_LowpassReader(reader, m_frequency, m_Q);
AUD_NEW("reader")
}
// calculate coefficients
float w0 = 2 * M_PI * m_frequency / reader->getSpecs().rate;
float alpha = sin(w0) / (2 * m_Q);
float norm = 1 + alpha;
float c = cos(w0);
std::vector<float> a, b;
a.push_back(1);
a.push_back(-2 * c / norm);
a.push_back((1 - alpha) / norm);
b.push_back((1 - c) / (2 * norm));
b.push_back((1 - c) / norm);
b.push_back(b[0]);
return reader;
return new AUD_IIRFilterReader(reader, b, a);
}

@ -37,12 +37,16 @@ private:
/**
* The attack value in seconds.
*/
float m_frequency;
const float m_frequency;
/**
* The Q factor.
*/
float m_Q;
const float m_Q;
// hide copy constructor and operator=
AUD_LowpassFactory(const AUD_LowpassFactory&);
AUD_LowpassFactory& operator=(const AUD_LowpassFactory&);
public:
/**
@ -53,14 +57,7 @@ public:
*/
AUD_LowpassFactory(AUD_IFactory* factory, float frequency, float Q = 1.0f);
/**
* Creates a new lowpass factory.
* \param frequency The cutoff frequency.
* \param Q The Q factor.
*/
AUD_LowpassFactory(float frequency, float Q = 1.0f);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_LOWPASSFACTORY

@ -1,115 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_LowpassReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define CC channels + channel
AUD_LowpassReader::AUD_LowpassReader(AUD_IReader* reader, float frequency,
float Q) :
AUD_EffectReader(reader)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_outvalues = new AUD_Buffer(samplesize * AUD_LOWPASS_ORDER);
AUD_NEW("buffer")
memset(m_outvalues->getBuffer(), 0, samplesize * AUD_LOWPASS_ORDER);
m_invalues = new AUD_Buffer(samplesize * AUD_LOWPASS_ORDER);
AUD_NEW("buffer")
memset(m_invalues->getBuffer(), 0, samplesize * AUD_LOWPASS_ORDER);
m_position = 0;
// calculate coefficients
float w0 = 2 * M_PI * frequency / specs.rate;
float alpha = sin(w0) / (2 * Q);
float norm = 1 + alpha;
m_coeff[0][0] = 0;
m_coeff[0][1] = -2 * cos(w0) / norm;
m_coeff[0][2] = (1 - alpha) / norm;
m_coeff[1][2] = m_coeff[1][0] = (1 - cos(w0)) / (2 * norm);
m_coeff[1][1] = (1 - cos(w0)) / norm;
}
AUD_LowpassReader::~AUD_LowpassReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_outvalues; AUD_DELETE("buffer")
delete m_invalues; AUD_DELETE("buffer");
}
void AUD_LowpassReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* outvalues;
sample_t* invalues;
outvalues = m_outvalues->getBuffer();
invalues = m_invalues->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
int channels = specs.channels;
for(int channel = 0; channel < channels; channel++)
{
for(int i = 0; i < length; i++)
{
invalues[m_position * CC] = buf[i * CC];
outvalues[m_position * CC] = 0;
for(int j = 0; j < AUD_LOWPASS_ORDER; j++)
{
outvalues[m_position * CC] += m_coeff[1][j] *
invalues[((m_position + j) % AUD_LOWPASS_ORDER) * CC] -
m_coeff[0][j] *
outvalues[((m_position + j) % AUD_LOWPASS_ORDER) * CC];
}
buffer[i * CC] = outvalues[m_position * CC];
m_position = (m_position + AUD_LOWPASS_ORDER-1) % AUD_LOWPASS_ORDER;
}
}
}

@ -28,40 +28,25 @@
#include "AUD_ReverseFactory.h"
AUD_PingPongFactory::AUD_PingPongFactory(AUD_IFactory* factory) :
AUD_EffectFactory(factory) {}
AUD_IReader* AUD_PingPongFactory::createReader()
AUD_EffectFactory(factory)
{
if(m_factory == 0)
return 0;
}
AUD_IReader* reader = m_factory->createReader();
AUD_IReader* AUD_PingPongFactory::createReader() const
{
AUD_IReader* reader = getReader();
AUD_IReader* reader2;
AUD_ReverseFactory factory(m_factory);
if(reader != 0)
try
{
AUD_IReader* reader2;
AUD_ReverseFactory factory(m_factory);
try
{
reader2 = factory.createReader();
}
catch(AUD_Exception)
{
reader2 = 0;
}
if(reader2 != 0)
{
reader = new AUD_DoubleReader(reader, reader2);
AUD_NEW("reader")
}
else
{
delete reader; AUD_DELETE("reader")
reader = 0;
}
reader2 = factory.createReader();
}
catch(AUD_Exception&)
{
delete reader;
throw;
}
return reader;
return new AUD_DoubleReader(reader, reader2);
}

@ -34,18 +34,19 @@
*/
class AUD_PingPongFactory : public AUD_EffectFactory
{
private:
// hide copy constructor and operator=
AUD_PingPongFactory(const AUD_PingPongFactory&);
AUD_PingPongFactory& operator=(const AUD_PingPongFactory&);
public:
/**
* Creates a new ping pong factory.
* \param factory The input factory.
*/
AUD_PingPongFactory(AUD_IFactory* factory = 0);
AUD_PingPongFactory(AUD_IFactory* factory);
/**
* Destroys the factory.
*/
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_PINGPONGFACTORY

@ -29,20 +29,11 @@
AUD_PitchFactory::AUD_PitchFactory(AUD_IFactory* factory, float pitch) :
AUD_EffectFactory(factory),
m_pitch(pitch) {}
AUD_PitchFactory::AUD_PitchFactory(float pitch) :
AUD_EffectFactory(0),
m_pitch(pitch) {}
AUD_IReader* AUD_PitchFactory::createReader()
m_pitch(pitch)
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_PitchReader(reader, m_pitch); AUD_NEW("reader")
}
return reader;
}
AUD_IReader* AUD_PitchFactory::createReader() const
{
return new AUD_PitchReader(getReader(), m_pitch);
}

@ -37,7 +37,11 @@ private:
/**
* The pitch.
*/
float m_pitch;
const float m_pitch;
// hide copy constructor and operator=
AUD_PitchFactory(const AUD_PitchFactory&);
AUD_PitchFactory& operator=(const AUD_PitchFactory&);
public:
/**
@ -45,26 +49,9 @@ public:
* \param factory The input factory.
* \param pitch The desired pitch.
*/
AUD_PitchFactory(AUD_IFactory* factory = 0, float pitch = 1.0f);
AUD_PitchFactory(AUD_IFactory* factory, float pitch);
/**
* Creates a new pitch factory.
* \param pitch The desired pitch.
*/
AUD_PitchFactory(float pitch);
/**
* Returns the pitch.
*/
float getPitch();
/**
* Sets the pitch.
* \param pitch The new pitch value. Should be between 0.0 and 1.0.
*/
void setPitch(float pitch);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_PITCHFACTORY

@ -26,12 +26,11 @@
#include "AUD_PitchReader.h"
AUD_PitchReader::AUD_PitchReader(AUD_IReader* reader, float pitch) :
AUD_EffectReader(reader)
AUD_EffectReader(reader), m_pitch(pitch)
{
m_pitch = pitch;
}
AUD_Specs AUD_PitchReader::getSpecs()
AUD_Specs AUD_PitchReader::getSpecs() const
{
AUD_Specs specs = m_reader->getSpecs();
specs.rate = (AUD_SampleRate)((int)(specs.rate * m_pitch));

@ -37,18 +37,21 @@ private:
/**
* The pitch level.
*/
float m_pitch;
const float m_pitch;
// hide copy constructor and operator=
AUD_PitchReader(const AUD_PitchReader&);
AUD_PitchReader& operator=(const AUD_PitchReader&);
public:
/**
* Creates a new pitch reader.
* \param reader The reader to read from.
* \param pitch The size of the buffer.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_PitchReader(AUD_IReader* reader, float pitch);
virtual AUD_Specs getSpecs();
virtual AUD_Specs getSpecs() const;
};
#endif //AUD_PITCHREADER

@ -24,22 +24,21 @@
*/
#include "AUD_RectifyFactory.h"
#include "AUD_RectifyReader.h"
#include "AUD_CallbackIIRFilterReader.h"
#include <cmath>
sample_t rectifyFilter(AUD_CallbackIIRFilterReader* reader, void* useless)
{
return fabs(reader->x(0));
}
AUD_RectifyFactory::AUD_RectifyFactory(AUD_IFactory* factory) :
AUD_EffectFactory(factory) {}
AUD_RectifyFactory::AUD_RectifyFactory() :
AUD_EffectFactory(0) {}
AUD_IReader* AUD_RectifyFactory::createReader()
AUD_EffectFactory(factory)
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_RectifyReader(reader); AUD_NEW("reader")
}
return reader;
}
AUD_IReader* AUD_RectifyFactory::createReader() const
{
return new AUD_CallbackIIRFilterReader(getReader(), 1, 1, rectifyFilter);
}

@ -33,19 +33,19 @@
*/
class AUD_RectifyFactory : public AUD_EffectFactory
{
private:
// hide copy constructor and operator=
AUD_RectifyFactory(const AUD_RectifyFactory&);
AUD_RectifyFactory& operator=(const AUD_RectifyFactory&);
public:
/**
* Creates a new rectify factory.
* \param factory The input factory.
*/
AUD_RectifyFactory(AUD_IFactory* factory = 0);
AUD_RectifyFactory(AUD_IFactory* factory);
/**
* Creates a new rectify factory.
*/
AUD_RectifyFactory();
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_RECTIFYFACTORY

@ -28,16 +28,11 @@
#include "AUD_Space.h"
AUD_ReverseFactory::AUD_ReverseFactory(AUD_IFactory* factory) :
AUD_EffectFactory(factory) {}
AUD_IReader* AUD_ReverseFactory::createReader()
AUD_EffectFactory(factory)
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_ReverseReader(reader); AUD_NEW("reader")
}
return reader;
}
AUD_IReader* AUD_ReverseFactory::createReader() const
{
return new AUD_ReverseReader(getReader());
}

@ -34,17 +34,19 @@
*/
class AUD_ReverseFactory : public AUD_EffectFactory
{
private:
// hide copy constructor and operator=
AUD_ReverseFactory(const AUD_ReverseFactory&);
AUD_ReverseFactory& operator=(const AUD_ReverseFactory&);
public:
/**
* Creates a new reverse factory.
* \param factory The input factory.
*/
AUD_ReverseFactory(AUD_IFactory* factory = 0);
AUD_ReverseFactory(AUD_IFactory* factory);
/**
* Destroys the factory.
*/
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_REVERSEFACTORY

@ -24,27 +24,19 @@
*/
#include "AUD_ReverseReader.h"
#include "AUD_Buffer.h"
#include <cstring>
static const char* props_error = "AUD_ReverseReader: The reader has to be "
"seekable and a finite length.";
AUD_ReverseReader::AUD_ReverseReader(AUD_IReader* reader) :
AUD_EffectReader(reader)
AUD_EffectReader(reader),
m_length(reader->getLength()),
m_position(0)
{
if(reader->getType() != AUD_TYPE_BUFFER)
AUD_THROW(AUD_ERROR_READER);
m_length = reader->getLength();
if(m_length < 0)
AUD_THROW(AUD_ERROR_READER);
m_position = 0;
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_ReverseReader::~AUD_ReverseReader()
{
delete m_buffer; AUD_DELETE("buffer")
if(m_length < 0 || !reader->isSeekable())
AUD_THROW(AUD_ERROR_PROPS, props_error);
}
void AUD_ReverseReader::seek(int position)
@ -52,12 +44,12 @@ void AUD_ReverseReader::seek(int position)
m_position = position;
}
int AUD_ReverseReader::getLength()
int AUD_ReverseReader::getLength() const
{
return m_length;
}
int AUD_ReverseReader::getPosition()
int AUD_ReverseReader::getPosition() const
{
return m_position;
}
@ -66,7 +58,7 @@ void AUD_ReverseReader::read(int & length, sample_t* & buffer)
{
// first correct the length
if(m_position + length > m_length)
length = m_length-m_position;
length = m_length - m_position;
if(length <= 0)
{
@ -78,10 +70,10 @@ void AUD_ReverseReader::read(int & length, sample_t* & buffer)
int samplesize = AUD_SAMPLE_SIZE(specs);
// resize buffer if needed
if(m_buffer->getSize() < length * samplesize)
m_buffer->resize(length * samplesize);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
buffer = m_buffer->getBuffer();
buffer = m_buffer.getBuffer();
sample_t* buf;
int len = length;
@ -105,5 +97,5 @@ void AUD_ReverseReader::read(int & length, sample_t* & buffer)
m_position += length;
buffer = m_buffer->getBuffer();
buffer = m_buffer.getBuffer();
}

@ -27,7 +27,7 @@
#define AUD_REVERSEREADER
#include "AUD_EffectReader.h"
class AUD_Buffer;
#include "AUD_Buffer.h"
/**
* This class reads another reader from back to front.
@ -36,38 +36,37 @@ class AUD_Buffer;
class AUD_ReverseReader : public AUD_EffectReader
{
private:
/**
* The sample count.
*/
const int m_length;
/**
* The current position.
*/
int m_position;
/**
* The sample count.
*/
int m_length;
/**
* The playback buffer.
*/
AUD_Buffer* m_buffer;
AUD_Buffer m_buffer;
// hide copy constructor and operator=
AUD_ReverseReader(const AUD_ReverseReader&);
AUD_ReverseReader& operator=(const AUD_ReverseReader&);
public:
/**
* Creates a new reverse reader.
* \param reader The reader to read from.
* \exception AUD_Exception Thrown if the reader specified is NULL or not
* a buffer.
* \exception AUD_Exception Thrown if the reader specified has an
* undeterminable/infinite length or is not seekable.
*/
AUD_ReverseReader(AUD_IReader* reader);
/**
* Destroys the reader.
*/
virtual ~AUD_ReverseReader();
virtual void seek(int position);
virtual int getLength();
virtual int getPosition();
virtual int getLength() const;
virtual int getPosition() const;
virtual void read(int & length, sample_t* & buffer);
};

@ -24,34 +24,39 @@
*/
#include "AUD_SquareFactory.h"
#include "AUD_SquareReader.h"
#include "AUD_CallbackIIRFilterReader.h"
sample_t squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold)
{
float in = reader->x(0);
if(in >= *threshold)
return 1;
else if(in <= -*threshold)
return -1;
else
return 0;
}
void endSquareFilter(float* threshold)
{
delete threshold;
}
AUD_SquareFactory::AUD_SquareFactory(AUD_IFactory* factory, float threshold) :
AUD_EffectFactory(factory),
m_threshold(threshold) {}
m_threshold(threshold)
{
}
AUD_SquareFactory::AUD_SquareFactory(float threshold) :
AUD_EffectFactory(0),
m_threshold(threshold) {}
float AUD_SquareFactory::getThreshold()
float AUD_SquareFactory::getThreshold() const
{
return m_threshold;
}
void AUD_SquareFactory::setThreshold(float threshold)
AUD_IReader* AUD_SquareFactory::createReader() const
{
m_threshold = threshold;
}
AUD_IReader* AUD_SquareFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_SquareReader(reader, m_threshold); AUD_NEW("reader")
}
return reader;
return new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
(doFilterIIR) squareFilter,
(endFilterIIR) endSquareFilter,
new float(m_threshold));
}

@ -37,7 +37,11 @@ private:
/**
* The threshold.
*/
float m_threshold;
const float m_threshold;
// hide copy constructor and operator=
AUD_SquareFactory(const AUD_SquareFactory&);
AUD_SquareFactory& operator=(const AUD_SquareFactory&);
public:
/**
@ -45,26 +49,14 @@ public:
* \param factory The input factory.
* \param threshold The threshold.
*/
AUD_SquareFactory(AUD_IFactory* factory = 0, float threshold = 0.0f);
/**
* Creates a new square factory.
* \param threshold The threshold.
*/
AUD_SquareFactory(float threshold);
AUD_SquareFactory(AUD_IFactory* factory, float threshold = 0.0f);
/**
* Returns the threshold.
*/
float getThreshold();
float getThreshold() const;
/**
* Sets the threshold.
* \param threshold The new threshold value. Should be between 0.0 and 1.0.
*/
void setThreshold(float threshold);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_SQUAREFACTORY

@ -24,20 +24,18 @@
*/
#include "AUD_SumFactory.h"
#include "AUD_SumReader.h"
#include "AUD_IIRFilterReader.h"
AUD_SumFactory::AUD_SumFactory(AUD_IFactory* factory) :
AUD_EffectFactory(factory) {}
AUD_IReader* AUD_SumFactory::createReader()
AUD_EffectFactory(factory)
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_SumReader(reader);
AUD_NEW("reader")
}
return reader;
}
AUD_IReader* AUD_SumFactory::createReader() const
{
std::vector<float> a, b;
a.push_back(1);
a.push_back(-1);
b.push_back(1);
return new AUD_IIRFilterReader(getReader(), b, a);
}

@ -33,14 +33,19 @@
*/
class AUD_SumFactory : public AUD_EffectFactory
{
private:
// hide copy constructor and operator=
AUD_SumFactory(const AUD_SumFactory&);
AUD_SumFactory& operator=(const AUD_SumFactory&);
public:
/**
* Creates a new sum factory.
* \param factory The input factory.
*/
AUD_SumFactory(AUD_IFactory* factory = 0);
AUD_SumFactory(AUD_IFactory* factory);
virtual AUD_IReader* createReader();
virtual AUD_IReader* createReader() const;
};
#endif //AUD_SUMFACTORY

@ -1,68 +0,0 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_SumReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#define CC specs.channels + channel
AUD_SumReader::AUD_SumReader(AUD_IReader* reader) :
AUD_EffectReader(reader)
{
AUD_Specs specs = reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_sums = new AUD_Buffer(samplesize); AUD_NEW("buffer")
memset(m_sums->getBuffer(), 0, samplesize);
}
AUD_SumReader::~AUD_SumReader()
{
delete m_buffer; AUD_DELETE("buffer")
delete m_sums; AUD_DELETE("buffer")
}
void AUD_SumReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* sums;
sums = m_sums->getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
for(int channel = 0; channel < specs.channels; channel++)
for(int i = 0; i < length * specs.channels; i++)
buffer[i * CC] = sums[channel] = sums[channel] + buf[i * CC];
}

@ -0,0 +1,49 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_SuperposeFactory.h"
#include "AUD_SuperposeReader.h"
AUD_SuperposeFactory::AUD_SuperposeFactory(AUD_IFactory* factory1, AUD_IFactory* factory2) :
m_factory1(factory1), m_factory2(factory2)
{
}
AUD_IReader* AUD_SuperposeFactory::createReader() const
{
AUD_IReader* reader1 = m_factory1->createReader();
AUD_IReader* reader2;
try
{
reader2 = m_factory2->createReader();
}
catch(AUD_Exception&)
{
delete reader1;
throw;
}
return new AUD_SuperposeReader(reader1, reader2);
}

@ -0,0 +1,63 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#ifndef AUD_SUPERPOSEFACTORY
#define AUD_SUPERPOSEFACTORY
#include "AUD_IFactory.h"
/**
* This factory plays two other factories behind each other.
* \note Readers from the underlying factories must have the same sample rate and channel count.
*/
class AUD_SuperposeFactory : public AUD_IFactory
{
private:
/**
* First played factory.
*/
AUD_IFactory* m_factory1;
/**
* Second played factory.
*/
AUD_IFactory* m_factory2;
// hide copy constructor and operator=
AUD_SuperposeFactory(const AUD_SuperposeFactory&);
AUD_SuperposeFactory& operator=(const AUD_SuperposeFactory&);
public:
/**
* Creates a new superpose factory.
* \param factory1 The first input factory.
* \param factory2 The second input factory.
*/
AUD_SuperposeFactory(AUD_IFactory* factory1, AUD_IFactory* factory2);
virtual AUD_IReader* createReader() const;
};
#endif //AUD_SUPERPOSEFACTORY

@ -0,0 +1,115 @@
/*
* $Id$
*
* ***** BEGIN LGPL LICENSE BLOCK *****
*
* Copyright 2009 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* AudaSpace is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
*
* ***** END LGPL LICENSE BLOCK *****
*/
#include "AUD_SuperposeReader.h"
#include <cstring>
static const char* specs_error = "AUD_SuperposeReader: Both readers have to "
"have the same specs.";
AUD_SuperposeReader::AUD_SuperposeReader(AUD_IReader* reader1, AUD_IReader* reader2) :
m_reader1(reader1), m_reader2(reader2)
{
try
{
AUD_Specs s1, s2;
s1 = reader1->getSpecs();
s2 = reader2->getSpecs();
if(memcmp(&s1, &s2, sizeof(AUD_Specs)))
AUD_THROW(AUD_ERROR_SPECS, specs_error);
}
catch(AUD_Exception&)
{
delete reader1;
delete reader2;
throw;
}
}
AUD_SuperposeReader::~AUD_SuperposeReader()
{
delete m_reader1;
delete m_reader2;
}
bool AUD_SuperposeReader::isSeekable() const
{
return m_reader1->isSeekable() && m_reader2->isSeekable();
}
void AUD_SuperposeReader::seek(int position)
{
m_reader1->seek(position);
m_reader2->seek(position);
}
int AUD_SuperposeReader::getLength() const
{
int len1 = m_reader1->getLength();
int len2 = m_reader2->getLength();
if((len1 < 0) || (len2 < 0))
return -1;
return AUD_MIN(len1, len2);
}
int AUD_SuperposeReader::getPosition() const
{
int pos1 = m_reader1->getPosition();
int pos2 = m_reader2->getPosition();
return AUD_MAX(pos1, pos2);
}
AUD_Specs AUD_SuperposeReader::getSpecs() const
{
return m_reader1->getSpecs();
}
void AUD_SuperposeReader::read(int & length, sample_t* & buffer)
{
AUD_Specs specs = m_reader1->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
buffer = m_buffer.getBuffer();
int len1 = length;
sample_t* buf;
m_reader1->read(len1, buf);
memcpy(buffer, buf, len1 * samplesize);
if(len1 < length)
memset(buffer + len1 * specs.channels, 0, (length - len1) * samplesize);
int len2 = length;
m_reader2->read(len2, buf);
for(int i = 0; i < len2 * specs.channels; i++)
buffer[i] += buf[i];
length = AUD_MAX(len1, len2);
}

Some files were not shown because too many files have changed in this diff Show More