Compare commits

..

66 Commits

Author SHA1 Message Date
496b510438 Merge branch 'master' into id_copy_refactor
Conflicts:
	source/blender/blenkernel/BKE_sequencer.h
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/sequencer.c
	source/blender/editors/space_sequencer/sequencer_edit.c
2017-08-10 15:43:52 +02:00
c116bb0c7f Merge branch 'master' into id_copy_refactor 2017-08-07 16:06:39 +02:00
881ee4fb26 Merge branch 'master' into id_copy_refactor 2017-08-07 12:52:25 +02:00
b54335b273 Merge branch 'master' into id_copy_refactor 2017-07-20 12:31:35 +02:00
2f2b3149ee Merge branch 'master' into id_copy_refactor 2017-07-18 11:08:03 +02:00
a8e4aae091 Extend a bit 'NO_MAIN'/'NO_USER_REFCOUNT'/etc. flags to ID allocation itself.
No real reason we keep this only to copying, creating ID outside of
database is handy as well!

Also, add helpers to add/remove an ID from Main, and to set/clear its
'user refcounting' status. Those will be useful in future complex ID
manipulation cases (like static override...).
2017-07-17 15:16:41 +02:00
a70e941fd0 Some cosmetic renaming. 2017-07-17 14:00:06 +02:00
2a992c2464 Merge branch 'master' into id_copy_refactor 2017-07-17 13:50:53 +02:00
f9904b05cc Merge branch 'master' into id_copy_refactor 2017-07-17 11:48:50 +02:00
5019fc1c8d Merge branch 'master' into id_copy_refactor 2017-07-11 15:57:40 +02:00
2f812e1d7b Fix stupid mistake in new LineStyle copying code. 2017-07-11 15:56:43 +02:00
e75db0e61b Fix several crashes and other issues in new ID copying code.
Mostly in core and animdata area. Code should now also be more robust,
and slightly simpler & cleaner.
2017-07-11 14:16:48 +02:00
524e03cae1 Huuuuge refactor of Scene copying, added to generic library ID copying.
Note: there are several known issues with this commit (and most likely
more unknown ones), to be fixed in next ones.
2017-07-11 10:31:04 +02:00
d3abcf3318 Merge branch 'master' into id_copy_refactor 2017-07-10 21:30:31 +02:00
0dc428410a Merge branch 'master' into id_copy_refactor 2017-07-10 15:23:44 +02:00
0698e892c7 Add VFont copying.
Not much happy, have to include BKE_curve in BLI_freetypefont to copy
nurbs... Not sure why fonts are in BLI tbh. We are already replicating
quite a bit of nurbs logic there. :(
2017-07-10 13:57:05 +02:00
a7bf34cc0b Add Sound copying callback. 2017-07-10 12:59:11 +02:00
0b009edbde Move Palette, PaintCurve and CacheFIle to new ID copying system. 2017-07-10 09:56:52 +02:00
8bcf950c28 Move Mask and FreestyleLineStyle to new ID copying code. 2017-07-09 22:44:21 +02:00
6637530b81 Move Text, Brush and GPencil datablocks to new copying code. 2017-07-09 22:14:00 +02:00
dcfbe9a6f0 Move Action to new copying code. 2017-07-09 21:41:24 +02:00
f5f013d231 Merge branch 'master' into id_copy_refactor 2017-07-09 21:21:48 +02:00
caae973b8a Move Group and ParticleSettings to new copying system.
Also fix several mistakes from previous commits.
2017-07-08 17:09:52 +02:00
5a1cae541a Move World and MovieClip to new copying system. 2017-07-08 12:46:33 +02:00
fe46bb8b0e Rename new BKE_<foo>_copy_ex to BKE_<foo>_copy_data.
Those are not actually copying the ID, only its internal subdata (and
other ID-specific handling). Generic processing common to all ID copying
is done by `BKE_id_copy_ex()`!
2017-07-08 12:20:54 +02:00
17ceb807dd Move Material, Texture and Image datablocks to new copying code.
Note that this is also bringing back Image copying code into 'regular'
process, instead of doing its own dirty cooking.
2017-07-08 12:14:31 +02:00
fc6619a9ff Merge branch 'master' into id_copy_refactor 2017-07-07 12:35:35 +02:00
022ad8f769 Change a bit ideas behind new copying code, now ID-specific copying never handles usercount.
Makes things much simpler, and more consistent.

Also fix issue with new copying and bloody nodetrees, using same hack as
in original ntree copying code to detect 'root' ntrees that shall never
be put into bmain :(((((((
2017-07-06 15:46:14 +02:00
8af813fee9 Merge branch 'master' into id_copy_refactor 2017-07-06 12:26:34 +02:00
af46458c62 Merge branch 'master' into id_copy_refactor 2017-06-26 11:01:21 +02:00
b7145a2662 Initial work on new copying for nodetrees.
Note that those are an nightmare to handle correctly, current code is
like a plate of noodle, so... most likeley not fully working, think I'll
have to nuke localize code as well :(
2017-06-26 10:53:51 +02:00
48a85f99eb Add remaining 'new copying' for obdata ID types. 2017-06-22 22:46:52 +02:00
6635284917 Merge branch 'master' into id_copy_refactor 2017-06-22 10:44:33 +02:00
c907b16065 Add mball and lattice new copying, tweak a bit more skey handling. 2017-06-21 11:08:50 +02:00
797a696734 Merge branch 'master' into id_copy_refactor 2017-06-21 10:49:39 +02:00
90a463dcfc Add new Curve copying code. 2017-06-20 21:34:18 +02:00
1f7c6fda5d Fix wrong assert, and issue with Key ID freeing tag after copying from mesh... 2017-06-20 21:20:43 +02:00
39b0c6f060 Add Mesh and Key support to new copying code. 2017-06-20 17:55:38 +02:00
3a86873b68 Make object copying fully compatible/aware of new copy flag system.
(continuation of previous WIP commit, sorry about that one :/ ).

This commits changes quite a few things, distributing new copying flags
into sub-data copying code (mostly concerns ID refcounting or not).

It also removes ID refcounting handling from Modifiers' copy callback
(this was ugly from the start, proved to be problematic in current
master, and generally bad practice). This is now done by calling code.

Also, it brings back ID refcounting handling to main BKE_library's copy
code, which means in generic ID copying lower-level IDType-specific copy
code should not use it at all. Support at lower-level remains needed
though, unfortunately, to cope with partial copying tools etc.
2017-06-20 17:55:38 +02:00
596c20c677 Alembic tests: make failures a bit easier to diagnose. 2017-06-20 17:55:38 +02:00
d0af31b317 Fix T51762: Unit test script_alembic_import is failing.
Implemented workaround for use with the legacy depsgraph.
2017-06-20 17:55:38 +02:00
12a5a628f3 Fixed bl_load_py_modules / script_load_modules unit test
It tried to assert that
addons/io_blend_utils/blender_bam-unpacked.whl/__init__.py was loaded when
the io_blend_utils module was imported. However, this happens only on
demand, and not directly when importing the add-on.
2017-06-20 17:55:38 +02:00
b72ba5c78d Use for/else instead of setting 'ok' variable.
This is more efficient, and this use case is exactly what the else clause
is for.
2017-06-20 17:55:38 +02:00
0687d8bdce Removed trailing spaces 2017-06-20 17:55:38 +02:00
258634b43c Fix (unreported) missing Image usercount increase when copying UVProject modifier. 2017-06-20 17:55:38 +02:00
babc0c9bd7 Fix (unreported) bad copying code of Surface Deform modifier. 2017-06-20 17:55:38 +02:00
749a8daf26 Fix compiler warnings from own recent rB0d5c7e5e36b9. 2017-06-20 17:55:38 +02:00
2d3b6b5ad7 Fix (unreported) bad copying of Ocean modifier.
Was needlessly complicated code, forgot to copy a value (foam_fade), and
was utterly leaking memory!
2017-06-20 17:55:38 +02:00
20e3434c5f Fix (unreported) bad copying code in Mesh Deform modifier. 2017-06-20 17:55:38 +02:00
77046ba9d8 Fix (unreported) Dynamic Paint modifier not increasing ID usercount in copy function.
*Sigh* One more example of why we should keep ID management handling in
as few places as possible! It's impossible to keep more than a few
places in sync regarding which ID pointer is refcounted etc.
2017-06-20 17:55:38 +02:00
147735587c Fix (unreported) memory leak in Fluid modifier copying.
Also generally simplify/sanitize this copy code.
2017-06-20 17:55:38 +02:00
44b1680fbf WIP 2017-06-20 17:55:38 +02:00
46af186d21 Cleanup: doxygen comments
Also remove duplicate & mismatching comments from grease-pencil header.
Keep comments close to implementation to avoid getting out of sync.
2017-06-20 17:55:38 +02:00
e61dbcd284 Fix T51774: Children particles hair interpolation not correct with textures or dp.
Children where always getting at least one segment of fixed length...

Now fully hidden ones (zero length) get no segment at all.

Note that even very short ones keep getting one 'unit' length segment - would
rather avoid changing that at this point, given how complex children
particles 'length' can get with all kind of modifiers... Think we can
live with that for now anyway.
2017-06-20 17:55:38 +02:00
5f6725337a Fix T51840: UI redraw in node editor header missing on pointcache bake
Missing a notifier handler in the node editor
2017-06-20 17:55:38 +02:00
780310578a Fix unreported: Copy-pasting nodes crashes when they have an undefined type 2017-06-20 17:55:38 +02:00
d8de772410 Docs: Fix file:line links in generated API docs 2017-06-20 17:55:38 +02:00
f45300856c Add Cone: tip soft-min should be zero
Default value should be included in range.
2017-06-20 17:55:38 +02:00
6493328e37 Guarded allocator: Fix type in macro definition
The crash did not happen yet because we always had proper vmemh defined in
the parent scope.

Patch by Ivan Ivanov (aka obiwanus), thanks!

Differential Revision: https://developer.blender.org/D2715
2017-06-20 17:55:38 +02:00
2e9580e417 PyAPI: Fix warning about indent 2017-06-20 17:55:38 +02:00
0e78b3b794 Fix T51810: Add minimal example of usage of translation API for non-official addons. 2017-06-20 17:55:38 +02:00
09e5d1bc84 Usual i18n/UI messages fixes.
Please do not add useless tooltips! We have enough messages to translate
already...
2017-06-20 17:55:38 +02:00
23941b425e Add same new ID freeing API as copying one.
Idea is the same, looks like it will be a tad simpler than with copy
though, since we should not need to change each ID type freeing func, as
ID usercount handling is done in main BKE_library code (would like to do
that for copy as well, but it's not that simple).
2017-06-16 10:48:42 +02:00
fa64dfa449 On second thought, avoid adding new stuff to ID.
We can extend ID->tag and store there our few alloc-related tags.
2017-06-16 10:48:42 +02:00
7edeccf81d Fleshing a bit new copy logic (using Object datablock as Guinea pig). 2017-06-16 10:48:42 +02:00
8d22d5a2a9 Layout initial ideas/code structure of new ID copying. 2017-06-16 10:48:42 +02:00
2417 changed files with 83767 additions and 220390 deletions

View File

@@ -1,6 +1,6 @@
{
"project_id" : "Blender",
"conduit_uri" : "https://developer.blender.org/",
"git.default-relative-commit" : "origin/blender2.8",
"git.default-relative-commit" : "origin/master",
"arc.land.update.default" : "rebase"
}

4
.gitmodules vendored
View File

@@ -1,24 +1,20 @@
[submodule "release/scripts/addons"]
path = release/scripts/addons
url = ../blender-addons.git
branch = blender2.8
ignore = all
branch = master
[submodule "release/scripts/addons_contrib"]
path = release/scripts/addons_contrib
url = ../blender-addons-contrib.git
branch = master
ignore = all
branch = master
[submodule "release/datafiles/locale"]
path = release/datafiles/locale
url = ../blender-translations.git
branch = master
ignore = all
branch = master
[submodule "source/tools"]
path = source/tools
url = ../blender-dev-tools.git
branch = master
ignore = all
branch = master

View File

@@ -45,7 +45,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
endif()
endif()
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 2.8)
if(NOT EXECUTABLE_OUTPUT_PATH)
set(FIRST_RUN TRUE)
@@ -244,8 +244,6 @@ endif()
option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
option(WITH_CLAY_ENGINE "Enable Clay engine" ON)
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
@@ -291,7 +289,7 @@ if(WITH_X11)
endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
else()
# not an option for other OS's
@@ -336,6 +334,10 @@ option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd
option(WITH_ALEMBIC "Enable Alembic Support" OFF)
option(WITH_ALEMBIC_HDF5 "Enable Legacy Alembic Support (not officially supported)" OFF)
if(APPLE)
option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" OFF)
endif()
# 3D format support
# Disable opencollada when we don't have precompiled libs
option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ${_init_OPENCOLLADA})
@@ -388,14 +390,10 @@ if(UNIX AND NOT APPLE)
endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
if(WITH_PYTHON_INSTALL OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH)
set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif()
if(WITH_PYTHON_INSTALL)
option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH)
if(UNIX AND NOT APPLE)
option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
@@ -466,16 +464,28 @@ endif()
# OpenGL
option(WITH_GLEW_MX "Support multiple GLEW contexts (experimental)" OFF )
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON )
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.2+ 'core' profile." OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
mark_as_advanced(
WITH_GLEW_MX
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_COMPAT
WITH_GL_PROFILE_CORE
WITH_GL_PROFILE_ES20
)
if(WITH_GL_PROFILE_COMPAT)
set(WITH_GLU ON)
else()
set(WITH_GLU OFF)
endif()
if(WIN32)
option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
mark_as_advanced(WITH_GL_ANGLE)
@@ -494,17 +504,13 @@ endif()
# Experimental support of C11 and C++11
#
# We default options to whatever default standard in the current compiler.
if(APPLE)
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
set(_c11_init ON)
set(_cxx11_init ON)
set(WITH_C11 ON)
set(WITH_CXX11 ON)
elseif(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
set(_c11_init ON)
else()
set(_c11_init OFF)
set(_cxx11_init OFF)
endif()
set(_cxx11_init ON)
option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init})
mark_as_advanced(WITH_C11)
@@ -518,8 +524,8 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
# Dependency graph
option(WITH_DEPSGRAPH_COPY_ON_WRITE "Build Blender with copy-on-write support for dependency graph" OFF)
mark_as_advanced(WITH_DEPSGRAPH_COPY_ON_WRITE)
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
if(WIN32)
# Use hardcoded paths or find_package to find externals
@@ -580,12 +586,6 @@ if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
endif()
if(NOT WITH_CXX11)
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
message(FATAL_ERROR "WITH_AUDASPACE requires WITH_CXX11")
endif()
endif()
if(NOT WITH_AUDASPACE)
if(WITH_OPENAL)
message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
@@ -634,11 +634,16 @@ if(NOT WITH_BOOST)
endmacro()
set_and_warn(WITH_CYCLES OFF)
set_and_warn(WITH_AUDASPACE OFF)
set_and_warn(WITH_INTERNATIONAL OFF)
set_and_warn(WITH_OPENVDB OFF)
set_and_warn(WITH_OPENCOLORIO OFF)
set_and_warn(WITH_MOD_BOOLEAN OFF)
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
set_and_warn(WITH_OPENAL OFF) # depends on AUDASPACE
set_and_warn(WITH_GAMEENGINE OFF) # depends on AUDASPACE
set_and_warn(WITH_PLAYER OFF) # depends on GAMEENGINE
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL OR
WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN)
# Keep enabled
else()
@@ -706,12 +711,37 @@ TEST_SHARED_PTR_SUPPORT()
TEST_UNORDERED_MAP_SUPPORT()
if(WITH_AUDASPACE)
if(NOT WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C" "${CMAKE_BINARY_DIR}/extern/audaspace")
set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings")
if(WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_DEFINITIONS
-DWITH_AUDASPACE
-DWITH_SYSTEM_AUDASPACE
"-DAUD_DEVICE_H=<AUD_Device.h>"
"-DAUD_SPECIAL_H=<AUD_Special.h>"
"-DAUD_SOUND_H=<AUD_Sound.h>"
"-DAUD_HANDLE_H=<AUD_Handle.h>"
"-DAUD_SEQUENCE_H=<AUD_Sequence.h>"
"-DAUD_TYPES_H=<AUD_Types.h>"
"-DAUD_PYTHON_H=<python/PyAPI.h>"
)
else()
set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_DEFINITIONS
-DWITH_AUDASPACE
"-DAUD_DEVICE_H=<AUD_C-API.h>"
"-DAUD_SPECIAL_H=<AUD_C-API.h>"
"-DAUD_SOUND_H=<AUD_C-API.h>"
"-DAUD_HANDLE_H=<AUD_C-API.h>"
"-DAUD_SEQUENCE_H=<AUD_C-API.h>"
"-DAUD_TYPES_H=<AUD_Space.h>"
)
endif()
endif()
if(APPLE)
apple_check_quicktime()
endif()
#-----------------------------------------------------------------------------
# Check for valid directories
# ... a partial checkout may cause this.
@@ -933,11 +963,19 @@ endif()
find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
if(WITH_GLU)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
list(APPEND GL_DEFINITIONS -DWITH_GLU)
endif()
if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES)
endif()
if(WITH_GL_PROFILE_ES20)
if(WITH_GL_PROFILE_COMPAT OR WITH_GL_PROFILE_CORE)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
elseif(WITH_GL_PROFILE_ES20)
if(WITH_SYSTEM_GLES)
if(NOT OPENGLES_LIBRARY)
message(FATAL_ERROR
@@ -997,9 +1035,6 @@ if(WITH_GL_PROFILE_ES20)
endif()
else()
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
endif()
if(WITH_GL_EGL)
@@ -1047,10 +1082,16 @@ if(WITH_GL_EGL)
endif()
if(WITH_GL_PROFILE_COMPAT)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_COMPAT)
endif()
if(WITH_GL_PROFILE_CORE)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif()
if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20)
else()
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif()
if(WITH_GL_EGL)
@@ -1087,6 +1128,10 @@ endif()
#-----------------------------------------------------------------------------
# Configure GLEW
if(WITH_GLEW_MX)
list(APPEND GL_DEFINITIONS -DWITH_GLEW_MX)
endif()
if(WITH_SYSTEM_GLEW)
find_package(GLEW)
@@ -1096,7 +1141,11 @@ if(WITH_SYSTEM_GLEW)
message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
endif()
set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
if(WITH_GLEW_MX)
set(BLENDER_GLEW_LIBRARIES ${GLEW_MX_LIBRARY})
else()
set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
else()
if(WITH_GLEW_ES)
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
@@ -1104,11 +1153,12 @@ else()
list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
# These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
else()
if(NOT WITH_GL_PROFILE_ES20)
# No ES functions are needed
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
elseif(NOT (WITH_GL_PROFILE_CORE OR WITH_GL_PROFILE_COMPAT))
# ES is enabled, but the other functions are all disabled
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
endif()
if(WITH_GL_PROFILE_ES20)
@@ -1145,7 +1195,9 @@ else()
endif()
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
if(NOT WITH_GLU)
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
endif()
#-----------------------------------------------------------------------------
# Configure Bullet
@@ -1277,7 +1329,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1319,7 +1370,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1356,7 +1406,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "-L${LIBDIR}/openmp/lib -liomp5") # these are only used for the checks
endif()
# strange, clang complains these are not supported, but then uses them.
# strange, clang complains these are not supported, but then yses them.
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
@@ -1430,7 +1480,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/wd4800" # forcing value to bool 'true' or 'false'
# errors:
"/we4013" # 'function' undefined; assuming extern returning int
"/we4133" # incompatible pointer types
"/we4431" # missing type specifier - int assumed
)
@@ -1453,15 +1502,10 @@ if(WITH_PYTHON)
)
endif()
if(WIN32)
if(WIN32 OR APPLE)
# pass, we have this in an archive to extract
elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
find_python_package(numpy)
unset(PYTHON_NUMPY_INCLUDE_DIRS CACHE)
set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif()
elseif(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
find_python_package(numpy)
endif()
if(WIN32 OR APPLE)
@@ -1698,7 +1742,10 @@ if(FIRST_RUN)
info_cfg_text("OpenGL:")
info_cfg_option(WITH_GLEW_ES)
info_cfg_option(WITH_GLU)
info_cfg_option(WITH_GL_EGL)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)
info_cfg_option(WITH_GL_PROFILE_ES20)
if(WIN32)
info_cfg_option(WITH_GL_ANGLE)
@@ -1712,3 +1759,4 @@ endif()
if(0)
print_all_vars()
endif()

View File

@@ -419,16 +419,10 @@ icons: .FORCE
"$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
update: .FORCE
if [ "$(OS_NCASE)" == "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
fi
if [ -d "../lib" ]; then \
svn cleanup ../lib/* ; \
svn update ../lib/* ; \
fi
git pull --rebase
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

View File

@@ -76,11 +76,9 @@ include(cmake/osl.cmake)
include(cmake/tbb.cmake)
include(cmake/openvdb.cmake)
include(cmake/python.cmake)
include(cmake/python_site_packages.cmake)
include(cmake/requests.cmake)
include(cmake/numpy.cmake)
if (WITH_WEBP)
include(cmake/webp.cmake)
endif()
include(cmake/webp.cmake)
if(WIN32)
include(cmake/hidapi.cmake)
endif()
@@ -96,7 +94,6 @@ else()
endif()
if(NOT WIN32 OR ENABLE_MINGW64)
include(cmake/openjpeg.cmake)
if(BUILD_MODE STREQUAL Release)
if(WIN32)
include(cmake/zlib_mingw.cmake)
@@ -110,6 +107,7 @@ if(NOT WIN32 OR ENABLE_MINGW64)
include(cmake/schroedinger.cmake)
include(cmake/x264.cmake)
include(cmake/xvidcore.cmake)
include(cmake/openjpeg.cmake)
include(cmake/faad.cmake)
include(cmake/ffmpeg.cmake)
include(cmake/fftw.cmake)

View File

@@ -40,27 +40,19 @@ if(WIN32)
set(semi_path "${PATCH_DIR}/semi.txt")
FILE(TO_NATIVE_PATH ${semi_path} semi_path)
set(BOOST_CONFIGURE_COMMAND bootstrap.bat &&
echo using python : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
echo using python : 3.5 : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
echo. : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" &&
echo. : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" &&
type ${semi_path} >> "${JAM_FILE}"
)
set(BOOST_BUILD_COMMAND bjam)
#--user-config=user-config.jam
set(BOOST_BUILD_OPTIONS runtime-link=static )
#set(BOOST_WITH_PYTHON --with-python)
set(BOOST_HARVEST_CMD ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ )
if(BUILD_MODE STREQUAL Release)
set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/)
endif()
set(BOOST_BUILD_OPTIONS runtime-link=static --user-config=user-config.jam)
set(BOOST_WITH_PYTHON --with-python)
elseif(APPLE)
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_COMMAND ./bjam)
set(BOOST_BUILD_OPTIONS toolset=clang cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
set(BOOST_HARVEST_CMD echo .)
else()
set(BOOST_HARVEST_CMD echo .)
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_COMMAND ./bjam)
set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
@@ -99,7 +91,7 @@ ExternalProject_Add(external_boost
CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} variant=${BOOST_BUILD_TYPE} link=static threading=multi ${BOOST_OPTIONS} --prefix=${LIBDIR}/boost install
BUILD_IN_SOURCE 1
INSTALL_COMMAND "${BOOST_HARVEST_CMD}"
INSTALL_COMMAND ""
)
if(WIN32)

View File

@@ -28,24 +28,8 @@ ExternalProject_Add(external_clang
URL_HASH MD5=${CLANG_HASH}
PATCH_COMMAND ${PATCH_CMD} -p 2 -N -R -d ${BUILD_DIR}/clang/src/external_clang < ${PATCH_DIR}/clang.diff
PREFIX ${BUILD_DIR}/clang
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/clang ${DEFAULT_CMAKE_FLAGS} ${CLANG_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/clang
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${DEFAULT_CMAKE_FLAGS} ${CLANG_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/llvm
)
if (MSVC)
if (BUILD_MODE STREQUAL Release)
set(CLANG_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/ ${HARVEST_TARGET}/llvm/ )
else()
set(CLANG_HARVEST_COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/include/ ${HARVEST_TARGET}/llvm/debug/include/
)
endif()
ExternalProject_Add_Step(external_clang after_install
COMMAND ${CLANG_HARVEST_COMMAND}
DEPENDEES mkdir update patch download configure build install
)
endif()
add_dependencies(external_clang ll)

View File

@@ -39,13 +39,6 @@ else()
--enable-libopenjpeg)
endif()
if(APPLE)
set(FFMPEG_EXTRA_FLAGS
${FFMPEG_EXTRA_FLAGS}
--target-os=darwin
)
endif()
ExternalProject_Add(external_ffmpeg
URL ${FFMPEG_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
@@ -53,7 +46,7 @@ ExternalProject_Add(external_ffmpeg
PREFIX ${BUILD_DIR}/ffmpeg
CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} &&
cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ &&
${FFMPEG_ENV} ${CONFIGURE_COMMAND_NO_TARGET} ${FFMPEG_EXTRA_FLAGS}
${FFMPEG_ENV} ${CONFIGURE_COMMAND} ${FFMPEG_EXTRA_FLAGS}
--disable-lzma
--disable-avfilter
--disable-vdpau

View File

@@ -33,6 +33,9 @@ if(BUILD_MODE STREQUAL Release)
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic.lib ${HARVEST_TARGET}/zlib/lib/libz_st.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/include/ ${HARVEST_TARGET}/zlib/include/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/bin/ ${HARVEST_TARGET}/zlib/bin/ &&
# Boost copy lib + rename boost_1_60 to boost
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/ &&
# jpeg rename libfile + copy include
${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpg/include/ ${HARVEST_TARGET}/jpeg/include/ &&
@@ -95,6 +98,8 @@ if(BUILD_MODE STREQUAL Release)
# tbb
${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/ &&
# llvm
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ &&
# opencollada
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencollada/ ${HARVEST_TARGET}/opencollada/ &&
# opensubdiv
@@ -109,9 +114,11 @@ if(BUILD_MODE STREQUAL Release)
${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb64/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb64.dll &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb32/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb.dll &&
# python
${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}.tar.gz &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/python35.tar.gz ${HARVEST_TARGET}/Release/python35.tar.gz &&
# requests
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/requests ${HARVEST_TARGET}/Release/site-packages/requests &&
# numpy
${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}.tar.gz &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_numpy${PYTHON_POSTFIX}_1.10.tar.gz ${HARVEST_TARGET}/Release/python35_numpy_1.10.tar.gz &&
# hidapi
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hidapi/ ${HARVEST_TARGET}/hidapi/ &&
# webp, straight up copy
@@ -147,6 +154,12 @@ if(BUILD_MODE STREQUAL Debug)
${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/xml.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/xml_d.lib &&
# blosc
${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc_d.lib ${HARVEST_TARGET}/blosc/lib/libblosc_d.lib &&
# boost
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ &&
# llvm
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include/ ${HARVEST_TARGET}/llvm/debug/include/ &&
# osl
${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib &&
@@ -165,9 +178,9 @@ if(BUILD_MODE STREQUAL Debug)
# hdf5
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib &&
# numpy
${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_numpy_1.10d.tar.gz ${HARVEST_TARGET}/Release/python35_numpy_1.10d.tar.gz &&
# python
${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz
${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_d.tar.gz ${HARVEST_TARGET}/Release/python35_d.tar.gz
DEPENDS Package_Python
)
endif(BUILD_MODE STREQUAL Debug)
@@ -195,9 +208,7 @@ function(harvest from to)
FILES_MATCHING PATTERN ${pattern}
PATTERN "pkgconfig" EXCLUDE
PATTERN "cmake" EXCLUDE
PATTERN "clang" EXCLUDE
PATTERN "__pycache__" EXCLUDE
PATTERN "tests" EXCLUDE)
PATTERN "clang" EXCLUDE)
endif()
endfunction()
@@ -256,7 +267,17 @@ harvest(png/include png/include "*.h")
harvest(png/lib png/lib "*.a")
harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m")
harvest(python/include python/include "*h")
harvest(python/lib python/lib "*")
if(UNIX AND NOT APPLE)
harvest(python/lib/libpython${PYTHON_SHORT_VERSION}m.a python/lib/libpython${PYTHON_SHORT_VERSION}m.a)
harvest(python/lib/python${PYTHON_SHORT_VERSION} python/lib/python${PYTHON_SHORT_VERSION} "*")
harvest(requests python/lib/python${PYTHON_SHORT_VERSION}/site-packages/requests "*")
harvest(numpy python/lib/python${PYTHON_SHORT_VERSION}/site-packages/numpy "*")
else()
harvest(python/lib/libpython${PYTHON_SHORT_VERSION}m.a python/lib/python${PYTHON_SHORT_VERSION}/libpython${PYTHON_SHORT_VERSION}m.a)
harvest(python/release release "*")
harvest(requests release/site-packages/requests "*")
harvest(numpy release/site-packages/numpy "*")
endif()
harvest(schroedinger/lib/libschroedinger-1.0.a ffmpeg/lib/libschroedinger.a)
harvest(sdl/include/SDL2 sdl/include "*.h")
harvest(sdl/lib sdl/lib "libSDL2.a")

View File

@@ -42,20 +42,3 @@ ExternalProject_Add(ll
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${DEFAULT_CMAKE_FLAGS} ${LLVM_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/llvm
)
if (MSVC)
if (BUILD_MODE STREQUAL Release)
set(LLVM_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ )
else()
set(LLVM_HARVEST_COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include/ ${HARVEST_TARGET}/llvm/debug/include/
)
endif()
ExternalProject_Add_Step(ll after_install
COMMAND ${LLVM_HARVEST_COMMAND}
DEPENDEES mkdir update patch download configure build install
)
endif()

View File

@@ -0,0 +1,40 @@
# ***** 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 *****
if(MSVC)
if(BUILD_MODE STREQUAL Release)
set(NUMPY_POSTFIX)
message("Python_binary = ${PYTHON_BINARY}")
message("Python_post = ${PYTHON_POSTFIX}")
ExternalProject_Add(external_numpy
URL ${NUMPY_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${NUMPY_HASH}
PREFIX ${BUILD_DIR}/numpy
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff
CONFIGURE_COMMAND ""
LOG_BUILD 1
BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build
INSTALL_COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5"
${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy${PYTHON_POSTFIX}_1.11.tar.gz" "."
)
add_dependencies(external_numpy Make_Python_Environment)
endif()
endif()

View File

@@ -32,14 +32,13 @@ set(NUMPY_POSTFIX)
if(WIN32)
set(NUMPY_INSTALL
${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/python/src/external_python/run/lib/site-packages/numpy/core/include/numpy" "${LIBDIR}/python/include/python${PYTHON_SHORT_VERSION}/numpy" &&
${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-${PYTHON_SHORT_VERSION}${NUMPY_DIR_POSTFIX}"
${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5${NUMPY_DIR_POSTFIX}"
${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
)
set(NUMPY_PATCH ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff )
else()
set(NUMPY_INSTALL echo .)
set(NUMPY_PATCH echo .)
set(NUMPY_INSTALL
${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5/numpy/" "${LIBDIR}/numpy/"
)
endif()
ExternalProject_Add(external_numpy
@@ -47,10 +46,10 @@ ExternalProject_Add(external_numpy
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${NUMPY_HASH}
PREFIX ${BUILD_DIR}/numpy
PATCH_COMMAND ${NUMPY_PATCH}
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff
CONFIGURE_COMMAND ""
LOG_BUILD 1
BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} install --old-and-unmanageable
BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION}
INSTALL_COMMAND ${NUMPY_INSTALL}
)

View File

@@ -32,31 +32,12 @@ endif()
if(WIN32)
set(PNG_LIBNAME libpng16_static${LIBEXT})
set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2 -DOPJ_STATIC=1)
set(OPENJPEG_POSTFIX _msvc)
set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2)
else()
set(PNG_LIBNAME libpng${LIBEXT})
set(OIIO_SIMD_FLAGS)
endif()
if (WITH_WEBP)
set(WEBP_ARGS -DWEBP_INCLUDE_DIR=${LIBDIR}/webp/include
-DWEBP_LIBRARY=${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT} )
set(WEBP_DEP external_webp)
endif()
if (MSVC)
set(OPENJPEG_FLAGS -DOPENJPEG_HOME=${LIBDIR}/openjpeg_msvc
-DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg_msvc/include/openjpeg-${OPENJPEG_SHORT_VERSION}
-DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg_msvc/lib/openjpeg${LIBEXT}
-DOPENJPEG_LIBRARY_DEBUG=${LIBDIR}/openjpeg_msvc/lib/openjpeg${LIBEXT}
)
else()
set(OPENJPEG_FLAGS -DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION}
-DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg/lib/${OPENJPEG_LIBRARY}
)
endif()
set(OPENIMAGEIO_EXTRA_ARGS
-DBUILDSTATIC=ON
${OPENIMAGEIO_LINKSTATIC}
@@ -78,7 +59,7 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DUSE_GIF=OFF
-DUSE_OPENCV=OFF
-DUSE_OPENSSL=OFF
-DUSE_OPENJPEG=ON
-DUSE_OPENJPEG=OFF
-DUSE_FFMPEG=OFF
-DUSE_PTEX=OFF
-DUSE_FREETYPE=OFF
@@ -97,7 +78,6 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DTIFF_INCLUDE_DIR=${LIBDIR}/tiff/include
-DJPEG_LIBRARY=${LIBDIR}/jpg/lib/${JPEG_LIBRARY}
-DJPEG_INCLUDE_DIR=${LIBDIR}/jpg/include
${OPENJPEG_FLAGS}
-DOCIO_PATH=${LIBDIR}/opencolorio/
-DOpenEXR_USE_STATIC_LIBS=On
-DOPENEXR_HOME=${LIBDIR}/openexr/
@@ -111,7 +91,8 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/
-DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}
-DSTOP_ON_WARNING=OFF
${WEBP_FLAGS}
-DWEBP_INCLUDE_DIR=${LIBDIR}/webp/include
-DWEBP_LIBRARY=${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT}
${OIIO_SIMD_FLAGS}
)
@@ -126,7 +107,7 @@ ExternalProject_Add(external_openimageio
INSTALL_DIR ${LIBDIR}/openimageio
)
add_dependencies(external_openimageio external_png external_zlib external_ilmbase external_openexr external_jpeg external_boost external_tiff external_opencolorio external_openjpeg${OPENJPEG_POSTFIX} ${WEBP_DEP})
add_dependencies(external_openimageio external_png external_zlib external_ilmbase external_openexr external_jpeg external_boost external_tiff external_webp external_opencolorio)
if(NOT WIN32)
add_dependencies(external_openimageio external_opencolorio_extra)
endif()

View File

@@ -38,20 +38,6 @@ ExternalProject_Add(external_openjpeg
INSTALL_DIR ${LIBDIR}/openjpeg
)
#on windows ffmpeg wants a mingw build, while oiio needs a msvc build
if (MSVC)
set(OPENJPEG_EXTRA_ARGS ${DEFAULT_CMAKE_FLAGS})
ExternalProject_Add(external_openjpeg_msvc
URL ${OPENJPEG_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${OPENJPEG_HASH}
PREFIX ${BUILD_DIR}/openjpeg_msvc
CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF
INSTALL_DIR ${LIBDIR}/openjpeg_msvc
)
endif()
set(OPENJPEG_LIBRARY libopenjpeg${LIBEXT})
if(MSVC)
set_target_properties(external_openjpeg PROPERTIES FOLDER Mingw)
endif(MSVC)

View File

@@ -19,7 +19,6 @@
if(WIN32)
option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON)
endif()
option(WITH_WEBP "Enable building of oiio with webp support" OFF)
set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with")
if(NOT BUILD_MODE)
@@ -34,8 +33,7 @@ ELSE(BUILD_MODE STREQUAL "Debug")
set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Release)
ENDIF(BUILD_MODE STREQUAL "Debug")
option(DOWNLOAD_DIR "Path for downloaded files" ${CMAKE_CURRENT_SOURCE_DIR}/downloads)
file(TO_CMAKE_PATH ${DOWNLOAD_DIR} DOWNLOAD_DIR)
set(DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/downloads)
set(PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches)
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
@@ -67,9 +65,9 @@ if(WIN32)
set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
if(WITH_OPTIMIZED_DEBUG)
set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
else()
set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
else()
set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
endif()
set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
@@ -109,21 +107,16 @@ if(WIN32)
)
set(CONFIGURE_COMMAND sh ./configure)
set(CONFIGURE_COMMAND_NO_TARGET ${CONFIGURE_COMMAND})
else()
set(PATCH_CMD patch)
set(LIBEXT ".a")
set(LIBPREFIX "lib")
if(APPLE)
# Let's get the current Xcode dir, to support xcode-select
execute_process(
COMMAND xcode-select --print-path
OUTPUT_VARIABLE XCODE_DEV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(OSX_ARCHITECTURES x86_64)
set(OSX_DEPLOYMENT_TARGET 10.9)
set(OSX_SDK_VERSION 10.12)
set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk)
set(OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk)
set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
@@ -169,7 +162,6 @@ else()
)
set(CONFIGURE_ENV_NO_PERL ${CONFIGURE_ENV})
set(CONFIGURE_COMMAND ./configure ${PLATFORM_BUILD_TARGET})
set(CONFIGURE_COMMAND_NO_TARGET ./configure)
endif()
set(DEFAULT_CMAKE_FLAGS

View File

@@ -21,9 +21,9 @@ if(WIN32)
set(OSL_FLEX_BISON -DFLEX_EXECUTABLE=${LIBDIR}/flexbison/win_flex.exe -DFLEX_EXTRA_OPTIONS="--wincompat" -DBISON_EXECUTABLE=${LIBDIR}/flexbison/win_bison.exe)
set(OSL_OPENIMAGEIO_LIBRARY "${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO${LIBEXT};${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO_Util${LIBEXT};${LIBDIR}/png/lib/libpng16${LIBEXT};${LIBDIR}/jpg/lib/${LIBPREFIX}jpeg${LIBEXT};${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT};${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
set(OSL_SIMD_FLAGS -DOIIO_NOSIMD=1 -DOIIO_SIMD=0)
set(OSL_SIMD_FLAGS -DOIIO_SIMD=0)
else()
set(OSL_SIMD_FLAGS -DOIIO_NOSIMD=1 -DOIIO_SIMD=sse2)
set(OSL_SIMD_FLAGS -DOIIO_SIMD=sse2)
endif()
else()
set(OSL_CMAKE_CXX_STANDARD_LIBRARIES)

View File

@@ -50,11 +50,11 @@ if(WIN32)
${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/pc < ${PATCH_DIR}/pyshell.diff
CONFIGURE_COMMAND ""
BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p ${PYTHON_ARCH} -c ${BUILD_MODE} -k ${PYTHON_COMPILER_STRING}
INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll &&
${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib &&
${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.exp ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.exp &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${LIBDIR}/python/include/Python${PYTHON_SHORT_VERSION} &&
${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${LIBDIR}/python/include/Python${PYTHON_SHORT_VERSION}/pyconfig.h
INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.dll ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.dll &&
${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.lib &&
${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.exp ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.exp &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${LIBDIR}/python/include/Python3.5 &&
${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${LIBDIR}/python/include/Python3.5/pyconfig.h
)
Message("PythinRedist = ${BUILD_DIR}/python/src/external_python/redist")
Message("POutput = ${PYTHON_OUTPUTDIR}")
@@ -82,12 +82,18 @@ else()
INSTALL_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make install
INSTALL_DIR ${LIBDIR}/python)
add_custom_target(Make_Python_Environment ALL DEPENDS external_python)
add_custom_command(
OUTPUT ${LIBDIR}/python/release/python_x86_64.zip
WORKING_DIRECTORY ${LIBDIR}/python
COMMAND mkdir -p release
COMMAND zip -r release/python_x86_64.zip lib/python${PYTHON_SHORT_VERSION} lib/pkgconfig --exclude *__pycache__*)
add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python/release/python_x86_64.zip)
add_custom_target(Make_Python_Environment ALL DEPENDS Package_Python)
endif()
if(MSVC)
add_custom_command(
OUTPUT ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz
OUTPUT ${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz
OUTPUT ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/lib ${BUILD_DIR}/python/src/external_python/redist/lib
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe
@@ -112,10 +118,10 @@ if(MSVC)
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testcapi${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testcapi${PYTHON_POSTFIX}.pyd
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testimportmultiple${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testimportmultiple${PYTHON_POSTFIX}.pyd
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testmultiphase${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testmultiphase${PYTHON_POSTFIX}.pyd
COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/python/src/external_python/redist" ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz" "."
COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/python/src/external_python/redist" ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz" "."
)
add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe)
add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe)
if(MSVC12)
set(PYTHON_DISTUTIL_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/run/lib/distutils < ${PATCH_DIR}/python_runtime_vc2013.diff)
@@ -127,9 +133,9 @@ if(MSVC)
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/redist ${BUILD_DIR}/python/src/external_python/run
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/run/include
COMMAND ${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${BUILD_DIR}/python/src/external_python/run/include/pyconfig.h
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll" ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib #missing postfix on purpose, distutils is not expecting it
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib #other things like numpy still want it though.
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.dll" ${BUILD_DIR}/python/src/external_python/run/python35${PYTHON_POSTFIX}.dll
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python35.lib #missing postfix on purpose, distutils is not expecting it
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python35${PYTHON_POSTFIX}.lib #other things like numpy still want it though.
COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe
COMMAND ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe -m ensurepip --upgrade
COMMAND ${PYTHON_DISTUTIL_PATCH}

View File

@@ -1,38 +0,0 @@
# ***** 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 *****
if(WIN32)
set(HARVEST_CMD cmd /C FOR /d /r ${BUILD_DIR}/python/src/external_python/run/lib/site-packages %d IN (__pycache__) DO @IF EXIST "%d" rd /s /q "%d" &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/idna ${HARVEST_TARGET}/Release/site-packages/idna &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/chardet ${HARVEST_TARGET}/Release/site-packages/chardet &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/urllib3 ${HARVEST_TARGET}/Release/site-packages/urllib3 &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/certifi ${HARVEST_TARGET}/Release/site-packages/certifi &&
${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/requests ${HARVEST_TARGET}/Release/site-packages/requests
)
else()
set(HARVEST_CMD echo .)
endif()
ExternalProject_Add(external_python_site_packages
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
PREFIX ${BUILD_DIR}/site_packages
INSTALL_COMMAND ${PYTHON_BINARY} -m pip install idna==${IDNA_VERSION} chardet==${CHARDET_VERSION} urllib3==${URLLIB3_VERSION} certifi==${CERTIFI_VERSION} requests==${REQUESTS_VERSION} --no-binary :all: && ${HARVEST_CMD}
)
add_dependencies(external_python_site_packages Make_Python_Environment)

View File

@@ -14,31 +14,16 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
../include
../../blenkernel
../../blenlib
../../blentranslation
../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
)
set(INC_SYS
)
set(SRC
scene_edit.c
)
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
blender_add_lib(bf_editor_scene "${SRC}" "${INC}" "${INC_SYS}")
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add(external_requests
URL ${REQUESTS_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${REQUESTS_HASH}
PREFIX ${BUILD_DIR}/requests
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/requests/src/external_requests/requests ${LIBDIR}/requests
)
endif(BUILD_MODE STREQUAL Release)

View File

@@ -21,16 +21,6 @@ set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR
if(WIN32)
set(SNDFILE_ENV set ${SNDFILE_ENV} &&)
#shared for windows because static libs will drag in a libgcc dependency.
set(SNDFILE_OPTIONS --disable-static --enable-shared )
else()
set(SNDFILE_OPTIONS --enable-static --disable-shared )
endif()
if(APPLE)
set(SNDFILE_PATCH_CMD ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/sndfile/src/external_sndfile < ${PATCH_DIR}/sndfile.diff)
else()
set(SNDFILE_PATCH_CMD)
endif()
ExternalProject_Add(external_sndfile
@@ -38,8 +28,7 @@ ExternalProject_Add(external_sndfile
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${SNDFILE_HASH}
PREFIX ${BUILD_DIR}/sndfile
PATCH_COMMAND ${SNDFILE_PATCH_CMD}
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} ${SNDFILE_OPTIONS} --prefix=${mingw_LIBDIR}/sndfile
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} --enable-static --disable-shared --prefix=${mingw_LIBDIR}/sndfile
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install
INSTALL_DIR ${LIBDIR}/sndfile

View File

@@ -131,11 +131,10 @@ set(OSL_VERSION 1.7.5)
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.zip)
set(OSL_HASH 6924dd5d453159e7b6eb106a08c358cf)
set(PYTHON_VERSION 3.6.2)
set(PYTHON_SHORT_VERSION 3.6)
set(PYTHON_SHORT_VERSION_NO_DOTS 36)
set(PYTHON_VERSION 3.5.3)
set(PYTHON_SHORT_VERSION 3.5)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH 2c68846471994897278364fc18730dd9)
set(PYTHON_HASH 57d1f8bfbabf4f2500273fb0706e6f21)
set(TBB_VERSION 44_20160128)
set(TBB_URI https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb${TBB_VERSION}oss_src_0.tgz)
@@ -145,16 +144,14 @@ set(OPENVDB_VERSION 3.1.0)
set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
set(OPENVDB_HASH 30a7e9571a03ab7bcf1a39fb62aa436f)
set(IDNA_VERSION 2.6)
set(CHARDET_VERSION 3.0.2)
set(URLLIB3_VERSION 1.22)
set(CERTIFI_VERSION 2017.7.27.1)
set(REQUESTS_VERSION 2.18.4)
set(REQUESTS_VERSION v2.10.0)
set(REQUESTS_URI https://github.com/kennethreitz/requests/archive/${REQUESTS_VERSION}.zip)
set(REQUESTS_HASH 6ebefdf0210c7f0933f61501334e46c3)
set(NUMPY_VERSION v1.13.1)
set(NUMPY_SHORT_VERSION 1.13)
set(NUMPY_URI https://pypi.python.org/packages/c0/3a/40967d9f5675fbb097ffec170f59c2ba19fc96373e73ad47c2cae9a30aed/numpy-1.13.1.zip)
set(NUMPY_HASH 2c3c0f4edf720c3a7b525dacc825b9ae)
set(NUMPY_VERSION v1.10.1)
set(NUMPY_SHORT_VERSION 1.10)
set(NUMPY_URI https://pypi.python.org/packages/a5/2e/5412784108f5dc0f827fb460ccdeaa9d76286979fe5ddd070d526d168a59/numpy-1.10.1.zip)
set(NUMPY_HASH 6f57c58bc5b28440fbeccd505da63d58)
set(LAME_VERSION 3.99.5)
set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.99/lame-${LAME_VERSION}.tar.gz)
@@ -195,11 +192,9 @@ set(XVIDCORE_VERSION 1.3.4)
set(XVIDCORE_URI http://downloads.xvid.org/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
set(XVIDCORE_HASH 4e9fd62728885855bc5007fe1be58df42e5e274497591fec37249e1052ae316f)
#this has to be in sync with the version in blenders /extern folder
set(OPENJPEG_VERSION 1.5.2)
set(OPENJPEG_SHORT_VERSION 1.5)
set(OPENJPEG_VERSION 1.5)
set(OPENJPEG_URI https://github.com/uclouvain/openjpeg/archive/version.${OPENJPEG_VERSION}.tar.gz)
set(OPENJPEG_HASH 3734e95edd0bef6e056815591755efd822228dc3cd866894e00a2c929026b16d)
set(OPENJPEG_HASH 60662566595e02104c0f6d1052f8b1669624c646e62b6280d5fd5a66d4e92f8d)
set(FAAD_VERSION 2-2.7)
set(FAAD_URI http://downloads.sourceforge.net/faac/faad${FAAD_VERSION}.tar.bz2)
@@ -221,9 +216,9 @@ set(LAPACK_VERSION 3.6.0)
set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz)
set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101)
set(SNDFILE_VERSION 1.0.28)
set(SNDFILE_VERSION 1.0.26)
set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz)
set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
set(SNDFILE_HASH ec810a0c60c08772a8a5552704b63393)
#set(HIDAPI_VERSION 0.8.0-rc1)
#set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz)

View File

@@ -23,11 +23,7 @@ if(WIN32)
set(VPX_EXTRA_FLAGS --target=x86-win32-gcc)
endif()
else()
if(APPLE)
set(VPX_EXTRA_FLAGS --target=x86_64-darwin13-gcc)
else()
set(VPX_EXTRA_FLAGS --target=generic-gnu)
endif()
set(VPX_EXTRA_FLAGS --target=generic-gnu)
endif()
ExternalProject_Add(external_vpx
@@ -37,7 +33,7 @@ ExternalProject_Add(external_vpx
PREFIX ${BUILD_DIR}/vpx
CONFIGURE_COMMAND ${CONFIGURE_ENV} &&
cd ${BUILD_DIR}/vpx/src/external_vpx/ &&
${CONFIGURE_COMMAND_NO_TARGET} --prefix=${LIBDIR}/vpx
${CONFIGURE_COMMAND} --prefix=${LIBDIR}/vpx
--disable-shared
--enable-static
--disable-install-bins

View File

@@ -25,7 +25,7 @@
ARGS=$( \
getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,use-cxx11,\
with-all,with-opencollada,with-jack,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
force-all,force-python,force-numpy,force-boost,\
@@ -104,6 +104,11 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--no-confirm
Disable any interaction with user (suitable for automated run).
--use-cxx11
Build all libraries in cpp11 'mode' (will be mandatory soon in blender2.8 branch).
NOTE: If your compiler is gcc-6.0 or above, you probably *want* to enable this option (since it's default
standard starting from this version).
--with-all
By default, a number of optional and not-so-often needed libraries are not installed.
This option will try to install them, at the cost of potential conflicts (depending on
@@ -285,15 +290,15 @@ SUDO="sudo"
NO_BUILD=false
NO_CONFIRM=false
USE_CXX11=true # Mandatory in blender2.8
USE_CXX11=false
PYTHON_VERSION="3.6.2"
PYTHON_VERSION_MIN="3.6"
PYTHON_VERSION="3.5.3"
PYTHON_VERSION_MIN="3.5"
PYTHON_FORCE_BUILD=false
PYTHON_FORCE_REBUILD=false
PYTHON_SKIP=false
NUMPY_VERSION="1.13.1"
NUMPY_VERSION="1.10.1"
NUMPY_VERSION_MIN="1.8"
NUMPY_FORCE_BUILD=false
NUMPY_FORCE_REBUILD=false
@@ -496,6 +501,9 @@ while true; do
--no-confirm)
NO_CONFIRM=true; shift; continue
;;
--use-cxx11)
USE_CXX11=true; shift; continue
;;
--with-all)
WITH_ALL=true; shift; continue
;;
@@ -731,7 +739,7 @@ PRINT ""
# This has to be done here, because user might force some versions...
PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" )
NUMPY_SOURCE=( "https://github.com/numpy/numpy/releases/download/v$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
NUMPY_SOURCE=( "http://sourceforge.net/projects/numpy/files/NumPy/$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" )
@@ -796,7 +804,7 @@ FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
CXXFLAGS_BACK=$CXXFLAGS
if [ "$USE_CXX11" = true ]; then
WARNING "C++11 is now mandatory for blender2.8, this *should* go smoothly with any very recent distribution.
WARNING "You are trying to use c++11, this *should* go smoothely with any very recent distribution
However, if you are experiencing linking errors (also when building Blender itself), please try the following:
* Re-run this script with '--build-all --force-all' options.
* Ensure your gcc version is at the very least 4.8, if possible you should really rather use gcc-5.1 or above.
@@ -1152,7 +1160,7 @@ compile_Numpy() {
cd $_src
$_python/bin/python3 setup.py install --old-and-unmanageable --prefix=$_inst
$_python/bin/python3 setup.py install --prefix=$_inst
if [ -d $_inst ]; then
# Can't use _create_inst_shortcut here...
@@ -1769,7 +1777,7 @@ compile_LLVM() {
cd $_src
# XXX Ugly patching hack!
patch -p1 -i "$SCRIPT_DIR/patches/install_deps_llvm.diff"
patch -p1 -i "$SCRIPT_DIR/patches/install_deps_llvm.patch"
cd $CWD
@@ -1875,7 +1883,7 @@ compile_OSL() {
git reset --hard
# XXX Ugly patching hack!
patch -p1 -i "$SCRIPT_DIR/patches/install_deps_osl.diff"
patch -p1 -i "$SCRIPT_DIR/patches/install_deps_osl.patch"
fi
# Always refresh the whole build!
@@ -2673,10 +2681,10 @@ install_DEB() {
install_packages_DEB $_packages
PRINT""
LIBSNDFILE_DEV="libsndfile1-dev"
check_package_DEB $LIBSNDFILE_DEV
SNDFILE_DEV="libsndfile1-dev"
check_package_DEB $SNDFILE_DEV
if [ $? -eq 0 ]; then
install_packages_DEB $LIBSNDFILE_DEV
install_packages_DEB $SNDFILE_DEV
fi
PRINT ""
@@ -3271,10 +3279,10 @@ install_RPM() {
fi
PRINT""
LIBSNDFILE_DEV="libsndfile-devel"
check_package_RPM $LIBSNDFILE_DEV
SNDFILE_DEV="libsndfile-devel"
check_package_RPM $SNDFILE_DEV
if [ $? -eq 0 ]; then
install_packages_RPM $LIBSNDFILE_DEV
install_packages_RPM $SNDFILE_DEV
fi
if [ "$WITH_ALL" = true ]; then
@@ -3678,10 +3686,10 @@ install_ARCH() {
install_packages_ARCH $_packages
PRINT""
LIBSNDFILE_DEV="libsndfile"
check_package_ARCH $LIBSNDFILE_DEV
SNDFILE_DEV="libsndfile"
check_package_ARCH $SNDFILE_DEV
if [ $? -eq 0 ]; then
install_packages_ARCH $LIBSNDFILE_DEV
install_packages_ARCH $SNDFILE_DEV
fi
PRINT ""

View File

@@ -1,11 +1,10 @@
--- CMakeLists.txt 2016-11-01 01:03:44 -0600
+++ CMakeLists.txt 2016-12-01 09:20:12 -0700
@@ -454,7 +454,7 @@
@@ -454,7 +454,6 @@
add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions (-D_SCL_SECURE_NO_WARNINGS)
add_definitions (-DJAS_WIN_MSVC_BUILD)
- add_definitions (-DOPENEXR_DLL)
+ add_definitions (-DOPJ_STATIC)
if (LINKSTATIC)
add_definitions (-DBoost_USE_STATIC_LIBS=1)
else ()

View File

@@ -1,45 +1,3 @@
--- Include/Python.h 2017-07-07 21:33:27 -0600
+++ Include/Python.h 2017-09-19 10:36:10 -0600
@@ -2,6 +2,10 @@
#define Py_PYTHON_H
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
+#if _MSC_VER < 1900
+#define inline __inline
+#endif
+
/* Include nearly all Python header files */
#include "patchlevel.h"
--- Include/pydtrace.h 2017-07-07 21:33:27 -0600
+++ Include/pydtrace.h 2017-09-19 10:32:31 -0600
@@ -2,6 +2,11 @@
#ifndef Py_DTRACE_H
#define Py_DTRACE_H
+
+#if _MSC_VER < 1900
+#define inline __inline
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
--- Modules/_blake2/impl/blake2.h 2017-07-07 21:33:27 -0600
+++ Modules/_blake2/impl/blake2.h 2017-09-19 10:22:41 -0600
@@ -19,6 +19,10 @@
#include <stddef.h>
#include <stdint.h>
+#if _MSC_VER < 1900
+#define inline __inline
+#endif
+
#ifdef BLAKE2_NO_INLINE
#define BLAKE2_LOCAL_INLINE(type) static type
#endif
--- pcbuild/build.bat 2016-05-21 09:53:55 -0600
+++ pcbuild/build.bat 2016-05-21 09:56:16 -0600
@@ -59,6 +59,7 @@
@@ -50,19 +8,19 @@
if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
@@ -120,7 +120,7 @@
@@ -126,7 +126,7 @@
:Kill
echo on
-%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
+%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose% /p:PlatformToolset=%vs_toolset%^
-msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
+msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose% /p:PlatformToolset=%vs_toolset%^
/p:Configuration=%conf% /p:Platform=%platf%^
/p:KillPython=true
@@ -130,7 +130,7 @@
@@ -95,7 +96,7 @@
rem batch is, shall we say, "lackluster"
echo on
%MSBUILD% "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
- /p:Configuration=%conf% /p:Platform=%platf%^
+ /p:Configuration=%conf% /p:Platform=%platf% /p:PlatformToolset=%vs_toolset%^
/p:IncludeExternals=%IncludeExternals%^

View File

@@ -1,5 +1,28 @@
--- pyconfig.h.in 2017-09-19 14:41:01.000000000 +0300
+++ pyconfig.h.in 2017-09-19 14:43:18.000000000 +0300
--- Modules/expat/expat_external.h 2016-12-17 06:51:30 -0500
+++ Modules/expat/expat_external.h 2016-12-17 06:55:29 -0500
@@ -7,9 +7,17 @@
/* External API definitions */
-/* Namespace external symbols to allow multiple libexpat version to
- co-exist. */
-#include "pyexpatns.h"
+/*
+
+ HACK: Fix build breakage on MacOS:
+ *** WARNING: renaming "pyexpat" since importing it failed: dlopen(build/lib.macosx-10.6-i386-3.3/pyexpat.so, 2): Symbol not found: _XML_ErrorString
+ This reverts c242a8f30806 from the python hg repo:
+ restore namespacing of pyexpat symbols (closes #19186)
+ See http://bugs.python.org/issue19186#msg214069
+ The recommendation to include Modules/inc at first broke the Linux build...
+ So do it this way, as it was before. Needs some realignment later.
+
+*/
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
#define XML_USE_MSC_EXTENSIONS 1
--- pyconfig.h.in 2017-04-05 02:47:52.000000000 +0200
+++ pyconfig.h.in 2017-04-05 02:51:33.000000000 +0200
@@ -119,12 +119,6 @@
/* Define to 1 if you have the `clock' function. */
#undef HAVE_CLOCK
@@ -10,10 +33,10 @@
-/* Define to 1 if you have the `clock_gettime' function. */
-#undef HAVE_CLOCK_GETTIME
-
/* Define to 1 if you have the `clock_settime' function. */
#undef HAVE_CLOCK_SETTIME
/* Define if the C compiler supports computed gotos. */
#undef HAVE_COMPUTED_GOTOS
@@ -369,9 +363,6 @@
@@ -338,9 +332,6 @@
/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */
#undef HAVE_GETC_UNLOCKED

View File

@@ -1,18 +1,6 @@
--- _msvccompiler.py.orig 2017-05-20 19:31:45 -0600
+++ _msvccompiler.py 2017-06-10 10:05:38 -0600
@@ -222,9 +222,9 @@
# use /MT[d] to build statically, then switch from libucrt[d].lib to ucrt[d].lib
# later to dynamically link to ucrtbase but not vcruntime.
self.compile_options = [
- '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG'
+ '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG' , '/MD'
]
- self.compile_options.append('/MD' if self._vcruntime_redist else '/MT')
+ #self.compile_options.append('/MD' if self._vcruntime_redist else '/MT')
self.compile_options_debug = [
'/nologo', '/Od', '/MDd', '/Zi', '/W3', '/D_DEBUG'
@@ -233,11 +233,11 @@
--- _msvccompiler.py 2016-08-12 10:44:32 -0600
+++ _msvccompiler.py 2016-08-12 10:47:29 -0600
@@ -246,8 +246,8 @@
ldflags = [
'/nologo', '/INCREMENTAL:NO', '/LTCG'
]
@@ -22,8 +10,4 @@
+ # ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib'))
ldflags_debug = [
- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL'
+ '/nologo', '/INCREMENTAL:NO', '/LTCG'
]
self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1']
'/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL'

View File

@@ -1,42 +0,0 @@
--- src/Makefile.in 2017-09-26 01:28:47.000000000 +0300
+++ src/Makefile.in 2017-09-26 01:19:06.000000000 +0300
@@ -513,7 +513,7 @@
libcommon_la_SOURCES = common.c file_io.c command.c pcm.c ulaw.c alaw.c \
float32.c double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
interleave.c strings.c dither.c cart.c broadcast.c audio_detect.c \
- ima_oki_adpcm.c ima_oki_adpcm.h alac.c chunk.c ogg.c chanmap.c \
+ ima_oki_adpcm.c ima_oki_adpcm.h alac.c chunk.c ogg.c chanmap.c \
windows.c id3.c $(WIN_VERSION_FILE)
@@ -719,10 +719,10 @@
$(AM_V_CCLD)$(LINK) $(GSM610_libgsm_la_OBJECTS) $(GSM610_libgsm_la_LIBADD) $(LIBS)
libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) $(EXTRA_libcommon_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS)
+ $(AM_V_CCLD)$(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS) $(EXTERNAL_XIPH_LIBS)
libsndfile.la: $(libsndfile_la_OBJECTS) $(libsndfile_la_DEPENDENCIES) $(EXTRA_libsndfile_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libsndfile_la_LINK) -rpath $(libdir) $(libsndfile_la_OBJECTS) $(libsndfile_la_LIBADD) $(LIBS)
+ $(AM_V_CCLD)$(libsndfile_la_LINK) -rpath $(libdir) $(libsndfile_la_OBJECTS) $(libsndfile_la_LIBADD) $(LIBS) $(EXTERNAL_XIPH_LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -924,7 +924,7 @@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -c -o libsndfile_la-dwd.lo `test -f 'dwd.c' || echo '$(srcdir)/'`dwd.c
libsndfile_la-flac.lo: flac.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -MT libsndfile_la-flac.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-flac.Tpo -c -o libsndfile_la-flac.lo `test -f 'flac.c' || echo '$(srcdir)/'`flac.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) $(EXTERNAL_XIPH_CFLAGS) -MT libsndfile_la-flac.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-flac.Tpo -c -o libsndfile_la-flac.lo `test -f 'flac.c' || echo '$(srcdir)/'`flac.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsndfile_la-flac.Tpo $(DEPDIR)/libsndfile_la-flac.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='flac.c' object='libsndfile_la-flac.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@@ -1092,7 +1092,7 @@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -c -o libsndfile_la-rf64.lo `test -f 'rf64.c' || echo '$(srcdir)/'`rf64.c
libsndfile_la-ogg_vorbis.lo: ogg_vorbis.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -MT libsndfile_la-ogg_vorbis.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo -c -o libsndfile_la-ogg_vorbis.lo `test -f 'ogg_vorbis.c' || echo '$(srcdir)/'`ogg_vorbis.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) $(EXTERNAL_XIPH_CFLAGS) -MT libsndfile_la-ogg_vorbis.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo -c -o libsndfile_la-ogg_vorbis.lo `test -f 'ogg_vorbis.c' || echo '$(srcdir)/'`ogg_vorbis.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo $(DEPDIR)/libsndfile_la-ogg_vorbis.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ogg_vorbis.c' object='libsndfile_la-ogg_vorbis.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@

View File

@@ -54,7 +54,7 @@ set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=On
if "%3" == "debug" set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=Off
set SOURCE_DIR=%~dp0\..
set BUILD_DIR=%cd%\build
set BUILD_DIR=%~dp0\..\..\..\..\build_windows\deps
set HARVEST_DIR=%BUILD_DIR%\output
set STAGING=%BUILD_DIR%\S
@@ -62,7 +62,7 @@ rem for python module build
set MSSdk=1
set DISTUTILS_USE_SDK=1
rem for python externals source to be shared between the various archs and compilers
mkdir %BUILD_DIR%\downloads\externals
mkdir %SOURCE_DIR%\downloads\externals
REM Detect MSVC Installation
if DEFINED VisualStudioVersion goto msvc_detect_finally
@@ -95,24 +95,24 @@ if %ERRORLEVEL% NEQ 0 (
)
set StatusFile=%BUILD_DIR%\%1_%2.log
set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%path%
set path=%SOURCE_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%SOURCE_DIR%\downloads\nasm-2.12.01\;%path%
mkdir %STAGING%\%BuildDir%%ARCH%R
cd %Staging%\%BuildDir%%ARCH%R
echo %DATE% %TIME% : Start > %StatusFile%
cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/
cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/
echo %DATE% %TIME% : Release Configuration done >> %StatusFile%
msbuild /m "ll.vcxproj" /p:Configuration=Release /fl /flp:logfile=BlenderDeps_llvm.log;Verbosity=normal
msbuild /m "BlenderDependencies.sln" /p:Configuration=Release /fl /flp:logfile=BlenderDeps.log;Verbosity=minimal /verbosity:minimal
msbuild /m "ll.vcxproj" /p:Configuration=Release /fl /flp:logfile=BlenderDeps_llvm.log
msbuild /m "BlenderDependencies.sln" /p:Configuration=Release /fl /flp:logfile=BlenderDeps.log
echo %DATE% %TIME% : Release Build done >> %StatusFile%
cmake --build . --target Harvest_Release_Results > Harvest_Release.txt
echo %DATE% %TIME% : Release Harvest done >> %StatusFile%
cd %BUILD_DIR%
mkdir %STAGING%\%BuildDir%%ARCH%D
cd %Staging%\%BuildDir%%ARCH%D
cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS%
cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS%
echo %DATE% %TIME% : Debug Configuration done >> %StatusFile%
msbuild /m "ll.vcxproj" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps_llvm.log;;Verbosity=normal
msbuild /m "BlenderDependencies.sln" /p:Configuration=Debug /verbosity:n /fl /flp:logfile=BlenderDeps.log;;Verbosity=normal
msbuild /m "ll.vcxproj" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps_llvm.log
msbuild /m "BlenderDependencies.sln" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps.log
echo %DATE% %TIME% : Debug Build done >> %StatusFile%
cmake --build . --target Harvest_Debug_Results> Harvest_Debug.txt
echo %DATE% %TIME% : Debug Harvest done >> %StatusFile%

View File

@@ -70,11 +70,11 @@ set(FFMPEG_LIBRARIES
)
# SndFile libraries
set(SNDFILE_LIBRARY "/usr/lib${MULTILIB}/libsndfile.a;/usr/lib${MULTILIB}/libFLAC.a" CACHE STRING "" FORCE)
set(SNDFILE_LIBRARY "/usr/lib/libsndfile.a;/usr/lib/libFLAC.a" CACHE STRING "" FORCE)
# OpenAL libraries
set(OPENAL_ROOT_DIR "/opt/lib/openal" CACHE STRING "" FORCE)
set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include/AL" CACHE STRING "" FORCE)
set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include" CACHE STRING "" FORCE)
set(OPENAL_LIBRARY
${OPENAL_ROOT_DIR}/lib/libopenal.a
${OPENAL_ROOT_DIR}/lib/libcommon.a

View File

@@ -245,7 +245,10 @@ def git_submodules_update():
def lib_svn_step(dir):
return SVN(name='lib svn',
name = "lib svn"
if dir == "darwin":
name = "C++11 lib svn"
return SVN(name=name,
baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir,
codebase='lib svn',
mode='update',
@@ -274,6 +277,9 @@ def generic_builder(id, libdir='', branch='', rsync=False):
f = BuildFactory()
if libdir != '':
f.addStep(lib_svn_step(libdir))
# Special trick to make sure we always have all the libs.
if libdir.startswith("darwin"):
f.addStep(lib_svn_step("darwin"))
for submodule in ('blender-translations',
'blender-addons',
@@ -306,13 +312,15 @@ def generic_builder(id, libdir='', branch='', rsync=False):
# Builders
add_builder(c, 'mac_x86_64_10_9_cmake', 'darwin', generic_builder, hour=1)
add_builder(c, 'linux_glibc219_i686_cmake', '', generic_builder, hour=2)
add_builder(c, 'linux_glibc219_x86_64_cmake', '', generic_builder, hour=1)
add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=1)
add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=2)
add_builder(c, 'win32_cmake_vc2015', 'windows_vc14', generic_builder, hour=3)
add_builder(c, 'win64_cmake_vc2015', 'win64_vc14', generic_builder, hour=4)
add_builder(c, 'mac_x86_64_10_6_cmake', 'darwin-9.x.universal', generic_builder, hour=5)
# add_builder(c, 'linux_glibc211_i686_cmake', '', generic_builder, hour=1)
# add_builder(c, 'linux_glibc211_x86_64_cmake', '', generic_builder, hour=2)
add_builder(c, 'linux_glibc219_i686_cmake', '', generic_builder, hour=3)
add_builder(c, 'linux_glibc219_x86_64_cmake', '', generic_builder, hour=4)
add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=3)
add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=4)
add_builder(c, 'win32_cmake_vc2015', 'windows_vc14', generic_builder, hour=5)
add_builder(c, 'win64_cmake_vc2015', 'win64_vc14', generic_builder, hour=6)
# STATUS TARGETS
#

View File

@@ -70,12 +70,15 @@ if 'cmake' in builder:
if builder.startswith('mac'):
# Set up OSX architecture
if builder.endswith('x86_64_10_9_cmake'):
if builder.endswith('x86_64_10_6_cmake'):
cmake_extra_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
cmake_extra_options.append('-DWITH_CODEC_QUICKTIME=OFF')
cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.6')
cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
elif builder.startswith('win'):
if builder.endswith('_vc2015'):
if builder.startswith('win64'):

View File

@@ -101,9 +101,13 @@ if builder.find('cmake') != -1:
platform = builder.split('_')[0]
if platform == 'mac':
# Special exception for OSX
platform = 'OSX-10.9-'
if builder.endswith('x86_64_10_9_cmake'):
platform = 'OSX-10.6-'
if builder.endswith('x86_64_10_6_cmake'):
platform += 'x86_64'
elif builder.endswith('i386_10_6_cmake'):
platform += 'i386'
elif builder.endswith('ppc_10_6_cmake'):
platform += 'ppc'
if builder.endswith('vc2015'):
platform += "-vc14"
builderified_name = 'blender-{}-{}-{}'.format(blender_full_version, git_hash, platform)

View File

@@ -9,6 +9,7 @@
#
# also defined,
# GLEW_LIBRARY, where to find the Glew library.
# GLEW_MX_LIBRARY, where to find the GlewMX library.
#=============================================================================
# Copyright 2014 Blender Foundation.
@@ -49,6 +50,16 @@ FIND_LIBRARY(GLEW_LIBRARY
lib64 lib
)
FIND_LIBRARY(GLEW_MX_LIBRARY
NAMES
GLEWmx
HINTS
${_glew_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
@@ -62,6 +73,7 @@ ENDIF(GLEW_FOUND)
MARK_AS_ADVANCED(
GLEW_INCLUDE_DIR
GLEW_LIBRARY
GLEW_MX_LIBRARY
)
UNSET(_glew_SEARCH_DIRS)

View File

@@ -38,7 +38,7 @@ IF(NOT PYTHON_ROOT_DIR AND NOT $ENV{PYTHON_ROOT_DIR} STREQUAL "")
SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR})
ENDIF()
SET(PYTHON_VERSION 3.6 CACHE STRING "Python Version (major and minor only)")
SET(PYTHON_VERSION 3.5 CACHE STRING "Python Version (major and minor only)")
MARK_AS_ADVANCED(PYTHON_VERSION)
@@ -77,12 +77,15 @@ SET(_python_SEARCH_DIRS
# only search for the dirs if we havn't already
IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
SET(_PYTHON_ABI_FLAGS_TEST
SET(_python_ABI_FLAGS
"m;mu;u; " # release
"dm;dmu;du;d" # debug
)
FOREACH(_CURRENT_ABI_FLAGS ${_PYTHON_ABI_FLAGS_TEST})
FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
#IF(CMAKE_BUILD_TYPE STREQUAL Debug)
# SET(_CURRENT_ABI_FLAGS "d${_CURRENT_ABI_FLAGS}")
#ENDIF()
@@ -167,7 +170,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
UNSET(_CURRENT_ABI_FLAGS)
UNSET(_CURRENT_PATH)
UNSET(_PYTHON_ABI_FLAGS_TEST)
UNSET(_python_ABI_FLAGS)
ENDIF()
UNSET(_IS_INC_DEF)

View File

@@ -1,15 +1,15 @@
# - Find SndFile library
# Find the native SndFile includes and library
# This module defines
# LIBSNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
# LIBSNDFILE_INCLUDE_DIR is found.
# LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
# LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
# SNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
# SNDFILE_INCLUDE_DIR is found.
# SNDFILE_LIBRARIES, libraries to link against to use SndFile.
# SNDFILE_ROOT_DIR, The base directory to search for SndFile.
# This can also be an environment variable.
# LIBSNDFILE_FOUND, If false, do not try to use SndFile.
# SNDFILE_FOUND, If false, do not try to use SndFile.
#
# also defined, but not for general use are
# LIBSNDFILE_LIBRARY, where to find the SndFile library.
# SNDFILE_LIBRARY, where to find the SndFile library.
#=============================================================================
# Copyright 2011 Blender Foundation.
@@ -22,27 +22,27 @@
# See the License for more information.
#=============================================================================
# If LIBSNDFILE_ROOT_DIR was defined in the environment, use it.
IF(NOT LIBSNDFILE_ROOT_DIR AND NOT $ENV{LIBSNDFILE_ROOT_DIR} STREQUAL "")
SET(LIBSNDFILE_ROOT_DIR $ENV{LIBSNDFILE_ROOT_DIR})
# If SNDFILE_ROOT_DIR was defined in the environment, use it.
IF(NOT SNDFILE_ROOT_DIR AND NOT $ENV{SNDFILE_ROOT_DIR} STREQUAL "")
SET(SNDFILE_ROOT_DIR $ENV{SNDFILE_ROOT_DIR})
ENDIF()
SET(_sndfile_SEARCH_DIRS
${LIBSNDFILE_ROOT_DIR}
${SNDFILE_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
)
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h
FIND_PATH(SNDFILE_INCLUDE_DIR sndfile.h
HINTS
${_sndfile_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(LIBSNDFILE_LIBRARY
FIND_LIBRARY(SNDFILE_LIBRARY
NAMES
sndfile
HINTS
@@ -51,18 +51,18 @@ FIND_LIBRARY(LIBSNDFILE_LIBRARY
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
IF(LIBSNDFILE_FOUND)
SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
SET(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
ENDIF(LIBSNDFILE_FOUND)
IF(SNDFILE_FOUND)
SET(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
SET(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
ENDIF(SNDFILE_FOUND)
MARK_AS_ADVANCED(
LIBSNDFILE_INCLUDE_DIR
LIBSNDFILE_LIBRARY
SNDFILE_INCLUDE_DIR
SNDFILE_LIBRARY
)

View File

@@ -61,8 +61,10 @@ def replace_line(f, i, text, keep_indent=True):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
if dirpath.startswith("."):
continue
for filename in filenames:
if filename_check is None or filename_check(filename):

View File

@@ -66,7 +66,9 @@ elseif(WIN32)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
# apple_check_quicktime()
endif()

View File

@@ -56,3 +56,7 @@ set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE OFF CACHE BOOL "" FORCE)
if(APPLE)
set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
endif()

View File

@@ -67,7 +67,9 @@ elseif(WIN32)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
# apple_check_quicktime()
endif()

View File

@@ -318,7 +318,7 @@ function(SETUP_LIBDIRS)
link_directories(${JACK_LIBPATH})
endif()
if(WITH_CODEC_SNDFILE)
link_directories(${LIBSNDFILE_LIBPATH})
link_directories(${SNDFILE_LIBPATH})
endif()
if(WITH_FFTW3)
link_directories(${FFTW3_LIBPATH})
@@ -398,11 +398,14 @@ function(setup_liblinks
target_link_libraries(${target} ${JACK_LIBRARIES})
endif()
if(WITH_CODEC_SNDFILE)
target_link_libraries(${target} ${LIBSNDFILE_LIBRARIES})
target_link_libraries(${target} ${SNDFILE_LIBRARIES})
endif()
if(WITH_SDL AND NOT WITH_SDL_DYNLOAD)
target_link_libraries(${target} ${SDL_LIBRARY})
endif()
if(WITH_CODEC_QUICKTIME)
target_link_libraries(${target} ${QUICKTIME_LIBRARIES})
endif()
if(WITH_IMAGE_TIFF)
target_link_libraries(${target} ${TIFF_LIBRARY})
endif()
@@ -546,12 +549,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
endif()
endif()
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
list(APPEND BLENDER_LINK_LIBS
audaspace
audaspace-py)
endif()
# Sort libraries
set(BLENDER_SORTED_LIBS
bf_windowmanager
@@ -582,14 +579,12 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_curve
bf_editor_gpencil
bf_editor_interface
bf_editor_manipulator_library
bf_editor_mesh
bf_editor_metaball
bf_editor_object
bf_editor_armature
bf_editor_physics
bf_editor_render
bf_editor_scene
bf_editor_screen
bf_editor_sculpt_paint
bf_editor_sound
@@ -602,7 +597,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_python
bf_python_ext
bf_python_mathutils
bf_python_gawain
bf_python_bmesh
bf_freestyle
bf_ikplugin
@@ -610,14 +604,11 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_alembic
bf_bmesh
bf_gpu
bf_draw
bf_blenloader
bf_blenkernel
bf_physics
bf_nodes
bf_rna
bf_editor_manipulator_library # rna -> manipulator bad-level calls
bf_python
bf_imbuf
bf_blenlib
bf_depsgraph
@@ -658,8 +649,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_blenfont
bf_blentranslation
bf_intern_audaspace
audaspace
audaspace-py
bf_intern_mikktspace
bf_intern_dualcon
bf_intern_cycles
@@ -671,7 +660,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
cycles_util
cycles_subd
bf_intern_opencolorio
bf_intern_gawain
bf_intern_eigen
extern_rangetree
extern_wcwidth
@@ -727,6 +715,10 @@ function(SETUP_BLENDER_SORTED_LIBS)
list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
endif()
if(WITH_CODEC_QUICKTIME)
list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
endif()
if(WITH_MOD_BOOLEAN)
list(APPEND BLENDER_SORTED_LIBS extern_carve)
endif()
@@ -1511,7 +1503,6 @@ function(find_python_package
NAMES
${package}
HINTS
"${PYTHON_LIBPATH}/"
"${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
"${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
PATH_SUFFIXES

View File

@@ -23,14 +23,16 @@
# Libraries configuration for Apple.
set(MACOSX_DEPLOYMENT_TARGET "10.9")
macro(find_package_wrapper)
# do nothing, just satisfy the macro
endmacro()
if(NOT DEFINED LIBDIR)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
if(WITH_CXX11)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
else()
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
endif()
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif()
@@ -42,7 +44,7 @@ if(WITH_OPENAL)
find_package(OpenAL)
if(OPENAL_FOUND)
set(WITH_OPENAL ON)
set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include/AL")
set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
else()
set(WITH_OPENAL OFF)
endif()
@@ -78,20 +80,20 @@ if(WITH_JACK)
endif()
if(WITH_CODEC_SNDFILE)
set(LIBSNDFILE ${LIBDIR}/sndfile)
set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
set(LIBSNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate
set(SNDFILE ${LIBDIR}/sndfile)
set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
set(SNDFILE_LIBPATH ${SNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate
endif()
if(WITH_PYTHON)
# we use precompiled libraries for py 3.5 and up by default
set(PYTHON_VERSION 3.6)
set(PYTHON_VERSION 3.5)
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
# normally cached but not since we include them with blender
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}m")
set(PYTHON_LIBRARY ${LIBDIR}/python/lib/libpython${PYTHON_VERSION}m.a)
set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
else()
@@ -111,9 +113,6 @@ if(WITH_PYTHON)
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
# needed for Audaspace, numpy is installed into python site-packages
set(NUMPY_INCLUDE_DIRS "${PYTHON_LIBPATH}/site-packages/numpy/core/include")
if(NOT EXISTS "${PYTHON_EXECUTABLE}")
message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}")
endif()
@@ -142,7 +141,11 @@ if(WITH_IMAGE_OPENEXR)
set(OPENEXR ${LIBDIR}/openexr)
set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR)
set(OPENEXR_POSTFIX -2_2)
if(WITH_CXX11)
set(OPENEXR_POSTFIX -2_2)
else()
set(OPENEXR_POSTFIX)
endif()
set(OPENEXR_LIBRARIES
Iex${OPENEXR_POSTFIX}
Half
@@ -159,16 +162,20 @@ if(WITH_CODEC_FFMPEG)
avcodec avdevice avformat avutil
mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg
)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} schroedinger orc vpx webp swresample)
if(WITH_CXX11)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} schroedinger orc vpx webp swresample)
endif()
set(FFMPEG_LIBPATH ${FFMPEG}/lib)
endif()
if(WITH_OPENJPEG OR WITH_CODEC_FFMPEG)
# use openjpeg from libdir that is linked into ffmpeg
set(OPENJPEG ${LIBDIR}/openjpeg)
set(WITH_SYSTEM_OPENJPEG ON)
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include)
set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/libopenjpeg.a)
if(WITH_CXX11)
set(OPENJPEG ${LIBDIR}/openjpeg)
set(WITH_SYSTEM_OPENJPEG ON)
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include)
set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/libopenjpeg.a)
endif()
endif()
find_library(SYSTEMSTUBS_LIBRARY
@@ -185,8 +192,19 @@ set(PLATFORM_CFLAGS "-pipe -funsigned-char")
set(PLATFORM_LINKFLAGS
"-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio"
)
if(WITH_CODEC_QUICKTIME)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
# libSDL still needs 32bit carbon quicktime
endif()
endif()
list(APPEND PLATFORM_LINKLIBS c++)
if(WITH_CXX11)
list(APPEND PLATFORM_LINKLIBS c++)
else()
list(APPEND PLATFORM_LINKLIBS stdc++)
endif()
if(WITH_JACK)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
@@ -237,7 +255,11 @@ if(WITH_SDL)
set(SDL_INCLUDE_DIR ${SDL}/include)
set(SDL_LIBRARY SDL2)
set(SDL_LIBPATH ${SDL}/lib)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
if(WITH_CXX11)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
else()
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback")
endif()
endif()
set(PNG "${LIBDIR}/png")
@@ -258,7 +280,11 @@ endif()
if(WITH_BOOST)
set(BOOST ${LIBDIR}/boost)
set(BOOST_INCLUDE_DIR ${BOOST}/include)
set(BOOST_POSTFIX)
if(WITH_CXX11)
set(BOOST_POSTFIX)
else()
set(BOOST_POSTFIX -mt)
endif()
set(BOOST_LIBRARIES
boost_date_time${BOOST_POSTFIX}
boost_filesystem${BOOST_POSTFIX}
@@ -295,7 +321,9 @@ if(WITH_OPENIMAGEIO)
${OPENEXR_LIBRARIES}
${ZLIB_LIBRARIES}
)
set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${LIBDIR}/ffmpeg/lib/libwebp.a)
if(WITH_CXX11)
set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${LIBDIR}/ffmpeg/lib/libwebp.a)
endif()
set(OPENIMAGEIO_LIBPATH
${OPENIMAGEIO}/lib
${JPEG_LIBPATH}
@@ -433,8 +461,10 @@ set(PLATFORM_LINKFLAGS
"${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++")
if(WITH_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++")
endif()
# Suppress ranlib "has no symbols" warnings (workaround for T48250)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")

View File

@@ -101,14 +101,21 @@ if(OSX_SYSTEM MATCHES 10.9)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT})
endif()
# 10.9 is our min. target, if you use higher sdk, weak linking happens
if(CMAKE_OSX_DEPLOYMENT_TARGET)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9)
message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11")
if(WITH_CXX11)
# 10.9 is our min. target, if you use higher sdk, weak linking happens
if(CMAKE_OSX_DEPLOYMENT_TARGET)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9)
message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
# 10.6 is our min. target, if you use higher sdk, weak linking happens
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE)
endif()
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -117,3 +124,12 @@ if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
macro(apple_check_quicktime)
# QuickTime framework is no longer available in SDK 10.12+
if(WITH_CODEC_QUICKTIME AND ${OSX_SYSTEM} VERSION_GREATER 10.11)
set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
message(STATUS "QuickTime not supported by SDK ${OSX_SYSTEM}, disabling WITH_CODEC_QUICKTIME")
endif()
endmacro()

View File

@@ -135,7 +135,7 @@ endif()
# Codecs
if(WITH_CODEC_SNDFILE)
find_package_wrapper(SndFile)
if(NOT LIBSNDFILE_FOUND)
if(NOT SNDFILE_FOUND)
set(WITH_CODEC_SNDFILE OFF)
endif()
endif()
@@ -400,6 +400,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
# CLang is the same as GCC for now.
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
# Solaris CC
elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro")
set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
# Intel C++ Compiler
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
# think these next two are broken

View File

@@ -36,7 +36,7 @@ set(WINTAB_INC ${LIBDIR}/wintab/include)
if(WITH_OPENAL)
set(OPENAL ${LIBDIR}/openal)
set(OPENALDIR ${LIBDIR}/openal)
set(OPENAL_INCLUDE_DIR ${OPENAL}/include/AL)
set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
if(MSVC)
set(OPENAL_LIBRARY openal32)
else()
@@ -46,10 +46,10 @@ if(WITH_OPENAL)
endif()
if(WITH_CODEC_SNDFILE)
set(LIBSNDFILE ${LIBDIR}/sndfile)
set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
set(LIBSNDFILE_LIBRARIES libsndfile-1)
set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib) # TODO, deprecate
set(SNDFILE ${LIBDIR}/sndfile)
set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
set(SNDFILE_LIBRARIES libsndfile-1)
set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
endif()
if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)

View File

@@ -134,10 +134,7 @@ if(NOT DEFINED LIBDIR)
message(STATUS "32 bit compiler detected.")
set(LIBDIR_BASE "windows")
endif()
if(MSVC_VERSION EQUAL 1911)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
elseif(MSVC_VERSION EQUAL 1910)
if(MSVC_VERSION EQUAL 1910)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
elseif(MSVC_VERSION EQUAL 1900)
@@ -302,7 +299,7 @@ if(WITH_JACK)
endif()
if(WITH_PYTHON)
set(PYTHON_VERSION 3.6) # CACHE STRING)
set(PYTHON_VERSION 3.5) # CACHE STRING)
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
# Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs

View File

@@ -84,8 +84,10 @@ def init(cmake_path):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
# skip '.svn'
if dirpath.startswith("."):
continue
for filename in filenames:
filepath = join(dirpath, filename)

View File

@@ -53,11 +53,7 @@ echo "OK"
# Create the tarball
cd "$blender_srcdir"
echo -n "Creating archive: \"$BASE_DIR/$TARBALL\" ..."
tar --transform "s,^,blender-$VERSION/,g" \
--use-compress-program="gzip --best" \
--create \
--file="$BASE_DIR/$TARBALL" \
--files-from="$BASE_DIR/$MANIFEST"
GZIP=-9 tar --transform "s,^,blender-$VERSION/,g" -zcf "$BASE_DIR/$TARBALL" -T "$BASE_DIR/$MANIFEST"
echo "OK"

View File

@@ -160,6 +160,9 @@
* merged in docs.
*/
/** \defgroup quicktime QuickTime
* \ingroup blender
/** \defgroup gui GUI */
/** \defgroup wm Window Manager
@@ -220,10 +223,6 @@
* \ingroup editors
*/
/** \defgroup edscene scene
* \ingroup editors
*/
/** \defgroup edsculpt sculpt and paint
* \ingroup editors
*/

View File

@@ -0,0 +1,170 @@
Simple Blender Python Developer's Guide
---------------------------------------
This is an outline for a future guide yet to be written. It is meant for
programmers wanting to understand and maybe help with the embedding of Python
inside Blender.
I - Introduction
We could praise Python here for its many qualities, but it's probably better
to just give some links:
The main site is at www.python.org , with documentation at www.python.org/doc/
Also worth of mention: it's an interpreted language and is available for
many different systems. The download includes the interpreter, many modules
(think libs), good documentation and some programs / examples. If you use
linux, there's a high chance you already have Python installed, just try
"man python".
The reason for embedding a language environment inside Blender is to give
users the ability to access the program's internal data and functionality.
This can be used to import / export (from / to other 2d / 3d formats) or
change the data (to create new objects procedurally, among many other
interesting possibilities). Script writers (Blender Python programmers) can
also expand Blender in new ways, adding new features on-the-fly, without having
to recompile it. It is usually much easier and faster to write scripts in
Python than to code the equivalent in C.
II - Reference material:
There are two important texts for us in the documentation that comes
with Python ( docs also available online at www.python.org ):
- Extending and Embedding (tutorial for C/C++ programmers)
and specially
- Python/C API.
You can read the first one to get a feel for how things are done
(reference counting is probably the most important part), but the second
doc is a must. Specially useful as a fast reference is its Index, at letter
P, where all commands are.
Specially useful commands are Py_BuildValue and the family of parsing
functions, PyArg_Parse* (PyArg_Parse(), PyArg_ParseTuple(),
PyArg_ParseTupleAndKeywords()). Py_BuildValue is usually the best way to make
Python Objects (the 'variables' that the Python Interpreter understands)
out of C ones. The PyArg_Parse* functions do the opposite, they parse
Python Objects to C variables.
So, understand PyArg_Parse* functions, Py_BuildValue and reference
counting. The first doc has a good discussion about them.
- C knowledge is also necessary, of course, use your favorite resource.
- The Blender 2.25 API documentation ( www.blender.org ) is, along with
the source, our basic API ref.
III - Directories
The previous Blender Python API's are spread in blender/intern/python
and the C part of the current one, bpython, is at
blender/source/blender/bpython/, specially in intern/. The current
solution is a Python wrapper on top of this bpython one, at
blender/intern/python/modules/Blender/
Note: since it's in Python, they needed the freeze Python utility, a
process/program that creates stand-alone executables out of Python
source files -- that is, it packs together an interpreter, the needed
modules and the source of a Python program so that users of this program
don't need to have the Python interpreter already installed in their
machines to run the program -- Blender, in this case.
The new implementation is pure C, so we won't need to "freeze" it.
Another important dir for starters is blender/source/blender/makesdna,
where the headers with Blender structs lie.
IV - Experimental Python
The new implementation, currently referred to as experimental python -
exppython - was started by Michel Selten. He chose to solve the mess in
Blender Python by starting over from scratch, in C, but keeping API
compatibility with the current 2.25 API used by Blender.
It is in blender/source/blender/python , more specifically inside
api2_2x/
To make it clear, exppython is the new implementation being worked on. It
will possibly become the de-facto implementation in Blender 2.28, the next
Blender version. Currently, Blender still comes with the same implementation
found in the 2.25 version of the program. So we call that the 2.25
implementation, or bpython.
BPython had plenty of "macro magic", lot's of complicate #define's, etc.,
since a lot of the embedding work is quite repetitive. But that makes it
much harder for newbies to jump in and learn, so the new files in exppython
avoid that.
This means: Blender, Object, Camera, Lamp, Image, Text, Window modules
(the files have the same names, ending obviously with .c and .h)
To speed things up, some independent parts of bpython are being
integrated directly into exppython. That already happened with Draw and
BGL, both taken from opy_draw.c in the bpython/intern dir. The same is
happening with NMesh (Mesh is written in Python and imports NMesh to
extend / change its functionality).
For a good example of dexterity with macros (cheers to the NaN
programmer(s)!), look at BGL.[ch], the OpenGL API wrapper. The defines
are in the header.
Besides keeping compatibility with the 2.25 API, there are already some
additions to exppython:
- some modules have access to more variables than 2.25 had;
- there are more method functions and the access is safer;
- the file selector (or file browser, if you prefer) is back:
It's now in the Window module, along with an image selector, too.
- there are totally new modules, unavailable in 2.25:
Fellow new developers joining our team are contributing new modules
that have been requested by the community for a long time.
V - Coding
The Camera module is a good reference, since it is like most others, in
terms of programming, but is smaller and simple. It's in Camera.c and
Camera.h . To have it working, it was also necessary to include a line to
the end of Blender.c (registering it as a Blender submodule) and another to
modules.h (declaring its init and CreateObject method)
Currently, one of our conventions is to prepend M_ to module functions,
doc strings, etc. and C_ to the new types we had to create for Python,
like C_Camera, C_Lamp, etc.
If you look at Camera.[ch], you'll find code for creating the Camera
module and the Camera "type", with all its methods and access policies.
It's really a new type defined in Python, like PyInt or PyFloat,
PyString, etc. In practice, it's a "thin" (because it doesn't make
copies of the variables) wrapper for the Blender Camera Data Object.
A note about Blender: objects in Blender share a common base, the
Object, whose attributes are things like the matrix, the location, the
rotation, the size, etc. A Camera is actually an Object of type Camera
(which means that its "data" field points to a Camera Data obj) and a
Camera Data object, which is the specific camera part of the object
(attributes like lens, clip start, etc.). Same for other objects, like
Lamp, Mesh, etc.
That's why C_Camera is a wrapper for the Blender Camera **Data**
object. The full wrapper is Object("Camera") linked with
Camera("camera_name").
How to write a new module for a simple object? Use Camera.[ch] as
templates, check the specifics of your object in the makesdna dir
(for example, the camera one is DNA_camera_types.h) and make the
necessary changes.
If you want to help exppython and in the process possibly learn more about
embedding, the Python/C API and Blender internals, there's this mailing list:
Bf-python mailing list
Bf-python@blender.org
http://www.blender.org/mailman/listinfo/bf-python
There you can ask what hasn't been done yet, get help, make suggestions for
new features we should consider, send bug reports, etc.

View File

@@ -12,7 +12,7 @@ bm = bmesh.new()
bmesh.ops.create_circle(
bm,
cap_ends=False,
radius=0.2,
diameter=0.2,
segments=8)

View File

@@ -1,29 +0,0 @@
"""
Manipulator Overview
--------------------
Manipulators are created using two classes.
- :class:`bpy.types.ManipulatorGroup` - stores a list of manipulators.
The manipulator group is associated with a space and region type.
- :class:`bpy.types.Manipulator` - a single item which can be used.
Each manipulator group has a collection of manipulators which it manages.
The following example shows a manipulator group with a single,
manipulator used to control a lamp objects energy.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_simple.py
It's also possible to use a manipulator to run an operator.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator_target.py
This more comprehensive example shows how an operator can create a temporary manipulator group to adjust its settings.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator.py
"""

View File

@@ -52,7 +52,6 @@ class OffScreenDraw(bpy.types.Operator):
@staticmethod
def _update_offscreen(context, offscreen):
scene = context.scene
render_layer = context.render_layer
render = scene.render
camera = scene.camera
@@ -66,7 +65,6 @@ class OffScreenDraw(bpy.types.Operator):
offscreen.draw_view3d(
scene,
render_layer,
context.space_data,
context.region,
projection_matrix,

File diff suppressed because it is too large Load Diff

View File

@@ -332,9 +332,6 @@ except ImportError:
# to avoid having to match Blender's source tree.
EXTRA_SOURCE_FILES = (
"../../../release/scripts/templates_py/bmesh_simple.py",
"../../../release/scripts/templates_py/manipulator_operator.py",
"../../../release/scripts/templates_py/manipulator_operator_target.py",
"../../../release/scripts/templates_py/manipulator_simple.py",
"../../../release/scripts/templates_py/operator_simple.py",
"../../../release/scripts/templates_py/ui_panel_simple.py",
"../../../release/scripts/templates_py/ui_previews_custom_icon.py",
@@ -1013,9 +1010,9 @@ def pymodule2sphinx(basepath, module_name, module, title):
context_type_map = {
"active_base": ("ObjectBase", False),
"active_bone": ("EditBone", False),
"active_gpencil_brush": ("GPencilSculptBrush", False),
"active_gpencil_frame": ("GreasePencilLayer", True),
"active_gpencil_layer": ("GPencilLayer", True),
"active_gpencil_brush": ("GPencilSculptBrush", False),
"active_gpencil_palette": ("GPencilPalette", True),
"active_gpencil_palettecolor": ("GPencilPaletteColor", True),
"active_node": ("Node", False),
@@ -1027,7 +1024,6 @@ context_type_map = {
"brush": ("Brush", False),
"camera": ("Camera", False),
"cloth": ("ClothModifier", False),
"collection": ("LayerCollection", False),
"collision": ("CollisionModifier", False),
"curve": ("Curve", False),
"dynamic_paint": ("DynamicPaintModifier", False),
@@ -1048,7 +1044,6 @@ context_type_map = {
"image_paint_object": ("Object", False),
"lamp": ("Lamp", False),
"lattice": ("Lattice", False),
"lightprobe": ("LightProbe", False),
"line_style": ("FreestyleLineStyle", False),
"material": ("Material", False),
"material_slot": ("MaterialSlot", False),
@@ -1060,7 +1055,6 @@ context_type_map = {
"particle_system": ("ParticleSystem", False),
"particle_system_editable": ("ParticleSystem", False),
"pose_bone": ("PoseBone", False),
"render_layer": ("SceneLayer", False),
"scene": ("Scene", False),
"sculpt_object": ("Object", False),
"selectable_bases": ("ObjectBase", True),
@@ -1069,7 +1063,6 @@ context_type_map = {
"selected_bones": ("EditBone", True),
"selected_editable_bases": ("ObjectBase", True),
"selected_editable_bones": ("EditBone", True),
"selected_editable_fcurves": ("FCurce", True),
"selected_editable_objects": ("Object", True),
"selected_editable_sequences": ("Sequence", True),
"selected_nodes": ("Node", True),

View File

@@ -113,8 +113,3 @@ endif()
if(WITH_SDL AND WITH_SDL_DYNLOAD)
add_subdirectory(sdlew)
endif()
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
add_subdirectory(audaspace)
endif()

View File

@@ -1,16 +0,0 @@
Main author: Jörg Müller <nexyon@gmail.com>
Minor improvements have been done while audaspace was an internal part of Blender by
- Campbell Barton (bug fixes and cleanup)
- Brecht Van Lommel (bug fixes and cleanup)
- Sergey Sharybin (bug fixes and cleanup)
- Nathan Letwory (bug fixes and cleanup)
- Peter Schlaile (ffmpeg)
- Jens Verwiebe (jack on Apple)
The first three of them were employed by the Blender Foundation during that time.
Some features (random sounds, dynamic music, playback manager, convolution and HRTFs support) were added as part of the VALS (Virtual Alliances for Learning Society) project by
- Juan Francisco Crespo Galán <dethon_5@outlook.com>

View File

@@ -1,115 +0,0 @@
Audaspace 1.3
=============
- New features:
- linear interpolation for volume changes in the software mixer
- dynamic Loading for JACK
- Bug fixes:
- renamed Jack to JACK
- C API was not working
- filter python API parameter check
- finding ffmpeg with pkgconfig
64884a7 Windows fixes.
53ba3e6 Implemented JACK dynamic loading.
5ee0ee1 Continues last commit.
c24b384 Trying to fix travis-ci python versioning once and for all (at least for python3).
1fbf3bf Rename Jack => JACK where possible.
6e4b31f Implemented linear interpolation for volume changes in the software mixer.
817043c Fixing C API not working.
c384daf Maybe travis-ci works now.
aa7ddd7 Fix (hopefully) for previous commit.
57c5dd7 Configure MACOSX_DEPLOYMENT_TARGET for travis-ci.
7ae6ff9 Fix travis-ci python path.
552fea4 Added posibillity to use math constants on MinGW
c18ed59 Bugfix: incorrect parameter check in python API.
6f048c3 CMake: fix finding ffmpeg with pkgconfig.
Audaspace 1.2
=============
- New features:
- sound list
- random sounds
- dynamic music playing
- playback manager
- convolution/reverbation
- multi-threading
- binaural audio
- API changes:
- changing default sample rate from 44.1 to 48 kHz
- Bug fixes:
- several standard library fixes.
- Bindings API:
- mixdown C API refactored
- CMake/Building:
- assuring numpy is installed
- building the Python module on Mac OS X with CMake
a6b6e70 Changing default sample rate from 44.1 to 48 kHz.
20f0164 Bugfix: CMake custom command for python module on OS X.
98679a2 Bugfix: using standard library (s)rand.
5ab4fe7 Bugfix: first step in fixing the vector of array problem.
e83f01d FFTW: trying to use complex to circumvent vector of array problem.
093ebc0 Bugfix: abs -> std::fabs.
328d7cc Bugfix: standard library include and call fixes.
f78e330 Bugfix: using correct includes.
64d7825 Behavior change: C API Mixdown
749896b Merge pull request #3 from DethonUSAL/master
6e9491c CMake: finding NumPy.
Audaspace 1.1
=============
- Bug fixes:
- pkgconfig uses cmake configured library directory
- FFMPEG file writing crashed, also corrected pts for encoding
- silenced Doxygen warnings about undefined defines
- C++ API:
- ResampleReader uses specs instead of sample rate
- Bindings API:
- writing sounds to files
- reading sound data, specs and length
- resampling sounds
- CMake/Building:
- first steps towards building for Mac
- windows builds copy dlls automatically
- Python module:
- using distutils instead of setuptools
- added numpy as dependency
- Documentation:
- added windows building and plugin documentation
- disabled html timestamps in doxygen
- updated sphinx template
- build binding documentation without installing the python module
Detailed list of changes:
326a300 Documentation: windows, dll copying now done automatically.
54cac4f Windows: install dlls.
65c2d78 Bindings: Sound length and specs properties.
c38da70 Bindings API: adding resampling.
374822f Documentation: Added windows and plugin documentation.
a9dc5b9 Python module: add numpy as dependency.
c933a02 C API: implement new API based on the python API.
ac54c52 Python API: silence numpy warnings.
c9491bb Python API: checking for a positive sample rate.
4eb1fa8 Python API: reorder functions.
ec7c00b Sphinx update and fixes.
e16d979 FFMPEG: correct pts during encoding.
7ab3935 Documentation: git path fix.
28d77bb Python: use distutils directly instead of setuptools.
1f43284 Silence doxygen warning about undefined defines.
0d52458 CMake: improvements and fixes for building on Mac.
37daedf FFMPEG: bugfixes for file writing.
780ca2a ResampleReader API change
4d9863d Python API: Optimization for cached sounds' data access.
ea04fee Python API: read sound data and create sound buffers as well as getting the specs of a sound.
335b293 Python sound writing API.
36a7252 Pkgconfig: use cmake configured library directory.
5503908 Doxygen: disable html timestamps.
Initial Release of Audaspace 1.0
================================
Audaspace has been the internal audio library of blender since blender 2.5. It is now released as a standalone library to be used in other projects as well.

View File

@@ -1,986 +0,0 @@
################################################################################
# Copyright 2009-2016 Jörg Müller
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
cmake_minimum_required(VERSION 3.0)
include(CMakeDependentOption)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
project(audaspace)
set(AUDASPACE_VERSION 1.3)
set(AUDASPACE_LONG_VERSION ${AUDASPACE_VERSION}.0)
if(DEFINED AUDASPACE_CMAKE_CFG)
include(${AUDASPACE_CMAKE_CFG})
endif()
if(NOT DEFINED AUDASPACE_STANDALONE)
set(AUDASPACE_STANDALONE TRUE)
endif()
# sources
set(SRC
src/devices/DefaultSynchronizer.cpp
src/devices/DeviceManager.cpp
src/devices/NULLDevice.cpp
src/devices/ReadDevice.cpp
src/devices/SoftwareDevice.cpp
src/Exception.cpp
src/file/File.cpp
src/file/FileManager.cpp
src/file/FileWriter.cpp
src/fx/Accumulator.cpp
src/fx/ADSR.cpp
src/fx/ADSRReader.cpp
src/fx/BaseIIRFilterReader.cpp
src/fx/ButterworthCalculator.cpp
src/fx/Butterworth.cpp
src/fx/CallbackIIRFilterReader.cpp
src/fx/Delay.cpp
src/fx/DelayReader.cpp
src/fx/DynamicIIRFilter.cpp
src/fx/DynamicIIRFilterReader.cpp
src/fx/DynamicMusic.cpp
src/fx/Effect.cpp
src/fx/EffectReader.cpp
src/fx/Envelope.cpp
src/fx/Fader.cpp
src/fx/FaderReader.cpp
src/fx/HighpassCalculator.cpp
src/fx/Highpass.cpp
src/fx/IIRFilter.cpp
src/fx/IIRFilterReader.cpp
src/fx/Limiter.cpp
src/fx/LimiterReader.cpp
src/fx/Loop.cpp
src/fx/LoopReader.cpp
src/fx/LowpassCalculator.cpp
src/fx/Lowpass.cpp
src/fx/MutableReader.cpp
src/fx/MutableSound.cpp
src/fx/Pitch.cpp
src/fx/PitchReader.cpp
src/fx/PlaybackManager.cpp
src/fx/PlaybackCategory.cpp
src/fx/Reverse.cpp
src/fx/ReverseReader.cpp
src/fx/SoundList.cpp
src/fx/Source.cpp
src/fx/Sum.cpp
src/fx/Threshold.cpp
src/fx/Volume.cpp
src/fx/VolumeReader.cpp
src/fx/VolumeSound.cpp
src/fx/VolumeStorage.cpp
src/generator/Sawtooth.cpp
src/generator/SawtoothReader.cpp
src/generator/Silence.cpp
src/generator/SilenceReader.cpp
src/generator/Sine.cpp
src/generator/SineReader.cpp
src/generator/Square.cpp
src/generator/SquareReader.cpp
src/generator/Triangle.cpp
src/generator/TriangleReader.cpp
src/respec/ChannelMapper.cpp
src/respec/ChannelMapperReader.cpp
src/respec/Converter.cpp
src/respec/ConverterFunctions.cpp
src/respec/ConverterReader.cpp
src/respec/JOSResample.cpp
src/respec/JOSResampleReaderCoeff.cpp
src/respec/JOSResampleReader.cpp
src/respec/LinearResample.cpp
src/respec/LinearResampleReader.cpp
src/respec/Mixer.cpp
src/respec/ResampleReader.cpp
src/respec/SpecsChanger.cpp
src/sequence/AnimateableProperty.cpp
src/sequence/Double.cpp
src/sequence/DoubleReader.cpp
src/sequence/PingPong.cpp
src/sequence/Sequence.cpp
src/sequence/SequenceData.cpp
src/sequence/SequenceEntry.cpp
src/sequence/SequenceHandle.cpp
src/sequence/SequenceReader.cpp
src/sequence/Superpose.cpp
src/sequence/SuperposeReader.cpp
src/util/Barrier.cpp
src/util/Buffer.cpp
src/util/BufferReader.cpp
src/util/StreamBuffer.cpp
src/util/ThreadPool.cpp
)
set(PRIVATE_HDR
src/sequence/SequenceHandle.h
)
set(PUBLIC_HDR
include/devices/DefaultSynchronizer.h
include/devices/DeviceManager.h
include/devices/I3DDevice.h
include/devices/I3DHandle.h
include/devices/IDeviceFactory.h
include/devices/IDevice.h
include/devices/IHandle.h
include/devices/ISynchronizer.h
include/devices/NULLDevice.h
include/devices/ReadDevice.h
include/devices/SoftwareDevice.h
include/Exception.h
include/file/File.h
include/file/FileManager.h
include/file/FileWriter.h
include/file/IFileInput.h
include/file/IFileOutput.h
include/file/IWriter.h
include/fx/Accumulator.h
include/fx/ADSR.h
include/fx/ADSRReader.h
include/fx/BaseIIRFilterReader.h
include/fx/ButterworthCalculator.h
include/fx/Butterworth.h
include/fx/CallbackIIRFilterReader.h
include/fx/Delay.h
include/fx/DelayReader.h
include/fx/DynamicIIRFilter.h
include/fx/DynamicIIRFilterReader.h
include/fx/DynamicMusic.h
include/fx/Effect.h
include/fx/EffectReader.h
include/fx/Envelope.h
include/fx/Fader.h
include/fx/FaderReader.h
include/fx/HighpassCalculator.h
include/fx/Highpass.h
include/fx/IDynamicIIRFilterCalculator.h
include/fx/IIRFilter.h
include/fx/IIRFilterReader.h
include/fx/Limiter.h
include/fx/LimiterReader.h
include/fx/Loop.h
include/fx/LoopReader.h
include/fx/LowpassCalculator.h
include/fx/Lowpass.h
include/fx/MutableReader.h
include/fx/MutableSound.h
include/fx/Pitch.h
include/fx/PitchReader.h
include/fx/PlaybackManager.h
include/fx/PlaybackCategory.h
include/fx/Reverse.h
include/fx/ReverseReader.h
include/fx/SoundList.h
include/fx/Source.h
include/fx/Sum.h
include/fx/Threshold.h
include/fx/Volume.h
include/fx/VolumeReader.h
include/fx/VolumeSound.h
include/fx/VolumeStorage.h
include/generator/Sawtooth.h
include/generator/SawtoothReader.h
include/generator/Silence.h
include/generator/SilenceReader.h
include/generator/Sine.h
include/generator/SineReader.h
include/generator/Square.h
include/generator/SquareReader.h
include/generator/Triangle.h
include/generator/TriangleReader.h
include/IReader.h
include/ISound.h
include/plugin/PluginManager.h
include/respec/ChannelMapper.h
include/respec/ChannelMapperReader.h
include/respec/ConverterFunctions.h
include/respec/Converter.h
include/respec/ConverterReader.h
include/respec/JOSResample.h
include/respec/JOSResampleReader.h
include/respec/LinearResample.h
include/respec/LinearResampleReader.h
include/respec/Mixer.h
include/respec/ResampleReader.h
include/respec/Specification.h
include/respec/SpecsChanger.h
include/sequence/AnimateableProperty.h
include/sequence/Double.h
include/sequence/DoubleReader.h
include/sequence/PingPong.h
include/sequence/SequenceData.h
include/sequence/SequenceEntry.h
include/sequence/Sequence.h
include/sequence/SequenceReader.h
include/sequence/Superpose.h
include/sequence/SuperposeReader.h
include/util/Barrier.h
include/util/Buffer.h
include/util/BufferReader.h
include/util/ILockable.h
include/util/Math3D.h
include/util/StreamBuffer.h
include/util/ThreadPool.h
)
set(HDR ${PRIVATE_HDR} ${PUBLIC_HDR})
set(INCLUDE ${CMAKE_CURRENT_BINARY_DIR} include)
if(WIN32)
set(LIBRARIES)
if(AUDASPACE_STANDALONE)
set(DLLS)
set(LIBRARY_PATH "../lib" CACHE PATH "Path which contains the libraries.")
file(GLOB LIBRARY_DIRS ${LIBRARY_PATH}/*)
list(APPEND CMAKE_PREFIX_PATH ${LIBRARY_DIRS})
endif()
else()
set(LIBRARIES ${CMAKE_DL_LIBS} -lpthread)
endif()
set(STATIC_PLUGINS "")
# dependencies
if(AUDASPACE_STANDALONE)
set(PACKAGE_OPTION QUIET)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
option(BUILD_DEMOS "Build and install demos" TRUE)
option(SHARED_LIBRARY "Build Shared Library" TRUE)
option(WITH_C "Build C Module" TRUE)
option(WITH_DOCS "Build C++ HTML Documentation with Doxygen" TRUE)
option(WITH_FFMPEG "Build With FFMPEG" TRUE)
option(WITH_FFTW "Build With FFTW" TRUE)
option(WITH_JACK "Build With Plugin" TRUE)
option(WITH_LIBSNDFILE "Build With LibSndFile" TRUE)
option(WITH_OPENAL "Build With OpenAL" TRUE)
option(WITH_PYTHON "Build With Python Library" TRUE)
option(WITH_SDL "Build With SDL" TRUE)
option(WITH_STRICT_DEPENDENCIES "Error and abort instead of warning if a library is not found." FALSE)
if(WITH_STRICT_DEPENDENCIES)
set(PACKAGE_OPTION REQUIRED)
endif()
endif()
if(WIN32)
set(DEFAULT_PLUGIN_PATH "." CACHE STRING "Default plugin installation and loading path.")
set(DOCUMENTATION_INSTALL_PATH "doc" CACHE PATH "Path where the documentation is installed.")
else()
set(DEFAULT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/share/audaspace/plugins" CACHE STRING "Default plugin installation and loading path.")
set(DOCUMENTATION_INSTALL_PATH "share/doc/audaspace" CACHE PATH "Path where the documentation is installed.")
endif()
if(AUDASPACE_STANDALONE)
cmake_dependent_option(SEPARATE_C "Build C Binding as separate library" TRUE "WITH_C" FALSE)
cmake_dependent_option(PLUGIN_FFMPEG "Build FFMPEG Plugin" TRUE "WITH_FFMPEG;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_JACK "Build JACK Plugin" TRUE "WITH_JACK;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_LIBSNDFILE "Build LibSndFile Plugin" TRUE "WITH_LIBSNDFILE;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_OPENAL "Build OpenAL Plugin" TRUE "WITH_OPENAL;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_SDL "Build SDL Plugin" TRUE "WITH_SDL;SHARED_LIBRARY" FALSE)
cmake_dependent_option(WITH_PYTHON_MODULE "Build Python Module" TRUE "WITH_PYTHON" FALSE)
cmake_dependent_option(USE_SDL2 "Use SDL2 instead of 1 if available" TRUE "WITH_SDL" FALSE)
cmake_dependent_option(DYNLOAD_JACK "Dynamically load JACK" FALSE "WITH_JACK" FALSE)
cmake_dependent_option(WITH_BINDING_DOCS "Build C/Python HTML Documentation with Sphinx" TRUE "WITH_PYTHON_MODULE" FALSE)
endif()
# compiler options
if(AUDASPACE_STANDALONE)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_definitions(-std=c++11)
list(APPEND CMAKE_C_COMPILER_FLAGS "-fvisibility=hidden")
list(APPEND CMAKE_CXX_COMPILER_FLAGS "-fvisibility=hidden")
endif()
if(MSVC)
list(APPEND CMAKE_C_FLAGS_DEBUG "/Zi /Od")
list(APPEND CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
list(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG")
list(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG "/DEBUG")
list(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
if(SHARED_LIBRARY)
include(GenerateExportHeader)
endif()
endif()
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
endif()
if(MSVC)
add_definitions(
/D_USE_MATH_DEFINES
/EHsc
/DNOMINMAX
/D_STDINT_H
)
endif()
# platform specific options
if(MSYS OR MINGW)
add_definitions(-D_USE_MATH_DEFINES)
endif()
# C
if(WITH_C)
set(C_SRC
bindings/C/AUD_ThreadPool.cpp
bindings/C/AUD_Source.cpp
bindings/C/AUD_Device.cpp
bindings/C/AUD_DynamicMusic.cpp
bindings/C/AUD_Handle.cpp
bindings/C/AUD_PlaybackManager.cpp
bindings/C/AUD_Sequence.cpp
bindings/C/AUD_Sound.cpp
bindings/C/AUD_Special.cpp
)
set(C_HDR
bindings/C/AUD_ThreadPool.h
bindings/C/AUD_Source.h
bindings/C/AUD_Device.h
bindings/C/AUD_DynamicMusic.h
bindings/C/AUD_Handle.h
bindings/C/AUD_PlaybackManager.h
bindings/C/AUD_Sequence.h
bindings/C/AUD_Sound.h
bindings/C/AUD_Special.h
bindings/C/AUD_Types.h
)
if(WITH_FFTW)
list(APPEND C_SRC
bindings/C/AUD_HRTF.cpp
bindings/C/AUD_ImpulseResponse.cpp
)
list(APPEND C_HDR
bindings/C/AUD_HRTF.h
bindings/C/AUD_ImpulseResponse.h
)
endif()
if(NOT SEPARATE_C)
list(APPEND SRC ${C_SRC})
list(APPEND HDR ${C_HDR})
else()
set(AUDASPACE_C_LIBRARY -laudaspace-c)
endif()
endif()
# FFMPEG
if(WITH_FFMPEG)
if(AUDASPACE_STANDALONE)
find_package(FFMPEG ${PACKAGE_OPTION})
endif()
if(FFMPEG_FOUND)
set(FFMPEG_SRC
plugins/ffmpeg/FFMPEG.cpp
plugins/ffmpeg/FFMPEGReader.cpp
plugins/ffmpeg/FFMPEGWriter.cpp
)
set(FFMPEG_HDR
plugins/ffmpeg/FFMPEG.h
plugins/ffmpeg/FFMPEGReader.h
plugins/ffmpeg/FFMPEGWriter.h
)
if(NOT PLUGIN_FFMPEG)
list(APPEND INCLUDE ${FFMPEG_INCLUDE_DIRS})
list(APPEND LIBRARIES ${FFMPEG_LIBRARIES})
list(APPEND SRC ${FFMPEG_SRC})
list(APPEND HDR ${FFMPEG_HDR})
list(APPEND STATIC_PLUGINS FFMPEG)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB FFMPEG_DLLS ${LIBRARY_PATH}/ffmpeg/bin/*.dll)
list(APPEND DLLS ${FFMPEG_DLLS})
endif()
else()
set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
message(WARNING "FFMPEG not found, plugin will not be built.")
endif()
endif()
# FFTW
if(WITH_FFTW)
if(AUDASPACE_STANDALONE)
find_package(FFTW ${PACKAGE_OPTION})
endif()
if(FFTW_FOUND)
set(FFTW_SRC
src/fx/BinauralSound.cpp
src/fx/BinauralReader.cpp
src/fx/Convolver.cpp
src/fx/ConvolverReader.cpp
src/fx/ConvolverSound.cpp
src/fx/FFTConvolver.cpp
src/fx/HRTF.cpp
src/fx/ImpulseResponse.cpp
src/util/FFTPlan.cpp
)
set(FFTW_HDR
include/fx/BinauralSound.h
include/fx/BinauralReader.h
include/fx/Convolver.h
include/fx/ConvolverReader.h
include/fx/ConvolverSound.h
include/fx/FFTConvolver.h
include/fx/HRTF.h
include/fx/HRTFLoader.h
include/fx/ImpulseResponse.h
include/util/FFTPlan.h
)
add_definitions(-DWITH_CONVOLUTION)
list(APPEND INCLUDE ${FFTW_INCLUDE_DIR})
list(APPEND LIBRARIES ${FFTW_LIBRARY})
list(APPEND SRC ${FFTW_SRC})
list(APPEND HDR ${FFTW_HDR})
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB FFTW_DLLS ${LIBRARY_PATH}/fftw/bin/*.dll)
list(APPEND DLLS ${FFTW_DLLS})
endif()
else()
set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
message(WARNING "FFTW not found, convolution functionality will not be built.")
endif()
endif()
# JACK
if(WITH_JACK)
if(AUDASPACE_STANDALONE)
find_package(Jack ${PACKAGE_OPTION})
endif()
if(JACK_FOUND)
set(JACK_SRC
plugins/jack/JackDevice.cpp
plugins/jack/JackSynchronizer.cpp
plugins/jack/JackLibrary.cpp
)
set(JACK_HDR
plugins/jack/JackDevice.h
plugins/jack/JackSynchronizer.h
plugins/jack/JackLibrary.h
plugins/jack/JackSymbols.h
)
if(DYNLOAD_JACK)
add_definitions(-DDYNLOAD_JACK)
endif()
if(NOT PLUGIN_JACK)
list(APPEND INCLUDE ${JACK_INCLUDE_DIRS})
if(NOT DYNLOAD_JACK)
list(APPEND LIBRARIES ${JACK_LIBRARIES})
endif()
list(APPEND SRC ${JACK_SRC})
list(APPEND HDR ${JACK_HDR})
list(APPEND STATIC_PLUGINS JackDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB JACK_DLLS ${LIBRARY_PATH}/jack/bin/*.dll)
list(APPEND DLLS ${JACK_DLLS})
endif()
else()
set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
message(WARNING "JACK not found, plugin will not be built.")
endif()
endif()
# LibSndFile
if(WITH_LIBSNDFILE)
if(AUDASPACE_STANDALONE)
find_package(LibSndFile ${PACKAGE_OPTION})
endif()
if(LIBSNDFILE_FOUND)
set(LIBSNDFILE_SRC
plugins/libsndfile/SndFile.cpp
plugins/libsndfile/SndFileReader.cpp
plugins/libsndfile/SndFileWriter.cpp
)
set(LIBSNDFILE_HDR
plugins/libsndfile/SndFile.h
plugins/libsndfile/SndFileReader.h
plugins/libsndfile/SndFileWriter.h
)
if(NOT PLUGIN_LIBSNDFILE)
list(APPEND INCLUDE ${LIBSNDFILE_INCLUDE_DIRS})
list(APPEND LIBRARIES ${LIBSNDFILE_LIBRARIES})
list(APPEND SRC ${LIBSNDFILE_SRC})
list(APPEND HDR ${LIBSNDFILE_HDR})
list(APPEND STATIC_PLUGINS SndFile)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB LIBSNDFILE_DLLS ${LIBRARY_PATH}/libsndfile/bin/*.dll)
list(APPEND DLLS ${LIBSNDFILE_DLLS})
endif()
else()
set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
message(WARNING "LibSndFile not found, plugin will not be built.")
endif()
endif()
# OpenAL
if(WITH_OPENAL)
if(AUDASPACE_STANDALONE)
find_package(OpenAL ${PACKAGE_OPTION})
endif()
if(OPENAL_FOUND)
set(OPENAL_SRC
plugins/openal/OpenALDevice.cpp
plugins/openal/OpenALReader.cpp
)
set(OPENAL_HDR
plugins/openal/OpenALDevice.h
plugins/openal/OpenALReader.h
)
if(NOT PLUGIN_OPENAL)
list(APPEND INCLUDE ${OPENAL_INCLUDE_DIR})
list(APPEND LIBRARIES ${OPENAL_LIBRARY})
list(APPEND SRC ${OPENAL_SRC})
list(APPEND HDR ${OPENAL_HDR})
list(APPEND STATIC_PLUGINS OpenALDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB OPENAL_DLLS ${LIBRARY_PATH}/OpenAL/bin/*.dll)
list(APPEND DLLS ${OPENAL_DLLS})
endif()
else()
set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
message(WARNING "OpenAL not found, plugin will not be built.")
endif()
endif()
# Python
if(WITH_PYTHON)
if(AUDASPACE_STANDALONE)
find_package(PythonLibs 3.2 ${PACKAGE_OPTION})
find_package(NumPy ${PACKAGE_OPTION})
endif()
if(PYTHONLIBS_FOUND AND NUMPY_FOUND)
list(APPEND INCLUDE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
if(WITH_PYTHON_MODULE)
find_package(PythonInterp 3.2 ${PACKAGE_OPTION})
if(NOT PYTHONINTERP_FOUND)
set(WITH_PYTHON_MODULE FALSE)
message(WARNING "Python interpreter not found, module will not be built.")
endif()
endif()
set(AUDASPACE_PY_LIBRARY -laudaspace-py)
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB PYTHON_DLLS ${LIBRARY_PATH}/Python/bin/*.dll)
list(APPEND DLLS ${PYTHON_DLLS})
endif()
else()
set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
message(WARNING "Python libraries not found, language binding will not be built.")
endif()
endif()
# SDL
if(WITH_SDL)
if(AUDASPACE_STANDALONE)
if(USE_SDL2)
find_package(SDL2)
if(SDL2_FOUND)
set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
set(SDL_LIBRARY ${SDL2_LIBRARY})
set(SDL_FOUND TRUE)
else()
find_package(SDL ${PACKAGE_OPTION})
endif()
else()
find_package(SDL ${PACKAGE_OPTION})
endif()
endif()
if(SDL_FOUND)
set(SDL_SRC
plugins/sdl/SDLDevice.cpp
)
set(SDL_HDR
plugins/sdl/SDLDevice.h
)
if(NOT PLUGIN_SDL)
list(APPEND INCLUDE ${SDL_INCLUDE_DIR})
list(APPEND LIBRARIES ${SDL_LIBRARY})
list(APPEND SRC ${SDL_SRC})
list(APPEND HDR ${SDL_HDR})
list(APPEND STATIC_PLUGINS SDLDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB SDL_DLLS ${LIBRARY_PATH}/sdl/bin/*.dll)
list(APPEND DLLS ${SDL_DLLS})
endif()
else()
set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
message(WARNING "SDL not found, plugin will not be built.")
endif()
endif()
# library configuration
if(SHARED_LIBRARY)
set(AUD_LIBRARY_TYPE AUD_SHARED_LIBRARY)
set(LIBRARY_TYPE SHARED)
add_definitions(-DAUD_BUILD_SHARED_LIBRARY)
else()
set(AUD_LIBRARY_TYPE AUD_STATIC_LIBRARY)
set(LIBRARY_TYPE STATIC)
endif()
# file configuration
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Audaspace.h.in ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h ESCAPE_QUOTES @ONLY)
list(APPEND HDR ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h)
set(STATIC_PLUGIN_CLASSES "")
set(STATIC_PLUGIN_REGISTERS "")
foreach(PLUGIN ${STATIC_PLUGINS})
list(APPEND STATIC_PLUGIN_CLASSES "STATIC_PLUGIN_CLASS(" ${PLUGIN} ")\n")
list(APPEND STATIC_PLUGIN_REGISTERS "\tSTATIC_PLUGIN_REGISTER(" ${PLUGIN} ")\n")
endforeach()
string(CONCAT STATIC_PLUGIN_CLASSES ${STATIC_PLUGIN_CLASSES})
string(CONCAT STATIC_PLUGIN_REGISTERS ${STATIC_PLUGIN_REGISTERS})
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerWindows.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
if(WITH_FFTW)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderWindows.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
endif()
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerUnix.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
if(WITH_FFTW)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderUnix.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
endif()
endif()
list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp)
if(WITH_FFTW)
list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp)
endif()
# directories
include_directories(${INCLUDE})
link_directories()
# install configuration
if(WIN32)
set(BIN_DESTINATION ".")
else()
set(BIN_DESTINATION "bin")
endif()
set(LIB_DESTINATION "lib${LIB_SUFFIX}")
# library
add_library(audaspace ${LIBRARY_TYPE} ${SRC} ${HDR})
target_link_libraries(audaspace ${LIBRARIES})
set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
if(AUDASPACE_STANDALONE)
install(TARGETS audaspace
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/audaspace)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h DESTINATION include/audaspace)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages/pkgconfig/audaspace.pc.in ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc @ONLY)
if(NOT WIN32 AND NOT APPLE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
endif()
endif()
# plugins
if(WITH_FFMPEG AND PLUGIN_FFMPEG)
add_definitions(-DFFMPEG_PLUGIN)
include_directories(${INCLUDE} ${FFMPEG_INCLUDE_DIRS})
add_library(audffmpeg SHARED ${FFMPEG_SRC} ${FFMPEG_HDR} ${HDR})
target_link_libraries(audffmpeg audaspace ${FFMPEG_LIBRARIES})
set_target_properties(audffmpeg PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audffmpeg DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_JACK AND PLUGIN_JACK)
add_definitions(-DJACK_PLUGIN)
include_directories(${INCLUDE} ${JACK_INCLUDE_DIRS})
add_library(audjack SHARED ${JACK_SRC} ${JACK_HDR} ${HDR})
if(DYNLOAD_JACK)
target_link_libraries(audjack audaspace)
else()
target_link_libraries(audjack audaspace ${JACK_LIBRARIES})
endif()
set_target_properties(audjack PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audjack DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_LIBSNDFILE AND PLUGIN_LIBSNDFILE)
add_definitions(-DLIBSNDFILE_PLUGIN)
include_directories(${INCLUDE} ${LIBSNDFILE_INCLUDE_DIRS})
add_library(audlibsndfile SHARED ${LIBSNDFILE_SRC} ${LIBSNDFILE_HDR} ${HDR})
set_target_properties(audlibsndfile PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audlibsndfile audaspace ${LIBSNDFILE_LIBRARIES})
install(TARGETS audlibsndfile DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_OPENAL AND PLUGIN_OPENAL)
add_definitions(-DOPENAL_PLUGIN)
include_directories(${INCLUDE} ${OPENAL_INCLUDE_DIR})
add_library(audopenal SHARED ${OPENAL_SRC} ${OPENAL_HDR} ${HDR})
set_target_properties(audopenal PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audopenal audaspace ${OPENAL_LIBRARY})
install(TARGETS audopenal DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_SDL AND PLUGIN_SDL)
add_definitions(-DSDL_PLUGIN)
include_directories(${INCLUDE} ${SDL_INCLUDE_DIR})
add_library(audsdl SHARED ${SDL_SRC} ${SDL_HDR} ${HDR})
set_target_properties(audsdl PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audsdl audaspace ${SDL_LIBRARY})
install(TARGETS audsdl DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
# dlls
if(WIN32)
if(DLLS)
install(FILES ${DLLS} DESTINATION ${BIN_DESTINATION})
endif()
endif()
# demos
if(BUILD_DEMOS)
include_directories(${INCLUDE})
set(DEMOS audaplay audaconvert audaremap signalgen randsounds dynamicmusic playbackmanager)
add_executable(audaplay demos/audaplay.cpp)
target_link_libraries(audaplay audaspace)
add_executable(audaconvert demos/audaconvert.cpp)
target_link_libraries(audaconvert audaspace)
add_executable(audaremap demos/audaremap.cpp)
target_link_libraries(audaremap audaspace)
add_executable(signalgen demos/signalgen.cpp)
target_link_libraries(signalgen audaspace)
add_executable(randsounds demos/randsounds.cpp)
target_link_libraries(randsounds audaspace)
add_executable(dynamicmusic demos/dynamicmusic.cpp)
target_link_libraries(dynamicmusic audaspace)
add_executable(playbackmanager demos/playbackmanager.cpp)
target_link_libraries(playbackmanager audaspace)
if(WITH_FFTW)
list(APPEND DEMOS convolution binaural)
add_executable(convolution demos/convolution.cpp)
target_link_libraries(convolution audaspace)
add_executable(binaural demos/binaural.cpp)
target_link_libraries(binaural audaspace)
endif()
if(WITH_OPENAL)
list(APPEND DEMOS openaldevices)
add_executable(openaldevices demos/openaldevices.cpp)
if(PLUGIN_OPENAL)
target_link_libraries(openaldevices audaspace audopenal)
else()
target_link_libraries(openaldevices audaspace)
endif()
endif()
install(TARGETS ${DEMOS}
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
endif()
# bindings
if(WITH_C)
if(SEPARATE_C)
add_library(audaspace-c ${LIBRARY_TYPE} ${C_SRC} ${C_HDR})
target_link_libraries(audaspace-c audaspace)
set_target_properties(audaspace-c PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audaspace-c
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
endif()
if(AUDASPACE_STANDALONE)
install(FILES ${C_HDR} DESTINATION include/audaspace)
endif()
endif()
if(WITH_PYTHON)
set(PYTHON_SRC
bindings/python/PyAPI.cpp
bindings/python/PyDevice.cpp
bindings/python/PyDynamicMusic.cpp
bindings/python/PyHandle.cpp
bindings/python/PyPlaybackManager.cpp
bindings/python/PySequence.cpp
bindings/python/PySequenceEntry.cpp
bindings/python/PySound.cpp
bindings/python/PySource.cpp
bindings/python/PyThreadPool.cpp
)
set(PYTHON_HDR
bindings/python/PyAPI.h
bindings/python/PyDevice.h
bindings/python/PyDynamicMusic.h
bindings/python/PyHandle.h
bindings/python/PyPlaybackManager.h
bindings/python/PySequence.h
bindings/python/PySequenceEntry.h
bindings/python/PySound.h
bindings/python/PySource.h
bindings/python/PyThreadPool.h
)
if(WITH_FFTW)
list(APPEND PYTHON_SRC
bindings/python/PyHRTF.cpp
bindings/python/PyImpulseResponse.cpp
)
list(APPEND PYTHON_HDR
bindings/python/PyHRTF.h
bindings/python/PyImpulseResponse.h
)
endif()
add_library(audaspace-py ${LIBRARY_TYPE} ${PYTHON_SRC} ${PYTHON_HDR})
target_link_libraries(audaspace-py audaspace ${PYTHON_LIBRARIES})
set_target_properties(audaspace-py PROPERTIES SOVERSION ${AUDASPACE_VERSION})
if(AUDASPACE_STANDALONE)
install(TARGETS audaspace-py
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
install(FILES ${PYTHON_HDR} DESTINATION include/audaspace/python)
endif()
if(WITH_PYTHON_MODULE)
set(PYTHON_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python)
configure_file(${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py ESCAPE_QUOTES @ONLY)
if(APPLE)
add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
elseif(WIN32)
set(ENV{VS100COMNTOOLS} $ENV{VS120COMNTOOLS})
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
else()
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
endif()
add_custom_target(pythonmodule ALL DEPENDS build SOURCES ${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${PYTHON_SRC} ${PYTHON_HDR})
add_dependencies(pythonmodule audaspace)
install(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} setup.py install --root=\$ENV{DESTDIR} --prefix=${CMAKE_INSTALL_PREFIX})")
endif()
endif()
# docs
if(WITH_DOCS)
find_package(Doxygen ${PACKAGE_OPTION})
if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(audaspace_doc ALL ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Building C++ HTML documentation with Doxygen.")
else()
set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
message(WARNING "Doxygen (and/or dot) not found, documentation will not be built.")
endif()
endif()
if(WITH_BINDING_DOCS)
find_package(Sphinx ${PACKAGE_OPTION})
if(SPHINX_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
add_custom_target(bindings_doc ALL COMMAND ${PYTHON_EXECUTABLE} setup.py --build-docs ${SPHINX_EXECUTABLE} -q -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${CMAKE_CURRENT_BINARY_DIR}/_doctrees" "${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc" "${CMAKE_CURRENT_BINARY_DIR}/doc/bindings" DEPENDS pythonmodule COMMENT "Building C/Python HTML documentation with Sphinx.")
else()
set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
message(WARNING "Sphinx not found, binding documentation will not be built.")
endif()
endif()
if(WITH_DOCS OR WITH_BINDING_DOCS)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ${DOCUMENTATION_INSTALL_PATH})
endif()

View File

@@ -1,107 +0,0 @@
Audaspace Installation Guide
============================
This document guides through the building and installation of audaspace.
The build system used to build audaspace is CMake and it allows very building the library for very different application scenarios from a very general shared library build with plugins that is suitable for system wide installations to building everything into a single static library to be linked into a standalone program.
Build Dependencies
------------------
Audaspace is written in C++ 11 so a fairly recent compiler (g++ 4.8.2, clang 3.3, MSVC 2013) is needed to build it. The build system used is CMake and you need at least version 3.0. The following build dependencies are all optional, but without any it's neither possible to open sound files nor play back through the speakers. For windows a library folder called build-dependencies can be downloaded from https://github.com/audaspace/audaspace/releases.
- OpenAL (input/output device)
- SDL (output device)
- Jack (output device)
- libsndfile (file access)
- ffmpeg (file access)
- Python (language binding)
Getting the Code
----------------
The audaspace source code or binary releases can be downloaded from https://github.com/audaspace/audaspace/releases.
For the most recent version you can use git to get the source code.
git clone https://github.com/audaspace/audaspace.git
Plugins
-------
Before diving into the exact build steps for each platform, we will have a look at plugins. There are so far two types of plugins: input and output plugins. Input plugins are for reading audio files in many different formats and output plugins are for output devices on different platforms. During the configuration audaspace's standard plugins can be enabled with their repsective `WITH_*` and `PLUGIN_*` configuration option. Plugins are built as shared libraries. By default audaspace looks in the `DEFAULT_PLUGIN_PATH` for shared libraries it can load. Building with a dependency (`WITH_*`) but without enabling the respective `PLUGIN_*` option will compile the plugin directly into the library, so the plugin always gets loaded when the plugins are initialised.
Building for Linux
------------------
### Configuration ###
It is highly recommended to build audaspace outside of the actual source code in a specific build directory.
mkdir build
cd build
Configuration is then either done interactively by using ccmake
ccmake ../audaspace
__or__ it can be done by defining variables directly during the run of cmake.
cmake ../build \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_DEMOS:BOOL=TRUE \
-DSHARED_LIBRARY:BOOL=TRUE \
-DWITH_C:BOOL=TRUE \
-DWITH_FFMPEG:BOOL=TRUE \
-DWITH_JACK:BOOL=TRUE \
-DWITH_LIBSNDFILE:BOOL=TRUE \
-DWITH_OPENAL:BOOL=TRUE \
-DWITH_PYTHON:BOOL=TRUE \
-DWITH_SDL:BOOL=TRUE \
-DDEFAULT_PLUGIN_PATH:PATH=/usr/share/audaspace/plugins
This specific configuration is recommended for a system wide installation of audaspace where all build dependencies are required.
### Building ###
After configuration the building is as easy as running
make
### Installation ###
Installation is then also simple using
make install
### Using the library ###
When audaspace is installed to the system, the required configuration for _pkgconfig_ is also installed and pkgconfig can then be used to compile projects with audaspace.
It is also possible to build audaspace as a static library and use it directly in a project. For this the library has to be configured accordingly with ccmake and after building the resulting library file can be added to the project's build system.
Building for Windows
--------------------
### Configuration ###
Using cmake-gui select Visual Studio 2013 or 2015 for the architecture you want to build for and choose audaspace's source directory and a build directory. It is highly recommended to build audaspace outside of the source directory. During the first configuration cmake tries to find the dependencies. Dependencies that are not installed on the system are automatically disabled. To prevent this, enable `WITH_STRICT_DEPENDENCIES`. To use the build dependencies folder from the website, set the `LIBRARY_PATH` to point to the extracted directory. Also don't forget to set the `CMAKE_INSTALL_PREFIX` to a path where your user account can install to. Finally enable the dependencies that you want to use (`WITH_*`), configure and generate.
### Building ###
Open the project in Visual Studio and set the configuration to Release. Then you can simply hit the build button.
### Installation ###
To install audaspace to your target folder, build the INSTALL target.
Note that if you don't use the libraries folder provided on the website, the INSTALL target might fail and you need to copy the files manually, including the dlls of the dependencies.
### Using the library ###
To use audaspace in your project, configure the include path and the libraries that you need, which you can find in the include and lib directories in your installation path.
### Notes for plugins on windows ###
- FFMPEG: Due to a problem with FFMPEG's 32 bit libraries, it is necessary to disable SAFESEH for the audffmpeg build target inside Visual Studio (Properties, Linker, Advanced). This has to be done after each generate step of CMake.
- Jack: If no jack server is running on windows and your application or one of the demos tries to use the jack plugin, this adds a long delay to the device initialisation. In case you don't need jack, make sure to disable the plugin or for the prebuilt version of audaspace simply delete audjack.dll (and any files with jack in the name to clean up).

View File

@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,47 +0,0 @@
audaspace
=========
Audaspace (pronounced "outer space") is a high level audio library written in C++ with language bindings for Python for example. It started out as the audio engine of the 3D modelling application Blender and is now released as a standalone library.
Documentation and Community
---------------------------
The documentation including guides for building and installing, demos, tutorials as well as the API reference for C++, C and python can be found on https://audaspace.github.io.
Bug reports and feature requests should go to the [issue tracker](https://github.com/audaspace/audaspace/issues).
For any other discussions about audaspace there is a [mailing list](https://groups.google.com/forum/#!forum/audaspace) and there is also the IRC channel #audaspace on irc.freenode.net.
Features
--------
The following (probably incomplete) features are supported by audaspace:
* input/output devices
* input from microphones, line in, etc.
* output devices including 3D audio support
* file reading/writing
* filters like low-/highpass and effects like delay, reverse or fading
* generators for simple waveforms like silence, sine and triangle
* respecification - this term is used for changing stream parameters which are
* channel count - channel remapping
* sample format - the library internally uses 32 bit floats
* sample rate - resampling
* simple (superposition, joining and ping-pong aka forward-reverse) and more complex (non-linear audio editing) sequencing of sounds
License
-------
> Copyright © 2009-2015 Jörg Müller. All rights reserved.
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.

View File

@@ -1,336 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "devices/DeviceManager.h"
#include "devices/I3DDevice.h"
#include "devices/IDeviceFactory.h"
#include "devices/ReadDevice.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Device.h"
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
{
aud::DeviceSpecs s;
s.specs = convCToSpec(specs.specs);
s.format = static_cast<SampleFormat>(specs.format);
return s;
}
AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name)
{
DeviceSpecs dspecs = convCToDSpec(specs);
if(dspecs.channels == CHANNELS_INVALID)
dspecs.channels = CHANNELS_STEREO;
if(dspecs.format == FORMAT_INVALID)
dspecs.format = FORMAT_FLOAT32;
if(dspecs.rate == RATE_INVALID)
dspecs.rate = RATE_48000;
if(buffersize < 128)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
if(name == nullptr)
name = "";
try
{
if(!type)
{
auto device = DeviceManager::getDevice();
if(!device)
{
DeviceManager::openDefaultDevice();
device = DeviceManager::getDevice();
}
return new AUD_Device(device);
}
if(type == std::string("read"))
{
return new AUD_Device(new ReadDevice(dspecs));
}
std::shared_ptr<IDeviceFactory> factory;
if(!*type)
factory = DeviceManager::getDefaultDeviceFactory();
else
factory = DeviceManager::getDeviceFactory(type);
if(factory)
{
factory->setName(name);
factory->setSpecs(dspecs);
factory->setBufferSize(buffersize);
return new AUD_Device(factory->openDevice());
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_Device_lock(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->lock();
}
AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep)
{
assert(sound);
auto dev = device ? *device : DeviceManager::getDevice();
try
{
AUD_Handle handle = dev->play(*sound, keep);
if(handle.get())
{
return new AUD_Handle(handle);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_Device_stopAll(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->stopAll();
}
AUD_API void AUD_Device_unlock(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->unlock();
}
AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return static_cast<AUD_Channels>(dev->getSpecs().channels);
}
AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return static_cast<AUD_DistanceModel>(dev->getDistanceModel());
}
AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setDistanceModel(static_cast<DistanceModel>(value));
}
AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return dev->getDopplerFactor();
}
AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setDopplerFactor(value);
}
AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return static_cast<AUD_SampleFormat>(dev->getSpecs().format);
}
AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v = dev->getListenerLocation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
}
AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v(value[0], value[1], value[2]);
dev->setListenerLocation(v);
}
AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Quaternion v = dev->getListenerOrientation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
value[3] = v.w();
}
AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Quaternion v(value[3], value[0], value[1], value[2]);
dev->setListenerOrientation(v);
}
AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v = dev->getListenerVelocity();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
}
AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v(value[0], value[1], value[2]);
dev->setListenerVelocity(v);
}
AUD_API double AUD_Device_getRate(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return dev->getSpecs().rate;
}
AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return dev->getSpeedOfSound();
}
AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setSpeedOfSound(value);
}
AUD_API float AUD_Device_getVolume(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return dev->getVolume();
}
AUD_API void AUD_Device_setVolume(AUD_Device* device, float value)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->setVolume(value);
}
AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length)
{
assert(device);
assert(buffer);
auto readDevice = std::dynamic_pointer_cast<ReadDevice>(*device);
if(!readDevice)
return false;
try
{
return readDevice->read(buffer, length);
}
catch(Exception&)
{
return false;
}
}
AUD_API void AUD_Device_free(AUD_Device* device)
{
assert(device);
try
{
delete device;
}
catch(Exception&)
{
}
}
AUD_API AUD_Device* AUD_Device_getCurrent()
{
auto device = DeviceManager::getDevice();
if(!device)
return nullptr;
return new AUD_Device(device);
}
AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->seek(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle), time);
}
AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
return synchronizer->getPosition(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle));
return (*reinterpret_cast<std::shared_ptr<IHandle>*>(handle))->getPosition();
}
AUD_API void AUD_playSynchronizer()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->play();
}
AUD_API void AUD_stopSynchronizer()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->stop();
}
AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->setSyncCallback(function, data);
}
AUD_API int AUD_isSynchronizerPlaying()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
return synchronizer->isPlaying();
return false;
}

View File

@@ -1,258 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Possible distance models for the 3D device.
typedef enum
{
AUD_DISTANCE_MODEL_INVALID = 0,
AUD_DISTANCE_MODEL_INVERSE,
AUD_DISTANCE_MODEL_INVERSE_CLAMPED,
AUD_DISTANCE_MODEL_LINEAR,
AUD_DISTANCE_MODEL_LINEAR_CLAMPED,
AUD_DISTANCE_MODEL_EXPONENT,
AUD_DISTANCE_MODEL_EXPONENT_CLAMPED
} AUD_DistanceModel;
typedef void (*AUD_syncFunction)(void*, int, float);
/**
* Opens a new sound device.
* \param type The name of the device.
* Can be NULL to open the default device with default settings or return the handle to the already opened one.
* Can be "" to open the a default factory device with given settings.
* Can be "read" to open a readable device.
* \param specs Specification of the device parameters.
* \param buffersize Size of the mixing buffer.
* \param name Custom name of the device.
* \return A handle to the opened device or NULL on failure.
*/
extern AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name);
/**
* Locks the playback device.
*/
extern AUD_API void AUD_Device_lock(AUD_Device* device);
/**
* Plays back a sound file.
* \param sound The handle of the sound file.
* \param keep When keep is true the sound source will not be deleted but set to
* paused when its end has been reached.
* \return A handle to the played back sound.
*/
extern AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep);
/**
* Stops all sounds playing.
*/
extern AUD_API void AUD_Device_stopAll(AUD_Device* device);
/**
* Unlocks the device.
*/
extern AUD_API void AUD_Device_unlock(AUD_Device* device);
/**
* Retrieves the channels of a device.
* param device The device to get the channels from.
* return The channels of the device.
*/
extern AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device);
/**
* Retrieves the distance model of a device.
* param device The device to get the distance model from.
* return The distance model of the device.
*/
extern AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device);
/**
* Sets the distance model of a device.
* param device The device to set the distance model from.
* param value The new distance model to set.
*/
extern AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value);
/**
* Retrieves the doppler factor of a device.
* param device The device to get the doppler factor from.
* return The doppler factor of the device.
*/
extern AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device);
/**
* Sets the doppler factor of a device.
* param device The device to set the doppler factor from.
* param value The new doppler factor to set.
*/
extern AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value);
/**
* Retrieves the format of a device.
* param device The device to get the format from.
* return The format of the device.
*/
extern AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device);
/**
* Retrieves the listener location of a device.
* param device The device to get the listener location from.
* return The listener location of the device.
*/
extern AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3]);
/**
* Sets the listener location of a device.
* param device The device to set the listener location from.
* param value The new listener location to set.
*/
extern AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3]);
/**
* Retrieves the listener orientation of a device.
* param device The device to get the listener orientation from.
* return The listener orientation of the device.
*/
extern AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4]);
/**
* Sets the listener orientation of a device.
* param device The device to set the listener orientation from.
* param value The new listener orientation to set.
*/
extern AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4]);
/**
* Retrieves the listener velocity of a device.
* param device The device to get the listener velocity from.
* return The listener velocity of the device.
*/
extern AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3]);
/**
* Sets the listener velocity of a device.
* param device The device to set the listener velocity from.
* param value The new listener velocity to set.
*/
extern AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3]);
/**
* Retrieves the rate of a device.
* param device The device to get the rate from.
* return The rate of the device.
*/
extern AUD_API double AUD_Device_getRate(AUD_Device* device);
/**
* Retrieves the speed of sound of a device.
* param device The device to get the speed of sound from.
* return The speed of sound of the device.
*/
extern AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device);
/**
* Sets the speed of sound of a device.
* param device The device to set the speed of sound from.
* param value The new speed of sound to set.
*/
extern AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value);
/**
* Retrieves the volume of a device.
* param device The device to get the volume from.
* return The volume of the device.
*/
extern AUD_API float AUD_Device_getVolume(AUD_Device* device);
/**
* Sets the volume of a device.
* param device The device to set the volume from.
* param value The new volume to set.
*/
extern AUD_API void AUD_Device_setVolume(AUD_Device* device, float value);
/**
* Reads the next samples into the supplied buffer.
* \param device The readable device.
* \param buffer The target buffer.
* \param length The length in samples to be filled.
* \return True if the reading succeeded, false if there are no sounds
* played back currently, in that case the buffer is filled with
* silence.
*/
extern AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length);
/**
* Closes a device. Handle becomes invalid afterwards.
* \param device The device to close.
*/
extern AUD_API void AUD_Device_free(AUD_Device* device);
/**
* Retrieves the current device of the DeviceManager.
* \return A pointer to the current device, which needs to be freed with
* AUD_Device_free.
*/
extern AUD_API AUD_Device* AUD_Device_getCurrent();
/**
* Seeks sequenced sound scene playback.
* \param handle Playback handle.
* \param time Time in seconds to seek to.
*/
extern AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time);
/**
* Returns the current sound scene playback time.
* \param handle Playback handle.
* \return The playback time in seconds.
*/
extern AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle);
/**
* Starts the playback of jack transport if possible.
*/
extern AUD_API void AUD_playSynchronizer();
/**
* Stops the playback of jack transport if possible.
*/
extern AUD_API void AUD_stopSynchronizer();
/**
* Sets the sync callback for jack transport.
* \param function The callback function.
* \param data The data parameter for the callback.
*/
extern AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data);
/**
* Returns whether jack transport is currently playing.
* \return Whether jack transport is currently playing.
*/
extern AUD_API int AUD_isSynchronizerPlaying();
#ifdef __cplusplus
}
#endif

View File

@@ -1,144 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_DynamicMusic.h"
AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device)
{
assert(device);
try
{
return new AUD_DynamicMusic(new DynamicMusic(*device));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player)
{
assert(player);
delete player;
}
AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene)
{
assert(player);
assert(scene);
return (*player)->addScene(*scene);
}
AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene)
{
assert(player);
return (*player)->changeScene(scene);
}
AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getScene();
}
AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition)
{
assert(player);
assert(transition);
return (*player)->addTransition(ini, end, *transition);
}
AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds)
{
assert(player);
(*player)->setFadeTime(seconds);
}
AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getFadeTime();
}
AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->resume();
}
AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->pause();
}
AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position)
{
assert(player);
return (*player)->seek(position);
}
AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getPosition();
}
AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getVolume();
}
AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume)
{
assert(player);
return (*player)->setVolume(volume);
}
AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player)
{
assert(player);
return static_cast<AUD_Status>((*player)->getStatus());
}
AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->stop();
}

View File

@@ -1,145 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#include "AUD_Handle.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new dynamic music player.
* \param device The device that will be used to play sounds.
* \return The new DynamicMusic object.
*/
extern AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device);
/**
* Deletes a dynamic music player.
* \param player The DynamicMusic object to be deleted.
*/
extern AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player);
/**
* Adds a sound scene to a dynamic music player.
* \param player The DynamicMusic object.
* \param scene The sound to be added as a scene.
* \return The index of the new scene.
*/
extern AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene);
/**
* Changes the current sound scene of a dynamic music player.
* \param player The DynamicMusic object.
* \param scene The index of the scene to be played.
* \return 0 if the target scene doesn't exist.
*/
extern AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene);
/**
* Retrives the index of the current scene.
* \param player The DynamicMusic object.
* \return The index of the current scene.
*/
extern AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player);
/**
* Adds a new transition between two scenes.
* \param player The DynamicMusic object.
* \param ini The origin scene for the transition.
* \param end The end scene for the transition.
* \param transition A sound that will be used as transition between two scenes.
* \return 0 if the ini or end scenes don't exist.
*/
extern AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition);
/**
* Changes the fade time for the default transitions of a dynamic music player.
* \param player The DynamicMusic object.
* \param seconds The amount of secods that the crossfade transition will take.
*/
extern AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds);
/**
* Retrieves the fade time of a dynamic music player.
* \param player The DynamicMusic object.
* \return The fade time of the player.
*/
extern AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player);
/**
* Resumes the current scene playback of a dynamic music player if it is paused.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't resumed.
*/
extern AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player);
/**
* Pauses the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't paused.
*/
extern AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player);
/**
* Seeks the current playing scene of a dynamic music player.
* \param player The DynamicMusic object.
* \param position The new position from which to play back, in seconds.
* \return 0 if the seeking wasn't possible.
*/
extern AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position);
/**
* Retrieves the position of the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return The position of the current playing scene.
*/
extern AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player);
/**
* Retrieves the volume of the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return The volume of the current playing scene.
*/
extern AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player);
/**
* Changes the volume of the current scene in a dynamic music player.
* \param player The DynamicMusic object.
* \param 0 if the volume couldn't be changed.
*/
extern AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume);
/**
* Retrieves the status of the current scene in a dynamic music player.
* \param player The DynamicMusic object.
* \return The Status of the current playing scene.
*/
extern AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player);
/**
* Stops the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't stopped.
*/
extern AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player);
#ifdef __cplusplus
}
#endif

View File

@@ -1,50 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_HRTF.h"
extern AUD_API AUD_HRTF* AUD_HRTF_create()
{
try
{
return new AUD_HRTF(new HRTF());
}
catch(Exception&)
{
return nullptr;
}
}
extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs)
{
assert(hrtfs);
delete hrtfs;
}
extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation)
{
assert(hrtfs);
assert(sound);
(*hrtfs)->addImpulseResponse(std::make_shared<StreamBuffer>(*sound), azimuth, elevation);
}

View File

@@ -1,48 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new HRTF object.
* \return The new HRTF object.
*/
extern AUD_API AUD_HRTF* AUD_HRTF_create();
/**
* Deletes a HRTF object.
* \param hrtfs The HRTF object to be deleted.
*/
extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs);
/**
* Adds a new impulse response to an HRTF object.
* \param hrtfs The HRTF object.
* \param sound A Sound object representing an HRTF.
* \param azimuth The azimuth angle of the HRTF.
* \param elevation The elevation angle of the HRTF.
*/
extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation);
#ifdef __cplusplus
}
#endif

View File

@@ -1,384 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "devices/I3DHandle.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Handle.h"
AUD_API int AUD_Handle_pause(AUD_Handle* handle)
{
assert(handle);
return (*handle)->pause();
}
AUD_API int AUD_Handle_resume(AUD_Handle* handle)
{
assert(handle);
return (*handle)->resume();
}
AUD_API int AUD_Handle_stop(AUD_Handle* handle)
{
assert(handle);
int result = (*handle)->stop();
delete handle;
return result;
}
AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getAttenuation();
return 0.0f;
}
AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setAttenuation(value);
return false;
}
AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeAngleInner();
return 0.0f;
}
AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeAngleInner(value);
return false;
}
AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeAngleOuter();
return 0.0f;
}
AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeAngleOuter(value);
return false;
}
AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeVolumeOuter();
return 0.0f;
}
AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeVolumeOuter(value);
return false;
}
AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getDistanceMaximum();
return 0.0f;
}
AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setDistanceMaximum(value);
return false;
}
AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getDistanceReference();
return 0.0f;
}
AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setDistanceReference(value);
return false;
}
AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getKeep();
}
AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value)
{
assert(handle);
return (*handle)->setKeep(value);
}
AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = h->getLocation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
return true;
}
return false;
}
AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = Vector3(value[0], value[1], value[2]);
return h->setLocation(v);
}
return false;
}
AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getLoopCount();
}
AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value)
{
assert(handle);
return (*handle)->setLoopCount(value);
}
AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Quaternion v = h->getOrientation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
value[3] = v.w();
return true;
}
return false;
}
AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Quaternion v(value[3], value[0], value[1], value[2]);
return h->setOrientation(v);
}
return false;
}
AUD_API float AUD_Handle_getPitch(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getPitch();
}
AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->setPitch(value);
}
AUD_API float AUD_Handle_getPosition(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getPosition();
}
AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->seek(value);
}
AUD_API int AUD_Handle_isRelative(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->isRelative();
return true;
}
AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setRelative(value);
return false;
}
AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle)
{
assert(handle);
return static_cast<AUD_Status>((*handle)->getStatus());
}
AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = h->getVelocity();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
return true;
}
return false;
}
AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = Vector3(value[0], value[1], value[2]);
return h->setVelocity(v);
}
return false;
}
AUD_API float AUD_Handle_getVolume(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getVolume();
}
AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->setVolume(value);
}
AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getVolumeMaximum();
return 0.0f;
}
AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setVolumeMaximum(value);
return false;
}
AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getVolumeMinimum();
return 0.0f;
}
AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setVolumeMinimum(value);
return false;
}
AUD_API void AUD_Handle_free(AUD_Handle* handle)
{
delete handle;
}

View File

@@ -1,308 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Status of a playback handle.
typedef enum
{
AUD_STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
AUD_STATUS_PLAYING, /// Sound is playing.
AUD_STATUS_PAUSED, /// Sound is being paused.
AUD_STATUS_STOPPED /// Sound is stopped but kept in the device.
} AUD_Status;
/**
* Pauses a played back sound.
* \param handle The handle to the sound.
* \return Whether the handle has been playing or not.
*/
extern AUD_API int AUD_Handle_pause(AUD_Handle* handle);
/**
* Resumes a paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been paused or not.
*/
extern AUD_API int AUD_Handle_resume(AUD_Handle* handle);
/**
* Stops a playing or paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been valid or not.
*/
extern AUD_API int AUD_Handle_stop(AUD_Handle* handle);
/**
* Retrieves the attenuation of a handle.
* param handle The handle to get the attenuation from.
* return The attenuation of the handle.
*/
extern AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle);
/**
* Sets the attenuation of a handle.
* param handle The handle to set the attenuation from.
* param value The new attenuation to set.
*/
extern AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value);
/**
* Retrieves the cone angle inner of a handle.
* param handle The handle to get the cone angle inner from.
* return The cone angle inner of the handle.
*/
extern AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle);
/**
* Sets the cone angle inner of a handle.
* param handle The handle to set the cone angle inner from.
* param value The new cone angle inner to set.
*/
extern AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value);
/**
* Retrieves the cone angle outer of a handle.
* param handle The handle to get the cone angle outer from.
* return The cone angle outer of the handle.
*/
extern AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle);
/**
* Sets the cone angle outer of a handle.
* param handle The handle to set the cone angle outer from.
* param value The new cone angle outer to set.
*/
extern AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value);
/**
* Retrieves the cone volume outer of a handle.
* param handle The handle to get the cone volume outer from.
* return The cone volume outer of the handle.
*/
extern AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle);
/**
* Sets the cone volume outer of a handle.
* param handle The handle to set the cone volume outer from.
* param value The new cone volume outer to set.
*/
extern AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value);
/**
* Retrieves the distance maximum of a handle.
* param handle The handle to get the distance maximum from.
* return The distance maximum of the handle.
*/
extern AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle);
/**
* Sets the distance maximum of a handle.
* param handle The handle to set the distance maximum from.
* param value The new distance maximum to set.
*/
extern AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value);
/**
* Retrieves the distance reference of a handle.
* param handle The handle to get the distance reference from.
* return The distance reference of the handle.
*/
extern AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle);
/**
* Sets the distance reference of a handle.
* param handle The handle to set the distance reference from.
* param value The new distance reference to set.
*/
extern AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value);
/**
* Retrieves the keep of a handle.
* param handle The handle to get the keep from.
* return The keep of the handle.
*/
extern AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle);
/**
* Sets the keep of a handle.
* param handle The handle to set the keep from.
* param value The new keep to set.
*/
extern AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value);
/**
* Retrieves the location of a handle.
* param handle The handle to get the location from.
* return The location of the handle.
*/
extern AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3]);
/**
* Sets the location of a handle.
* param handle The handle to set the location from.
* param value The new location to set.
*/
extern AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3]);
/**
* Retrieves the loop count of a handle.
* param handle The handle to get the loop count from.
* return The loop count of the handle.
*/
extern AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle);
/**
* Sets the loop count of a handle.
* param handle The handle to set the loop count from.
* param value The new loop count to set.
*/
extern AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value);
/**
* Retrieves the orientation of a handle.
* param handle The handle to get the orientation from.
* return The orientation of the handle.
*/
extern AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4]);
/**
* Sets the orientation of a handle.
* param handle The handle to set the orientation from.
* param value The new orientation to set.
*/
extern AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4]);
/**
* Retrieves the pitch of a handle.
* param handle The handle to get the pitch from.
* return The pitch of the handle.
*/
extern AUD_API float AUD_Handle_getPitch(AUD_Handle* handle);
/**
* Sets the pitch of a handle.
* param handle The handle to set the pitch from.
* param value The new pitch to set.
*/
extern AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value);
/**
* Retrieves the position of a handle.
* param handle The handle to get the position from.
* return The position of the handle.
*/
extern AUD_API float AUD_Handle_getPosition(AUD_Handle* handle);
/**
* Sets the position of a handle.
* param handle The handle to set the position from.
* param value The new position to set.
*/
extern AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value);
/**
* Retrieves the relative of a handle.
* param handle The handle to get the relative from.
* return The relative of the handle.
*/
extern AUD_API int AUD_Handle_isRelative(AUD_Handle* handle);
/**
* Sets the relative of a handle.
* param handle The handle to set the relative from.
* param value The new relative to set.
*/
extern AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value);
/**
* Retrieves the status of a handle.
* param handle The handle to get the status from.
* return The status of the handle.
*/
extern AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle);
/**
* Retrieves the velocity of a handle.
* param handle The handle to get the velocity from.
* return The velocity of the handle.
*/
extern AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3]);
/**
* Sets the velocity of a handle.
* param handle The handle to set the velocity from.
* param value The new velocity to set.
*/
extern AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3]);
/**
* Retrieves the volume of a handle.
* param handle The handle to get the volume from.
* return The volume of the handle.
*/
extern AUD_API float AUD_Handle_getVolume(AUD_Handle* handle);
/**
* Sets the volume of a handle.
* param handle The handle to set the volume from.
* param value The new volume to set.
*/
extern AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value);
/**
* Retrieves the volume maximum of a handle.
* param handle The handle to get the volume maximum from.
* return The volume maximum of the handle.
*/
extern AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle);
/**
* Sets the volume maximum of a handle.
* param handle The handle to set the volume maximum from.
* param value The new volume maximum to set.
*/
extern AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value);
/**
* Retrieves the volume minimum of a handle.
* param handle The handle to get the volume minimum from.
* return The volume minimum of the handle.
*/
extern AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle);
/**
* Sets the volume minimum of a handle.
* param handle The handle to set the volume minimum from.
* param value The new volume minimum to set.
*/
extern AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value);
/**
* Frees a handle.
* \param channel Handle to free.
*/
extern AUD_API void AUD_Handle_free(AUD_Handle* channel);
#ifdef __cplusplus
}
#endif

View File

@@ -1,44 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_ImpulseResponse.h"
AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_ImpulseResponse(new ImpulseResponse(std::make_shared<StreamBuffer>(*sound)));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter)
{
assert(filter);
delete filter;
}

View File

@@ -1,40 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new ImpulseResponse object.
* \param sound A Sound object representing a impulse response.
* \return The new ImpulseResponse object.
*/
extern AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound);
/**
* Deletes a ImpulseResponse object.
* \param threadPool The ImpulseResponse object to be deleted.
*/
extern AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter);
#ifdef __cplusplus
}
#endif

View File

@@ -1,94 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_PlaybackManager.h"
AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device)
{
assert(device);
try
{
return new AUD_PlaybackManager(new PlaybackManager(*device));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager)
{
assert(manager);
delete manager;
}
AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey)
{
assert(manager);
assert(sound);
(*manager)->play(*sound, catKey);
}
AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->resume(catKey);
}
AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->pause(catKey);
}
AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume)
{
assert(manager);
return (*manager)->addCategory(volume);
}
AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->getVolume(catKey);
}
AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey)
{
assert(manager);
return (*manager)->setVolume(volume, catKey);
}
AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->stop(catKey);
}
AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager)
{
assert(manager);
(*manager)->clean();
}

View File

@@ -1,103 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new PlaybackManager object.
* \param device The device that will be used to play sounds.
* \return The new PlaybackManager object.
*/
extern AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device);
/**
* Deletes a PlaybackManager object.
* \param manager The PlaybackManager object to be deleted.
*/
extern AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager);
/**
* Plays a sound through the playback manager, adding it into a category.
* \param manager The PlaybackManager object.
* \param sound The sound to be played.
* \param catKey The key of the category into which the sound will be added. If it doesn't exist a new one will be creatd.
*/
extern AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey);
/**
* Resumes the playback of all the paused sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Pauses all the sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Adds a new category with a custom volume.
* \param manager The PlaybackManager object.
* \param volume The volume value.
* \return The key of the new category.
*/
extern AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume);
/**
* Retrieves the volume of a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return The volume of the category.
*/
extern AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Changes the voulume of a category of a playback manager.
* \param manager The PlaybackManager object.
* \param volume The new volume of the category.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey);
/**
* Stops all the sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Cleans all the invalid handles in a playback manager
* \param manager The PlaybackManager object.
*/
extern AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager);
#ifdef __cplusplus
}
#endif

View File

@@ -1,315 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "devices/I3DDevice.h"
#include "devices/DeviceManager.h"
#include "sequence/Sequence.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Sequence.h"
AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted)
{
// specs are changed at a later point!
Specs specs;
specs.channels = CHANNELS_STEREO;
specs.rate = RATE_48000;
AUD_Sound* sequence = new AUD_Sound(std::shared_ptr<Sequence>(new Sequence(specs, fps, muted)));
return sequence;
}
AUD_API void AUD_Sequence_free(AUD_Sound* sequence)
{
delete sequence;
}
AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip)
{
if(!sound)
return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(AUD_Sound(), begin, end, skip));
return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(*sound, begin, end, skip));
}
AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry)
{
dynamic_cast<Sequence *>(sequence->get())->remove(*entry);
delete entry;
}
AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
{
AnimateableProperty* prop = dynamic_cast<Sequence *>(sequence->get())->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(animated)
{
if(frame >= 0)
{
prop->write(data, frame, 1);
}
}
else
{
prop->write(data);
}
}
AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence)
{
assert(sequence);
return static_cast<AUD_DistanceModel>(dynamic_cast<Sequence *>(sequence->get())->getDistanceModel());
}
AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setDistanceModel(static_cast<DistanceModel>(value));
}
AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getDopplerFactor();
}
AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setDopplerFactor(value);
}
AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getFPS();
}
AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setFPS(value);
}
AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->isMuted();
}
AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->mute(value);
}
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence)
{
assert(sequence);
return convSpecToC(dynamic_cast<Sequence *>(sequence->get())->getSpecs());
}
AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setSpecs(convCToSpec(value));
}
AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getSpeedOfSound();
}
AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setSpeedOfSound(value);
}
AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip)
{
(*entry)->move(begin, end, skip);
}
AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
{
AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(animated)
{
if(frame >= 0)
prop->write(data, frame, 1);
}
else
{
prop->write(data);
}
}
AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getAttenuation();
}
AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setAttenuation(value);
}
AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeAngleInner();
}
AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleInner(value);
}
AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeAngleOuter();
}
AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleOuter(value);
}
AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeVolumeOuter();
}
AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeVolumeOuter(value);
}
AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getDistanceMaximum();
}
AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceMaximum(value);
}
AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getDistanceReference();
}
AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceReference(value);
}
AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->isMuted();
}
AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value)
{
assert(sequence_entry);
(*sequence_entry)->mute(value);
}
AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->isRelative();
}
AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value)
{
assert(sequence_entry);
(*sequence_entry)->setRelative(value);
}
AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return new std::shared_ptr<ISound>((*sequence_entry)->getSound());
}
AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value)
{
assert(sequence_entry);
if(value)
(*sequence_entry)->setSound(*value);
else
(*sequence_entry)->setSound(AUD_Sound());
}
AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getVolumeMaximum();
}
AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMaximum(value);
}
AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getVolumeMinimum();
}
AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMinimum(value);
}

View File

@@ -1,338 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Device.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Possible animatable properties for Sequence Factories and Entries.
typedef enum
{
AUD_AP_VOLUME,
AUD_AP_PANNING,
AUD_AP_PITCH,
AUD_AP_LOCATION,
AUD_AP_ORIENTATION
} AUD_AnimateablePropertyType;
/**
* Creates a new sequenced sound scene.
* \param fps The FPS of the scene.
* \param muted Whether the scene is muted.
* \return The new sound scene.
*/
extern AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted);
/**
* Deletes a sound scene.
* \param sequence The sound scene.
*/
extern AUD_API void AUD_Sequence_free(AUD_Sound* sequence);
/**
* Adds a new entry to the scene.
* \param sequence The sound scene.
* \param sound The sound this entry should play.
* \param begin The start time.
* \param end The end time or a negative value if determined by the sound.
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
extern AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip);
/**
* Removes an entry from the scene.
* \param sequence The sound scene.
* \param entry The entry to remove.
*/
extern AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry);
/**
* Writes animation data to a sequence.
* \param sequence The sound scene.
* \param type The type of animation data.
* \param frame The frame this data is for.
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
/**
* Retrieves the distance model of a sequence.
* param sequence The sequence to get the distance model from.
* return The distance model of the sequence.
*/
extern AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence);
/**
* Sets the distance model of a sequence.
* param sequence The sequence to set the distance model from.
* param value The new distance model to set.
*/
extern AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value);
/**
* Retrieves the doppler factor of a sequence.
* param sequence The sequence to get the doppler factor from.
* return The doppler factor of the sequence.
*/
extern AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence);
/**
* Sets the doppler factor of a sequence.
* param sequence The sequence to set the doppler factor from.
* param value The new doppler factor to set.
*/
extern AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value);
/**
* Retrieves the fps of a sequence.
* param sequence The sequence to get the fps from.
* return The fps of the sequence.
*/
extern AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence);
/**
* Sets the fps of a sequence.
* param sequence The sequence to set the fps from.
* param value The new fps to set.
*/
extern AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value);
/**
* Retrieves the muted of a sequence.
* param sequence The sequence to get the muted from.
* return The muted of the sequence.
*/
extern AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence);
/**
* Sets the muted of a sequence.
* param sequence The sequence to set the muted from.
* param value The new muted to set.
*/
extern AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value);
/**
* Retrieves the specs of a sequence.
* param sequence The sequence to get the specs from.
* return The specs of the sequence.
*/
extern AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence);
/**
* Sets the specs of a sequence.
* param sequence The sequence to set the specs from.
* param value The new specs to set.
*/
extern AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value);
/**
* Retrieves the speed of sound of a sequence.
* param sequence The sequence to get the speed of sound from.
* return The speed of sound of the sequence.
*/
extern AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence);
/**
* Sets the speed of sound of a sequence.
* param sequence The sequence to set the speed of sound from.
* param value The new speed of sound to set.
*/
extern AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value);
/**
* Moves the entry.
* \param entry The sequenced entry.
* \param begin The new start time.
* \param end The new end time or a negative value if unknown.
* \param skip How many seconds to skip at the beginning.
*/
extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip);
/**
* Writes animation data to a sequenced entry.
* \param entry The sequenced entry.
* \param type The type of animation data.
* \param frame The frame this data is for.
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
/**
* Retrieves the attenuation of a sequence_entry.
* param sequence_entry The sequence_entry to get the attenuation from.
* return The attenuation of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry);
/**
* Sets the attenuation of a sequence_entry.
* param sequence_entry The sequence_entry to set the attenuation from.
* param value The new attenuation to set.
*/
extern AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone angle inner of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone angle inner from.
* return The cone angle inner of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone angle inner of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle inner from.
* param value The new cone angle inner to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone angle outer of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone angle outer from.
* return The cone angle outer of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone angle outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle outer from.
* param value The new cone angle outer to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone volume outer of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone volume outer from.
* return The cone volume outer of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone volume outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone volume outer from.
* param value The new cone volume outer to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the distance maximum of a sequence_entry.
* param sequence_entry The sequence_entry to get the distance maximum from.
* return The distance maximum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the distance maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance maximum from.
* param value The new distance maximum to set.
*/
extern AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the distance reference of a sequence_entry.
* param sequence_entry The sequence_entry to get the distance reference from.
* return The distance reference of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry);
/**
* Sets the distance reference of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance reference from.
* param value The new distance reference to set.
*/
extern AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the muted of a sequence_entry.
* param sequence_entry The sequence_entry to get the muted from.
* return The muted of the sequence_entry.
*/
extern AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry);
/**
* Sets the muted of a sequence_entry.
* param sequence_entry The sequence_entry to set the muted from.
* param value The new muted to set.
*/
extern AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value);
/**
* Retrieves the relative of a sequence_entry.
* param sequence_entry The sequence_entry to get the relative from.
* return The relative of the sequence_entry.
*/
extern AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry);
/**
* Sets the relative of a sequence_entry.
* param sequence_entry The sequence_entry to set the relative from.
* param value The new relative to set.
*/
extern AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value);
/**
* Retrieves the sound of a sequence_entry.
* param sequence_entry The sequence_entry to get the sound from.
* return The sound of the sequence_entry.
*/
extern AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry);
/**
* Sets the sound of a sequence_entry.
* param sequence_entry The sequence_entry to set the sound from.
* param value The new sound to set.
*/
extern AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value);
/**
* Retrieves the volume maximum of a sequence_entry.
* param sequence_entry The sequence_entry to get the volume maximum from.
* return The volume maximum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the volume maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume maximum from.
* param value The new volume maximum to set.
*/
extern AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the volume minimum of a sequence_entry.
* param sequence_entry The sequence_entry to get the volume minimum from.
* return The volume minimum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the volume minimum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume minimum from.
* param value The new volume minimum to set.
*/
extern AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value);
#ifdef __cplusplus
}
#endif

View File

@@ -1,709 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "generator/Sawtooth.h"
#include "generator/Sine.h"
#include "generator/Silence.h"
#include "generator/Square.h"
#include "generator/Triangle.h"
#include "file/File.h"
#include "file/FileWriter.h"
#include "util/StreamBuffer.h"
#include "fx/Accumulator.h"
#include "fx/ADSR.h"
#include "fx/Delay.h"
#include "fx/Envelope.h"
#include "fx/Fader.h"
#include "fx/Highpass.h"
#include "fx/IIRFilter.h"
#include "fx/Limiter.h"
#include "fx/Loop.h"
#include "fx/Lowpass.h"
#include "fx/Pitch.h"
#include "fx/Reverse.h"
#include "fx/Sum.h"
#include "fx/Threshold.h"
#include "fx/Volume.h"
#include "fx/SoundList.h"
#include "fx/MutableSound.h"
#include "sequence/Double.h"
#include "sequence/Superpose.h"
#include "sequence/PingPong.h"
#include "respec/LinearResample.h"
#include "respec/JOSResample.h"
#include "respec/JOSResampleReader.h"
#include "respec/ChannelMapper.h"
#include "respec/ChannelMapperReader.h"
#include "util/Buffer.h"
#include "Exception.h"
#ifdef WITH_CONVOLUTION
#include "fx/BinauralSound.h"
#include "fx/ConvolverSound.h"
#endif
#include <cassert>
#include <cstring>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Sound.h"
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound)
{
assert(sound);
return convSpecToC((*sound)->createReader()->getSpecs());
}
AUD_API int AUD_Sound_getLength(AUD_Sound* sound)
{
assert(sound);
return (*sound)->createReader()->getLength();
}
AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs)
{
assert(sound);
assert(length);
assert(specs);
auto stream_buffer = std::dynamic_pointer_cast<StreamBuffer>(*sound);
if(!stream_buffer)
stream_buffer = std::make_shared<StreamBuffer>(*sound);
*specs = convSpecToC(stream_buffer->getSpecs());
auto buffer = stream_buffer->getBuffer();
*length = buffer->getSize() / AUD_SAMPLE_SIZE((*specs));
sample_t* data = new sample_t[buffer->getSize()];
std::memcpy(data, buffer->getBuffer(), buffer->getSize());
return data;
}
AUD_API void AUD_Sound_freeData(sample_t* data)
{
delete[] data;
}
AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize)
{
assert(sound);
assert(filename);
try
{
std::shared_ptr<IReader> reader = (*sound)->createReader();
DeviceSpecs specs;
specs.specs = reader->getSpecs();
if((rate != RATE_INVALID) && (specs.rate != rate))
{
specs.rate = rate;
reader = std::make_shared<JOSResampleReader>(reader, rate);
}
if((channels != AUD_CHANNELS_INVALID) && (specs.channels != static_cast<Channels>(channels)))
{
specs.channels = static_cast<Channels>(channels);
reader = std::make_shared<ChannelMapperReader>(reader, specs.channels);
}
if(format == AUD_FORMAT_INVALID)
format = AUD_FORMAT_S16;
specs.format = static_cast<SampleFormat>(format);
const char* invalid_container_error = "Container could not be determined from filename.";
if(container == AUD_CONTAINER_INVALID)
{
std::string path = filename;
if(path.length() < 4)
return invalid_container_error;
std::string extension = path.substr(path.length() - 4);
if(extension == ".ac3")
container = AUD_CONTAINER_AC3;
else if(extension == "flac")
container = AUD_CONTAINER_FLAC;
else if(extension == ".mkv")
container = AUD_CONTAINER_MATROSKA;
else if(extension == ".mp2")
container = AUD_CONTAINER_MP2;
else if(extension == ".mp3")
container = AUD_CONTAINER_MP3;
else if(extension == ".ogg")
container = AUD_CONTAINER_OGG;
else if(extension == ".wav")
container = AUD_CONTAINER_WAV;
else
return invalid_container_error;
}
if(codec == AUD_CODEC_INVALID)
{
switch(container)
{
case AUD_CONTAINER_AC3:
codec = AUD_CODEC_AC3;
break;
case AUD_CONTAINER_FLAC:
codec = AUD_CODEC_FLAC;
break;
case AUD_CONTAINER_MATROSKA:
codec = AUD_CODEC_OPUS;
break;
case AUD_CONTAINER_MP2:
codec = AUD_CODEC_MP2;
break;
case AUD_CONTAINER_MP3:
codec = AUD_CODEC_MP3;
break;
case AUD_CONTAINER_OGG:
codec = AUD_CODEC_VORBIS;
break;
case AUD_CONTAINER_WAV:
codec = AUD_CODEC_PCM;
break;
default:
return "Unknown container, cannot select default codec.";
}
}
if(buffersize <= 0)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, specs, static_cast<Container>(container), static_cast<Codec>(codec), bitrate);
FileWriter::writeReader(reader, writer, 0, buffersize);
}
catch(Exception& e)
{
return "An exception occured while writing.";
}
return nullptr;
}
AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs)
{
assert(data);
if(length <= 0 || specs.rate <= 0 || specs.channels <= 0)
{
return nullptr;
}
int size = length * AUD_SAMPLE_SIZE(specs);
std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(size);
std::memcpy(buffer->getBuffer(), data, size);
try
{
return new AUD_Sound(new StreamBuffer(buffer, convCToSpec(specs)));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size)
{
assert(buffer);
return new AUD_Sound(new File(buffer, size));
}
AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new StreamBuffer(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_file(const char* filename)
{
assert(filename);
return new AUD_Sound(new File(filename));
}
AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Sawtooth(frequency, rate));
}
AUD_API AUD_Sound*AUD_Sound_silence()
{
return new AUD_Sound(new Silence());
}
AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Sine(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Square(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Triangle(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive)
{
assert(sound);
try
{
return new AUD_Sound(new Accumulator(*sound, additive));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release)
{
assert(sound);
try
{
return new AUD_Sound(new ADSR(*sound, attack, decay, sustain, release));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay)
{
assert(sound);
try
{
return new AUD_Sound(new Delay(*sound, delay));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold)
{
assert(sound);
try
{
return new AUD_Sound(new Envelope(*sound, attack, release, threshold, arthreshold));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length)
{
assert(sound);
try
{
return new AUD_Sound(new Fader(*sound, FADE_IN, start, length));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length)
{
assert(sound);
try
{
return new AUD_Sound(new Fader(*sound, FADE_OUT, start, length));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length)
{
assert(sound);
try
{
std::vector<float> a_coeff, b_coeff;
if(b)
for(int i = 0; i < b_length; i++)
b_coeff.push_back(b[i]);
if(a)
{
for(int i = 0; i < a_length; i++)
a_coeff.push_back(a[i]);
if(*a == 0.0f)
a_coeff[0] = 1.0f;
}
return new AUD_Sound(new IIRFilter(*sound, b_coeff, a_coeff));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q)
{
assert(sound);
try
{
return new AUD_Sound(new Highpass(*sound, frequency, Q));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end)
{
assert(sound);
try
{
return new AUD_Sound(new Limiter(*sound, start, end));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count)
{
assert(sound);
try
{
return new AUD_Sound(new Loop(*sound, count));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q)
{
assert(sound);
try
{
return new AUD_Sound(new Lowpass(*sound, frequency, Q));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor)
{
assert(sound);
try
{
return new AUD_Sound(new Pitch(*sound, factor));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels)
{
assert(sound);
try
{
DeviceSpecs specs;
specs.channels = static_cast<Channels>(channels);
specs.rate = RATE_INVALID;
specs.format = FORMAT_INVALID;
return new AUD_Sound(new ChannelMapper(*sound, specs));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality)
{
assert(sound);
try
{
DeviceSpecs specs;
specs.channels = CHANNELS_INVALID;
specs.rate = rate;
specs.format = FORMAT_INVALID;
if(high_quality)
return new AUD_Sound(new JOSResample(*sound, specs));
else
return new AUD_Sound(new LinearResample(*sound, specs));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new Reverse(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new Sum(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold)
{
assert(sound);
try
{
return new AUD_Sound(new Threshold(*sound, threshold));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume)
{
assert(sound);
try
{
return new AUD_Sound(new Volume(*sound, volume));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second)
{
assert(first);
assert(second);
try
{
return new AUD_Sound(new Double(*first, *second));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second)
{
assert(first);
assert(second);
try
{
return new AUD_Sound(new Superpose(*first, *second));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new PingPong(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_Sound_free(AUD_Sound* sound)
{
assert(sound);
delete sound;
}
AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound)
{
return new std::shared_ptr<ISound>(*sound);
}
AUD_API AUD_Sound* AUD_Sound_list(int random)
{
try
{
return new AUD_Sound(new SoundList(random));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound)
{
assert(sound);
assert(list);
std::shared_ptr<SoundList> s = std::dynamic_pointer_cast<SoundList>(*list);
if(s.get())
{
s->addSound(*sound);
return 1;
}
else
return 0;
}
AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new MutableSound(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
#ifdef WITH_CONVOLUTION
AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool)
{
assert(sound);
assert(filter);
assert(threadPool);
try
{
return new AUD_Sound(new ConvolverSound(*sound, *filter, *threadPool));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool)
{
assert(sound);
assert(hrtfs);
assert(source);
assert(threadPool);
try
{
return new AUD_Sound(new BinauralSound(*sound, *hrtfs, *source, *threadPool));
}
catch(Exception&)
{
return nullptr;
}
}
#endif

View File

@@ -1,370 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Retrieves the sample specification of the sound.
* \param sound The sound to retrieve from.
* \return The sample specification of the sound.
* \note This function creates a reader from the sound and deletes it again.
*/
extern AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound);
/**
* Retrieves the approximate length of the sound.
* \param sound The sound to retrieve from.
* \return The length of the sound in samples.
* \note This function creates a reader from the sound and deletes it again.
*/
extern AUD_API int AUD_getLength(AUD_Sound* sound);
/**
* Reads a sound's samples into memory.
* \param sound The sound to read.
* \param length Pointer to store the length of memory read.
* \param specs Pointer to store the data's sample specification.
* \return A pointer to the sample data.
* \warning The data has to be freed with AUD_Sound_freeData.
*/
extern AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs);
/**
* Frees a buffer previously allocated with AUD_Sound_data.
* \param data The buffer to be freed.
*/
extern AUD_API void AUD_Sound_freeData(sample_t* data);
/**
* Writes the sound to a file.
* \param sound The sound to write.
* \param filename The path to write to..
* \param rate The sample rate to write with.
* \param channels The number of channels to write with.
* \param format The sample format to write with.
* \param container The container format for the file.
* \param codec The codec to use in the file.
* \param bitrate The bitrate to write with.
* \param buffersize The size of the writing buffer.
* \return A nullptr or an error message in case of error.
* \note Most parameters can be set to zero for default values.
*/
extern AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize);
/**
* Creates a sound from a data buffer.
* \param data The data as interleaved samples.
* \param length The data's length in samples.
* \param specs The data's sample specification.
* \return A handle of the sound.
* \note The data gets copied to an internal memory buffer.
* The pointer does not need to stay valid for the lifetime of the object.
*/
extern AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs);
/**
* Loads a sound file from a memory buffer.
* \param buffer The buffer which contains the sound file.
* \param size The size of the buffer.
* \return A handle of the sound file.
*/
extern AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size);
/**
* Caches a sound into a memory buffer.
* \param sound The sound to cache.
* \return A handle of the cached sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound);
/**
* Loads a sound file.
* \param filename The filename of the sound file.
* \return A handle of the sound file.
*/
extern AUD_API AUD_Sound* AUD_Sound_file(const char* filename);
/**
* Creates a sawtooth sound.
* \param frequency The frequency of the generated sawtooth sound.
* \param rate The sample rate of the sawtooth sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate);
/**
* Creates a quiet sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_silence();
/**
* Creates a sine sound.
* \param frequency The frequency of the generated sine sound.
* \param rate The sample rate of the sine sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate);
/**
* Creates a square sound.
* \param frequency The frequency of the generated square sound.
* \param rate The sample rate of the square sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate);
/**
* Creates a triangle sound.
* \param frequency The frequency of the generated triangle sound.
* \param rate The sample rate of the triangle sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate);
/**
* Accumulates a sound by summing over positive input differences thus generating a monotonic sigal.
* If additivity is set to true negative input differences get added too, but positive ones with a factor of two.
* Note that with additivity the signal is not monotonic anymore.
* \param sound The sound to accumulate.
* \param additive Whether the accumulation should be additive or not.
* \return A handle of the accumulated sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive);
/**
* Attack-Decay-Sustain-Release envelopes the volume of a sound.
* Note: there is currently no way to trigger the release with this API.
* \param sound The sound to filter.
* \param attack The attack time in seconds.
* \param decay The decay time in seconds.
* \param sustain The sustain level.
* \param release The release time in seconds.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release);
/**
* Delays a sound.
* \param sound The sound to dealy.
* \param delay The delay in seconds.
* \return A handle of the delayed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay);
/**
* Envelopes a sound.
* \param sound The sound to envelope.
* \param attack The attack factor.
* \param release The release factor.
* \param threshold The general threshold value.
* \param arthreshold The attack/release threshold value.
* \return A handle of the enveloped sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold);
/**
* Fade in a sound.
* \param sound The sound to be fade in.
* \param start The time when the fading should start in seconds.
* \param length The duration of the fade in seconds.
* \return A handle of the faded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length);
/**
* Fade out a sound.
* \param sound The sound to be fade out.
* \param start The time when the fading should start in seconds.
* \param length The duration of the fade in seconds.
* \return A handle of the faded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length);
/**
* Filter a sound.
* \param sound The sound to be filtered.
* \param b The nominator filter coefficients, may be NULL.
* \param b_length The length of the b array.
* \param a The denominator filter coefficients, may be NULL.
* \param a_length The length of the a array.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length);
/**
* Highpass filters a sound.
* \param sound The sound to filter.
* \param frequency The filter cut-off frequency.
* \param Q The filter quality. If usunsure which value to use, pass 1.0f.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q);
/**
* Limits a sound.
* \param sound The sound to limit.
* \param start The start time in seconds.
* \param end The stop time in seconds.
* \return A handle of the limited sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end);
/**
* Loops a sound.
* \param sound The sound to loop.
* \param count How often the sound should be looped. Negative values mean endlessly.
* \return A handle of the looped sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count);
/**
* Lowpass filters a sound.
* \param sound The sound to filter.
* \param frequency The filter cut-off frequency.
* \param Q The filter quality. If usunsure which value to use, pass 1.0f.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q);
/**
* Changes the pitch of a sound.
* \param sound The sound to change.
* \param factor The factor to change the pitch with.
* \return A handle of the pitched sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor);
/**
* Rechannels the sound.
* \param sound The sound to rechannel.
* \param channels The new channel configuration.
* \return The rechanneled sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels);
/**
* Resamples the sound.
* \param sound The sound to resample.
* \param rate The new sample rate.
* \param high_quality When true use a higher quality but slower resampler.
* \return The resampled sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality);
/**
* Reverses a sound. Make sure the sound source can be reversed.
* \param sound The sound to reverse.
* \return A handle of the reversed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound);
/**
* Sums the samples of a sound.
* \param sound The sound to sum.
* \return A handle of the summed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound);
/**
* Turns a sound into a square wave by thresholding.
* \param sound The sound to threshold.
* \param threshold Threshold value over which an amplitude counts non-zero.
* \return A handle of the thresholded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold);
/**
* Changes the volume of a sound.
* \param sound The sound to change.
* \param volume The new volume of the sound. Should be in the range 0 to 1. Use higher values with caution.
* \return A handle of the amplified sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume);
/**
* Joins two sound, which means playing them one after the other.
* \param first The first sound.
* \param second The second sound.
* \return A handle of the joined sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second);
/**
* Mixes two sound, which means superposing the sound samples.
* \param first The first sound.
* \param second The second sound.
* \return A handle of the mixed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second);
/**
* Ping pongs a sound.
* \param sound The sound to ping pong.
* \return A handle of the ping pong sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound);
/**
* Unloads a sound of any type.
* \param sound The handle of the sound.
*/
extern AUD_API void AUD_Sound_free(AUD_Sound* sound);
/**
* Copies a sound.
* \param sound Sound to copy.
* \return Copied sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound);
/**
* Creates an empty sound list that can contain several sounds.
* \param random A flag that indicates how the list will be played: Randomly or sequentially.
* if 0 the playback will be sequential, if not 0 the playback will be random.
* \return A handle of the sound list.
*/
extern AUD_API AUD_Sound* AUD_Sound_list(int random);
/**
* Adds a new sound to a sound list.
* \param list The sound list in which the sound will be added.
* \param sound The sound that will be added to the list.
* \return 0 if the sound couldn't be added (the list parameter isn't a sound list).
*/
extern AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound);
/**
* Creates a sound that will be restarted when sought backwards. If the original sound is a sound list, the playing sound can change.
* \param sound The handle of the sound.
* \return A handle of the mutable sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound);
#ifdef WITH_CONVOLUTION
extern AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool);
extern AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -1,84 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Source.h"
extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance)
{
try
{
return new AUD_Source(new Source(azimuth, elevation, distance));
}
catch(Exception&)
{
return nullptr;
}
}
extern AUD_API void AUD_Source_free(AUD_Source* source)
{
assert(source);
delete source;
}
extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source)
{
assert(source);
return (*source)->getAzimuth();
}
extern AUD_API float AUD_Source_getElevation(AUD_Source* source)
{
assert(source);
return (*source)->getElevation();
}
extern AUD_API float AUD_Source_getDistance(AUD_Source* source)
{
assert(source);
return (*source)->getDistance();
}
extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth)
{
assert(source);
(*source)->setAzimuth(azimuth);
}
extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation)
{
assert(source);
(*source)->setElevation(elevation);
}
extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance)
{
assert(source);
(*source)->setDistance(distance);
}

View File

@@ -1,84 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new Source object.
* \param azimuth The azimuth angle.
* \param elevation The elevation angle.
* \param elevation The distance value. [0,1]
* \return The new Source object.
*/
extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance);
/**
* Deletes a Source object.
* \param source The Source object to be deleted.
*/
extern AUD_API void AUD_Source_free(AUD_Source* source);
/**
* Retrieves the azimuth angle of a Source object.
* \param source The Source object.
* \return The azimuth angle.
*/
extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source);
/**
* Retrieves the elevation angle oa a Source object.
* \param source The Source object.
* \return The elevation angle.
*/
extern AUD_API float AUD_Source_getElevation(AUD_Source* source);
/**
* Retrieves the distance of a Source object. [0,1]
* \param source The Source object.
* \return The distance.
*/
extern AUD_API float AUD_Source_getDistance(AUD_Source* distance);
/**
* Changes the azimuth angle of a Source object.
* \param source The Source object.
* \param azimuth The azimuth angle.
*/
extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth);
/**
* Changes the elevation angle of a Source object.
* \param source The Source object.
* \param elevation The elevation angle.
*/
extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation);
/**
* Changes the distance of a Source object. [0,1]
* \param source The Source object.
* \param distance The distance.
*/
extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance);
#ifdef __cplusplus
}
#endif

View File

@@ -1,420 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include "IReader.h"
#include "file/File.h"
#include "respec/ChannelMapper.h"
#include "fx/Lowpass.h"
#include "fx/Highpass.h"
#include "fx/Envelope.h"
#include "respec/LinearResample.h"
#include "fx/Threshold.h"
#include "fx/Accumulator.h"
#include "fx/Sum.h"
#include "generator/Silence.h"
#include "fx/Limiter.h"
#include "devices/DeviceManager.h"
#include "sequence/Sequence.h"
#include "file/FileWriter.h"
#include "devices/ReadDevice.h"
#include "plugin/PluginManager.h"
#include "devices/DeviceManager.h"
#include "devices/IDeviceFactory.h"
#include "devices/NULLDevice.h"
#include <cassert>
#include <cstring>
#include <cmath>
#include <sstream>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Special.h"
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
static inline AUD_DeviceSpecs convDSpecToC(aud::DeviceSpecs specs)
{
AUD_DeviceSpecs s;
s.specs = convSpecToC(specs.specs);
s.format = static_cast<AUD_SampleFormat>(specs.format);
return s;
}
static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
{
aud::DeviceSpecs s;
s.specs = convCToSpec(specs.specs);
s.format = static_cast<SampleFormat>(specs.format);
return s;
}
AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
assert(sound);
AUD_SoundInfo info;
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
try
{
std::shared_ptr<IReader> reader = (*sound)->createReader();
if(reader.get())
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) info.specs.rate;
}
}
catch(Exception&)
{
}
return info;
}
AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate, int* length)
{
Buffer buffer;
DeviceSpecs specs;
specs.channels = CHANNELS_MONO;
specs.rate = (SampleRate)samplerate;
std::shared_ptr<ISound> sound;
std::shared_ptr<ISound> file = std::shared_ptr<ISound>(new File(filename));
int position = 0;
try
{
std::shared_ptr<IReader> reader = file->createReader();
SampleRate rate = reader->getSpecs().rate;
sound = std::shared_ptr<ISound>(new ChannelMapper(file, specs));
if(high < rate)
sound = std::shared_ptr<ISound>(new Lowpass(sound, high));
if(low > 0)
sound = std::shared_ptr<ISound>(new Highpass(sound, low));
sound = std::shared_ptr<ISound>(new Envelope(sound, attack, release, threshold, 0.1f));
sound = std::shared_ptr<ISound>(new LinearResample(sound, specs));
if(square)
sound = std::shared_ptr<ISound>(new Threshold(sound, sthreshold));
if(accumulate)
sound = std::shared_ptr<ISound>(new Accumulator(sound, additive));
else if(additive)
sound = std::shared_ptr<ISound>(new Sum(sound));
reader = sound->createReader();
if(!reader.get())
return nullptr;
int len;
bool eos;
do
{
len = samplerate;
buffer.resize((position + len) * sizeof(float), true);
reader->read(len, eos, buffer.getBuffer() + position);
position += len;
} while(!eos);
}
catch(Exception&)
{
return nullptr;
}
float * result = (float *)malloc(position * sizeof(float));
std::memcpy(result, buffer.getBuffer(), position * sizeof(float));
*length = position;
return result;
}
static void pauseSound(AUD_Handle* handle)
{
assert(handle);
(*handle)->pause();
}
AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
{
std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence);
std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds));
auto device = DeviceManager::getDevice();
std::lock_guard<ILockable> lock(*device);
try
{
AUD_Handle handle2 = device->play(limiter);
if(handle2.get())
{
handle2->setStopCallback((stopCallback)pauseSound, handle);
return new AUD_Handle(handle2);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt)
{
DeviceSpecs specs;
float* buf;
Buffer aBuffer;
specs.rate = RATE_INVALID;
specs.channels = CHANNELS_MONO;
specs.format = FORMAT_INVALID;
std::shared_ptr<IReader> reader = ChannelMapper(*sound, specs).createReader();
specs.specs = reader->getSpecs();
int len;
float samplejump = specs.rate / samples_per_second;
float min, max, power, overallmax;
bool eos;
overallmax = 0;
for(int i = 0; i < length; i++)
{
len = floor(samplejump * (i+1)) - floor(samplejump * i);
if(*interrupt)
return 0;
aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
buf = aBuffer.getBuffer();
reader->read(len, eos, buf);
max = min = *buf;
power = *buf * *buf;
for(int j = 1; j < len; j++)
{
if(buf[j] < min)
min = buf[j];
if(buf[j] > max)
max = buf[j];
power += buf[j] * buf[j];
}
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
buffer[i * 3 + 2] = sqrt(power) / len;
if(overallmax < max)
overallmax = max;
if(overallmax < -min)
overallmax = -min;
if(eos)
{
length = i;
break;
}
}
if(overallmax > 1.0f)
{
for(int i = 0; i < length * 3; i++)
{
buffer[i] /= overallmax;
}
}
return length;
}
AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
try
{
Sequence* f = dynamic_cast<Sequence *>(sound->get());
f->setSpecs(convCToSpec(specs.specs));
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate);
FileWriter::writeReader(reader, writer, length, buffersize);
return nullptr;
}
catch(Exception& e)
{
return e.getMessage().c_str();
}
}
AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
try
{
Sequence* f = dynamic_cast<Sequence *>(sound->get());
f->setSpecs(convCToSpec(specs.specs));
std::vector<std::shared_ptr<IWriter> > writers;
int channels = specs.channels;
specs.channels = AUD_CHANNELS_MONO;
for(int i = 0; i < channels; i++)
{
std::stringstream stream;
std::string fn = filename;
size_t index = fn.find_last_of('.');
size_t index_slash = fn.find_last_of('/');
size_t index_backslash = fn.find_last_of('\\');
if((index == std::string::npos) ||
((index < index_slash) && (index_slash != std::string::npos)) ||
((index < index_backslash) && (index_backslash != std::string::npos)))
{
stream << filename << "_" << (i + 1);
}
else
{
stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
}
writers.push_back(FileWriter::createWriter(stream.str(), convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate));
}
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
FileWriter::writeReader(reader, writers, length, buffersize);
return nullptr;
}
catch(Exception& e)
{
return e.getMessage().c_str();
}
}
AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
{
try
{
ReadDevice* device = new ReadDevice(convCToDSpec(specs));
device->setQuality(true);
device->setVolume(volume);
Sequence* f = dynamic_cast<Sequence*>(sequencer->get());
f->setSpecs(convCToSpec(specs.specs));
AUD_Handle handle = device->play(f->createQualityReader());
if(handle.get())
{
handle->seek(start);
}
return new AUD_Device(device);
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_initOnce()
{
PluginManager::loadPlugins();
NULLDevice::registerPlugin();
}
AUD_API void AUD_exitOnce()
{
}
AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name)
{
try
{
std::shared_ptr<IDeviceFactory> factory = DeviceManager::getDeviceFactory(device);
if(factory)
{
factory->setName(name);
factory->setBufferSize(buffersize);
factory->setSpecs(convCToDSpec(specs));
auto device = factory->openDevice();
DeviceManager::setDevice(device);
return new AUD_Device(device);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_exit(AUD_Device* device)
{
delete device;
DeviceManager::releaseDevice();
}
AUD_API char** AUD_getDeviceNames()
{
std::vector<std::string> v_names = DeviceManager::getAvailableDeviceNames();
char** names = (char**) malloc(sizeof(char*) * (v_names.size() + 1));
for(int i = 0; i < v_names.size(); i++)
{
std::string name = v_names[i];
names[i] = (char*) malloc(sizeof(char) * (name.length() + 1));
strcpy(names[i], name.c_str());
}
names[v_names.size()] = nullptr;
return names;
}

View File

@@ -1,138 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Returns information about a sound.
* \param sound The sound to get the info about.
* \return The AUD_SoundInfo structure with filled in data.
*/
extern AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound);
/**
* Reads a sound file into a newly created float buffer.
* The sound is therefore bandpassed, rectified and resampled.
*/
extern AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate,
int* length);
/**
* Pauses a playing sound after a specific amount of time.
* \param handle The handle to the sound.
* \param seconds The time in seconds.
* \return The silence handle.
*/
extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
/**
* Reads a sound into a buffer for drawing at a specific sampling rate.
* \param sound The sound to read.
* \param buffer The buffer to write to. Must have a size of 3*4*length.
* \param length How many samples to read from the sound.
* \param samples_per_second How many samples to read per second of the sound.
* \return How many samples really have been read. Always <= length.
*/
extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);
/**
* Mixes a sound down into a file.
* \param sound The sound scene to mix down.
* \param start The start frame.
* \param length The count of frames to write.
* \param buffersize How many samples should be written at once.
* \param filename The file to write to.
* \param specs The file's audio specification.
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate);
/**
* Mixes a sound down into multiple files.
* \param sound The sound scene to mix down.
* \param start The start frame.
* \param length The count of frames to write.
* \param buffersize How many samples should be written at once.
* \param filename The file to write to, the channel number and an underscore are added at the beginning.
* \param specs The file's audio specification.
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate);
/**
* Opens a read device and prepares it for mixdown of the sound scene.
* \param specs Output audio specifications.
* \param sequencer The sound scene to mix down.
* \param volume The overall mixdown volume.
* \param start The start time of the mixdown in the sound scene.
* \return The read device for the mixdown.
*/
extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
/**
* Initializes audio routines (FFMPEG/JACK if it is enabled).
*/
extern AUD_API void AUD_initOnce();
/**
* Unitinitializes an audio routines.
*/
extern AUD_API void AUD_exitOnce();
/**
* Initializes an audio device.
* \param device The device type that should be used.
* \param specs The audio specification to be used.
* \param buffersize The buffersize for the device.
* \return Whether the device has been initialized.
*/
extern AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
/**
* Unitinitializes an audio device.
* \param device The device to free.
*/
extern AUD_API void AUD_exit(AUD_Device* device);
/**
* Retrieves available devices. Note that all memory returned has to be freed!
*/
extern AUD_API char** AUD_getDeviceNames();
#ifdef __cplusplus
}
#endif

View File

@@ -1,42 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_ThreadPool.h"
AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads)
{
try
{
return new AUD_ThreadPool(new ThreadPool(nThreads));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* pool)
{
assert(pool);
delete pool;
}

View File

@@ -1,40 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new ThreadPool object.
* \param nThreads The number of threads of the pool.
* \return The new ThreadPool object.
*/
extern AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads);
/**
* Deletes a ThreadPool object.
* \param threadPool The ThreadPool object to be deleted.
*/
extern AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* threadPool);
#ifdef __cplusplus
}
#endif

View File

@@ -1,179 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include "Audaspace.h"
#ifdef __cplusplus
using namespace aud;
#endif
#ifdef AUD_CAPI_IMPLEMENTATION
#include "ISound.h"
#include "devices/IHandle.h"
#include "devices/IDevice.h"
#include "sequence/SequenceEntry.h"
#include "fx/PlaybackManager.h"
#include "fx/DynamicMusic.h"
#include "fx/Source.h"
#include "util/ThreadPool.h"
#ifdef WITH_CONVOLUTION
#include "fx/ImpulseResponse.h"
#include "fx/HRTF.h"
#endif
typedef std::shared_ptr<aud::ISound> AUD_Sound;
typedef std::shared_ptr<aud::IHandle> AUD_Handle;
typedef std::shared_ptr<aud::IDevice> AUD_Device;
typedef std::shared_ptr<aud::SequenceEntry> AUD_SequenceEntry;
typedef std::shared_ptr<aud::PlaybackManager> AUD_PlaybackManager;
typedef std::shared_ptr<aud::DynamicMusic> AUD_DynamicMusic;
typedef std::shared_ptr<aud::ThreadPool> AUD_ThreadPool;
typedef std::shared_ptr<aud::Source> AUD_Source;
#ifdef WITH_CONVOLUTION
typedef std::shared_ptr<aud::ImpulseResponse> AUD_ImpulseResponse;
typedef std::shared_ptr<aud::HRTF> AUD_HRTF;
#endif
#else
typedef void AUD_Sound;
typedef void AUD_Handle;
typedef void AUD_Device;
typedef void AUD_SequenceEntry;
typedef void AUD_PlaybackManager;
typedef void AUD_DynamicMusic;
typedef void AUD_ThreadPool;
typedef void AUD_Source;
#ifdef WITH_CONVOLUTION
typedef void AUD_ImpulseResponse;
typedef void AUD_HRTF;
#endif
#endif
/// Container formats for writers.
typedef enum
{
AUD_CONTAINER_INVALID = 0,
AUD_CONTAINER_AC3,
AUD_CONTAINER_FLAC,
AUD_CONTAINER_MATROSKA,
AUD_CONTAINER_MP2,
AUD_CONTAINER_MP3,
AUD_CONTAINER_OGG,
AUD_CONTAINER_WAV
} AUD_Container;
/// Audio codecs for writers.
typedef enum
{
AUD_CODEC_INVALID = 0,
AUD_CODEC_AAC,
AUD_CODEC_AC3,
AUD_CODEC_FLAC,
AUD_CODEC_MP2,
AUD_CODEC_MP3,
AUD_CODEC_PCM,
AUD_CODEC_VORBIS,
AUD_CODEC_OPUS
} AUD_Codec;
/**
* The format of a sample.
* The last 4 bit save the byte count of the format.
*/
typedef enum
{
AUD_FORMAT_INVALID = 0x00, /// Invalid sample format.
AUD_FORMAT_U8 = 0x01, /// 1 byte unsigned byte.
AUD_FORMAT_S16 = 0x12, /// 2 byte signed integer.
AUD_FORMAT_S24 = 0x13, /// 3 byte signed integer.
AUD_FORMAT_S32 = 0x14, /// 4 byte signed integer.
AUD_FORMAT_FLOAT32 = 0x24, /// 4 byte float.
AUD_FORMAT_FLOAT64 = 0x28 /// 8 byte float.
} AUD_SampleFormat;
/// The channel count.
typedef enum
{
AUD_CHANNELS_INVALID = 0, /// Invalid channel count.
AUD_CHANNELS_MONO = 1, /// Mono.
AUD_CHANNELS_STEREO = 2, /// Stereo.
AUD_CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel.
AUD_CHANNELS_SURROUND4 = 4, /// 4 channel surround sound.
AUD_CHANNELS_SURROUND5 = 5, /// 5 channel surround sound.
AUD_CHANNELS_SURROUND51 = 6, /// 5.1 surround sound.
AUD_CHANNELS_SURROUND61 = 7, /// 6.1 surround sound.
AUD_CHANNELS_SURROUND71 = 8 /// 7.1 surround sound.
} AUD_Channels;
/**
* The sample rate tells how many samples are played back within one second.
* Some exotic formats may use other sample rates than provided here.
*/
typedef enum
{
AUD_RATE_INVALID = 0, /// Invalid sample rate.
AUD_RATE_8000 = 8000, /// 8000 Hz.
AUD_RATE_16000 = 16000, /// 16000 Hz.
AUD_RATE_11025 = 11025, /// 11025 Hz.
AUD_RATE_22050 = 22050, /// 22050 Hz.
AUD_RATE_32000 = 32000, /// 32000 Hz.
AUD_RATE_44100 = 44100, /// 44100 Hz.
AUD_RATE_48000 = 48000, /// 48000 Hz.
AUD_RATE_88200 = 88200, /// 88200 Hz.
AUD_RATE_96000 = 96000, /// 96000 Hz.
AUD_RATE_192000 = 192000 /// 192000 Hz.
} AUD_DefaultSampleRate;
/// Sample rate type.
typedef double AUD_SampleRate;
/// Specification of a sound source.
typedef struct
{
/// Sample rate in Hz.
AUD_SampleRate rate;
/// Channel count.
AUD_Channels channels;
} AUD_Specs;
/// Specification of a sound device.
typedef struct
{
/// Sample format.
AUD_SampleFormat format;
union
{
struct
{
/// Sample rate in Hz.
AUD_SampleRate rate;
/// Channel count.
AUD_Channels channels;
};
AUD_Specs specs;
};
} AUD_DeviceSpecs;
/// Sound information structure.
typedef struct
{
AUD_Specs specs;
float length;
} AUD_SoundInfo;

View File

@@ -1,261 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# audaspace documentation build configuration file, created by
# sphinx-quickstart on Tue Sep 9 01:48:48 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = []
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'audaspace'
copyright = '2009-2015, Jörg Müller'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '@AUDASPACE_VERSION@'
# The full version, including alpha/beta/rc tags.
release = '@AUDASPACE_LONG_VERSION@'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'audaspacedoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'audaspace.tex', 'audaspace Documentation',
'Jörg Müller', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'audaspace', 'audaspace Documentation',
['Jörg Müller'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'audaspace', 'audaspace Documentation',
'Jörg Müller', 'audaspace', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

View File

@@ -1,7 +0,0 @@
Device
======
.. currentmodule:: aud
.. autoclass:: Device
:members:

View File

@@ -1,7 +0,0 @@
Handle
======
.. currentmodule:: aud
.. autoclass:: Handle
:members:

View File

@@ -1,35 +0,0 @@
.. audaspace documentation master file, created by
sphinx-quickstart on Tue Sep 9 01:48:48 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to audaspace's documentation!
=====================================
.. automodule:: aud
This documentation is valid for both the Python and C bindings of audaspace. If you are looking for installation instructions check the `C++ API documentation <../index.html>`_. As C is not an object oriented language everything is accessible via functions where the first paramter is always the object. For methods these are named as ``AUD_ClassName_method()`` and properties are accessed via ``AUD_ClassName_property_get/set()``. Python users simply ``import aud`` to access the library.
.. toctree::
:maxdepth: 2
tutorials
Classes:
.. toctree::
:maxdepth: 2
device
sound
handle
sequence
sequence_entry
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@@ -1,7 +0,0 @@
Sequence
========
.. currentmodule:: aud
.. autoclass:: Sequence
:members:

View File

@@ -1,7 +0,0 @@
Sequence Entry
==============
.. currentmodule:: aud
.. autoclass:: SequenceEntry
:members:

View File

@@ -1,7 +0,0 @@
Sound
=====
.. currentmodule:: aud
.. autoclass:: Sound
:members:

View File

@@ -1,166 +0,0 @@
Tutorials
=========
Introduction
------------
The C and Python binding for audaspace were designed with simplicity in mind. This means however that to use the full capabilities of audaspace, there is no way around the C++ library.
Simple Demo
-----------
The **simple.py** example program contains all the basic building blocks for an application using audaspace. These building blocks are basically the classes :class:`aud.Device`, :class:`aud.Sound` and :class:`aud.Handle`.
We start with importing :mod:`aud` and :mod:`time` as the modules we need for our simple example.
.. code-block:: python
#!/usr/bin/python
import aud, time
The first step now is to open an output device and this can simply be done by allocating a :class:`aud.Device` object.
.. code-block:: python
device = aud.Device()
To create a sound we can choose to load one from a :func:`aud.Sound.file`, or we use one of our signal generators. We decide to do the latter and create a :func:`aud.Sound.sine` signal with a frequency of 440 Hz.
.. code-block:: python
sine = aud.Sound.sine(440)
.. note:: At this point nothing is playing back yet, :class:`aud.Sound` objects are just descriptions of sounds.
However instead of a sine wave, we would like to have a square wave to produce a more retro gaming sound. We could of course use the :func:`aud.Sound.square` generator instead of sine, but we want to show how to apply effects, so we apply a :func:`aud.Sound.threshold` which makes a square wave out of our sine too, even if less efficient than directly generating the square wave.
.. code-block:: python
square = sine.threshold()
.. note:: The :class:`aud.Sound` class offers generator and effect functions.
The we can play our sound by calling the :func:`aud.Device.play` method of our device. This method returns a :class:`aud.Handle` which is used to control the playback of the sound.
.. code-block:: python
handle = device.play(square)
Now if we do nothing else anymore the application will quit immediately, so we won't hear much of our square wave, so we decide to wait for three seconds before quitting the application by calling :func:`time.sleep`.
.. code-block:: python
time.sleep(3)
Audioplayer
-----------
Now that we know the basics of audaspace, we can build our own music player easily by just slightly changing the previous program. The **player.py** example does exactly that, let's have a short look at the differences:
Instead of creating a sine signal and thresholding it, we in fact use the :func:`aud.Sound.file` function to load a sound from a file. The filename we pass is the first command line argument our application got.
.. code-block:: python
sound = aud.Sound.file(sys.argv[1])
When the sound gets played back we now want to wait until the whole file has been played, so we use the :data:`aud.Handle.status` property to determine whether the sound finished playing.
.. code-block:: python
while handle.status:
time.sleep(0.1)
We don't make any error checks if the user actually added a command line argument. As an exercise you could extend this program to play any number of command line supplied files in sequence.
Siren
-----
Let's get a little bit more complex. The **siren.py** example plays a generated siren sound that circles around your head. Depending on how many speakers you have and if the output device used supports the speaker setup, you will hear this effect. With stereo speakers you should at least hear some left-right-panning.
We start off again with importing the modules we need and we also define some properties of our siren sound. We want it to consist of two sine sounds with different frequencies. We define a length for the sine sounds and how long a fade in/out should take. We also know already how to open a device.
.. code-block:: python
#!/usr/bin/python
import aud, math, time
length = 0.5
fadelength = 0.05
device = aud.Device()
The next thing to do is to define our sine waves and apply all the required effects. As each of the effect functions returns the corresponding sound, we can easily chain those calls together.
.. code-block:: python
high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
The next step is to connect the two sines, which we do using the :func:`aud.Sound.join` function.
.. code-block:: python
sound = high.join(low)
The generated siren sound can now be played back and what we also do is to loop it. Therefore we set the :data:`aud.Handle.loop_count` to a negative value to loop forever.
.. code-block:: python
handle = device.play(sound)
handle.loop_count = -1
Now we use some timing code to make sure our demo runs for 10 seconds, but we also use the time to update the location of our playing sound, with the :data:`aud.Handle.location` property, which is a three dimensional vector. The trigonometic calculation based on the running time of the program keeps the sound on the XZ plane letting it follow a circle around us.
.. code-block:: python
start = time.time()
while time.time() - start < 10:
angle = time.time() - start
handle.location = [math.sin(angle), 0, -math.cos(angle)]
As an exercise you could try to let the sound come from the far left and go to the far right and a little bit in front of you within the 10 second runtime of the program. With this change you should be able to hear the volume of the sound change, depending on how far it is away from you. Updating the :data:`aud.Handle.velocity` property properly also enables the doppler effect. Compare your solution to the **siren2.py** demo.
Tetris
------
The **tetris.py** demo application shows an even more complex application which generates retro tetris music. Looking at the source code there should be nothing new here, again the functions used from audaspace are the same as in the previous examples. In the :func:`parseNote` function all single notes get joined which leads to a very long chain of sounds. If you think of :func:`aud.Sound.join` as a function that creates a binary tree with the two joined sounds as leaves then the :func:`parseNote` function creates a very unbalanced tree.
Insted we could rewrite the code to use two other classes: :class:`aud.Sequence` and :class:`aud.SequenceEntry` to sequence the notes. The **tetris2.py** application does exactly that. Before the while loop we add a variable that stores the current position in the score and create a new :class:`aud.Sequence` object.
.. code-block:: python
position = 0
sequence = aud.Sequence()
Then in the loop we can create the note simply by chaining the :func:`aud.Sound.square` generator and :func:`aud.Sound.fadein` and :func:`aud.Sound.fadeout` effects.
.. code-block:: python
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
Now instead of using :func:`aud.Sound.limit` and :func:`aud.Sound.join` we simply add the sound to the sequence.
.. code-block:: python
entry = sequence.add(note, position, position + length, 0)
The entry returned from the :func:`aud.Sequence.add` function is an object of the :class:`aud.SequenceEntry` class. We can use this entry to mute the note in case it's actually a pause.
.. code-block:: python
if char == 'p':
entry.muted = True
Lastly we have to update our position variable.
.. code-block:: python
position += length
Now in **tetris2.py** we used the :data:`aud.SequenceEntry.muted` property to show how the :class:`aud.SequenceEntry` class can be used, but it would actually be smarter to not even create a note for pauses and just skip them. You can try to implement this as an exercise and then check out the solution in **tetris3.py**.
Conclusion
----------
We introduced all five currently available classes in the audaspace Python API. Of course all classes offer a lot more functions than have been used in these demo applications, check out the specific class documentation for more details.

View File

@@ -1,231 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "PyAPI.h"
#include "PySound.h"
#include "PyHandle.h"
#include "PyDevice.h"
#include "PySequenceEntry.h"
#include "PySequence.h"
#include "PyPlaybackManager.h"
#include "PyDynamicMusic.h"
#include "PyThreadPool.h"
#include "PySource.h"
#ifdef WITH_CONVOLUTION
#include "PyImpulseResponse.h"
#include "PyHRTF.h"
#endif
#include "respec/Specification.h"
#include "devices/IHandle.h"
#include "devices/I3DDevice.h"
#include "file/IWriter.h"
#include "plugin/PluginManager.h"
#include "sequence/AnimateableProperty.h"
#include "ISound.h"
#include <memory>
#include <structmember.h>
using namespace aud;
// ====================================================================
#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
// ====================================================================
extern PyObject* AUDError;
PyObject* AUDError = nullptr;
// ====================================================================
PyDoc_STRVAR(M_aud_doc,
"Audaspace (pronounced \"outer space\") is a high level audio library.");
static struct PyModuleDef audmodule = {
PyModuleDef_HEAD_INIT,
"aud", /* name of module */
M_aud_doc, /* module documentation */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
nullptr, nullptr, nullptr, nullptr, nullptr
};
PyMODINIT_FUNC
PyInit_aud()
{
PyObject* module;
PluginManager::loadPlugins();
if(!initializeSound())
return nullptr;
if(!initializeDevice())
return nullptr;
if(!initializeHandle())
return nullptr;
if(!initializeSequenceEntry())
return nullptr;
if(!initializeSequence())
return nullptr;
if(!initializeDynamicMusic())
return nullptr;
if(!initializePlaybackManager())
return nullptr;
if(!initializeThreadPool())
return nullptr;
if(!initializeSource())
return nullptr;
#ifdef WITH_CONVOLUTION
if(!initializeImpulseResponse())
return nullptr;
if(!initializeHRTF())
return nullptr;
#endif
module = PyModule_Create(&audmodule);
if(module == nullptr)
return nullptr;
addSoundToModule(module);
addHandleToModule(module);
addDeviceToModule(module);
addSequenceEntryToModule(module);
addSequenceToModule(module);
addDynamicMusicToModule(module);
addPlaybackManagerToModule(module);
addThreadPoolToModule(module);
addSourceToModule(module);
#ifdef WITH_CONVOLUTION
addImpulseResponseToModule(module);
addHRTFToModule(module);
#endif
AUDError = PyErr_NewException("aud.error", nullptr, nullptr);
Py_INCREF(AUDError);
PyModule_AddObject(module, "error", AUDError);
// animatable property type constants
PY_MODULE_ADD_CONSTANT(module, AP_VOLUME);
PY_MODULE_ADD_CONSTANT(module, AP_PANNING);
PY_MODULE_ADD_CONSTANT(module, AP_PITCH);
PY_MODULE_ADD_CONSTANT(module, AP_LOCATION);
PY_MODULE_ADD_CONSTANT(module, AP_ORIENTATION);
// channels constants
PY_MODULE_ADD_CONSTANT(module, CHANNELS_INVALID);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_MONO);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO_LFE);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND4);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND5);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND51);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND61);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND71);
// codec constants
PY_MODULE_ADD_CONSTANT(module, CODEC_INVALID);
PY_MODULE_ADD_CONSTANT(module, CODEC_AAC);
PY_MODULE_ADD_CONSTANT(module, CODEC_AC3);
PY_MODULE_ADD_CONSTANT(module, CODEC_FLAC);
PY_MODULE_ADD_CONSTANT(module, CODEC_MP2);
PY_MODULE_ADD_CONSTANT(module, CODEC_MP3);
PY_MODULE_ADD_CONSTANT(module, CODEC_PCM);
PY_MODULE_ADD_CONSTANT(module, CODEC_VORBIS);
PY_MODULE_ADD_CONSTANT(module, CODEC_OPUS);
// container constants
PY_MODULE_ADD_CONSTANT(module, CONTAINER_INVALID);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_AC3);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_FLAC);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MATROSKA);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP2);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP3);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_OGG);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_WAV);
// distance model constants
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVALID);
// format constants
PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT32);
PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT64);
PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S16);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S24);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S32);
PY_MODULE_ADD_CONSTANT(module, FORMAT_U8);
// rate constants
PY_MODULE_ADD_CONSTANT(module, RATE_INVALID);
PY_MODULE_ADD_CONSTANT(module, RATE_8000);
PY_MODULE_ADD_CONSTANT(module, RATE_16000);
PY_MODULE_ADD_CONSTANT(module, RATE_11025);
PY_MODULE_ADD_CONSTANT(module, RATE_22050);
PY_MODULE_ADD_CONSTANT(module, RATE_32000);
PY_MODULE_ADD_CONSTANT(module, RATE_44100);
PY_MODULE_ADD_CONSTANT(module, RATE_48000);
PY_MODULE_ADD_CONSTANT(module, RATE_88200);
PY_MODULE_ADD_CONSTANT(module, RATE_96000);
PY_MODULE_ADD_CONSTANT(module, RATE_192000);
// status constants
PY_MODULE_ADD_CONSTANT(module, STATUS_INVALID);
PY_MODULE_ADD_CONSTANT(module, STATUS_PAUSED);
PY_MODULE_ADD_CONSTANT(module, STATUS_PLAYING);
PY_MODULE_ADD_CONSTANT(module, STATUS_STOPPED);
return module;
}
AUD_API PyObject* AUD_getPythonSound(void* sound)
{
if(sound)
{
Sound* object = (Sound*) Sound_empty();
if(object)
{
object->sound = new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound));
return (PyObject *) object;
}
}
return nullptr;
}
AUD_API void* AUD_getSoundFromPython(PyObject* object)
{
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
return new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
}

View File

@@ -1,45 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
#ifdef __cplusplus
extern "C" {
#endif
PyMODINIT_FUNC
PyInit_aud();
/**
* Retrieves the python factory of a sound.
* \param sound The sound factory.
* \return The python factory.
*/
extern AUD_API PyObject* AUD_getPythonSound(void* sound);
/**
* Retrieves the sound factory of a python factory.
* \param sound The python factory.
* \return The sound factory.
*/
extern AUD_API void* AUD_getSoundFromPython(PyObject* object);
#ifdef __cplusplus
}
#endif

View File

@@ -1,785 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "PyDevice.h"
#include "PySound.h"
#include "PyHandle.h"
#include "Exception.h"
#include "devices/IDevice.h"
#include "devices/I3DDevice.h"
#include "devices/DeviceManager.h"
#include "devices/IDeviceFactory.h"
#include <structmember.h>
using namespace aud;
extern PyObject* AUDError;
static const char* device_not_3d_error = "Device is not a 3D device!";
// ====================================================================
static void
Device_dealloc(Device* self)
{
if(self->device)
delete reinterpret_cast<std::shared_ptr<IDevice>*>(self->device);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyObject *
Device_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
Device* self;
static const char* kwlist[] = {"type", "rate", "channels", "format", "buffer_size", "name", nullptr};
const char* device = nullptr;
double rate = RATE_48000;
int channels = CHANNELS_STEREO;
int format = FORMAT_FLOAT32;
int buffersize = AUD_DEFAULT_BUFFER_SIZE;
const char* name = "";
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|sdiiis:Device", const_cast<char**>(kwlist),
&device, &rate, &channels, &format, &buffersize, &name))
return nullptr;
if(buffersize < 128)
{
PyErr_SetString(PyExc_ValueError, "buffer_size must be at least 128!");
return nullptr;
}
self = (Device*)type->tp_alloc(type, 0);
if(self != nullptr)
{
DeviceSpecs specs;
specs.channels = (Channels)channels;
specs.format = (SampleFormat)format;
specs.rate = (SampleRate)rate;
self->device = nullptr;
try
{
if(!device)
{
auto dev = DeviceManager::getDevice();
if(!dev)
{
DeviceManager::openDefaultDevice();
dev = DeviceManager::getDevice();
}
self->device = new std::shared_ptr<IDevice>(dev);
}
else
{
std::shared_ptr<IDeviceFactory> factory;
if(!*device)
factory = DeviceManager::getDefaultDeviceFactory();
else
factory = DeviceManager::getDeviceFactory(device);
if(factory)
{
factory->setName(name);
factory->setSpecs(specs);
factory->setBufferSize(buffersize);
self->device = new std::shared_ptr<IDevice>(factory->openDevice());
}
}
}
catch(Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
if(!self->device)
{
Py_DECREF(self);
PyErr_SetString(AUDError, "Unsupported device type!");
return nullptr;
}
}
return (PyObject *)self;
}
PyDoc_STRVAR(M_aud_Device_lock_doc,
"lock()\n\n"
"Locks the device so that it's guaranteed, that no samples are "
"read from the streams until :meth:`unlock` is called.\n"
"This is useful if you want to do start/stop/pause/resume some "
"sounds at the same time.\n\n"
".. note:: The device has to be unlocked as often as locked to be "
"able to continue playback.\n\n"
".. warning:: Make sure the time between locking and unlocking is "
"as short as possible to avoid clicks.");
static PyObject *
Device_lock(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->lock();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_play_doc,
"play(sound, keep=False)\n\n"
"Plays a sound.\n\n"
":arg sound: The sound to play.\n"
":type sound: :class:`Sound`\n"
":arg keep: See :attr:`Handle.keep`.\n"
":type keep: bool\n"
":return: The playback handle with which playback can be "
"controlled with.\n"
":rtype: :class:`Handle`");
static PyObject *
Device_play(Device* self, PyObject* args, PyObject* kwds)
{
PyObject* object;
PyObject* keepo = nullptr;
bool keep = false;
static const char* kwlist[] = {"sound", "keep", nullptr};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:play", const_cast<char**>(kwlist), &object, &keepo))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
if(keepo != nullptr)
{
if(!PyBool_Check(keepo))
{
PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
return nullptr;
}
keep = keepo == Py_True;
}
Handle* handle;
handle = (Handle*)Handle_empty();
if(handle != nullptr)
{
try
{
handle->handle = new std::shared_ptr<IHandle>((*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->play(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), keep));
}
catch(Exception& e)
{
Py_DECREF(handle);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)handle;
}
PyDoc_STRVAR(M_aud_Device_stopAll_doc,
"stopAll()\n\n"
"Stops all playing and paused sounds.");
static PyObject *
Device_stopAll(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->stopAll();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_unlock_doc,
"unlock()\n\n"
"Unlocks the device after a lock call, see :meth:`lock` for "
"details.");
static PyObject *
Device_unlock(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->unlock();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef Device_methods[] = {
{"lock", (PyCFunction)Device_lock, METH_NOARGS,
M_aud_Device_lock_doc
},
{"play", (PyCFunction)Device_play, METH_VARARGS | METH_KEYWORDS,
M_aud_Device_play_doc
},
{"stopAll", (PyCFunction)Device_stopAll, METH_NOARGS,
M_aud_Device_stopAll_doc
},
{"unlock", (PyCFunction)Device_unlock, METH_NOARGS,
M_aud_Device_unlock_doc
},
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Device_channels_doc,
"The channel count of the device.");
static PyObject *
Device_get_channels(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.channels);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_distance_model_doc,
"The distance model of the device.\n\n"
".. seealso:: http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm#_Toc199835864");
static PyObject *
Device_get_distance_model(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("i", int(device->getDistanceModel()));
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_distance_model(Device* self, PyObject* args, void* nothing)
{
int model;
if(!PyArg_Parse(args, "i:distance_model", &model))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setDistanceModel(DistanceModel(model));
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_doppler_factor_doc,
"The doppler factor of the device.\n"
"This factor is a scaling factor for the velocity vectors in "
"doppler calculation. So a value bigger than 1 will exaggerate "
"the effect as it raises the velocity.");
static PyObject *
Device_get_doppler_factor(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getDopplerFactor());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_doppler_factor(Device* self, PyObject* args, void* nothing)
{
float factor;
if(!PyArg_Parse(args, "f:doppler_factor", &factor))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setDopplerFactor(factor);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_format_doc,
"The native sample format of the device.");
static PyObject *
Device_get_format(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.format);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_listener_location_doc,
"The listeners's location in 3D space, a 3D tuple of floats.");
static PyObject *
Device_get_listener_location(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 v = device->getListenerLocation();
return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_location(Device* self, PyObject* args, void* nothing)
{
float x, y, z;
if(!PyArg_Parse(args, "(fff):listener_location", &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 location(x, y, z);
device->setListenerLocation(location);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_listener_orientation_doc,
"The listener's orientation in 3D space as quaternion, a 4 float tuple.");
static PyObject *
Device_get_listener_orientation(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Quaternion o = device->getListenerOrientation();
return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_orientation(Device* self, PyObject* args, void* nothing)
{
float w, x, y, z;
if(!PyArg_Parse(args, "(ffff):listener_orientation", &w, &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Quaternion orientation(w, x, y, z);
device->setListenerOrientation(orientation);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_listener_velocity_doc,
"The listener's velocity in 3D space, a 3D tuple of floats.");
static PyObject *
Device_get_listener_velocity(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 v = device->getListenerVelocity();
return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_velocity(Device* self, PyObject* args, void* nothing)
{
float x, y, z;
if(!PyArg_Parse(args, "(fff):listener_velocity", &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 velocity(x, y, z);
device->setListenerVelocity(velocity);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_rate_doc,
"The sampling rate of the device in Hz.");
static PyObject *
Device_get_rate(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("d", specs.rate);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_speed_of_sound_doc,
"The speed of sound of the device.\n"
"The speed of sound in air is typically 343.3 m/s.");
static PyObject *
Device_get_speed_of_sound(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getSpeedOfSound());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_speed_of_sound(Device* self, PyObject* args, void* nothing)
{
float speed;
if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setSpeedOfSound(speed);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_volume_doc,
"The overall volume of the device.");
static PyObject *
Device_get_volume(Device* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getVolume());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_volume(Device* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume", &volume))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->setVolume(volume);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
static PyGetSetDef Device_properties[] = {
{(char*)"channels", (getter)Device_get_channels, nullptr,
M_aud_Device_channels_doc, nullptr },
{(char*)"distance_model", (getter)Device_get_distance_model, (setter)Device_set_distance_model,
M_aud_Device_distance_model_doc, nullptr },
{(char*)"doppler_factor", (getter)Device_get_doppler_factor, (setter)Device_set_doppler_factor,
M_aud_Device_doppler_factor_doc, nullptr },
{(char*)"format", (getter)Device_get_format, nullptr,
M_aud_Device_format_doc, nullptr },
{(char*)"listener_location", (getter)Device_get_listener_location, (setter)Device_set_listener_location,
M_aud_Device_listener_location_doc, nullptr },
{(char*)"listener_orientation", (getter)Device_get_listener_orientation, (setter)Device_set_listener_orientation,
M_aud_Device_listener_orientation_doc, nullptr },
{(char*)"listener_velocity", (getter)Device_get_listener_velocity, (setter)Device_set_listener_velocity,
M_aud_Device_listener_velocity_doc, nullptr },
{(char*)"rate", (getter)Device_get_rate, nullptr,
M_aud_Device_rate_doc, nullptr },
{(char*)"speed_of_sound", (getter)Device_get_speed_of_sound, (setter)Device_set_speed_of_sound,
M_aud_Device_speed_of_sound_doc, nullptr },
{(char*)"volume", (getter)Device_get_volume, (setter)Device_set_volume,
M_aud_Device_volume_doc, nullptr },
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Device_doc,
"Device objects represent an audio output backend like OpenAL or "
"SDL, but might also represent a file output or RAM buffer "
"output.");
static PyTypeObject DeviceType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.Device", /* tp_name */
sizeof(Device), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)Device_dealloc,/* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_Device_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Device_methods, /* tp_methods */
0, /* tp_members */
Device_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
Device_new, /* tp_new */
};
AUD_API PyObject* Device_empty()
{
return DeviceType.tp_alloc(&DeviceType, 0);
}
AUD_API Device* checkDevice(PyObject* device)
{
if(!PyObject_TypeCheck(device, &DeviceType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type Device!");
return nullptr;
}
return (Device*)device;
}
bool initializeDevice()
{
return PyType_Ready(&DeviceType) >= 0;
}
void addDeviceToModule(PyObject* module)
{
Py_INCREF(&DeviceType);
PyModule_AddObject(module, "Device", (PyObject *)&DeviceType);
}

View File

@@ -1,33 +0,0 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_IDevice;
typedef struct {
PyObject_HEAD
Reference_IDevice* device;
} Device;
extern AUD_API PyObject* Device_empty();
extern AUD_API Device* checkDevice(PyObject* device);
bool initializeDevice();
void addDeviceToModule(PyObject* module);

View File

@@ -1,467 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "PyDynamicMusic.h"
#include "PySound.h"
#include "PyHandle.h"
#include "PyDevice.h"
#include "Exception.h"
#include "fx/DynamicMusic.h"
extern PyObject* AUDError;
static PyObject *
DynamicMusic_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DynamicMusicP* self = (DynamicMusicP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
PyObject* object;
if(!PyArg_ParseTuple(args, "O:device", &object))
return nullptr;
Device* device = checkDevice(object);
try
{
self->dynamicMusic = new std::shared_ptr<aud::DynamicMusic>(new aud::DynamicMusic(*reinterpret_cast<std::shared_ptr<aud::IDevice>*>(device->device)));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
DynamicMusic_dealloc(DynamicMusicP* self)
{
if(self->dynamicMusic)
delete reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_DynamicMusic_addScene_doc,
"addScene(scene)\n\n"
"Adds a new scene.\n\n"
":arg scene: The scene sound.\n"
":type scene: :class:`Sound`\n"
":return: The new scene id.\n"
":rtype: int");
static PyObject *
DynamicMusic_addScene(DynamicMusicP* self, PyObject* args)
{
PyObject* object;
if(!PyArg_Parse(args, "O:sound", &object))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
try
{
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addScene(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound)));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_addTransition_doc,
"addTransition(ini, end, transition)\n\n"
"Adds a new scene.\n\n"
":arg ini: the initial scene foor the transition.\n"
":type ini: int\n"
":arg end: The final scene for the transition.\n"
":type end: int\n"
":arg transition: The transition sound.\n"
":type transition: :class:`Sound`\n"
":return: false if the ini or end scenes don't exist, true othrwise.\n"
":rtype: bool");
static PyObject *
DynamicMusic_addTransition(DynamicMusicP* self, PyObject* args)
{
PyObject* object;
int ini, end;
if(!PyArg_ParseTuple(args, "iiO:sound", &ini, &end, &object))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
try
{
(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addTransition(ini, end, *reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound));
Py_RETURN_NONE;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_resume_doc,
"resume()\n\n"
"Resumes playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
DynamicMusic_resume(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->resume());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_pause_doc,
"pause()\n\n"
"Pauses playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
DynamicMusic_pause(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->pause());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_stop_doc,
"stop()\n\n"
"Stops playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool\n\n");
static PyObject *
DynamicMusic_stop(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->stop());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef DynamicMusic_methods[] = {
{ "addScene", (PyCFunction)DynamicMusic_addScene, METH_O,
M_aud_DynamicMusic_addScene_doc
},
{ "addTransition", (PyCFunction)DynamicMusic_addTransition, METH_VARARGS,
M_aud_DynamicMusic_addTransition_doc
},
{ "resume", (PyCFunction)DynamicMusic_resume, METH_NOARGS,
M_aud_DynamicMusic_resume_doc
},
{ "pause", (PyCFunction)DynamicMusic_pause, METH_NOARGS,
M_aud_DynamicMusic_pause_doc
},
{ "stop", (PyCFunction)DynamicMusic_stop, METH_NOARGS,
M_aud_DynamicMusic_stop_doc
},
{ nullptr } /* Sentinel */
};
/////////////////////////////////////////////////////
PyDoc_STRVAR(M_aud_DynamicMusic_status_doc,
"Whether the scene is playing, paused or stopped (=invalid).");
static PyObject *
DynamicMusic_get_status(DynamicMusicP* self, void* nothing)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getStatus());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_position_doc,
"The playback position of the scene in seconds.");
static int
DynamicMusic_set_position(DynamicMusicP* self, PyObject* args, void* nothing)
{
float position;
if(!PyArg_Parse(args, "f:position", &position))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->seek(position))
return 0;
PyErr_SetString(AUDError, "Couldn't seek the sound!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_position(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getPosition());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_fadeTime_doc,
"The length in seconds of the crossfade transition");
static int
DynamicMusic_set_fadeTime(DynamicMusicP* self, PyObject* args, void* nothing)
{
float fadeTime;
if(!PyArg_Parse(args, "f:fadeTime", &fadeTime))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setFadeTime(fadeTime);
return 0;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_fadeTime(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getFadeTime());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_scene_doc,
"The current scene");
static int
DynamicMusic_set_scene(DynamicMusicP* self, PyObject* args, void* nothing)
{
int scene;
if(!PyArg_Parse(args, "i:scene", &scene))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->changeScene(scene))
return 0;
PyErr_SetString(AUDError, "Couldn't change the scene!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_scene(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getScene());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_volume_doc,
"The volume of the scene.");
static int
DynamicMusic_set_volume(DynamicMusicP* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume", &volume))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setVolume(volume))
return 0;
PyErr_SetString(AUDError, "Couldn't change the volume!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_volume(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getVolume());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyGetSetDef DynamicMusic_properties[] = {
{ (char*)"status", (getter)DynamicMusic_get_status, nullptr,
M_aud_DynamicMusic_status_doc, nullptr },
{ (char*)"position", (getter)DynamicMusic_get_position, (setter)DynamicMusic_set_position,
M_aud_DynamicMusic_position_doc, nullptr },
{ (char*)"fadeTime", (getter)DynamicMusic_get_fadeTime, (setter)DynamicMusic_set_fadeTime,
M_aud_DynamicMusic_fadeTime_doc, nullptr },
{ (char*)"scene", (getter)DynamicMusic_get_scene, (setter)DynamicMusic_set_scene,
M_aud_DynamicMusic_scene_doc, nullptr },
{ (char*)"volume", (getter)DynamicMusic_get_volume, (setter)DynamicMusic_set_volume,
M_aud_DynamicMusic_volume_doc, nullptr },
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_DynamicMusic_doc,
"The DynamicMusic object allows to play music depending on a current scene, scene changes are managed by the class, with the possibility of custom transitions.\n"
"The default transition is a crossfade effect, and the default scene is silent and has id 0");
PyTypeObject DynamicMusicType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.DynamicMusic", /* tp_name */
sizeof(DynamicMusicP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)DynamicMusic_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_DynamicMusic_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DynamicMusic_methods, /* tp_methods */
0, /* tp_members */
DynamicMusic_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
DynamicMusic_new, /* tp_new */
};
AUD_API PyObject* DynamicMusic_empty()
{
return DynamicMusicType.tp_alloc(&DynamicMusicType, 0);
}
AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic)
{
if(!PyObject_TypeCheck(dynamicMusic, &DynamicMusicType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type DynamicMusic!");
return nullptr;
}
return (DynamicMusicP*)dynamicMusic;
}
bool initializeDynamicMusic()
{
return PyType_Ready(&DynamicMusicType) >= 0;
}
void addDynamicMusicToModule(PyObject* module)
{
Py_INCREF(&DynamicMusicType);
PyModule_AddObject(module, "DynamicMusic", (PyObject *)&DynamicMusicType);
}

View File

@@ -1,33 +0,0 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_DynamicMusic;
typedef struct {
PyObject_HEAD
Reference_DynamicMusic* dynamicMusic;
} DynamicMusicP;
extern AUD_API PyObject* DynamicMusic_empty();
extern AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic);
bool initializeDynamicMusic();
void addDynamicMusicToModule(PyObject* module);

View File

@@ -1,247 +0,0 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "PyHRTF.h"
#include "PySound.h"
#include "Exception.h"
#include "fx/HRTF.h"
#include "fx/HRTFLoader.h"
extern PyObject* AUDError;
static PyObject *
HRTF_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
HRTFP* self = (HRTFP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(new aud::HRTF());
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
HRTF_dealloc(HRTFP* self)
{
if(self->hrtf)
delete reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_HRTF_addImpulseResponse_doc,
"addImpulseResponseFromSound(sound, azimuth, elevation)\n\n"
"Adds a new hrtf to the HRTF object\n\n"
":arg sound: The sound that contains the hrtf.\n"
":type sound: :class:`Sound`\n"
":arg azimuth: The azimuth angle of the hrtf.\n"
":type azimuth: float\n"
":arg elevation: The elevation angle of the hrtf.\n"
":type elevation: float\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
HRTF_addImpulseResponseFromSound(HRTFP* self, PyObject* args)
{
PyObject* object;
float azimuth, elevation;
if(!PyArg_ParseTuple(args, "Off:hrtf", &object, &azimuth, &elevation))
return nullptr;
Sound* ir = checkSound(object);
if(!ir)
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf))->addImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(ir->sound)), azimuth, elevation));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_HRTF_loadLeftHrtfSet_doc,
"loadLeftHrtfSet(extension, directory)\n\n"
"Loads all HRTFs from a directory.\n\n"
":arg extension: The file extension of the hrtfs.\n"
":type extension: string\n"
":arg directory: The path to where the HRTF files are located.\n"
":type extension: string\n"
":return: The loaded :class:`HRTF` object.\n"
":rtype: :class:`HRTF`\n\n");
static PyObject *
HRTF_loadLeftHrtfSet(PyTypeObject* type, PyObject* args)
{
const char* dir = nullptr;
const char* ext = nullptr;
if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
return nullptr;
HRTFP* self;
self = (HRTFP*)type->tp_alloc(type, 0);
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadLeftHRTFs(ext, dir));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
return (PyObject *)self;
}
PyDoc_STRVAR(M_aud_HRTF_loadRightHrtfSet_doc,
"loadLeftHrtfSet(extension, directory)\n\n"
"Loads all HRTFs from a directory.\n\n"
":arg extension: The file extension of the hrtfs.\n"
":type extension: string\n"
":arg directory: The path to where the HRTF files are located.\n"
":type extension: string\n"
":return: The loaded :class:`HRTF` object.\n"
":rtype: :class:`HRTF`\n\n");
static PyObject *
HRTF_loadRightHrtfSet(PyTypeObject* type, PyObject* args)
{
const char* dir = nullptr;
const char* ext = nullptr;
if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
return nullptr;
HRTFP* self;
self = (HRTFP*)type->tp_alloc(type, 0);
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadRightHRTFs(ext, dir));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
return (PyObject *)self;
}
static PyMethodDef HRTF_methods[] = {
{ "addImpulseResponseFromSound", (PyCFunction)HRTF_addImpulseResponseFromSound, METH_VARARGS | METH_KEYWORDS,
M_aud_HRTF_addImpulseResponse_doc
},
{ "loadLeftHrtfSet", (PyCFunction)HRTF_loadLeftHrtfSet, METH_VARARGS | METH_CLASS,
M_aud_HRTF_loadLeftHrtfSet_doc
},
{ "loadRightHrtfSet", (PyCFunction)HRTF_loadRightHrtfSet, METH_VARARGS | METH_CLASS,
M_aud_HRTF_loadRightHrtfSet_doc
},
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_HRTF_doc,
"An HRTF object represents a set of head related transfer functions as impulse responses. It's used for binaural sound");
PyTypeObject HRTFType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.HRTF", /* tp_name */
sizeof(HRTFP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)HRTF_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_HRTF_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
HRTF_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
HRTF_new, /* tp_new */
};
AUD_API PyObject* HRTF_empty()
{
return HRTFType.tp_alloc(&HRTFType, 0);
}
AUD_API HRTFP* checkHRTF(PyObject* hrtf)
{
if(!PyObject_TypeCheck(hrtf, &HRTFType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type HRTF!");
return nullptr;
}
return (HRTFP*)hrtf;
}
bool initializeHRTF()
{
return PyType_Ready(&HRTFType) >= 0;
}
void addHRTFToModule(PyObject* module)
{
Py_INCREF(&HRTFType);
PyModule_AddObject(module, "HRTF", (PyObject *)&HRTFType);
}

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