Add Chromium-only Blender WebEngine parity work
This commit is contained in:
2
blender-5.2.0/extern/.clang-format
vendored
Normal file
2
blender-5.2.0/extern/.clang-format
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
DisableFormat: true
|
||||
SortIncludes: false
|
||||
109
blender-5.2.0/extern/CMakeLists.txt
vendored
Normal file
109
blender-5.2.0/extern/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# SPDX-FileCopyrightText: 2006 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# Libs that adhere to strict flags
|
||||
add_subdirectory(curve_fit_nd)
|
||||
add_subdirectory(fast_float)
|
||||
add_subdirectory(json)
|
||||
if(WITH_IO_FBX)
|
||||
add_subdirectory(ufbx)
|
||||
endif()
|
||||
|
||||
# Otherwise we get warnings here that we can't fix in external projects
|
||||
remove_strict_flags()
|
||||
|
||||
# Not a strict flag, but noisy for code we don't maintain
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
remove_c_and_cxx_flag(
|
||||
"-Wextra"
|
||||
"-Wmisleading-indentation"
|
||||
)
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
remove_c_and_cxx_flag(
|
||||
"-Weverything"
|
||||
"-Wextra"
|
||||
"-Wnull-pointer-subtraction"
|
||||
"-Wcast-function-type-mismatch"
|
||||
"-Wignored-qualifiers"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_COMPILER_ASAN AND NOT WITH_COMPILER_ASAN_EXTERN)
|
||||
# Not only does MSVC not have an -fno-sanitize=all option, if you remove the /fsanitize=address
|
||||
# flag at this point, it will give a linker error as it generates an ODR violation for some
|
||||
# vector classes, for details see :
|
||||
# https://learn.microsoft.com/en-us/cpp/sanitizers/error-container-overflow?view=msvc-170
|
||||
if(NOT MSVC)
|
||||
# Disable ASAN for extern dependencies, as it can lead to linking issues due to too large binaries.
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -fno-sanitize=all")
|
||||
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -fno-sanitize=all")
|
||||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fno-sanitize=all")
|
||||
string(APPEND CMAKE_C_FLAGS_DEBUG " -fno-sanitize=all")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(rangetree)
|
||||
add_subdirectory(nanosvg)
|
||||
add_subdirectory(wcwidth)
|
||||
add_subdirectory(xxhash)
|
||||
|
||||
if(WITH_BULLET)
|
||||
if(NOT WITH_SYSTEM_BULLET)
|
||||
add_subdirectory(bullet2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_BINRELOC)
|
||||
add_subdirectory(binreloc)
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES OR WITH_OPENSUBDIV)
|
||||
if((WITH_CYCLES_DEVICE_CUDA OR WITH_CYCLES_DEVICE_OPTIX) AND WITH_CUDA_DYNLOAD)
|
||||
add_subdirectory(cuew)
|
||||
endif()
|
||||
if(WITH_CYCLES_DEVICE_HIP AND WITH_HIP_DYNLOAD)
|
||||
add_subdirectory(hipew)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_GHOST_X11 AND WITH_GHOST_XDND)
|
||||
add_subdirectory(xdnd)
|
||||
endif()
|
||||
|
||||
if(WITH_LIBMV OR WITH_GTESTS)
|
||||
if(NOT WITH_SYSTEM_GFLAGS)
|
||||
add_subdirectory(gflags)
|
||||
endif()
|
||||
add_subdirectory(glog)
|
||||
endif()
|
||||
|
||||
if(WITH_GTESTS)
|
||||
add_subdirectory(gtest)
|
||||
add_subdirectory(gmock)
|
||||
endif()
|
||||
|
||||
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
|
||||
set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
|
||||
set(LIB_SUFFIX "") # Quiet uninitialized warning.
|
||||
add_subdirectory(audaspace)
|
||||
unset(LIB_SUFFIX)
|
||||
endif()
|
||||
|
||||
if(WITH_QUADRIFLOW)
|
||||
set(QUADRIFLOW_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/quadriflow/blender_config.cmake)
|
||||
add_subdirectory(quadriflow)
|
||||
endif()
|
||||
|
||||
if(WITH_MOD_FLUID)
|
||||
add_subdirectory(mantaflow)
|
||||
endif()
|
||||
|
||||
if(WITH_VULKAN_BACKEND)
|
||||
add_subdirectory(vulkan_memory_allocator)
|
||||
endif()
|
||||
|
||||
if(WITH_TRACY)
|
||||
add_subdirectory(tracy_profiler)
|
||||
endif()
|
||||
3
blender-5.2.0/extern/README
vendored
Normal file
3
blender-5.2.0/extern/README
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
When updating a library remember to:
|
||||
|
||||
* Update the README.blender with the corresponding version.
|
||||
50
blender-5.2.0/extern/audaspace/AUTHORS
vendored
Normal file
50
blender-5.2.0/extern/audaspace/AUTHORS
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
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>
|
||||
|
||||
The Equalizer sound effect has been added by
|
||||
|
||||
- Marcos Perez
|
||||
|
||||
Some performance improvements, especially to the JOSResampler have been made by
|
||||
|
||||
- Aras Pranckevičius
|
||||
|
||||
The pipewire backend and many fixes have been provided by
|
||||
|
||||
- Sebastian Parborg
|
||||
|
||||
The rubberband integration (for time stretching and pitch scaling) has been provided by
|
||||
|
||||
- Kacey La
|
||||
|
||||
The echo effect has been provided by
|
||||
|
||||
- AGoldenDragon
|
||||
|
||||
Several people provided fixes:
|
||||
|
||||
- Aaron Carlisle
|
||||
- Leon Zandman
|
||||
- Richard Antalik
|
||||
- Robert-André Mauchin
|
||||
- Lalit Shankar Chowdhury
|
||||
- Nathan Burnham
|
||||
- Weizhen Huang
|
||||
- Jonas Holzman
|
||||
- Andrej Zhilenkov
|
||||
- Jacques Lucke
|
||||
- Ray Molenkamp
|
||||
348
blender-5.2.0/extern/audaspace/CHANGES
vendored
Normal file
348
blender-5.2.0/extern/audaspace/CHANGES
vendored
Normal file
@@ -0,0 +1,348 @@
|
||||
Audaspace 1.9
|
||||
|
||||
- New Echo effect (thanks AGoldenDragon)
|
||||
- Bugfix for Catmull-Rom spline interpolation
|
||||
- Build fixes for Mac (thanks Jonas Holzman)
|
||||
- Python API documentation for class constructors (thanks Andrej Zhilenkov)
|
||||
- CMake fixes (thanks Campbell Barton)
|
||||
- Sample rate type warnings (thanks Jacques Lucke and Ray Molenkamp)
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
e4a3d40 Porting fixes from blender
|
||||
3348de2 PyDoc: Add constructor docstrings to aud types
|
||||
7b04aa9 Build: macOS: Fix bitwise operation enum type warning in Audaspace
|
||||
a931d65 Bugfix: Catmull-Rom spline interpolation was wrong.
|
||||
1550e14 Fix AUD_Sound_Echo wrongly inside WITH_CONVOLUTION guard
|
||||
ddda09e Echo: change wet/dry behavior.
|
||||
31a59c4 Fixing Echo effect:
|
||||
c3d4ba9 Implemented a new Echo effect (#63)
|
||||
|
||||
Audaspace 1.8
|
||||
|
||||
- Time stretching and pitch scaling including animation and python API added (thanks Kacey La!).
|
||||
- Update API of AUD_readSound to fix interruption logic in Blender.
|
||||
- Minor other fixes including in the PulseAudio, CoreAudio and FFMPEG plugins.
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
9b1be5f Include stdbool.h
|
||||
2663809 Use boolean for interrupting AUD_readSound function
|
||||
83721b1 Fix broken doc-string function argument type definition
|
||||
05d35ba Some fixes for the just introduced better seeking of time stretching.
|
||||
301f874 AnimateableTimeStretchPitchScale Seek - Frame-Approach (#58)
|
||||
fa006ac FFMPEG: fix memory leak and remove deprecated AV_INPUT_BUFFER_MIN_SIZE.
|
||||
3be6dfd Python API for AnimateableProperty and AnimatedTimeScalePitchScale (#54)
|
||||
ff127cf Minor fixes.
|
||||
5e09510 AnimatedTimeStretchPitchScale effect (#53)
|
||||
39caef7 Updating AUTHORS
|
||||
b1058e6 Porting PulseAudio and CoreAudio fixes from upstream Blender.
|
||||
d1b3c5b Rename StretcherQuality to just StretcherQualityOption.
|
||||
f00f081 Fixer for Rubberband.
|
||||
924a19b Add TimeStretchPitchScale effect (#52)
|
||||
|
||||
Audaspace 1.7
|
||||
|
||||
- Rewrite of the Synchronizer API.
|
||||
- Unified backends with a mixing thread (Jack, Pulse, Pipewire, CoreAudio)
|
||||
- Various fixes for CoreAudio.
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
46036fa Bugfix for MixingThreadDevice.
|
||||
bdd4ba5 Reintroducing ThreadedDevice.
|
||||
eabbeee CoreAudio: remove OpenCloseDevice functionality.
|
||||
a746d92 CoreAudio fixes.
|
||||
0cbd14e Fixes.
|
||||
82585f8 CoreAudioDevice/OpenCloseDevice: base on MixingThreadDevice.
|
||||
a6341e7 Adding MixingThreadDevice and refactor deriving classes.
|
||||
d2de831 Refactor PipeWireDevice and use own RingBuffer class.
|
||||
78291ef Jack: use own RingBuffer class.
|
||||
cbf62c2 CoreAudio: compile fixes.
|
||||
caafed6 Remove resumeOnSync API again since no device supports it properly.
|
||||
22f9c8d Modifying Jack transport sync callback behavior.
|
||||
8cf2429 Remove sync callbacks for own calls.
|
||||
c070757 Add resumeOnSync method for precise synchronization with Jack.
|
||||
ce417e5 Finish synchronizer refactor.
|
||||
fbec554 First step towards handle independent synchronizer.
|
||||
|
||||
Audaspace 1.6
|
||||
|
||||
- Pipewire support (thanks Sebastian Parborg!)
|
||||
- AAC container (ADTS stream).
|
||||
- Update to C++17.
|
||||
- Improvements for PulseAudio backend.
|
||||
- Many (bug) fixes.
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
70b18a5 Port fix by Weizhen Huang from Blender.
|
||||
ecaa71c CoreAudio: closing issue fixed from Apple for newer MacOS versions.
|
||||
0035101 Port Blender changes to upstream.
|
||||
dd419af Blender bug fix #129162: High idle CPU usage with PulseAudio in Linux
|
||||
9220ab5 Set C++ version python plugin bulid to 17.
|
||||
9db9578 Add AAC container You could already use Matroska container with AAC codec, but if someone wants raw .aac file ("ADTS stream"), there was no container option to pick.
|
||||
d3b7471 Fix whitespace
|
||||
d1f1704 Fix rendering audio to Matroska container
|
||||
5aabc89 Pipewire support (#43)
|
||||
f5e8ccc Audaspace: Update PulseAudio sync functions to be more accurate (#42)
|
||||
f4611c0 Porting ffmpeg compatibility back from Blender.
|
||||
6afeab2 Update to C++17.
|
||||
81b0d76 PulseAudio: try to play as much as possible of buffered data on playback stop.
|
||||
426dab5 Fix Sound.filter a argument default not a sequence
|
||||
d701d0b loadRight documented as duplicate of loadLeft
|
||||
4326b24 Fix for building python module without fftw.
|
||||
901f14e Bugfix for MacOS from Blender.
|
||||
ee59832 Fix a typo
|
||||
27bc641 Update AUTHORS.
|
||||
689d645 Windows: Use COM smart pointers in WASAPI plugin
|
||||
5efc5c4 Update FFmpeg code to avoid direct assignation of ch_layout
|
||||
56edbe4 Making the OpenCloseDevice thread safe.
|
||||
|
||||
Audaspace 1.5
|
||||
|
||||
- Performance improvements and two more quality presets for the JOS resampler.
|
||||
- Bugfixes for PulseAudio.
|
||||
- CoreAudio device is only opened on demand.
|
||||
- FFMPEG 7 support and dropped support for FFMPEG older than 6.
|
||||
- Various minor fixes and improvements.
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
3566597 FFMPEG Update
|
||||
c158a27 Porting bugfix from Blender.
|
||||
edb388b Bugfix for PulseAudio: buffers not cleared after pause.
|
||||
6affec8 Port fix from Blender.
|
||||
a99262e Load CoreAudio device on demand
|
||||
ae29ce2 Adding default quality parameter also to JOSResample.
|
||||
dae2044 Renaming resample quality enum values in the C API.
|
||||
8c810b5 Add resampling quality parameter to various mixdown functions, and to PySound resample
|
||||
1b9b7f9 Add ResampleQuality enum and APIs to control resampling quality
|
||||
4bfd596 Avoid std::string copies by value
|
||||
0d18fe7 JOSResampleReader performance and faster quality settings (#18)
|
||||
2a300d9 Filter design python script.
|
||||
5f745ff Bugfix for reading an animated property with a negative time value.
|
||||
04eeb56 Fix python documentation.
|
||||
631850b Update AUTHORS.
|
||||
db2ff58 Improve seeking for animated sequences
|
||||
|
||||
Audaspace 1.4
|
||||
|
||||
- Support for OS specific/native audio devices/backends has been added, that is PulseAudio (Linux), WASAPI (Windows) and CoreAudio (MacOS).
|
||||
- New sound effects have been added, namely Modulator and Equalizer. Thanks to Marcos Perez for contributing the Equalizer.
|
||||
- File stream info: if an audio file contains multiple streams you can choose which one to process instead of taking the first one (this feature is only supported by ffmpeg, not libsndfile).
|
||||
- API Change: double instead of float for time values for more precise timing control.
|
||||
- There have been lots of bugfixes, which are basically the majority of all changes.
|
||||
- And some other minor improvements were implemented as well.
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
d4042d9 Port changes in Blender to upstream.
|
||||
b60fb45 Equalizer
|
||||
ab04e84 Fixes
|
||||
8f0c305 Fix build error with MSVC 17.4+ ported from Blender.
|
||||
ce44342 Minor documentation update.
|
||||
cdcb3f4 Migrate from distuils to setuptools for python module.
|
||||
21eccef Fix FindFFTW to find the float version fftw3f.
|
||||
ab15e2f Bugfix: API change in new ffmpeg version.
|
||||
a097be8 Clang format file added, valid from now on.
|
||||
2fc9fb7 Porting bugfix from Blender upstream.
|
||||
bb655b7 Bugfix: wrong sample size computation for PulseAudio.
|
||||
a150495 Bugfix: Buffer did not support buffers > 2 GB.
|
||||
034645c Update for ffmpeg 5.
|
||||
932739c Bugfix: WASAPI hangs.
|
||||
4fcd47c WASAPI: fix bug when switching the default device while there is no playback.
|
||||
a16fbd2 Python API: fix to get convolution in the python API.
|
||||
27ac5c1 WASAPI: always switch to default audio device.
|
||||
1b03e6c Bugfix: catch exception if file cannot be read.
|
||||
369ff6e PulseAudio: remove unused underflow callback.
|
||||
2d8bf3a PulseAudio: improve synchronization accuracy.
|
||||
4868e14 Revert PulseAudioDevice back from ThreadedDevice to threaded mainloop.
|
||||
6a04446 Adding a jack style mixing thread with a ring buffer for pulseaudio.
|
||||
5d4b57b Implement RingBuffer class.
|
||||
e02d3aa FFMPEG: fix seeking and duration calculation.
|
||||
07b9fa0 Adding file stream functionality.
|
||||
5a8ad27 Porting changes from Blender.
|
||||
fa47258 Bugfix: PulseAudio writing to little data on request.
|
||||
ca3edb5 PulseAudio: increase buffersize.
|
||||
6d36f3e Pulseaudio: may fix crackling playback start bug.
|
||||
dbeac4b WASAPI: reinitialize device when lost.
|
||||
0cba4d3 Bugfix Pulseaudio: might hang.
|
||||
b73dc6d Bugfix: ffmpeg 4.4 requires channels to be set.
|
||||
f1ecbe0 Fixed typo.
|
||||
09e4f27 Rewrite PulseAudioDevice to use ThreadedDevice.
|
||||
9516924 WASAPI: refactor to simplify and use ThreadedDevice.
|
||||
749c974 Add ThreadedDevice.
|
||||
e68b355 Fix some locks in SoftwareDevice.
|
||||
44b57af Bugfix for deadlock in WASAPIDevice.
|
||||
8c4b266 CMake: fix ERROR to FATAL_ERROR in MESSAGE.
|
||||
5a17338 Rename NullDevice's reported name to None.
|
||||
cd138d7 PulseAudio: add dynamic loading and threading fixes.
|
||||
6e0250f CoreAudio: add CoreAudioClock as synchronizer.
|
||||
43aff35 Fix leakage in CoreAudioDevice.cpp
|
||||
7f6f059 Remove unnecessary cmake code.
|
||||
a5c1a02 Add CoreAudio device for Apple.
|
||||
af96f67 Indentation fix.
|
||||
eec8fd5 WASAPI: use padding also for first buffer submission.
|
||||
c63bd9b WASAPI: deal with IsFormatSupported case.
|
||||
079cccb Hide WITH_PULSEAUDIO when not on Linux.
|
||||
67b5013 Add mingw64 cross compilation toolchain on Linux.
|
||||
a7bfa58 Add WASAPI backend for Windows.
|
||||
be1cb25 Allow AUD_init with nullptr to use default device.
|
||||
fc68868 Compilation fix for mingw.
|
||||
bb79d25 Add a PulseAudio output device.
|
||||
a11f593 Bugfix for unwanted volume fading at the beginning of sounds.
|
||||
8510acf Bugfix: more accurate positioning of sequences.
|
||||
cb816c1 Fix API docs for python playback manager play function
|
||||
d125fa2 Add callback for mixing down audio.
|
||||
789832e Fix numpy import.
|
||||
9a6a802 Bugfix: JOS resampling type bugfix caused integer underflow.
|
||||
ece0842 Fix corrupted document in python bindings
|
||||
28b2ea2 SDL 2: support more audio formats.
|
||||
a39b7e3 Trying to fix Travis CI build for OS X.
|
||||
c924007 Some more changes of times from flaot to double.
|
||||
659afd4 Porting fixes from blender.
|
||||
8e5e2e6 Fix documentation warnings.
|
||||
7a6054f API: All times are now double instead of float.
|
||||
452a724 Mixer sample buffer added channels twice
|
||||
8ddb6c1 Docs: Cleanup Line Wrapping for python examples
|
||||
a0c37b2 Docs: Use class methods for api docs
|
||||
2f8b2e3 Bugfix for invalid offsets provided by ffmpeg's seeking code.
|
||||
20a7a28 Bug fixes for files with more than 8 channels.
|
||||
94dc527 Bugfix: Fading from full volume.
|
||||
2fb9862 Fix: Missing include in FileManager.h.
|
||||
afadb94 Minor CMakeLists.txt formatting fixes.
|
||||
734ef03 Add sample rate parameter to silence generation.
|
||||
ed50f3b Bugfix: Return correct length for modulator and superpose.
|
||||
cb7a314 Adding a modulator sound effect.
|
||||
101c714 Bugfix: don't add non-existing devices to the device manager.
|
||||
7ad99df OpenAL: recreate device if disconnected.
|
||||
a2ff4e8 Bugfix: memory leak in python API.
|
||||
5fb21bb Silence some warnings.
|
||||
9b38605 Some fixes backported from Blender.
|
||||
40a0a34 Udpate for travis.ci.
|
||||
212b4b6 Support newer ffmpeg versions.
|
||||
d27746c Build option: configure whether to build versioned plugins.
|
||||
19c8d9f Make fftw3 optional.
|
||||
aa11968 Bugfix for building with gcc7.
|
||||
10413c5 Fix for seeking with modified pitch.
|
||||
|
||||
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
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
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
|
||||
|
||||
Detailed list of changes:
|
||||
|
||||
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.
|
||||
1296
blender-5.2.0/extern/audaspace/CMakeLists.txt
vendored
Normal file
1296
blender-5.2.0/extern/audaspace/CMakeLists.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
107
blender-5.2.0/extern/audaspace/INSTALL
vendored
Normal file
107
blender-5.2.0/extern/audaspace/INSTALL
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
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, needs NumPy as well)
|
||||
|
||||
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).
|
||||
202
blender-5.2.0/extern/audaspace/LICENSE
vendored
Normal file
202
blender-5.2.0/extern/audaspace/LICENSE
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
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.
|
||||
6
blender-5.2.0/extern/audaspace/README.blender
vendored
Normal file
6
blender-5.2.0/extern/audaspace/README.blender
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Project: Audaspace
|
||||
URL: https://audaspace.github.io/
|
||||
License: SPDX:Apache-2.0
|
||||
Upstream version: 1.6.0 (cb493a1, 2025 Mar 3)
|
||||
Copyright: "Copyright © 2009-2025 Jörg Müller. All rights reserved."
|
||||
Local modifications: none
|
||||
47
blender-5.2.0/extern/audaspace/README.md
vendored
Normal file
47
blender-5.2.0/extern/audaspace/README.md
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
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-2025 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.
|
||||
321
blender-5.2.0/extern/audaspace/bindings/C/AUD_Device.cpp
vendored
Normal file
321
blender-5.2.0/extern/audaspace/bindings/C/AUD_Device.cpp
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
/*******************************************************************************
|
||||
* 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 == double(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(double time)
|
||||
{
|
||||
DeviceManager::getDevice()->seekSynchronizer(time);
|
||||
}
|
||||
|
||||
AUD_API double AUD_getSynchronizerPosition()
|
||||
{
|
||||
return DeviceManager::getDevice()->getSynchronizerPosition();
|
||||
}
|
||||
|
||||
AUD_API void AUD_playSynchronizer()
|
||||
{
|
||||
DeviceManager::getDevice()->playSynchronizer();
|
||||
}
|
||||
|
||||
AUD_API void AUD_stopSynchronizer()
|
||||
{
|
||||
DeviceManager::getDevice()->stopSynchronizer();
|
||||
}
|
||||
|
||||
AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data)
|
||||
{
|
||||
DeviceManager::getDevice()->setSyncCallback(function, data);
|
||||
}
|
||||
|
||||
AUD_API int AUD_isSynchronizerPlaying()
|
||||
{
|
||||
return DeviceManager::getDevice()->isSynchronizerPlaying();
|
||||
}
|
||||
258
blender-5.2.0/extern/audaspace/bindings/C/AUD_Device.h
vendored
Normal file
258
blender-5.2.0/extern/audaspace/bindings/C/AUD_Device.h
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
/*******************************************************************************
|
||||
* 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(double time);
|
||||
|
||||
/**
|
||||
* Returns the current sound scene playback time.
|
||||
* \param handle Playback handle.
|
||||
* \return The playback time in seconds.
|
||||
*/
|
||||
extern AUD_API double AUD_getSynchronizerPosition();
|
||||
|
||||
/**
|
||||
* 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
|
||||
144
blender-5.2.0/extern/audaspace/bindings/C/AUD_DynamicMusic.cpp
vendored
Normal file
144
blender-5.2.0/extern/audaspace/bindings/C/AUD_DynamicMusic.cpp
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/*******************************************************************************
|
||||
* 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, double position)
|
||||
{
|
||||
assert(player);
|
||||
|
||||
return (*player)->seek(position);
|
||||
}
|
||||
|
||||
AUD_API double 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();
|
||||
}
|
||||
145
blender-5.2.0/extern/audaspace/bindings/C/AUD_DynamicMusic.h
vendored
Normal file
145
blender-5.2.0/extern/audaspace/bindings/C/AUD_DynamicMusic.h
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*******************************************************************************
|
||||
* 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, double 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 double 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
|
||||
50
blender-5.2.0/extern/audaspace/bindings/C/AUD_HRTF.cpp
vendored
Normal file
50
blender-5.2.0/extern/audaspace/bindings/C/AUD_HRTF.cpp
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
48
blender-5.2.0/extern/audaspace/bindings/C/AUD_HRTF.h
vendored
Normal file
48
blender-5.2.0/extern/audaspace/bindings/C/AUD_HRTF.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
384
blender-5.2.0/extern/audaspace/bindings/C/AUD_Handle.cpp
vendored
Normal file
384
blender-5.2.0/extern/audaspace/bindings/C/AUD_Handle.cpp
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
/*******************************************************************************
|
||||
* 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 double AUD_Handle_getPosition(AUD_Handle* handle)
|
||||
{
|
||||
assert(handle);
|
||||
return (*handle)->getPosition();
|
||||
}
|
||||
|
||||
AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, double 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;
|
||||
}
|
||||
308
blender-5.2.0/extern/audaspace/bindings/C/AUD_Handle.h
vendored
Normal file
308
blender-5.2.0/extern/audaspace/bindings/C/AUD_Handle.h
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
/*******************************************************************************
|
||||
* 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 double 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, double 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
|
||||
44
blender-5.2.0/extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp
vendored
Normal file
44
blender-5.2.0/extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
40
blender-5.2.0/extern/audaspace/bindings/C/AUD_ImpulseResponse.h
vendored
Normal file
40
blender-5.2.0/extern/audaspace/bindings/C/AUD_ImpulseResponse.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
94
blender-5.2.0/extern/audaspace/bindings/C/AUD_PlaybackManager.cpp
vendored
Normal file
94
blender-5.2.0/extern/audaspace/bindings/C/AUD_PlaybackManager.cpp
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
103
blender-5.2.0/extern/audaspace/bindings/C/AUD_PlaybackManager.h
vendored
Normal file
103
blender-5.2.0/extern/audaspace/bindings/C/AUD_PlaybackManager.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/*******************************************************************************
|
||||
* 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 created.
|
||||
*/
|
||||
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
|
||||
321
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sequence.cpp
vendored
Normal file
321
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sequence.cpp
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
/*******************************************************************************
|
||||
* 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, double begin, double end, double 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, double begin, double end, double skip)
|
||||
{
|
||||
(*entry)->move(begin, end, skip);
|
||||
}
|
||||
|
||||
AUD_API void AUD_SequenceEntry_setConstantRangeAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame_start, int frame_end, float* data)
|
||||
{
|
||||
AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
|
||||
prop->writeConstantRange(data, frame_start, frame_end);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
338
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sequence.h
vendored
Normal file
338
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sequence.h
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* 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, double begin, double end, double 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_start Start of the frame range.
|
||||
* \param frame_end End of the frame range.
|
||||
* \param data The data to write.
|
||||
*/
|
||||
AUD_API void AUD_SequenceEntry_setConstantRangeAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame_start, int frame_end, float* data);
|
||||
|
||||
/**
|
||||
* 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_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, double begin, double end, double 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
|
||||
880
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sound.cpp
vendored
Normal file
880
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sound.cpp
vendored
Normal file
@@ -0,0 +1,880 @@
|
||||
/*******************************************************************************
|
||||
* 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/Modulator.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"
|
||||
|
||||
#include "fx/Echo.h"
|
||||
|
||||
#ifdef WITH_CONVOLUTION
|
||||
#include "fx/BinauralSound.h"
|
||||
#include "fx/ConvolverSound.h"
|
||||
#include "fx/Equalizer.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_RUBBERBAND
|
||||
#include "fx/TimeStretchPitchScale.h"
|
||||
#include "fx/AnimateableTimeStretchPitchScale.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 int AUD_Sound_getFileStreams(AUD_Sound* sound, AUD_StreamInfo **stream_infos)
|
||||
{
|
||||
assert(sound);
|
||||
|
||||
std::shared_ptr<File> file = std::dynamic_pointer_cast<File>(*sound);
|
||||
|
||||
if(file)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto streams = file->queryStreams();
|
||||
|
||||
size_t size = sizeof(AUD_StreamInfo) * streams.size();
|
||||
|
||||
if(!size)
|
||||
{
|
||||
*stream_infos = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*stream_infos = reinterpret_cast<AUD_StreamInfo*>(std::malloc(size));
|
||||
std::memcpy(*stream_infos, streams.data(), size);
|
||||
|
||||
return streams.size();
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
*stream_infos = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 != double(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 if(extension == ".aac")
|
||||
container = AUD_CONTAINER_AAC;
|
||||
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;
|
||||
case AUD_CONTAINER_AAC:
|
||||
codec = AUD_CODEC_AAC;
|
||||
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&)
|
||||
{
|
||||
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_bufferFileStream(unsigned char* buffer, int size, int stream)
|
||||
{
|
||||
assert(buffer);
|
||||
return new AUD_Sound(new File(buffer, size, stream));
|
||||
}
|
||||
|
||||
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_fileStream(const char* filename, int stream)
|
||||
{
|
||||
assert(filename);
|
||||
return new AUD_Sound(new File(filename, stream));
|
||||
}
|
||||
|
||||
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(AUD_SampleRate rate)
|
||||
{
|
||||
return new AUD_Sound(new Silence(rate));
|
||||
}
|
||||
|
||||
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_modulate(AUD_Sound* first, AUD_Sound* second)
|
||||
{
|
||||
assert(first);
|
||||
assert(second);
|
||||
|
||||
try
|
||||
{
|
||||
return new AUD_Sound(new Modulator(*first, *second));
|
||||
}
|
||||
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, AUD_ResampleQuality quality)
|
||||
{
|
||||
assert(sound);
|
||||
|
||||
try
|
||||
{
|
||||
DeviceSpecs specs;
|
||||
specs.channels = CHANNELS_INVALID;
|
||||
specs.rate = rate;
|
||||
specs.format = FORMAT_INVALID;
|
||||
if (quality == AUD_RESAMPLE_QUALITY_FASTEST)
|
||||
{
|
||||
return new AUD_Sound(new LinearResample(*sound, specs));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new AUD_Sound(new JOSResample(*sound, specs, static_cast<ResampleQuality>(quality)));
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
AUD_API AUD_Sound* AUD_Sound_Echo(AUD_Sound* sound, float delay, float feedback, float mix, bool resetBuffer)
|
||||
{
|
||||
assert(sound);
|
||||
try
|
||||
{
|
||||
return new AUD_Sound(new Echo(*sound, delay, feedback, mix, resetBuffer));
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_CONVOLUTION
|
||||
AUD_API AUD_Sound* AUD_Sound_equalize(AUD_Sound* sound, float *definition, int size, float maxFreqEq, int sizeConversion)
|
||||
{
|
||||
assert(sound);
|
||||
|
||||
std::shared_ptr<Buffer> buf = std::shared_ptr<Buffer>(new Buffer(sizeof(float)*size));
|
||||
std::memcpy(buf->getBuffer(), definition, sizeof(float)*size);
|
||||
AUD_Sound *equalizer=new AUD_Sound(new Equalizer(*sound, buf, size, maxFreqEq, sizeConversion));
|
||||
return equalizer;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_RUBBERBAND
|
||||
AUD_API AUD_Sound* AUD_Sound_timeStretchPitchScale(AUD_Sound* sound, double timeRatio, double pitchScale, AUD_StretcherQuality quality, char preserveFormant)
|
||||
{
|
||||
assert(sound);
|
||||
try
|
||||
{
|
||||
return new AUD_Sound(new TimeStretchPitchScale(*sound, timeRatio, pitchScale, static_cast<StretcherQuality>(quality), preserveFormant));
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
AUD_API AUD_Sound* AUD_Sound_animateableTimeStretchPitchScale(AUD_Sound* sound, float fps, double timeRatio, double pitchScale, AUD_StretcherQuality quality, char preserveFormant)
|
||||
{
|
||||
assert(sound);
|
||||
try
|
||||
{
|
||||
return new AUD_Sound(new AnimateableTimeStretchPitchScale(*sound, fps, timeRatio, pitchScale, static_cast<StretcherQuality>(quality), preserveFormant));
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
AUD_API void AUD_Sound_animateableTimeStretchPitchScale_setConstantRangeAnimationData(AUD_Sound* sound, AUD_AnimateablePropertyType type, int frame_start, int frame_end,
|
||||
float* data)
|
||||
{
|
||||
std::shared_ptr<AnimateableProperty> prop = std::dynamic_pointer_cast<AnimateableTimeStretchPitchScale>(*sound)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
|
||||
prop->writeConstantRange(data, frame_start, frame_end);
|
||||
}
|
||||
|
||||
AUD_API void AUD_Sound_animateableTimeStretchPitchScale_setAnimationData(AUD_Sound* sound, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
|
||||
{
|
||||
std::shared_ptr<AnimateableProperty> prop = std::dynamic_pointer_cast<AnimateableTimeStretchPitchScale>(*sound)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
|
||||
if(animated)
|
||||
{
|
||||
if(frame >= 0)
|
||||
prop->write(data, frame, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop->write(data);
|
||||
}
|
||||
}
|
||||
|
||||
AUD_API float AUD_Sound_animateableTimeStretchPitchScale_getFPS(AUD_Sound* sound)
|
||||
{
|
||||
assert(sound);
|
||||
return dynamic_cast<AnimateableTimeStretchPitchScale*>(sound->get())->getFPS();
|
||||
}
|
||||
|
||||
AUD_API void AUD_Sound_animateableTimeStretchPitchScale_setFPS(AUD_Sound* sound, float value)
|
||||
{
|
||||
assert(sound);
|
||||
dynamic_cast<AnimateableTimeStretchPitchScale*>(sound->get())->setFPS(value);
|
||||
}
|
||||
|
||||
AUD_API bool AUD_Sound_isAnimateableTimeStretchPitchScale(AUD_Sound* sound)
|
||||
{
|
||||
assert(sound);
|
||||
return dynamic_cast<AnimateableTimeStretchPitchScale*>(sound->get()) != nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
491
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sound.h
vendored
Normal file
491
blender-5.2.0/extern/audaspace/bindings/C/AUD_Sound.h
vendored
Normal file
@@ -0,0 +1,491 @@
|
||||
/*******************************************************************************
|
||||
* 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_Sound_getLength(AUD_Sound* sound);
|
||||
|
||||
/**
|
||||
* Retrieves the stream infos of a sound file.
|
||||
* \param sound The sound to retrieve from which must be a file sound.
|
||||
* \param infos A pointer to a AUD_StreamInfo array that will be allocated and must afterwards be freed by the caller.
|
||||
* \return The number of items in the infos array.
|
||||
*/
|
||||
extern AUD_API int AUD_Sound_getFileStreams(AUD_Sound* sound, AUD_StreamInfo** stream_infos);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Loads a sound file from a memory buffer.
|
||||
* \param buffer The buffer which contains the sound file.
|
||||
* \param size The size of the buffer.
|
||||
* \param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
* \return A handle of the sound file.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_bufferFileStream(unsigned char* buffer, int size, int stream);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Loads a sound file.
|
||||
* \param filename The filename of the sound file.
|
||||
* \param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
* \return A handle of the sound file.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_fileStream(const char* filename, int stream);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* \param rate The sample rate of the silence sound.
|
||||
* \return A handle of the sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_silence(AUD_SampleRate rate);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Modulates two sound, which means multiplying the sound samples.
|
||||
* \param first The first sound.
|
||||
* \param second The second sound.
|
||||
* \return A handle of the modulated sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_modulate(AUD_Sound* first, AUD_Sound* second);
|
||||
|
||||
/**
|
||||
* 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 quality Resampling quality vs performance choice.
|
||||
* \return The resampled sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, AUD_ResampleQuality 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);
|
||||
|
||||
/**
|
||||
* Adds Echo effect to the sound.
|
||||
* \param sound The handle of the sound.
|
||||
* \param delay The delay time in seconds.
|
||||
* \param feedback The feedback amount (0.0 to 1.0).
|
||||
* \param mix The wet/dry mix (0.0 to 1.0).
|
||||
* \param resetBuffer Whether to reset the delay buffer on seek.
|
||||
* \return A handle of the time-stretched, pitch scaled sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_Echo(AUD_Sound* sound, float delay, float feedback, float mix, bool resetBuffer);
|
||||
|
||||
#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);
|
||||
|
||||
/**
|
||||
* Creates an Equalizer for the sound
|
||||
* \param sound The handle of the sound
|
||||
* \param definition buffer of size*sizeof(float) with the array of equalization values
|
||||
* \param maxFreqEq Maximum frequency refered by the array
|
||||
* \param sizeConversion Size of the transformation. Must be 2^number (for example 1024, 2048,...)
|
||||
* \return A handle to the Equalizer refered to that sound
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_equalize(AUD_Sound* sound, float *definition, int size, float maxFreqEq, int sizeConversion);
|
||||
#endif
|
||||
|
||||
#ifdef WITH_RUBBERBAND
|
||||
/**
|
||||
* Time-stretches and pitch scales a sound.
|
||||
* \param sound The handle of the sound.
|
||||
* \param timeRatio The factor by which to stretch or compress time.
|
||||
* \param pitchScale The factor by which to adjust the pitch.
|
||||
* \param quality The processing quality level of the stretcher.
|
||||
* \param preserveFormant Whether to preserve the vocal formants for the stretcher.
|
||||
* \return A handle of the time-stretched, pitch scaled sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_timeStretchPitchScale(AUD_Sound* sound, double timeRatio, double pitchScale, AUD_StretcherQuality quality, char preserveFormant);
|
||||
|
||||
/**
|
||||
* Time-stretches and pitch scales a sound with animation support
|
||||
* \param sound The handle of the sound.
|
||||
* \param fps The fps
|
||||
* \param timeRatio The initial factor by which to stretch or compress time.
|
||||
* \param pitchScale The initial factor by which to adjust the pitch.
|
||||
* \param quality The processing quality level of the stretcher.
|
||||
* \param preserveFormant Whether to preserve the vocal formants for the stretcher.
|
||||
* \return A handle of the time-stretched, pitch scaled sound.
|
||||
*/
|
||||
extern AUD_API AUD_Sound* AUD_Sound_animateableTimeStretchPitchScale(AUD_Sound* sound, float fps, double timeRatio, double pitchScale, AUD_StretcherQuality quality,
|
||||
char preserveFormant);
|
||||
|
||||
/**
|
||||
* Writes animation data to the AnimatableTimeStretchPitchScale effect
|
||||
* \param sequence The sound scene.
|
||||
* \param type The type of animation data.
|
||||
* \param frame_start Start of the frame range.
|
||||
* \param frame_end End of the frame range.
|
||||
* \param data The data to write.
|
||||
*/
|
||||
AUD_API void AUD_Sound_animateableTimeStretchPitchScale_setConstantRangeAnimationData(AUD_Sound* sound, AUD_AnimateablePropertyType type, int frame_start, int frame_end,
|
||||
float* data);
|
||||
|
||||
/**
|
||||
* Writes animation data to the AnimatableTimeStretchPitchScale effect
|
||||
* \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_Sound_animateableTimeStretchPitchScale_setAnimationData(AUD_Sound* sound, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
|
||||
|
||||
/**
|
||||
* Sets the fps of an animated time-stretch, pitch-scaled sound.
|
||||
* \param sound The sound to set the fps from.
|
||||
* \param value The new fps to set.
|
||||
*/
|
||||
extern AUD_API void AUD_Sound_animateableTimeStretchPitchScale_setFPS(AUD_Sound* sound, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
|
||||
|
||||
/**
|
||||
* Retrieves the fps of an animated time-stretch, pitch-scaled sound.
|
||||
* \param sequence The sound to get the fps from.
|
||||
* \return The fps of the sound.
|
||||
*/
|
||||
extern AUD_API float AUD_Sound_animateableTimeStretchPitchScale_getFPS(AUD_Sound* sequence);
|
||||
|
||||
/**
|
||||
* Checks if sound is an instance of AnimateableTimeStretchPitchScale effect.
|
||||
*/
|
||||
extern AUD_API bool AUD_Sound_isAnimateableTimeStretchPitchScale(AUD_Sound* sound);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
84
blender-5.2.0/extern/audaspace/bindings/C/AUD_Source.cpp
vendored
Normal file
84
blender-5.2.0/extern/audaspace/bindings/C/AUD_Source.cpp
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
84
blender-5.2.0/extern/audaspace/bindings/C/AUD_Source.h
vendored
Normal file
84
blender-5.2.0/extern/audaspace/bindings/C/AUD_Source.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
430
blender-5.2.0/extern/audaspace/bindings/C/AUD_Special.cpp
vendored
Normal file
430
blender-5.2.0/extern/audaspace/bindings/C/AUD_Special.cpp
vendored
Normal file
@@ -0,0 +1,430 @@
|
||||
/*******************************************************************************
|
||||
* 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, int stream)
|
||||
{
|
||||
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, stream));
|
||||
|
||||
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, double seconds)
|
||||
{
|
||||
auto device = DeviceManager::getDevice();
|
||||
|
||||
std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence(device->getSpecs().rate));
|
||||
std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds));
|
||||
|
||||
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, bool* 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] = std::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 int 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, AUD_ResampleQuality quality, bool(*callback)(float, void*), void* data, char* error, size_t errorsize)
|
||||
{
|
||||
try
|
||||
{
|
||||
Sequence* f = dynamic_cast<Sequence *>(sound->get());
|
||||
|
||||
f->setSpecs(convCToSpec(specs.specs));
|
||||
std::shared_ptr<IReader> reader = f->createQualityReader(static_cast<ResampleQuality>(quality));
|
||||
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, callback, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
if(error && errorsize)
|
||||
{
|
||||
std::strncpy(error, e.getMessage().c_str(), errorsize);
|
||||
error[errorsize - 1] = '\0';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AUD_API int 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, AUD_ResampleQuality quality, bool(*callback)(float, void*), void* data, char* error, size_t errorsize)
|
||||
{
|
||||
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(static_cast<ResampleQuality>(quality));
|
||||
reader->seek(start);
|
||||
FileWriter::writeReader(reader, writers, length, buffersize, callback, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
if(error && errorsize)
|
||||
{
|
||||
std::strncpy(error, e.getMessage().c_str(), errorsize);
|
||||
error[errorsize - 1] = '\0';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, AUD_ResampleQuality quality, double start)
|
||||
{
|
||||
try
|
||||
{
|
||||
ReadDevice* device = new ReadDevice(convCToDSpec(specs));
|
||||
device->setQuality(static_cast<ResampleQuality>(quality));
|
||||
device->setVolume(volume);
|
||||
|
||||
Sequence* f = dynamic_cast<Sequence*>(sequencer->get());
|
||||
|
||||
f->setSpecs(convCToSpec(specs.specs));
|
||||
|
||||
AUD_Handle handle = device->play(f->createQualityReader(static_cast<ResampleQuality>(quality)));
|
||||
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 = device ? DeviceManager::getDeviceFactory(device) : DeviceManager::getDefaultDeviceFactory();
|
||||
|
||||
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;
|
||||
}
|
||||
155
blender-5.2.0/extern/audaspace/bindings/C/AUD_Special.h
vendored
Normal file
155
blender-5.2.0/extern/audaspace/bindings/C/AUD_Special.h
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*******************************************************************************
|
||||
* 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"
|
||||
|
||||
#include <stdbool.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, int stream);
|
||||
|
||||
/**
|
||||
* 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, double 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.
|
||||
* \param interrupt Must point to a bool that equals false. If it is set to true, the method will be interrupted and return 0.
|
||||
* \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, bool* 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.
|
||||
* \param quality The resampling quality.
|
||||
* \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Mixdown is canceled if the callback returns false. Can be NULL.
|
||||
* \param data Pass through parameter that is passed to the callback.
|
||||
* \param error String buffer to copy the error message to in case of failure.
|
||||
* \param errorsize The size of the error buffer.
|
||||
* \return Whether or not the operation succeeded.
|
||||
*/
|
||||
extern AUD_API int 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, AUD_ResampleQuality quality,
|
||||
bool(*callback)(float, void*), void* data, char* error, size_t errorsize);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* \param quality The resampling quality.
|
||||
* \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Mixdown is canceled if the callback returns false. Can be NULL.
|
||||
* \param data Pass through parameter that is passed to the callback.
|
||||
* \param error String buffer to copy the error message to in case of failure.
|
||||
* \param errorsize The size of the error buffer.
|
||||
* \return Whether or not the operation succeeded.
|
||||
*/
|
||||
extern AUD_API int 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, AUD_ResampleQuality quality,
|
||||
bool(*callback)(float, void*), void* data, char* error, size_t errorsize);
|
||||
|
||||
/**
|
||||
* 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 quality The resampling quality.
|
||||
* \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, AUD_ResampleQuality quality, double 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
|
||||
42
blender-5.2.0/extern/audaspace/bindings/C/AUD_ThreadPool.cpp
vendored
Normal file
42
blender-5.2.0/extern/audaspace/bindings/C/AUD_ThreadPool.cpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
40
blender-5.2.0/extern/audaspace/bindings/C/AUD_ThreadPool.h
vendored
Normal file
40
blender-5.2.0/extern/audaspace/bindings/C/AUD_ThreadPool.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
224
blender-5.2.0/extern/audaspace/bindings/C/AUD_Types.h
vendored
Normal file
224
blender-5.2.0/extern/audaspace/bindings/C/AUD_Types.h
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/*******************************************************************************
|
||||
* 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_AAC
|
||||
} 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;
|
||||
|
||||
/// Resampling algorithm and quality.
|
||||
typedef enum
|
||||
{
|
||||
AUD_RESAMPLE_QUALITY_FASTEST = 0, /// Linear resample, very fast but lowest quality.
|
||||
AUD_RESAMPLE_QUALITY_LOW = 1, /// JOS resample at low quality preset.
|
||||
AUD_RESAMPLE_QUALITY_MEDIUM = 2, /// JOS resample at medium quality preset.
|
||||
AUD_RESAMPLE_QUALITY_HIGH = 3 /// JOS resample at high quality preset.
|
||||
} AUD_ResampleQuality;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/// Specification of a sound source.
|
||||
typedef struct
|
||||
{
|
||||
/// Start time in seconds.
|
||||
double start;
|
||||
|
||||
/// Duration in seconds. May be estimated or 0 if unknown.
|
||||
double duration;
|
||||
|
||||
/// Audio data parameters.
|
||||
AUD_DeviceSpecs specs;
|
||||
} AUD_StreamInfo;
|
||||
|
||||
/**
|
||||
* The Rubber Band stretcher quality.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AUD_STRETCHER_QUALITY_HIGH = 0, /// Prioritize high-quality pitch processing
|
||||
AUD_STRETCHER_QUALITY_FAST = 1, /// Prioritize speed over audio quality
|
||||
AUD_STRETCHER_QUALITY_CONSISTENT = 2 /// Prioritize consistency for dynamic pitch changes
|
||||
} AUD_StretcherQuality;
|
||||
|
||||
/// 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_AP_TIME_STRETCH,
|
||||
AUD_AP_PITCH_SCALE
|
||||
} AUD_AnimateablePropertyType;
|
||||
261
blender-5.2.0/extern/audaspace/bindings/doc/conf.py.in
vendored
Normal file
261
blender-5.2.0/extern/audaspace/bindings/doc/conf.py.in
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
#!/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
|
||||
8
blender-5.2.0/extern/audaspace/bindings/doc/device.rst
vendored
Normal file
8
blender-5.2.0/extern/audaspace/bindings/doc/device.rst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Device
|
||||
======
|
||||
|
||||
.. currentmodule:: aud
|
||||
.. autoclass:: Device
|
||||
:members:
|
||||
:noindex:
|
||||
|
||||
8
blender-5.2.0/extern/audaspace/bindings/doc/handle.rst
vendored
Normal file
8
blender-5.2.0/extern/audaspace/bindings/doc/handle.rst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Handle
|
||||
======
|
||||
|
||||
.. currentmodule:: aud
|
||||
.. autoclass:: Handle
|
||||
:members:
|
||||
:noindex:
|
||||
|
||||
36
blender-5.2.0/extern/audaspace/bindings/doc/index.rst
vendored
Normal file
36
blender-5.2.0/extern/audaspace/bindings/doc/index.rst
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
.. 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
|
||||
:no-members:
|
||||
|
||||
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: 1
|
||||
|
||||
device
|
||||
sound
|
||||
handle
|
||||
sequence
|
||||
sequence_entry
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
8
blender-5.2.0/extern/audaspace/bindings/doc/sequence.rst
vendored
Normal file
8
blender-5.2.0/extern/audaspace/bindings/doc/sequence.rst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Sequence
|
||||
========
|
||||
|
||||
.. currentmodule:: aud
|
||||
.. autoclass:: Sequence
|
||||
:members:
|
||||
:noindex:
|
||||
|
||||
8
blender-5.2.0/extern/audaspace/bindings/doc/sequence_entry.rst
vendored
Normal file
8
blender-5.2.0/extern/audaspace/bindings/doc/sequence_entry.rst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Sequence Entry
|
||||
==============
|
||||
|
||||
.. currentmodule:: aud
|
||||
.. autoclass:: SequenceEntry
|
||||
:members:
|
||||
:noindex:
|
||||
|
||||
8
blender-5.2.0/extern/audaspace/bindings/doc/sound.rst
vendored
Normal file
8
blender-5.2.0/extern/audaspace/bindings/doc/sound.rst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Sound
|
||||
=====
|
||||
|
||||
.. currentmodule:: aud
|
||||
.. autoclass:: Sound
|
||||
:members:
|
||||
:noindex:
|
||||
|
||||
240
blender-5.2.0/extern/audaspace/bindings/doc/tutorials.rst
vendored
Normal file
240
blender-5.2.0/extern/audaspace/bindings/doc/tutorials.rst
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
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.
|
||||
249
blender-5.2.0/extern/audaspace/bindings/python/PyAPI.cpp
vendored
Normal file
249
blender-5.2.0/extern/audaspace/bindings/python/PyAPI.cpp
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PyAnimateableProperty.h"
|
||||
#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
|
||||
|
||||
#ifdef WITH_RUBBERBAND
|
||||
#include "fx/TimeStretchPitchScale.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;
|
||||
|
||||
if(!initializeAnimateableProperty())
|
||||
return nullptr;
|
||||
|
||||
#ifdef WITH_CONVOLUTION
|
||||
if(!initializeImpulseResponse())
|
||||
return nullptr;
|
||||
|
||||
if(!initializeHRTF())
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
module = PyModule_Create(&audmodule);
|
||||
if(module == nullptr)
|
||||
return nullptr;
|
||||
|
||||
addAnimateablePropertyToModule(module);
|
||||
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);
|
||||
PY_MODULE_ADD_CONSTANT(module, AP_TIME_STRETCH);
|
||||
PY_MODULE_ADD_CONSTANT(module, AP_PITCH_SCALE);
|
||||
// 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);
|
||||
PY_MODULE_ADD_CONSTANT(module, CONTAINER_AAC);
|
||||
// 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);
|
||||
|
||||
#ifdef WITH_RUBBERBAND
|
||||
// stretcher quality
|
||||
PyModule_AddIntConstant(module, "STRETCHER_QUALITY_HIGH", static_cast<int>(StretcherQuality::HIGH));
|
||||
PyModule_AddIntConstant(module, "STRETCHER_QUALITY_FAST", static_cast<int>(StretcherQuality::FAST));
|
||||
PyModule_AddIntConstant(module, "STRETCHER_QUALITY_CONSISTENT", static_cast<int>(StretcherQuality::CONSISTENT));
|
||||
#endif
|
||||
|
||||
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));
|
||||
}
|
||||
45
blender-5.2.0/extern/audaspace/bindings/python/PyAPI.h
vendored
Normal file
45
blender-5.2.0/extern/audaspace/bindings/python/PyAPI.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
404
blender-5.2.0/extern/audaspace/bindings/python/PyAnimateableProperty.cpp
vendored
Normal file
404
blender-5.2.0/extern/audaspace/bindings/python/PyAnimateableProperty.cpp
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2025 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 "PyAnimateableProperty.h"
|
||||
|
||||
#include "Exception.h"
|
||||
|
||||
#include "sequence/AnimateableProperty.h"
|
||||
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
#include <memory>
|
||||
|
||||
#include <numpy/ndarrayobject.h>
|
||||
|
||||
using namespace aud;
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
static PyObject* AnimateableProperty_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
AnimateablePropertyP* self = (AnimateablePropertyP*) type->tp_alloc(type, 0);
|
||||
|
||||
int count;
|
||||
float value;
|
||||
|
||||
if(self != nullptr)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "i|f:animateableProperty", &count, &value))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
if(PyTuple_Size(args) == 1)
|
||||
{
|
||||
self->animateableProperty = new std::shared_ptr<aud::AnimateableProperty>(new aud::AnimateableProperty(count));
|
||||
}
|
||||
else
|
||||
{
|
||||
self->animateableProperty = new std::shared_ptr<aud::AnimateableProperty>(new aud::AnimateableProperty(count, value));
|
||||
}
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(self);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject*) self;
|
||||
}
|
||||
|
||||
static void AnimateableProperty_dealloc(AnimateablePropertyP* self)
|
||||
{
|
||||
if(self->animateableProperty)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty);
|
||||
Py_TYPE(self)->tp_free((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyObject* AnimateableProperty_read(AnimateablePropertyP* self, PyObject* args)
|
||||
{
|
||||
float position;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "f", &position))
|
||||
return nullptr;
|
||||
|
||||
int count = (*reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty))->getCount();
|
||||
npy_intp dims[1] = {count};
|
||||
PyObject* np_array = PyArray_SimpleNew(1, dims, NPY_FLOAT32);
|
||||
if(!np_array)
|
||||
return nullptr;
|
||||
|
||||
float* out = static_cast<float*>(PyArray_DATA(reinterpret_cast<PyArrayObject*>(np_array)));
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty))->read(position, out);
|
||||
return np_array;
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(np_array);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_read_doc, ".. method:: read(position)\n\n"
|
||||
" Reads the properties value at the given position.\n\n"
|
||||
" :param position: The position in the animation in frames.\n"
|
||||
" :type position: float\n"
|
||||
" :return: A numpy array of values representing the properties value.\n"
|
||||
" :rtype: :class:`numpy.ndarray`\n");
|
||||
|
||||
static PyObject* AnimateableProperty_readSingle(AnimateablePropertyP* self, PyObject* args)
|
||||
{
|
||||
float position;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "f", &position))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
float value = (*reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty))->readSingle(position);
|
||||
return Py_BuildValue("f", value);
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_readSingle_doc, ".. method:: readSingle(position)\n\n"
|
||||
" Reads the properties value at the given position, assuming there is exactly one value.\n\n"
|
||||
" :param position: The position in the animation in frames.\n"
|
||||
" :type position: float\n"
|
||||
" :return: The value at that position.\n"
|
||||
" :rtype: float\n\n");
|
||||
|
||||
static PyObject* AnimateableProperty_write(AnimateablePropertyP* self, PyObject* args)
|
||||
{
|
||||
PyObject* array_obj;
|
||||
int position = -1;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O|i", &array_obj, &position))
|
||||
return nullptr;
|
||||
|
||||
PyArrayObject* np_array = reinterpret_cast<PyArrayObject*>(PyArray_FROM_OTF(array_obj, NPY_FLOAT32, NPY_ARRAY_IN_ARRAY | NPY_ARRAY_FORCECAST));
|
||||
|
||||
if(!np_array)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "data must be a numpy array of dtype float32");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto& prop = *reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty);
|
||||
int prop_count = prop->getCount();
|
||||
npy_intp size = PyArray_SIZE(np_array);
|
||||
|
||||
int ndim = PyArray_NDIM(np_array);
|
||||
|
||||
bool valid_shape = false;
|
||||
|
||||
// For 1D arrays, the total number of elements must be a multiple of the property count
|
||||
if(ndim == 1)
|
||||
{
|
||||
valid_shape = (size % prop_count == 0);
|
||||
}
|
||||
// For 2D arrays, the number of elements in the second dimension must be the property count
|
||||
else if(ndim == 2)
|
||||
{
|
||||
npy_intp* shape = PyArray_DIMS(np_array);
|
||||
valid_shape = (shape[1] == prop_count);
|
||||
}
|
||||
|
||||
if(!valid_shape)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "array shape is invalid: must be 1D with length multiple of property count or 2D with the last dimension equal to property count");
|
||||
Py_DECREF(np_array);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int count = static_cast<int>(size / prop_count);
|
||||
|
||||
if(count < 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "input array must have at least 1 element");
|
||||
Py_DECREF(np_array);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float* data_ptr = reinterpret_cast<float*>(PyArray_DATA(np_array));
|
||||
try
|
||||
{
|
||||
if(position == -1)
|
||||
{
|
||||
if(count != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "input array must have exactly 1 element when position is not specified");
|
||||
Py_DECREF(np_array);
|
||||
return nullptr;
|
||||
}
|
||||
prop->write(data_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop->write(data_ptr, position, count);
|
||||
}
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
Py_DECREF(np_array);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_write_doc, ".. method:: write(data[, position])\n\n"
|
||||
" Writes the properties value.\n\n"
|
||||
" If `position` is also given, the property is marked animated and\n"
|
||||
" the values are written starting at `position`.\n\n"
|
||||
" :param data: numpy array of float32 values.\n"
|
||||
" :type data: numpy.ndarray\n"
|
||||
" :param position: The starting position in frames.\n"
|
||||
" :type position: int\n\n");
|
||||
|
||||
static PyObject* AnimateableProperty_writeConstantRange(AnimateablePropertyP* self, PyObject* args)
|
||||
{
|
||||
PyObject* array_obj;
|
||||
int position_start;
|
||||
int position_end;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oii", &array_obj, &position_start, &position_end))
|
||||
return nullptr;
|
||||
|
||||
PyArrayObject* np_array = reinterpret_cast<PyArrayObject*>(PyArray_FROM_OTF(array_obj, NPY_FLOAT32, NPY_ARRAY_IN_ARRAY | NPY_ARRAY_FORCECAST));
|
||||
if(!np_array)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "data must be a numpy array of dtype float32");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int ndim = PyArray_NDIM(np_array);
|
||||
if(ndim != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "data must be a 1D numpy array");
|
||||
Py_DECREF(np_array);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float* data_ptr = reinterpret_cast<float*>(PyArray_DATA(np_array));
|
||||
|
||||
auto& prop = *reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty);
|
||||
int prop_count = prop->getCount();
|
||||
|
||||
npy_intp size = PyArray_SIZE(np_array);
|
||||
|
||||
if(size != prop_count)
|
||||
{
|
||||
PyErr_Format(PyExc_ValueError, "input array length (%lld) does not match property count (%d)", size, prop_count);
|
||||
Py_DECREF(np_array);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
prop->writeConstantRange(data_ptr, position_start, position_end);
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_DECREF(np_array);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_writeConstantRange_doc, ".. method:: writeConstantRange(data, position_start, position_end)\n\n"
|
||||
" Fills the properties frame range with a constant value and marks it animated.\n\n"
|
||||
" :param data: numpy array of float values representing the constant value.\n"
|
||||
" :type data: numpy.ndarray\n"
|
||||
" :param position_start: The start position in frames.\n"
|
||||
" :type position_start: int\n"
|
||||
" :param position_end: The end position in frames.\n"
|
||||
" :type position_end: int\n\n");
|
||||
|
||||
static PyMethodDef AnimateableProperty_methods[] = {
|
||||
|
||||
{(char*) "read", (PyCFunction) AnimateableProperty_read, METH_VARARGS, M_aud_AnimateableProperty_read_doc},
|
||||
{(char*) "readSingle", (PyCFunction) AnimateableProperty_readSingle, METH_VARARGS, M_aud_AnimateableProperty_readSingle_doc},
|
||||
{(char*) "write", (PyCFunction) AnimateableProperty_write, METH_VARARGS, M_aud_AnimateableProperty_write_doc},
|
||||
{(char*) "writeConstantRange", (PyCFunction) AnimateableProperty_writeConstantRange, METH_VARARGS, M_aud_AnimateableProperty_writeConstantRange_doc},
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyObject* AnimateableProperty_get_count(AnimateablePropertyP* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = (*reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty))->getCount();
|
||||
return Py_BuildValue("i", count);
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_count_doc, "The count of floats for a property.");
|
||||
|
||||
static PyObject* AnimateableProperty_get_animated(AnimateablePropertyP* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool animated = (*reinterpret_cast<std::shared_ptr<aud::AnimateableProperty>*>(self->animateableProperty))->isAnimated();
|
||||
return PyBool_FromLong(animated);
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_animated_doc, "Whether the property is animated.");
|
||||
|
||||
static PyGetSetDef AnimateableProperty_properties[] = {
|
||||
{(char*) "count", (getter) AnimateableProperty_get_count, nullptr, M_aud_AnimateableProperty_count_doc, nullptr},
|
||||
{(char*) "animated", (getter) AnimateableProperty_get_animated, nullptr, M_aud_AnimateableProperty_animated_doc, nullptr},
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_AnimateableProperty_doc,
|
||||
".. class:: AnimateableProperty(count, value=0.0, /)\n\n"
|
||||
" An AnimateableProperty object stores an array of float values for animating sound properties (e.g. pan, volume, pitch-scale).\n\n"
|
||||
" :arg count: The number of float values to store per frame.\n"
|
||||
" :type count: int\n"
|
||||
" :arg value: The initial value for all elements.\n"
|
||||
" :type value: float\n");
|
||||
|
||||
// Note that AnimateablePropertyType name is already taken
|
||||
PyTypeObject AnimateablePropertyPyType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0) "aud.AnimateableProperty", /* tp_name */
|
||||
sizeof(AnimateablePropertyP), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor) AnimateableProperty_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_AnimateableProperty_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
AnimateableProperty_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
AnimateableProperty_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 */
|
||||
AnimateableProperty_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* AnimateableProperty_empty()
|
||||
{
|
||||
return AnimateablePropertyPyType.tp_alloc(&AnimateablePropertyPyType, 0);
|
||||
}
|
||||
|
||||
AUD_API AnimateablePropertyP* checkAnimateableProperty(PyObject* animateableProperty)
|
||||
{
|
||||
if(!PyObject_TypeCheck(animateableProperty, &AnimateablePropertyPyType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type AnimateableProperty!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (AnimateablePropertyP*) animateableProperty;
|
||||
}
|
||||
|
||||
bool initializeAnimateableProperty()
|
||||
{
|
||||
import_array1(false);
|
||||
return PyType_Ready(&AnimateablePropertyPyType) >= 0;
|
||||
}
|
||||
|
||||
void addAnimateablePropertyToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&AnimateablePropertyPyType);
|
||||
PyModule_AddObject(module, "AnimateableProperty", (PyObject*) &AnimateablePropertyPyType);
|
||||
}
|
||||
34
blender-5.2.0/extern/audaspace/bindings/python/PyAnimateableProperty.h
vendored
Normal file
34
blender-5.2.0/extern/audaspace/bindings/python/PyAnimateableProperty.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2025 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_AnimateableProperty;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD Reference_AnimateableProperty* animateableProperty;
|
||||
} AnimateablePropertyP;
|
||||
|
||||
extern AUD_API PyObject* AnimateableProperty_empty();
|
||||
extern AUD_API AnimateablePropertyP* checkAnimateableProperty(PyObject* animateableProperty);
|
||||
|
||||
bool initializeAnimateableProperty();
|
||||
void addAnimateablePropertyToModule(PyObject* module);
|
||||
800
blender-5.2.0/extern/audaspace/bindings/python/PyDevice.cpp
vendored
Normal file
800
blender-5.2.0/extern/audaspace/bindings/python/PyDevice.cpp
vendored
Normal file
@@ -0,0 +1,800 @@
|
||||
/*******************************************************************************
|
||||
* 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,
|
||||
".. method:: lock()\n\n"
|
||||
" Locks the device so that it's guaranteed, that no samples are\n"
|
||||
" read from the streams until :meth:`unlock` is called.\n"
|
||||
" This is useful if you want to do start/stop/pause/resume some\n"
|
||||
" sounds at the same time.\n\n"
|
||||
" .. note::\n\n"
|
||||
" The device has to be unlocked as often as locked to be\n"
|
||||
" able to continue playback.\n\n"
|
||||
" .. warning::\n\n"
|
||||
" Make sure the time between locking and unlocking is\n"
|
||||
" 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,
|
||||
".. method:: 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\n"
|
||||
" 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,
|
||||
".. method:: 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,
|
||||
".. method:: unlock()\n\n"
|
||||
" Unlocks the device after a lock call, see :meth:`lock` for\n"
|
||||
" 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:: `OpenAL Documentation <https://www.openal.org/documentation/>`__");
|
||||
|
||||
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,
|
||||
".. class:: Device(type='', rate=48000.0, channels=2, format=36, buffer_size=1024, name='')\n\n"
|
||||
" Device objects represent an audio output backend like OpenAL or "
|
||||
"SDL, but might also represent a file output or RAM buffer "
|
||||
"output.\n\n"
|
||||
" :arg type: The device type. An empty string means the default device.\n"
|
||||
" :type type: string\n"
|
||||
" :arg rate: The sample rate in Hz.\n"
|
||||
" :type rate: double\n"
|
||||
" :arg channels: The number of channels.\n"
|
||||
" :type channels: int\n"
|
||||
" :arg format: The sample format.\n"
|
||||
" :type format: int\n"
|
||||
" :arg buffer_size: The size of the audio buffer in samples.\n"
|
||||
" :type buffer_size: int\n"
|
||||
" :arg name: The name of the device.\n"
|
||||
" :type name: string\n");
|
||||
|
||||
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);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyDevice.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyDevice.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
470
blender-5.2.0/extern/audaspace/bindings/python/PyDynamicMusic.cpp
vendored
Normal file
470
blender-5.2.0/extern/audaspace/bindings/python/PyDynamicMusic.cpp
vendored
Normal file
@@ -0,0 +1,470 @@
|
||||
/*******************************************************************************
|
||||
* 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,
|
||||
".. method:: 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,
|
||||
".. method:: 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 otherwise.\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,
|
||||
".. method:: 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,
|
||||
".. method:: 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,
|
||||
".. method:: 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)
|
||||
{
|
||||
double position;
|
||||
|
||||
if(!PyArg_Parse(args, "d: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("d", (*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,
|
||||
".. class:: DynamicMusic(device, /)\n\n"
|
||||
" 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.\n\n"
|
||||
" :arg device: The device that will be used to play sounds.\n"
|
||||
" :type device: :class:`Device`\n");
|
||||
|
||||
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);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyDynamicMusic.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyDynamicMusic.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
248
blender-5.2.0/extern/audaspace/bindings/python/PyHRTF.cpp
vendored
Normal file
248
blender-5.2.0/extern/audaspace/bindings/python/PyHRTF.cpp
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
/*******************************************************************************
|
||||
* 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,
|
||||
".. method:: 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,
|
||||
".. method:: 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,
|
||||
".. method:: loadRightHrtfSet(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,
|
||||
".. class:: HRTF()\n\n"
|
||||
" An HRTF object represents a set of head related transfer functions as impulse responses. It's used for binaural sound.\n");
|
||||
|
||||
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);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyHRTF.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyHRTF.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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 <Python.h>
|
||||
#include "Audaspace.h"
|
||||
|
||||
typedef void Reference_HRTF;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_HRTF* hrtf;
|
||||
} HRTFP;
|
||||
|
||||
extern AUD_API PyObject* HRTF_empty();
|
||||
extern AUD_API HRTFP* checkHRTF(PyObject* hrtf);
|
||||
|
||||
bool initializeHRTF();
|
||||
void addHRTFToModule(PyObject* module);
|
||||
1124
blender-5.2.0/extern/audaspace/bindings/python/PyHandle.cpp
vendored
Normal file
1124
blender-5.2.0/extern/audaspace/bindings/python/PyHandle.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
33
blender-5.2.0/extern/audaspace/bindings/python/PyHandle.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyHandle.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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_IHandle;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_IHandle* handle;
|
||||
} Handle;
|
||||
|
||||
extern AUD_API PyObject* Handle_empty();
|
||||
extern AUD_API Handle* checkHandle(PyObject* handle);
|
||||
|
||||
bool initializeHandle();
|
||||
void addHandleToModule(PyObject* module);
|
||||
140
blender-5.2.0/extern/audaspace/bindings/python/PyImpulseResponse.cpp
vendored
Normal file
140
blender-5.2.0/extern/audaspace/bindings/python/PyImpulseResponse.cpp
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PyImpulseResponse.h"
|
||||
#include "PySound.h"
|
||||
|
||||
#include "Exception.h"
|
||||
#include "fx/ImpulseResponse.h"
|
||||
#include "util/StreamBuffer.h"
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
static PyObject *
|
||||
ImpulseResponse_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ImpulseResponseP* self = (ImpulseResponseP*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != nullptr)
|
||||
{
|
||||
PyObject* object;
|
||||
if(!PyArg_ParseTuple(args, "O:sound", &object))
|
||||
return nullptr;
|
||||
Sound* sound = checkSound(object);
|
||||
|
||||
try
|
||||
{
|
||||
self->impulseResponse = new std::shared_ptr<aud::ImpulseResponse>(new aud::ImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound))));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(self);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static void
|
||||
ImpulseResponse_dealloc(ImpulseResponseP* self)
|
||||
{
|
||||
if(self->impulseResponse)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::ImpulseResponse>*>(self->impulseResponse);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyMethodDef ImpulseResponse_methods[] = {
|
||||
{ nullptr } /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_ImpulseResponse_doc,
|
||||
".. class:: ImpulseResponse(sound, /)\n\n"
|
||||
" An ImpulseResponse object represents a filter with which to convolve a sound.\n\n"
|
||||
" :arg sound: The sound to use as the impulse response.\n"
|
||||
" :type sound: :class:`Sound`\n");
|
||||
|
||||
PyTypeObject ImpulseResponseType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.ImpulseResponse", /* tp_name */
|
||||
sizeof(ImpulseResponseP), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)ImpulseResponse_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_ImpulseResponse_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
ImpulseResponse_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 */
|
||||
ImpulseResponse_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* ImpulseResponse_empty()
|
||||
{
|
||||
return ImpulseResponseType.tp_alloc(&ImpulseResponseType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse)
|
||||
{
|
||||
if(!PyObject_TypeCheck(impulseResponse, &ImpulseResponseType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type ImpulseResponse!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (ImpulseResponseP*)impulseResponse;
|
||||
}
|
||||
|
||||
|
||||
bool initializeImpulseResponse()
|
||||
{
|
||||
return PyType_Ready(&ImpulseResponseType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addImpulseResponseToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&ImpulseResponseType);
|
||||
PyModule_AddObject(module, "ImpulseResponse", (PyObject *)&ImpulseResponseType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyImpulseResponse.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyImpulseResponse.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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 <Python.h>
|
||||
#include "Audaspace.h"
|
||||
|
||||
typedef void Reference_ImpulseResponse;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_ImpulseResponse* impulseResponse;
|
||||
} ImpulseResponseP;
|
||||
|
||||
extern AUD_API PyObject* ImpulseResponse_empty();
|
||||
extern AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse);
|
||||
|
||||
bool initializeImpulseResponse();
|
||||
void addImpulseResponseToModule(PyObject* module);
|
||||
393
blender-5.2.0/extern/audaspace/bindings/python/PyPlaybackManager.cpp
vendored
Normal file
393
blender-5.2.0/extern/audaspace/bindings/python/PyPlaybackManager.cpp
vendored
Normal file
@@ -0,0 +1,393 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PyPlaybackManager.h"
|
||||
#include "PySound.h"
|
||||
#include "PyHandle.h"
|
||||
#include "PyDevice.h"
|
||||
|
||||
#include "Exception.h"
|
||||
#include "fx/PlaybackManager.h"
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
PlaybackManagerP* self = (PlaybackManagerP*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != nullptr)
|
||||
{
|
||||
PyObject* object;
|
||||
if(!PyArg_ParseTuple(args, "O:catKey", &object))
|
||||
return nullptr;
|
||||
Device* device = checkDevice(object);
|
||||
|
||||
try
|
||||
{
|
||||
self->playbackManager = new std::shared_ptr<aud::PlaybackManager>(new aud::PlaybackManager(*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
|
||||
PlaybackManager_dealloc(PlaybackManagerP* self)
|
||||
{
|
||||
if(self->playbackManager)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_play_doc,
|
||||
".. method:: play(sound, catKey)\n\n"
|
||||
" Plays a sound through the playback manager and assigns it to a category.\n\n"
|
||||
" :arg sound: The sound to play.\n"
|
||||
" :type sound: :class:`Sound`\n"
|
||||
" :arg catKey: the key of the category in which the sound will be added,\n"
|
||||
" if it doesn't exist, a new one will be created.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: The playback handle with which playback can be controlled with.\n"
|
||||
" :rtype: :class:`Handle`");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_play(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
PyObject* object;
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "OI:catKey", &object, &cat))
|
||||
return nullptr;
|
||||
|
||||
Sound* sound = checkSound(object);
|
||||
if(!sound)
|
||||
return nullptr;
|
||||
|
||||
Handle* handle;
|
||||
|
||||
handle = (Handle*)Handle_empty();
|
||||
if(handle != nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
handle->handle = new std::shared_ptr<aud::IHandle>((*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->play(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound), cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(handle);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)handle;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_resume_doc,
|
||||
".. method:: resume(catKey)\n\n"
|
||||
" Resumes playback of the catgory.\n\n"
|
||||
" :arg catKey: the key of the category.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: Whether the action succeeded.\n"
|
||||
" :rtype: bool");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_resume(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->resume(cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_pause_doc,
|
||||
".. method:: pause(catKey)\n\n"
|
||||
" Pauses playback of the category.\n\n"
|
||||
" :arg catKey: the key of the category.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: Whether the action succeeded.\n"
|
||||
" :rtype: bool");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_pause(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->pause(cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_add_category_doc,
|
||||
".. method:: addCategory(volume)\n\n"
|
||||
" Adds a category with a custom volume.\n\n"
|
||||
" :arg volume: The volume for ther new category.\n"
|
||||
" :type volume: float\n"
|
||||
" :return: The key of the new category.\n"
|
||||
" :rtype: int\n\n");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_add_category(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
float vol;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "f:volume", &vol))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("I", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->addCategory(vol));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_get_volume_doc,
|
||||
".. method:: getVolume(catKey)\n\n"
|
||||
" Retrieves the volume of a category.\n\n"
|
||||
" :arg catKey: the key of the category.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: The volume of the category.\n"
|
||||
" :rtype: float\n\n");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_get_volume(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->getVolume(cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_set_volume_doc,
|
||||
".. method:: setVolume(volume, catKey)\n\n"
|
||||
" Changes the volume of a category.\n\n"
|
||||
" :arg volume: the new volume value.\n"
|
||||
" :type volume: float\n"
|
||||
" :arg catKey: the key of the category.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: Whether the action succeeded.\n"
|
||||
" :rtype: int\n\n");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_set_volume(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
float volume;
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "fI:volume", &volume, &cat))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->setVolume(volume, cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_stop_doc,
|
||||
".. method:: stop(catKey)\n\n"
|
||||
" Stops playback of the category.\n\n"
|
||||
" :arg catKey: the key of the category.\n"
|
||||
" :type catKey: int\n"
|
||||
" :return: Whether the action succeeded.\n"
|
||||
" :rtype: bool\n\n");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_stop(PlaybackManagerP* self, PyObject* args)
|
||||
{
|
||||
unsigned int cat;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->stop(cat));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_clean_doc,
|
||||
".. method:: clean()\n\n"
|
||||
" Cleans all the invalid and finished sound from the playback manager.\n\n");
|
||||
|
||||
static PyObject *
|
||||
PlaybackManager_clean(PlaybackManagerP* self)
|
||||
{
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->clean();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMethodDef PlaybackManager_methods[] = {
|
||||
{ "play", (PyCFunction)PlaybackManager_play, METH_VARARGS | METH_KEYWORDS,
|
||||
M_aud_PlaybackManager_play_doc
|
||||
},
|
||||
{ "resume", (PyCFunction)PlaybackManager_resume, METH_VARARGS,
|
||||
M_aud_PlaybackManager_resume_doc
|
||||
},
|
||||
{ "pause", (PyCFunction)PlaybackManager_pause, METH_VARARGS,
|
||||
M_aud_PlaybackManager_pause_doc
|
||||
},
|
||||
{ "stop", (PyCFunction)PlaybackManager_stop, METH_VARARGS,
|
||||
M_aud_PlaybackManager_stop_doc
|
||||
},
|
||||
{ "addCategory", (PyCFunction)PlaybackManager_add_category, METH_VARARGS,
|
||||
M_aud_PlaybackManager_add_category_doc
|
||||
},
|
||||
{ "getVolume", (PyCFunction)PlaybackManager_get_volume, METH_VARARGS,
|
||||
M_aud_PlaybackManager_get_volume_doc
|
||||
},
|
||||
{ "setVolume", (PyCFunction)PlaybackManager_set_volume, METH_VARARGS,
|
||||
M_aud_PlaybackManager_set_volume_doc
|
||||
},
|
||||
{ "clean", (PyCFunction)PlaybackManager_clean, METH_NOARGS,
|
||||
M_aud_PlaybackManager_clean_doc
|
||||
},
|
||||
{ nullptr } /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_PlaybackManager_doc,
|
||||
".. class:: PlaybackManager(device, /)\n\n"
|
||||
" A PlaybackManager object allows to easily control groups of sounds organized in categories.\n\n"
|
||||
" :arg device: The device that will be used to play sounds.\n"
|
||||
" :type device: :class:`Device`\n");
|
||||
|
||||
PyTypeObject PlaybackManagerType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.PlaybackManager", /* tp_name */
|
||||
sizeof(PlaybackManagerP), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)PlaybackManager_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_PlaybackManager_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
PlaybackManager_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 */
|
||||
PlaybackManager_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* PlaybackManager_empty()
|
||||
{
|
||||
return PlaybackManagerType.tp_alloc(&PlaybackManagerType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager)
|
||||
{
|
||||
if(!PyObject_TypeCheck(playbackManager, &PlaybackManagerType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type PlaybackManager!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (PlaybackManagerP*)playbackManager;
|
||||
}
|
||||
|
||||
|
||||
bool initializePlaybackManager()
|
||||
{
|
||||
return PyType_Ready(&PlaybackManagerType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addPlaybackManagerToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&PlaybackManagerType);
|
||||
PyModule_AddObject(module, "PlaybackManager", (PyObject *)&PlaybackManagerType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyPlaybackManager.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyPlaybackManager.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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_PlaybackManager;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_PlaybackManager* playbackManager;
|
||||
} PlaybackManagerP;
|
||||
|
||||
extern AUD_API PyObject* PlaybackManager_empty();
|
||||
extern AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager);
|
||||
|
||||
bool initializePlaybackManager();
|
||||
void addPlaybackManagerToModule(PyObject* module);
|
||||
664
blender-5.2.0/extern/audaspace/bindings/python/PySequence.cpp
vendored
Normal file
664
blender-5.2.0/extern/audaspace/bindings/python/PySequence.cpp
vendored
Normal file
@@ -0,0 +1,664 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PySequence.h"
|
||||
|
||||
#include "PySound.h"
|
||||
#include "PySequenceEntry.h"
|
||||
|
||||
#include "sequence/AnimateableProperty.h"
|
||||
#include "sequence/Sequence.h"
|
||||
#include "Exception.h"
|
||||
|
||||
#include <vector>
|
||||
#include <structmember.h>
|
||||
|
||||
using aud::Channels;
|
||||
using aud::DistanceModel;
|
||||
using aud::Exception;
|
||||
using aud::ISound;
|
||||
using aud::AnimateableProperty;
|
||||
using aud::AnimateablePropertyType;
|
||||
using aud::Specs;
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
// ====================================================================
|
||||
|
||||
static void
|
||||
Sequence_dealloc(Sequence* self)
|
||||
{
|
||||
if(self->sequence)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
Sequence_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
Sequence* self;
|
||||
|
||||
int channels = aud::CHANNELS_STEREO;
|
||||
double rate = aud::RATE_48000;
|
||||
float fps = 30.0f;
|
||||
bool muted = false;
|
||||
PyObject* mutedo = nullptr;
|
||||
|
||||
self = (Sequence*)type->tp_alloc(type, 0);
|
||||
if(self != nullptr)
|
||||
{
|
||||
static const char* kwlist[] = {"channels", "rate", "fps", "muted", nullptr};
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|idfO:Sequence", const_cast<char**>(kwlist), &channels, &rate, &fps, &mutedo))
|
||||
{
|
||||
Py_DECREF(self);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(mutedo)
|
||||
{
|
||||
if(!PyBool_Check(mutedo))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
muted = mutedo == Py_True;
|
||||
}
|
||||
|
||||
aud::Specs specs;
|
||||
specs.channels = static_cast<aud::Channels>(channels);
|
||||
specs.rate = rate;
|
||||
|
||||
try
|
||||
{
|
||||
self->sequence = new std::shared_ptr<aud::Sequence>(new aud::Sequence(specs, fps, muted));
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
Py_DECREF(self);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_add_doc,
|
||||
".. method:: add()\n\n"
|
||||
" Adds a new entry to the sequence.\n\n"
|
||||
" :arg sound: The sound this entry should play.\n"
|
||||
" :type sound: :class:`Sound`\n"
|
||||
" :arg begin: The start time.\n"
|
||||
" :type begin: double\n"
|
||||
" :arg end: The end time or a negative value if determined by the sound.\n"
|
||||
" :type end: double\n"
|
||||
" :arg skip: How much seconds should be skipped at the beginning.\n"
|
||||
" :type skip: double\n"
|
||||
" :return: The entry added.\n"
|
||||
" :rtype: :class:`SequenceEntry`");
|
||||
|
||||
static PyObject *
|
||||
Sequence_add(Sequence* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
PyObject* object;
|
||||
double begin;
|
||||
double end = -1.0;
|
||||
double skip = 0.0;
|
||||
|
||||
static const char* kwlist[] = {"sound", "begin", "end", "skip", nullptr};
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "Od|dd:add", const_cast<char**>(kwlist), &object, &begin, &end, &skip))
|
||||
return nullptr;
|
||||
|
||||
Sound* sound = checkSound(object);
|
||||
|
||||
if(!sound)
|
||||
return nullptr;
|
||||
|
||||
SequenceEntry* entry;
|
||||
|
||||
entry = (SequenceEntry*)SequenceEntry_empty();
|
||||
if(entry != nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
entry->entry = new std::shared_ptr<aud::SequenceEntry>((*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->add(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), begin, end, skip));
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
Py_DECREF(entry);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)entry;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_remove_doc,
|
||||
".. method:: remove()\n\n"
|
||||
" Removes an entry from the sequence.\n\n"
|
||||
" :arg entry: The entry to remove.\n"
|
||||
" :type entry: :class:`SequenceEntry`\n");
|
||||
|
||||
static PyObject *
|
||||
Sequence_remove(Sequence* self, PyObject* args)
|
||||
{
|
||||
PyObject* object;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O:remove", &object))
|
||||
return nullptr;
|
||||
|
||||
SequenceEntry* entry = checkSequenceEntry(object);
|
||||
|
||||
if(!entry)
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->remove(*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(entry->entry));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
Py_DECREF(entry);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_setAnimationData_doc,
|
||||
".. method:: setAnimationData()\n\n"
|
||||
" Writes animation data to a sequence.\n\n"
|
||||
" :arg type: The type of animation data.\n"
|
||||
" :type type: int\n"
|
||||
" :arg frame: The frame this data is for.\n"
|
||||
" :type frame: int\n"
|
||||
" :arg data: The data to write.\n"
|
||||
" :type data: sequence of float\n"
|
||||
" :arg animated: Whether the attribute is animated.\n"
|
||||
" :type animated: bool");
|
||||
|
||||
static PyObject *
|
||||
Sequence_setAnimationData(Sequence* self, PyObject* args)
|
||||
{
|
||||
int type, frame;
|
||||
PyObject* py_data;
|
||||
Py_ssize_t py_data_len;
|
||||
PyObject* animatedo;
|
||||
bool animated;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
|
||||
return nullptr;
|
||||
|
||||
if(!PySequence_Check(py_data))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
py_data_len= PySequence_Size(py_data);
|
||||
|
||||
std::vector<float> data;
|
||||
data.reserve(py_data_len);
|
||||
|
||||
PyObject* py_value;
|
||||
float value;
|
||||
|
||||
for(Py_ssize_t i = 0; i < py_data_len; i++)
|
||||
{
|
||||
py_value = PySequence_GetItem(py_data, i);
|
||||
value= (float)PyFloat_AsDouble(py_value);
|
||||
Py_DECREF(py_value);
|
||||
|
||||
if(value == -1.0f && PyErr_Occurred()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
data.push_back(value);
|
||||
}
|
||||
|
||||
if(!PyBool_Check(animatedo))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
animated = animatedo == Py_True;
|
||||
|
||||
try
|
||||
{
|
||||
AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
|
||||
|
||||
if(prop->getCount() != py_data_len)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(animated)
|
||||
{
|
||||
if(frame >= 0)
|
||||
prop->write(&data[0], frame, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop->write(&data[0]);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMethodDef Sequence_methods[] = {
|
||||
{"add", (PyCFunction)Sequence_add, METH_VARARGS | METH_KEYWORDS,
|
||||
M_aud_Sequence_add_doc
|
||||
},
|
||||
{"remove", (PyCFunction)Sequence_remove, METH_VARARGS,
|
||||
M_aud_Sequence_remove_doc
|
||||
},
|
||||
{"setAnimationData", (PyCFunction)Sequence_setAnimationData, METH_VARARGS,
|
||||
M_aud_Sequence_setAnimationData_doc
|
||||
},
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_channels_doc,
|
||||
"The channel count of the sequence.");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_channels(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
|
||||
return Py_BuildValue("i", specs.channels);
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_channels(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
int channels;
|
||||
|
||||
if(!PyArg_Parse(args, "i:channels", &channels))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
|
||||
Specs specs = sequence->getSpecs();
|
||||
specs.channels = static_cast<Channels>(channels);
|
||||
sequence->setSpecs(specs);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_distance_model_doc,
|
||||
"The distance model of the sequence.\n\n"
|
||||
".. seealso:: `OpenAL Documentation <https://www.openal.org/documentation/>`__");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_distance_model(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDistanceModel());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_distance_model(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
int distance_model;
|
||||
|
||||
if(!PyArg_Parse(args, "i:distance_model", &distance_model))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDistanceModel(static_cast<DistanceModel>(distance_model));
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_doppler_factor_doc,
|
||||
"The doppler factor of the sequence.\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 *
|
||||
Sequence_get_doppler_factor(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDopplerFactor());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_doppler_factor(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float factor;
|
||||
|
||||
if(!PyArg_Parse(args, "f:doppler_factor", &factor))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDopplerFactor(factor);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_fps_doc,
|
||||
"The listeners's location in 3D space, a 3D tuple of floats.");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_fps(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getFPS());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_fps(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float fps;
|
||||
|
||||
if(!PyArg_Parse(args, "f:fps", &fps))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setFPS(fps);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_muted_doc,
|
||||
"Whether the whole sequence is muted.\n");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_muted(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
|
||||
return PyBool_FromLong((long)(*sequence)->isMuted());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_muted(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
if(!PyBool_Check(args))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool muted = args == Py_True;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
|
||||
(*sequence)->mute(muted);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_rate_doc,
|
||||
"The sampling rate of the sequence in Hz.");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_rate(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
|
||||
return Py_BuildValue("d", specs.rate);
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_rate(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
double rate;
|
||||
|
||||
if(!PyArg_Parse(args, "d:rate", &rate))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
|
||||
Specs specs = sequence->getSpecs();
|
||||
specs.rate = rate;
|
||||
sequence->setSpecs(specs);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_speed_of_sound_doc,
|
||||
"The speed of sound of the sequence.\n"
|
||||
"The speed of sound in air is typically 343.3 m/s.");
|
||||
|
||||
static PyObject *
|
||||
Sequence_get_speed_of_sound(Sequence* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpeedOfSound());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Sequence_set_speed_of_sound(Sequence* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float speed;
|
||||
|
||||
if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setSpeedOfSound(speed);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef Sequence_properties[] = {
|
||||
{(char*)"channels", (getter)Sequence_get_channels, (setter)Sequence_set_channels,
|
||||
M_aud_Sequence_channels_doc, nullptr },
|
||||
{(char*)"distance_model", (getter)Sequence_get_distance_model, (setter)Sequence_set_distance_model,
|
||||
M_aud_Sequence_distance_model_doc, nullptr },
|
||||
{(char*)"doppler_factor", (getter)Sequence_get_doppler_factor, (setter)Sequence_set_doppler_factor,
|
||||
M_aud_Sequence_doppler_factor_doc, nullptr },
|
||||
{(char*)"fps", (getter)Sequence_get_fps, (setter)Sequence_set_fps,
|
||||
M_aud_Sequence_fps_doc, nullptr },
|
||||
{(char*)"muted", (getter)Sequence_get_muted, (setter)Sequence_set_muted,
|
||||
M_aud_Sequence_muted_doc, nullptr },
|
||||
{(char*)"rate", (getter)Sequence_get_rate, (setter)Sequence_set_rate,
|
||||
M_aud_Sequence_rate_doc, nullptr },
|
||||
{(char*)"speed_of_sound", (getter)Sequence_get_speed_of_sound, (setter)Sequence_set_speed_of_sound,
|
||||
M_aud_Sequence_speed_of_sound_doc, nullptr },
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_Sequence_doc,
|
||||
".. class:: Sequence(channels=2, rate=48000.0, fps=30.0, muted=False)\n\n"
|
||||
" This sound represents sequenced entries to play a sound sequence.\n\n"
|
||||
" :arg channels: The number of channels.\n"
|
||||
" :type channels: int\n"
|
||||
" :arg rate: The sample rate in Hz.\n"
|
||||
" :type rate: double\n"
|
||||
" :arg fps: The frames per second of the sequence.\n"
|
||||
" :type fps: float\n"
|
||||
" :arg muted: Whether the sequence is muted.\n"
|
||||
" :type muted: bool\n");
|
||||
|
||||
extern PyTypeObject SoundType;
|
||||
|
||||
static PyTypeObject SequenceType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.Sequence", /* tp_name */
|
||||
sizeof(Sequence), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)Sequence_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_Sequence_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
Sequence_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
Sequence_properties, /* tp_getset */
|
||||
&SoundType, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
Sequence_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* Sequence_empty()
|
||||
{
|
||||
return SequenceType.tp_alloc(&SequenceType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API Sequence* checkSequence(PyObject* sequence)
|
||||
{
|
||||
if(!PyObject_TypeCheck(sequence, &SequenceType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type Sequence!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (Sequence*)sequence;
|
||||
}
|
||||
|
||||
|
||||
bool initializeSequence()
|
||||
{
|
||||
return PyType_Ready(&SequenceType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addSequenceToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&SequenceType);
|
||||
PyModule_AddObject(module, "Sequence", (PyObject *)&SequenceType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PySequence.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PySequence.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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_Sequence;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_Sequence* sequence;
|
||||
} Sequence;
|
||||
|
||||
extern AUD_API PyObject* Sequence_empty();
|
||||
extern AUD_API Sequence* checkSequence(PyObject* sequence);
|
||||
|
||||
bool initializeSequence();
|
||||
void addSequenceToModule(PyObject* module);
|
||||
740
blender-5.2.0/extern/audaspace/bindings/python/PySequenceEntry.cpp
vendored
Normal file
740
blender-5.2.0/extern/audaspace/bindings/python/PySequenceEntry.cpp
vendored
Normal file
@@ -0,0 +1,740 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PySequenceEntry.h"
|
||||
|
||||
#include "PySound.h"
|
||||
|
||||
#include "Exception.h"
|
||||
#include "sequence/AnimateableProperty.h"
|
||||
#include "sequence/SequenceEntry.h"
|
||||
|
||||
#include <structmember.h>
|
||||
#include <vector>
|
||||
|
||||
using aud::Exception;
|
||||
using aud::AnimateableProperty;
|
||||
using aud::AnimateablePropertyType;
|
||||
using aud::ISound;
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
// ====================================================================
|
||||
|
||||
static void
|
||||
SequenceEntry_dealloc(SequenceEntry* self)
|
||||
{
|
||||
if(self->entry)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_move_doc,
|
||||
".. method:: move()\n\n"
|
||||
" Moves the entry.\n\n"
|
||||
" :arg begin: The new start time.\n"
|
||||
" :type begin: double\n"
|
||||
" :arg end: The new end time or a negative value if unknown.\n"
|
||||
" :type end: double\n"
|
||||
" :arg skip: How many seconds to skip at the beginning.\n"
|
||||
" :type skip: double\n");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_move(SequenceEntry* self, PyObject* args)
|
||||
{
|
||||
double begin, end, skip;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "ddd:move", &begin, &end, &skip))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->move(begin, end, skip);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_setAnimationData_doc,
|
||||
".. method:: setAnimationData()\n\n"
|
||||
" Writes animation data to a sequenced entry.\n\n"
|
||||
" :arg type: The type of animation data.\n"
|
||||
" :type type: int\n"
|
||||
" :arg frame: The frame this data is for.\n"
|
||||
" :type frame: int\n"
|
||||
" :arg data: The data to write.\n"
|
||||
" :type data: sequence of float\n"
|
||||
" :arg animated: Whether the attribute is animated.\n"
|
||||
" :type animated: bool");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_setAnimationData(SequenceEntry* self, PyObject* args)
|
||||
{
|
||||
int type, frame;
|
||||
PyObject* py_data;
|
||||
Py_ssize_t py_data_len;
|
||||
PyObject* animatedo;
|
||||
bool animated;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
|
||||
return nullptr;
|
||||
|
||||
if(!PySequence_Check(py_data))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
py_data_len= PySequence_Size(py_data);
|
||||
|
||||
std::vector<float> data;
|
||||
data.reserve(py_data_len);
|
||||
|
||||
PyObject* py_value;
|
||||
float value;
|
||||
|
||||
for(Py_ssize_t i = 0; i < py_data_len; i++)
|
||||
{
|
||||
py_value = PySequence_GetItem(py_data, i);
|
||||
value= (float)PyFloat_AsDouble(py_value);
|
||||
Py_DECREF(py_value);
|
||||
|
||||
if(value == -1.0f && PyErr_Occurred()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
data.push_back(value);
|
||||
}
|
||||
|
||||
if(!PyBool_Check(animatedo))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
animated = animatedo == Py_True;
|
||||
|
||||
try
|
||||
{
|
||||
AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
|
||||
|
||||
if(prop->getCount() != py_data_len)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(animated)
|
||||
{
|
||||
if(frame >= 0)
|
||||
prop->write(&data[0], frame, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop->write(&data[0]);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMethodDef SequenceEntry_methods[] = {
|
||||
{"move", (PyCFunction)SequenceEntry_move, METH_VARARGS,
|
||||
M_aud_SequenceEntry_move_doc
|
||||
},
|
||||
{"setAnimationData", (PyCFunction)SequenceEntry_setAnimationData, METH_VARARGS,
|
||||
M_aud_SequenceEntry_setAnimationData_doc
|
||||
},
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_attenuation_doc,
|
||||
"This factor is used for distance based attenuation of the "
|
||||
"source.\n\n"
|
||||
".. seealso:: :attr:`Device.distance_model`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_attenuation(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getAttenuation());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_attenuation(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float factor;
|
||||
|
||||
if(!PyArg_Parse(args, "f:attenuation", &factor))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setAttenuation(factor);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_inner_doc,
|
||||
"The opening angle of the inner cone of the source. If the cone "
|
||||
"values of a source are set there are two (audible) cones with "
|
||||
"the apex at the :attr:`location` of the source and with infinite "
|
||||
"height, heading in the direction of the source's "
|
||||
":attr:`orientation`.\n"
|
||||
"In the inner cone the volume is normal. Outside the outer cone "
|
||||
"the volume will be :attr:`cone_volume_outer` and in the area "
|
||||
"between the volume will be interpolated linearly.");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_cone_angle_inner(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getConeAngleInner());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_cone_angle_inner(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float angle;
|
||||
|
||||
if(!PyArg_Parse(args, "f:cone_angle_inner", &angle))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setConeAngleInner(angle);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_outer_doc,
|
||||
"The opening angle of the outer cone of the source.\n\n"
|
||||
".. seealso:: :attr:`cone_angle_inner`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_cone_angle_outer(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getConeAngleOuter());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_cone_angle_outer(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float angle;
|
||||
|
||||
if(!PyArg_Parse(args, "f:cone_angle_outer", &angle))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setConeAngleOuter(angle);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_cone_volume_outer_doc,
|
||||
"The volume outside the outer cone of the source.\n\n"
|
||||
".. seealso:: :attr:`cone_angle_inner`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_cone_volume_outer(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getConeVolumeOuter());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_cone_volume_outer(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float volume;
|
||||
|
||||
if(!PyArg_Parse(args, "f:cone_volume_outer", &volume))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setConeVolumeOuter(volume);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_distance_maximum_doc,
|
||||
"The maximum distance of the source.\n"
|
||||
"If the listener is further away the source volume will be 0.\n\n"
|
||||
".. seealso:: :attr:`Device.distance_model`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_distance_maximum(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getDistanceMaximum());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_distance_maximum(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if(!PyArg_Parse(args, "f:distance_maximum", &distance))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setDistanceMaximum(distance);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_distance_reference_doc,
|
||||
"The reference distance of the source.\n"
|
||||
"At this distance the volume will be exactly :attr:`volume`.\n\n"
|
||||
".. seealso:: :attr:`Device.distance_model`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_distance_reference(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getDistanceReference());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_distance_reference(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if(!PyArg_Parse(args, "f:distance_reference", &distance))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setDistanceReference(distance);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_muted_doc,
|
||||
"Whether the entry is muted.\n");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_muted(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return PyBool_FromLong((long)(*entry)->isMuted());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_muted(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
if(!PyBool_Check(args))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool muted = args == Py_True;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->mute(muted);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_relative_doc,
|
||||
"Whether the source's location, velocity and orientation is relative or absolute to the listener.");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_relative(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return PyBool_FromLong((long)(*entry)->isRelative());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_relative(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
if(!PyBool_Check(args))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Value is not a boolean!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool relative = (args == Py_True);
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setRelative(relative);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_sound_doc,
|
||||
"The sound the entry is representing and will be played in the sequence.");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_sound(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
Sound* object = (Sound*) Sound_empty();
|
||||
if(object)
|
||||
{
|
||||
object->sound = new std::shared_ptr<ISound>((*entry)->getSound());
|
||||
return (PyObject *) object;
|
||||
}
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_sound(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
Sound* sound = checkSound(args);
|
||||
|
||||
if(!sound)
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setSound(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_volume_maximum_doc,
|
||||
"The maximum volume of the source.\n\n"
|
||||
".. seealso:: :attr:`Device.distance_model`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_volume_maximum(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getVolumeMaximum());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_volume_maximum(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float volume;
|
||||
|
||||
if(!PyArg_Parse(args, "f:volume_maximum", &volume))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setVolumeMaximum(volume);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_volume_minimum_doc,
|
||||
"The minimum volume of the source.\n\n"
|
||||
".. seealso:: :attr:`Device.distance_model`");
|
||||
|
||||
static PyObject *
|
||||
SequenceEntry_get_volume_minimum(SequenceEntry* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
return Py_BuildValue("f", (*entry)->getVolumeMinimum());
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SequenceEntry_set_volume_minimum(SequenceEntry* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float volume;
|
||||
|
||||
if(!PyArg_Parse(args, "f:volume_minimum", &volume))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
|
||||
(*entry)->setVolumeMinimum(volume);
|
||||
return 0;
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyGetSetDef SequenceEntry_properties[] = {
|
||||
{(char*)"attenuation", (getter)SequenceEntry_get_attenuation, (setter)SequenceEntry_set_attenuation,
|
||||
M_aud_SequenceEntry_attenuation_doc, nullptr },
|
||||
{(char*)"cone_angle_inner", (getter)SequenceEntry_get_cone_angle_inner, (setter)SequenceEntry_set_cone_angle_inner,
|
||||
M_aud_SequenceEntry_cone_angle_inner_doc, nullptr },
|
||||
{(char*)"cone_angle_outer", (getter)SequenceEntry_get_cone_angle_outer, (setter)SequenceEntry_set_cone_angle_outer,
|
||||
M_aud_SequenceEntry_cone_angle_outer_doc, nullptr },
|
||||
{(char*)"cone_volume_outer", (getter)SequenceEntry_get_cone_volume_outer, (setter)SequenceEntry_set_cone_volume_outer,
|
||||
M_aud_SequenceEntry_cone_volume_outer_doc, nullptr },
|
||||
{(char*)"distance_maximum", (getter)SequenceEntry_get_distance_maximum, (setter)SequenceEntry_set_distance_maximum,
|
||||
M_aud_SequenceEntry_distance_maximum_doc, nullptr },
|
||||
{(char*)"distance_reference", (getter)SequenceEntry_get_distance_reference, (setter)SequenceEntry_set_distance_reference,
|
||||
M_aud_SequenceEntry_distance_reference_doc, nullptr },
|
||||
{(char*)"muted", (getter)SequenceEntry_get_muted, (setter)SequenceEntry_set_muted,
|
||||
M_aud_SequenceEntry_muted_doc, nullptr },
|
||||
{(char*)"relative", (getter)SequenceEntry_get_relative, (setter)SequenceEntry_set_relative,
|
||||
M_aud_SequenceEntry_relative_doc, nullptr },
|
||||
{(char*)"sound", (getter)SequenceEntry_get_sound, (setter)SequenceEntry_set_sound,
|
||||
M_aud_SequenceEntry_sound_doc, nullptr },
|
||||
{(char*)"volume_maximum", (getter)SequenceEntry_get_volume_maximum, (setter)SequenceEntry_set_volume_maximum,
|
||||
M_aud_SequenceEntry_volume_maximum_doc, nullptr },
|
||||
{(char*)"volume_minimum", (getter)SequenceEntry_get_volume_minimum, (setter)SequenceEntry_set_volume_minimum,
|
||||
M_aud_SequenceEntry_volume_minimum_doc, nullptr },
|
||||
{nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_SequenceEntry_doc,
|
||||
"SequenceEntry objects represent an entry of a sequenced sound.");
|
||||
|
||||
static PyTypeObject SequenceEntryType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.SequenceEntry", /* tp_name */
|
||||
sizeof(SequenceEntry), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)SequenceEntry_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_SequenceEntry_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
SequenceEntry_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
SequenceEntry_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 */
|
||||
0, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* SequenceEntry_empty()
|
||||
{
|
||||
return SequenceEntryType.tp_alloc(&SequenceEntryType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry)
|
||||
{
|
||||
if(!PyObject_TypeCheck(entry, &SequenceEntryType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type SequenceEntry!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (SequenceEntry*)entry;
|
||||
}
|
||||
|
||||
|
||||
bool initializeSequenceEntry()
|
||||
{
|
||||
return PyType_Ready(&SequenceEntryType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addSequenceEntryToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&SequenceEntryType);
|
||||
PyModule_AddObject(module, "SequenceEntry", (PyObject *)&SequenceEntryType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PySequenceEntry.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PySequenceEntry.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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_SequenceEntry;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_SequenceEntry* entry;
|
||||
} SequenceEntry;
|
||||
|
||||
extern AUD_API PyObject* SequenceEntry_empty();
|
||||
extern AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry);
|
||||
|
||||
bool initializeSequenceEntry();
|
||||
void addSequenceEntryToModule(PyObject* module);
|
||||
2260
blender-5.2.0/extern/audaspace/bindings/python/PySound.cpp
vendored
Normal file
2260
blender-5.2.0/extern/audaspace/bindings/python/PySound.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
33
blender-5.2.0/extern/audaspace/bindings/python/PySound.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PySound.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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_ISound;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_ISound* sound;
|
||||
} Sound;
|
||||
|
||||
extern AUD_API PyObject* Sound_empty();
|
||||
extern AUD_API Sound* checkSound(PyObject* sound);
|
||||
|
||||
bool initializeSound();
|
||||
void addSoundToModule(PyObject* module);
|
||||
267
blender-5.2.0/extern/audaspace/bindings/python/PySource.cpp
vendored
Normal file
267
blender-5.2.0/extern/audaspace/bindings/python/PySource.cpp
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PySource.h"
|
||||
|
||||
#include "Exception.h"
|
||||
#include "fx/Source.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
static PyObject *
|
||||
Source_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
SourceP* self = (SourceP*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != nullptr)
|
||||
{
|
||||
float azimuth, elevation, distance;
|
||||
if(!PyArg_ParseTuple(args, "fff:angles", &azimuth, &elevation, &distance))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
self->source = new std::shared_ptr<aud::Source>(new aud::Source(azimuth, elevation, distance));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(self);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static void
|
||||
Source_dealloc(SourceP* self)
|
||||
{
|
||||
if(self->source)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyMethodDef Source_methods[] = {
|
||||
{ nullptr } /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_Source_azimuth_doc,
|
||||
"The azimuth angle.");
|
||||
|
||||
static int
|
||||
Source_set_azimuth(SourceP* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float azimuth;
|
||||
|
||||
if(!PyArg_Parse(args, "f:azimuth", &azimuth))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setAzimuth(azimuth);
|
||||
return 0;
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
Source_get_azimuth(SourceP* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getAzimuth());
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Source_elevation_doc,
|
||||
"The elevation angle.");
|
||||
|
||||
static int
|
||||
Source_set_elevation(SourceP* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float elevation;
|
||||
|
||||
if(!PyArg_Parse(args, "f:elevation", &elevation))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setElevation(elevation);
|
||||
return 0;
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
Source_get_elevation(SourceP* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getElevation());
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Source_distance_doc,
|
||||
"The distance value. 0 is min, 1 is max.");
|
||||
|
||||
static int
|
||||
Source_set_distance(SourceP* self, PyObject* args, void* nothing)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if(!PyArg_Parse(args, "f:distance", &distance))
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setDistance(distance);
|
||||
return 0;
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
Source_get_distance(SourceP* self, void* nothing)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getDistance());
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static PyGetSetDef Source_properties[] = {
|
||||
{ (char*)"azimuth", (getter)Source_get_azimuth, (setter)Source_set_azimuth,
|
||||
M_aud_Source_azimuth_doc, nullptr },
|
||||
{ (char*)"elevation", (getter)Source_get_elevation, (setter)Source_set_elevation,
|
||||
M_aud_Source_elevation_doc, nullptr },
|
||||
{ (char*)"distance", (getter)Source_get_distance, (setter)Source_set_distance,
|
||||
M_aud_Source_distance_doc, nullptr },
|
||||
{ nullptr } /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_Source_doc,
|
||||
".. class:: Source(azimuth, elevation, distance, /)\n\n"
|
||||
" The source object represents the source position of a binaural sound.\n\n"
|
||||
" :arg azimuth: The azimuth angle in degrees.\n"
|
||||
" :type azimuth: float\n"
|
||||
" :arg elevation: The elevation angle in degrees.\n"
|
||||
" :type elevation: float\n"
|
||||
" :arg distance: The distance of the source.\n"
|
||||
" :type distance: float\n");
|
||||
|
||||
PyTypeObject SourceType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.Source", /* tp_name */
|
||||
sizeof(SourceP), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)Source_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_Source_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
Source_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
Source_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 */
|
||||
Source_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* Source_empty()
|
||||
{
|
||||
return SourceType.tp_alloc(&SourceType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API SourceP* checkSource(PyObject* source)
|
||||
{
|
||||
if(!PyObject_TypeCheck(source, &SourceType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type Source!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (SourceP*)source;
|
||||
}
|
||||
|
||||
|
||||
bool initializeSource()
|
||||
{
|
||||
return PyType_Ready(&SourceType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addSourceToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&SourceType);
|
||||
PyModule_AddObject(module, "Source", (PyObject *)&SourceType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PySource.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PySource.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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 <Python.h>
|
||||
#include "Audaspace.h"
|
||||
|
||||
typedef void Reference_Source;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_Source* source;
|
||||
} SourceP;
|
||||
|
||||
extern AUD_API PyObject* Source_empty();
|
||||
extern AUD_API SourceP* checkSource(PyObject* source);
|
||||
|
||||
bool initializeSource();
|
||||
void addSourceToModule(PyObject* module);
|
||||
137
blender-5.2.0/extern/audaspace/bindings/python/PyThreadPool.cpp
vendored
Normal file
137
blender-5.2.0/extern/audaspace/bindings/python/PyThreadPool.cpp
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/*******************************************************************************
|
||||
* 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 "PyThreadPool.h"
|
||||
|
||||
#include "Exception.h"
|
||||
#include "util/ThreadPool.h"
|
||||
|
||||
extern PyObject* AUDError;
|
||||
|
||||
static PyObject *
|
||||
ThreadPool_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ThreadPoolP* self = (ThreadPoolP*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != nullptr)
|
||||
{
|
||||
unsigned int nThreads;
|
||||
if(!PyArg_ParseTuple(args, "I:nThreads", &nThreads))
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
self->threadPool = new std::shared_ptr<aud::ThreadPool>(new aud::ThreadPool(nThreads));
|
||||
}
|
||||
catch(aud::Exception& e)
|
||||
{
|
||||
Py_DECREF(self);
|
||||
PyErr_SetString(AUDError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static void
|
||||
ThreadPool_dealloc(ThreadPoolP* self)
|
||||
{
|
||||
if(self->threadPool)
|
||||
delete reinterpret_cast<std::shared_ptr<aud::ThreadPool>*>(self->threadPool);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyMethodDef ThreadPool_methods[] = {
|
||||
{ nullptr } /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(M_aud_ThreadPool_doc,
|
||||
".. class:: ThreadPool(nThreads, /)\n\n"
|
||||
" A ThreadPool is used to parallelize convolution efficiently.\n\n"
|
||||
" :arg nThreads: The number of threads in the pool.\n"
|
||||
" :type nThreads: int\n");
|
||||
|
||||
PyTypeObject ThreadPoolType = {
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
"aud.ThreadPool", /* tp_name */
|
||||
sizeof(ThreadPoolP), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)ThreadPool_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_ThreadPool_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
ThreadPool_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 */
|
||||
ThreadPool_new, /* tp_new */
|
||||
};
|
||||
|
||||
AUD_API PyObject* ThreadPool_empty()
|
||||
{
|
||||
return ThreadPoolType.tp_alloc(&ThreadPoolType, 0);
|
||||
}
|
||||
|
||||
|
||||
AUD_API ThreadPoolP* checkThreadPool(PyObject* threadPool)
|
||||
{
|
||||
if(!PyObject_TypeCheck(threadPool, &ThreadPoolType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Object is not of type ThreadPool!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (ThreadPoolP*)threadPool;
|
||||
}
|
||||
|
||||
|
||||
bool initializeThreadPool()
|
||||
{
|
||||
return PyType_Ready(&ThreadPoolType) >= 0;
|
||||
}
|
||||
|
||||
|
||||
void addThreadPoolToModule(PyObject* module)
|
||||
{
|
||||
Py_INCREF(&ThreadPoolType);
|
||||
PyModule_AddObject(module, "ThreadPool", (PyObject *)&ThreadPoolType);
|
||||
}
|
||||
33
blender-5.2.0/extern/audaspace/bindings/python/PyThreadPool.h
vendored
Normal file
33
blender-5.2.0/extern/audaspace/bindings/python/PyThreadPool.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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 <Python.h>
|
||||
#include "Audaspace.h"
|
||||
|
||||
typedef void Reference_ThreadPool;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Reference_ThreadPool* threadPool;
|
||||
} ThreadPoolP;
|
||||
|
||||
extern AUD_API PyObject* ThreadPool_empty();
|
||||
extern AUD_API ThreadPoolP* checkThreadPool(PyObject* ThreadPool);
|
||||
|
||||
bool initializeThreadPool();
|
||||
void addThreadPoolToModule(PyObject* module);
|
||||
13
blender-5.2.0/extern/audaspace/bindings/python/examples/binaural.py
vendored
Normal file
13
blender-5.2.0/extern/audaspace/bindings/python/examples/binaural.py
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
import aud, sys, time, multiprocessing
|
||||
device = aud.Device()
|
||||
hrtf = aud.HRTF().loadLeftHrtfSet(".wav", sys.argv[2])
|
||||
threadPool = aud.ThreadPool(multiprocessing.cpu_count())
|
||||
source = aud.Source(0, 0, 0)
|
||||
sound = aud.Sound.file(sys.argv[1]).rechannel(1).binaural(hrtf, source, threadPool)
|
||||
handle = device.play(sound)
|
||||
|
||||
while handle.status:
|
||||
source.azimuth += 1
|
||||
print("Azimuth: " + str(source.azimuth))
|
||||
time.sleep(0.1)
|
||||
10
blender-5.2.0/extern/audaspace/bindings/python/examples/convolution.py
vendored
Normal file
10
blender-5.2.0/extern/audaspace/bindings/python/examples/convolution.py
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/python
|
||||
import aud, sys, time, multiprocessing
|
||||
device = aud.Device()
|
||||
ir = aud.ImpulseResponse(aud.Sound.file(sys.argv[2]))
|
||||
threadPool = aud.ThreadPool(multiprocessing.cpu_count())
|
||||
sound = aud.Sound.file(sys.argv[1]).convolver(ir, threadPool)
|
||||
handle = device.play(sound)
|
||||
handle.volume = 0.1
|
||||
while handle.status:
|
||||
time.sleep(0.1)
|
||||
20
blender-5.2.0/extern/audaspace/bindings/python/examples/dynamicmusic.py
vendored
Normal file
20
blender-5.2.0/extern/audaspace/bindings/python/examples/dynamicmusic.py
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import aud, sys, time
|
||||
|
||||
device=aud.Device()
|
||||
dMusic = aud.DynamicMusic(device)
|
||||
sound1 = aud.Sound.file(sys.argv[1])
|
||||
sound2 = aud.Sound.file(sys.argv[2])
|
||||
effect = aud.Sound.file(sys.argv[3])
|
||||
|
||||
dMusic.addScene(sound1)
|
||||
dMusic.addScene(sound2)
|
||||
dMusic.addTransition(1,2,effect)
|
||||
|
||||
dMusic.fadeTime=3
|
||||
dMusic.volume=0.5
|
||||
|
||||
dMusic.scene=1
|
||||
time.sleep(5)
|
||||
dMusic.scene=2
|
||||
|
||||
time.sleep(500)
|
||||
27
blender-5.2.0/extern/audaspace/bindings/python/examples/playbackmanager.py
vendored
Normal file
27
blender-5.2.0/extern/audaspace/bindings/python/examples/playbackmanager.py
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import aud, sys, time
|
||||
|
||||
device=aud.Device()
|
||||
manager = aud.PlaybackManager(device)
|
||||
sound1 = aud.Sound.file(sys.argv[1])
|
||||
sound2 = aud.Sound.file(sys.argv[2])
|
||||
sound3 = aud.Sound.file(sys.argv[3])
|
||||
sound4 = aud.Sound.file(sys.argv[4])
|
||||
|
||||
manager.play(sound1, 0)
|
||||
manager.play(sound2, 0)
|
||||
manager.play(sound3, 1)
|
||||
manager.play(sound4, 1)
|
||||
|
||||
manager.setVolume(0.2, 0)
|
||||
time.sleep(5)
|
||||
manager.setVolume(0.0, 1)
|
||||
time.sleep(5)
|
||||
manager.pause(0)
|
||||
time.sleep(5)
|
||||
manager.setVolume(0.5, 1)
|
||||
manager.setVolume(1.0, 0)
|
||||
time.sleep(5)
|
||||
manager.stop(1)
|
||||
manager.resume(0)
|
||||
|
||||
time.sleep(500)
|
||||
7
blender-5.2.0/extern/audaspace/bindings/python/examples/player.py
vendored
Normal file
7
blender-5.2.0/extern/audaspace/bindings/python/examples/player.py
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
import aud, sys, time
|
||||
device = aud.Device()
|
||||
sound = aud.Sound.file(sys.argv[1])
|
||||
handle = device.play(sound)
|
||||
while handle.status:
|
||||
time.sleep(0.1)
|
||||
21
blender-5.2.0/extern/audaspace/bindings/python/examples/randomSounds.py
vendored
Normal file
21
blender-5.2.0/extern/audaspace/bindings/python/examples/randomSounds.py
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import aud, sys, time
|
||||
|
||||
device=aud.Device()
|
||||
sound1 = aud.Sound.file(sys.argv[1])
|
||||
sound2 = aud.Sound.file(sys.argv[2])
|
||||
sound3 = aud.Sound.file(sys.argv[3])
|
||||
sound4 = aud.Sound.file(sys.argv[4])
|
||||
list=aud.Sound.list(True)
|
||||
|
||||
list.addSound(sound1)
|
||||
list.addSound(sound2)
|
||||
list.addSound(sound3)
|
||||
list.addSound(sound4)
|
||||
mutable=aud.Sound.mutable(list)
|
||||
|
||||
device.lock()
|
||||
handle=device.play(mutable)
|
||||
handle.loop_count=2
|
||||
device.unlock()
|
||||
|
||||
time.sleep(500)
|
||||
7
blender-5.2.0/extern/audaspace/bindings/python/examples/simple.py
vendored
Normal file
7
blender-5.2.0/extern/audaspace/bindings/python/examples/simple.py
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
import aud, time
|
||||
device = aud.Device()
|
||||
sine = aud.Sound.sine(440)
|
||||
square = sine.threshold()
|
||||
handle = device.play(square)
|
||||
time.sleep(3)
|
||||
19
blender-5.2.0/extern/audaspace/bindings/python/examples/siren.py
vendored
Normal file
19
blender-5.2.0/extern/audaspace/bindings/python/examples/siren.py
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
import aud, math, time
|
||||
length = 0.5
|
||||
fadelength = 0.05
|
||||
|
||||
device = aud.Device()
|
||||
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)
|
||||
sound = high.join(low)
|
||||
handle = device.play(sound)
|
||||
handle.loop_count = -1
|
||||
|
||||
start = time.time()
|
||||
|
||||
while time.time() - start < 10:
|
||||
angle = time.time() - start
|
||||
|
||||
handle.location = [math.sin(angle), 0, -math.cos(angle)]
|
||||
|
||||
23
blender-5.2.0/extern/audaspace/bindings/python/examples/siren2.py
vendored
Normal file
23
blender-5.2.0/extern/audaspace/bindings/python/examples/siren2.py
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
import aud, math, time
|
||||
length = 0.5
|
||||
fadelength = 0.05
|
||||
runtime = 10
|
||||
distance = 100
|
||||
velocity = 2 * distance / runtime
|
||||
|
||||
device = aud.Device()
|
||||
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)
|
||||
sound = high.join(low)
|
||||
handle = device.play(sound)
|
||||
handle.loop_count = -1
|
||||
|
||||
handle.velocity = [velocity, 0, 0]
|
||||
|
||||
start = time.time()
|
||||
|
||||
while time.time() - start < runtime:
|
||||
location = -distance + velocity * (time.time() - start)
|
||||
|
||||
handle.location = [location, 10, 0]
|
||||
66
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris.py
vendored
Normal file
66
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris.py
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/python
|
||||
import aud, math, time
|
||||
|
||||
def parseNotes(notes, bpm, basefreq, rate = 44100,
|
||||
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
|
||||
pos = 0
|
||||
fadelength = 60/bpm/10
|
||||
halfchars = "#b"
|
||||
durationchars = "2345678"
|
||||
sound = None
|
||||
|
||||
while pos < len(notes):
|
||||
char = notes[pos]
|
||||
mod = None
|
||||
dur = 1
|
||||
pos += 1
|
||||
while pos < len(notes) and notes[pos] not in notechars:
|
||||
if notes[pos] in halfchars:
|
||||
mod = notes[pos]
|
||||
elif notes[pos] in durationchars:
|
||||
dur = notes[pos]
|
||||
pos += 1
|
||||
|
||||
freq = notechars.find(char)
|
||||
if mod == '#':
|
||||
freq += 1
|
||||
elif mod == 'b':
|
||||
freq -= 1
|
||||
|
||||
freq = math.pow(2, freq/12)*basefreq
|
||||
length = float(dur)*60/bpm
|
||||
|
||||
snd = aud.Sound.square(freq, rate)
|
||||
if char == 'p':
|
||||
snd = snd.volume(0)
|
||||
snd = snd.limit(0, length)
|
||||
snd = snd.fadein(0, fadelength)
|
||||
snd = snd.fadeout(length - fadelength, fadelength)
|
||||
|
||||
if sound:
|
||||
sound = sound.join(snd)
|
||||
else:
|
||||
sound = snd
|
||||
return sound
|
||||
|
||||
def tetris(bpm = 300, freq = 220, rate = 44100):
|
||||
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
|
||||
s11 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
|
||||
s12 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
|
||||
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
|
||||
|
||||
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
|
||||
s22 = parseNotes(notes, bpm, freq/2, rate)
|
||||
|
||||
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
|
||||
|
||||
if __name__ == "__main__":
|
||||
dev = aud.Device()
|
||||
handle = dev.play(tetris(300, 220, dev.rate))
|
||||
while handle.status:
|
||||
time.sleep(0.1)
|
||||
|
||||
64
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris2.py
vendored
Normal file
64
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris2.py
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/python
|
||||
import aud, math, time
|
||||
|
||||
def parseNotes(notes, bpm, basefreq, rate = 44100,
|
||||
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
|
||||
pos = 0
|
||||
fadelength = 60/bpm/10
|
||||
halfchars = "#b"
|
||||
durationchars = "2345678"
|
||||
position = 0
|
||||
sequence = aud.Sequence()
|
||||
|
||||
while pos < len(notes):
|
||||
char = notes[pos]
|
||||
mod = None
|
||||
dur = 1
|
||||
pos += 1
|
||||
while pos < len(notes) and notes[pos] not in notechars:
|
||||
if notes[pos] in halfchars:
|
||||
mod = notes[pos]
|
||||
elif notes[pos] in durationchars:
|
||||
dur = notes[pos]
|
||||
pos += 1
|
||||
|
||||
freq = notechars.find(char)
|
||||
if mod == '#':
|
||||
freq += 1
|
||||
elif mod == 'b':
|
||||
freq -= 1
|
||||
|
||||
freq = math.pow(2, freq/12)*basefreq
|
||||
length = float(dur)*60/bpm
|
||||
|
||||
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
|
||||
|
||||
entry = sequence.add(note, position, position + length, 0)
|
||||
if char == 'p':
|
||||
entry.muted = True
|
||||
|
||||
position += length
|
||||
|
||||
return sequence.limit(0, position)
|
||||
|
||||
def tetris(bpm = 300, freq = 220, rate = 44100):
|
||||
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
|
||||
s11 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
|
||||
s12 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
|
||||
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
|
||||
|
||||
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
|
||||
s22 = parseNotes(notes, bpm, freq/2, rate)
|
||||
|
||||
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
|
||||
|
||||
if __name__ == "__main__":
|
||||
dev = aud.Device()
|
||||
handle = dev.play(tetris(300, 220, dev.rate))
|
||||
while handle.status:
|
||||
time.sleep(0.1)
|
||||
|
||||
63
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris3.py
vendored
Normal file
63
blender-5.2.0/extern/audaspace/bindings/python/examples/tetris3.py
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python
|
||||
import aud, math, time
|
||||
|
||||
def parseNotes(notes, bpm, basefreq, rate = 44100,
|
||||
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
|
||||
pos = 0
|
||||
fadelength = 60/bpm/10
|
||||
halfchars = "#b"
|
||||
durationchars = "2345678"
|
||||
position = 0
|
||||
sequence = aud.Sequence()
|
||||
|
||||
while pos < len(notes):
|
||||
char = notes[pos]
|
||||
mod = None
|
||||
dur = 1
|
||||
pos += 1
|
||||
while pos < len(notes) and notes[pos] not in notechars:
|
||||
if notes[pos] in halfchars:
|
||||
mod = notes[pos]
|
||||
elif notes[pos] in durationchars:
|
||||
dur = notes[pos]
|
||||
pos += 1
|
||||
|
||||
freq = notechars.find(char)
|
||||
if mod == '#':
|
||||
freq += 1
|
||||
elif mod == 'b':
|
||||
freq -= 1
|
||||
|
||||
freq = math.pow(2, freq/12)*basefreq
|
||||
length = float(dur)*60/bpm
|
||||
|
||||
if char != 'p':
|
||||
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
|
||||
|
||||
sequence.add(note, position, position + length, 0)
|
||||
|
||||
position += length
|
||||
|
||||
return sequence.limit(0, position)
|
||||
|
||||
def tetris(bpm = 300, freq = 220, rate = 44100):
|
||||
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
|
||||
s11 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
|
||||
s12 = parseNotes(notes, bpm, freq, rate)
|
||||
|
||||
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
|
||||
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
|
||||
|
||||
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
|
||||
s22 = parseNotes(notes, bpm, freq/2, rate)
|
||||
|
||||
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
|
||||
|
||||
if __name__ == "__main__":
|
||||
dev = aud.Device()
|
||||
handle = dev.play(tetris(300, 220, dev.rate))
|
||||
while handle.status:
|
||||
time.sleep(0.1)
|
||||
|
||||
70
blender-5.2.0/extern/audaspace/bindings/python/setup.py.in
vendored
Normal file
70
blender-5.2.0/extern/audaspace/bindings/python/setup.py.in
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import codecs
|
||||
import numpy
|
||||
|
||||
from setuptools import setup, Extension
|
||||
|
||||
if len(sys.argv) > 2 and sys.argv[1] == '--build-docs':
|
||||
import subprocess
|
||||
from setuptools import Distribution
|
||||
from setuptools.command.build import build
|
||||
|
||||
dist = Distribution()
|
||||
cmd = build(dist)
|
||||
cmd.finalize_options()
|
||||
#print(cmd.build_platlib)
|
||||
|
||||
os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), cmd.build_platlib)
|
||||
os.environ['LD_LIBRARY_PATH'] = os.getcwd()
|
||||
|
||||
ret = subprocess.call(sys.argv[2:])
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
# the following line is not working due to https://bugs.python.org/issue9023
|
||||
#source_directory = os.path.relpath('@PYTHON_SOURCE_DIRECTORY@')
|
||||
source_directory = '@PYTHON_SOURCE_DIRECTORY@'
|
||||
|
||||
extra_args = []
|
||||
|
||||
if sys.platform == 'win32':
|
||||
extra_args.append('/EHsc')
|
||||
extra_args.append('/DAUD_BUILD_SHARED_LIBRARY')
|
||||
else:
|
||||
extra_args.append('-std=c++17')
|
||||
|
||||
macros = []
|
||||
|
||||
if '@WITH_FFTW@' == 'ON':
|
||||
macros.append(('WITH_CONVOLUTION', None))
|
||||
|
||||
if '@WITH_RUBBERBAND@' == 'ON':
|
||||
macros.append(('WITH_RUBBERBAND', None))
|
||||
|
||||
audaspace = Extension(
|
||||
'aud',
|
||||
include_dirs = ['@CMAKE_CURRENT_BINARY_DIR@', os.path.join(source_directory, '../../include'), numpy.get_include()] + (['@FFTW_INCLUDE_DIR@'] if '@WITH_FFTW@' == 'ON' else []),
|
||||
libraries = ['audaspace'],
|
||||
library_dirs = ['.', 'Release', 'Debug'],
|
||||
language = 'c++',
|
||||
extra_compile_args = extra_args,
|
||||
define_macros = macros,
|
||||
sources = [os.path.join(source_directory, file) for file in ['PyAnimateableProperty.cpp', 'PyAPI.cpp', 'PyDevice.cpp', 'PyHandle.cpp', 'PySound.cpp', 'PySequenceEntry.cpp', 'PySequence.cpp', 'PyPlaybackManager.cpp', 'PyDynamicMusic.cpp', 'PyThreadPool.cpp', 'PySource.cpp'] + (['PyImpulseResponse.cpp', 'PyHRTF.cpp'] if '@WITH_FFTW@' == 'ON' else [])]
|
||||
)
|
||||
|
||||
setup(
|
||||
name = 'audaspace',
|
||||
version = '@AUDASPACE_LONG_VERSION@',
|
||||
description = 'Audaspace is a high level audio library.',
|
||||
author = 'Jörg Müller',
|
||||
author_email = 'nexyon@gmail.com',
|
||||
url = 'https://github.com/audaspace/audaspace',
|
||||
license = 'Apache License 2.0',
|
||||
long_description = codecs.open(os.path.join(source_directory, '../../README.md'), 'r', 'utf-8').read(),
|
||||
ext_modules = [audaspace],
|
||||
headers = [os.path.join(source_directory, file) for file in ['PyAnimateableProperty.h', 'PyAPI.h', 'PyDevice.h', 'PyHandle.h', 'PySound.h', 'PySequenceEntry.h', 'PySequence.h', 'PyPlaybackManager.h', 'PyDynamicMusic.h', 'PyThreadPool.h', 'PySource.h'] + (['PyImpulseResponse.h', 'PyHRTF.h'] if '@WITH_FFTW@' == 'ON' else [])] + ['Audaspace.h']
|
||||
)
|
||||
|
||||
48
blender-5.2.0/extern/audaspace/blender_config.cmake
vendored
Normal file
48
blender-5.2.0/extern/audaspace/blender_config.cmake
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# Do NOT use CACHE behavior here, as this has the same effect as defining an option,
|
||||
# it exposes the setting in main CMake config (which we do not want here).
|
||||
|
||||
set(AUDASPACE_STANDALONE FALSE)
|
||||
set(BUILD_DEMOS FALSE) # "Build and install demos"
|
||||
set(SHARED_LIBRARY FALSE) # "Build Shared Library"
|
||||
set(WITH_C FALSE) # "Build C Module"
|
||||
set(WITH_DOCS FALSE) # "Build C++ HTML Documentation with Doxygen"
|
||||
set(WITH_FFMPEG ${WITH_CODEC_FFMPEG}) # "Build With FFMPEG"
|
||||
if(DEFINED WITH_FFTW3 AND WITH_FFTW3) # "Build With FFTW"
|
||||
set(FFTW_FOUND TRUE)
|
||||
set(WITH_FFTW ${WITH_FFTW3})
|
||||
set(FFTW_INCLUDE_DIR ${FFTW3_INCLUDE_DIRS})
|
||||
set(FFTW_LIBRARY ${FFTW3_LIBRARIES})
|
||||
endif()
|
||||
set(WITH_LIBSNDFILE ${WITH_CODEC_SNDFILE}) # "Build With LibSndFile"
|
||||
set(WITH_RUBBERBAND ${WITH_RUBBERBAND}) # "Build With Rubber Band Library"
|
||||
set(SEPARATE_C FALSE) # "Build C Binding as separate library"
|
||||
set(PLUGIN_COREAUDIO FALSE) # "Build CoreAudio Plugin"
|
||||
set(PLUGIN_FFMPEG FALSE) # "Build FFMPEG Plugin"
|
||||
set(PLUGIN_JACK FALSE) # "Build JACK Plugin"
|
||||
set(PLUGIN_LIBSNDFILE FALSE) # "Build LibSndFile Plugin"
|
||||
set(PLUGIN_OPENAL FALSE) # "Build OpenAL Plugin"
|
||||
set(PLUGIN_PIPEWIRE FALSE) # "Build PipeWire Plugin"
|
||||
set(PLUGIN_PULSEAUDIO FALSE) # "Build PulseAudio Plugin"
|
||||
set(PLUGIN_SDL FALSE) # "Build SDL Plugin"
|
||||
set(PLUGIN_WASAPI FALSE) # "Build WASAPI Plugin"
|
||||
set(WITH_PYTHON_MODULE FALSE) # "Build Python Module"
|
||||
set(DYNLOAD_JACK ${WITH_JACK_DYNLOAD}) # "Dynamically load JACK"
|
||||
set(DYNLOAD_PULSEAUDIO ${WITH_PULSEAUDIO_DYNLOAD}) # "Dynamically load PulseAudio"
|
||||
set(DYNLOAD_PIPEWIRE ${WITH_PIPEWIRE_DYNLOAD}) # "Dynamically load PipeWire"
|
||||
set(WITH_BINDING_DOCS FALSE) # "Build C/Python HTML Documentation with Sphinx"
|
||||
set(DEFAULT_PLUGIN_PATH "plugins") # "Default plugin installation and loading path."
|
||||
set(FFMPEG_FOUND ${WITH_CODEC_FFMPEG})
|
||||
set(JACK_FOUND ${WITH_JACK})
|
||||
set(LIBSNDFILE_FOUND ${WITH_CODEC_SNDFILE})
|
||||
set(OPENAL_FOUND ${WITH_OPENAL})
|
||||
set(LIBPULSE_FOUND ${WITH_PULSEAUDIO})
|
||||
set(PYTHONLIBS_FOUND TRUE)
|
||||
set(NUMPY_FOUND ${WITH_PYTHON_NUMPY})
|
||||
set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS})
|
||||
|
||||
set(SDL_FOUND ${WITH_SDL_AUDIO})
|
||||
if(SDL_FOUND)
|
||||
set(USE_SDL3 TRUE)
|
||||
set(SDL_LIBRARY bf::dependencies::optional::sdl)
|
||||
get_target_property(SDL_INCLUDE_DIR SDL3::Headers INTERFACE_INCLUDE_DIRECTORIES)
|
||||
endif()
|
||||
131
blender-5.2.0/extern/audaspace/config/Audaspace.h.in
vendored
Normal file
131
blender-5.2.0/extern/audaspace/config/Audaspace.h.in
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file Audaspace.h
|
||||
* @ingroup general
|
||||
* The main header file of the library defining the namespace and basic data types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def AUD_API
|
||||
* Used for exporting symbols in the shared library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def AUD_PLUGIN_API
|
||||
* Used for exporting symbols in the shared library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def AUD_EXPORT_API
|
||||
* Used for using exporting symbols of the shared library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def AUD_USE_API
|
||||
* Used for using exporting symbols of the shared library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def AUD_LOCAL
|
||||
* Used for hiding symbols from export in the shared library.
|
||||
*/
|
||||
|
||||
// the following two defines and undefines are a hack to silence an error by doxygen
|
||||
|
||||
/**
|
||||
* \def AUD_SHARED_LIBRARY
|
||||
* Defined when audaspace was built as a shared library.
|
||||
*/
|
||||
#define AUD_SHARED_LIBRARY
|
||||
#undef AUD_SHARED_LIBRARY
|
||||
|
||||
/**
|
||||
* \def AUD_STATIC_LIBRARY
|
||||
* Defined when audaspace was built as a static library.
|
||||
*/
|
||||
#define AUD_STATIC_LIBRARY
|
||||
#undef AUD_STATIC_LIBRARY
|
||||
|
||||
#define @AUD_LIBRARY_TYPE@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define AUD_EXPORT_API __declspec(dllexport)
|
||||
#define AUD_USE_API __declspec(dllimport)
|
||||
#define AUD_LOCAL
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define AUD_EXPORT_API __attribute__((visibility ("default")))
|
||||
#define AUD_USE_API AUD_EXPORT_API
|
||||
#define AUD_LOCAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
#define AUD_EXPORT_API
|
||||
#define AUD_USE_API
|
||||
#define AUD_LOCAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef AUD_SHARED_LIBRARY
|
||||
#ifdef AUD_BUILD_PLUGIN
|
||||
#define AUD_API AUD_USE_API
|
||||
#define AUD_PLUGIN_API AUD_EXPORT_API
|
||||
#else
|
||||
#ifdef AUD_BUILD_SHARED_LIBRARY
|
||||
#define AUD_API AUD_EXPORT_API
|
||||
#define AUD_PLUGIN_API AUD_EXPORT_API
|
||||
#else
|
||||
#define AUD_API AUD_USE_API
|
||||
#define AUD_PLUGIN_API AUD_USE_API
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define AUD_API
|
||||
#define AUD_PLUGIN_API
|
||||
#endif
|
||||
|
||||
/// The default playback buffer size of a device.
|
||||
#define AUD_DEFAULT_BUFFER_SIZE 1024
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/// Opens the audaspace namespace aud.
|
||||
#define AUD_NAMESPACE_BEGIN namespace aud {
|
||||
|
||||
/// Closes the audaspace namespace aud.
|
||||
#define AUD_NAMESPACE_END }
|
||||
|
||||
#else
|
||||
|
||||
/// Opens the audaspace namespace aud.
|
||||
#define AUD_NAMESPACE_BEGIN
|
||||
|
||||
/// Closes the audaspace namespace aud.
|
||||
#define AUD_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/// Sample type.(float samples)
|
||||
typedef float sample_t;
|
||||
|
||||
/// Sample data type (format samples)
|
||||
typedef unsigned char data_t;
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
185
blender-5.2.0/extern/audaspace/include/Exception.h
vendored
Normal file
185
blender-5.2.0/extern/audaspace/include/Exception.h
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* \def AUD_NOEXCEPT
|
||||
* Compatibility macro for noexcept.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#define AUD_NOEXCEPT
|
||||
#else
|
||||
#define AUD_NOEXCEPT noexcept
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file Exception.h
|
||||
* @ingroup general
|
||||
* Defines the Exception class as well as the AUD_THROW macro for easy throwing.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
/// Throws a Exception with the provided error code.
|
||||
#define AUD_THROW(exception, message) { throw exception(message, __FILE__, __LINE__); }
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* The Exception class is the general exception base class.
|
||||
*/
|
||||
class AUD_API Exception : public std::exception
|
||||
{
|
||||
protected:
|
||||
/// A message describing the problem.
|
||||
const std::string m_message;
|
||||
|
||||
/// The source code file in which the exception was thrown.
|
||||
const std::string m_file;
|
||||
|
||||
/// The source code line from which the exception was thrown.
|
||||
const int m_line;
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param exception The exception to be copied.
|
||||
*/
|
||||
Exception(const Exception& exception);
|
||||
|
||||
/**
|
||||
* Creates a new Exception object.
|
||||
* @param message A message describing the problem.
|
||||
* @param file The source code file in which the exception was thrown.
|
||||
* @param line The source code line from which the exception was thrown.
|
||||
*/
|
||||
Exception(const std::string &message, const std::string &file, int line);
|
||||
public:
|
||||
/**
|
||||
* Destroys the object.
|
||||
*/
|
||||
virtual ~Exception() AUD_NOEXCEPT;
|
||||
|
||||
/**
|
||||
* Returns the error message.
|
||||
* @return A C string error message.
|
||||
*/
|
||||
virtual const char* what() const AUD_NOEXCEPT;
|
||||
|
||||
/**
|
||||
* Returns the error message plus file and line number for debugging purposes.
|
||||
* @return The error message including debug information.
|
||||
*/
|
||||
virtual std::string getDebugMessage() const;
|
||||
|
||||
/**
|
||||
* Returns the error message.
|
||||
* @return The error message as string.
|
||||
*/
|
||||
const std::string& getMessage() const;
|
||||
|
||||
/**
|
||||
* Returns the file in which the exception was thrown.
|
||||
* @return The name of the file in which the exception was thrown.
|
||||
*/
|
||||
const std::string& getFile() const;
|
||||
|
||||
/**
|
||||
* Returns the line where the exception was originally thrown.
|
||||
* @return The line of the source file where the exception was generated.
|
||||
*/
|
||||
int getLine() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* The FileException class is used for error cases in which files cannot
|
||||
* be read or written due to unknown containers or codecs.
|
||||
*/
|
||||
class AUD_API FileException : public Exception
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new FileException object.
|
||||
* @param message A message describing the problem.
|
||||
* @param file The source code file in which the exception was thrown.
|
||||
* @param line The source code line from which the exception was thrown.
|
||||
*/
|
||||
FileException(const std::string &message, const std::string &file, int line);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param exception The exception to be copied.
|
||||
*/
|
||||
FileException(const FileException& exception);
|
||||
|
||||
~FileException() AUD_NOEXCEPT;
|
||||
};
|
||||
|
||||
/**
|
||||
* The DeviceException class is used for error cases in connection with
|
||||
* devices, which usually happens when specific features or requests
|
||||
* cannot be fulfilled by a device, for example when the device is opened.
|
||||
*/
|
||||
class AUD_API DeviceException : public Exception
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new DeviceException object.
|
||||
* @param message A message describing the problem.
|
||||
* @param file The source code file in which the exception was thrown.
|
||||
* @param line The source code line from which the exception was thrown.
|
||||
*/
|
||||
DeviceException(const std::string &message, const std::string &file, int line);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param exception The exception to be copied.
|
||||
*/
|
||||
DeviceException(const DeviceException& exception);
|
||||
|
||||
~DeviceException() AUD_NOEXCEPT;
|
||||
};
|
||||
|
||||
/**
|
||||
* The StateException class is used for error cases of sounds or readers
|
||||
* with illegal states or requirements for states of dependent classes.
|
||||
* It is used for example when an effect reader needs a specific
|
||||
* specification from its input.
|
||||
*/
|
||||
class AUD_API StateException : public Exception
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new StateException object.
|
||||
* @param message A message describing the problem.
|
||||
* @param file The source code file in which the exception was thrown.
|
||||
* @param line The source code line from which the exception was thrown.
|
||||
*/
|
||||
StateException(const std::string &message, const std::string &file, int line);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param exception The exception to be copied.
|
||||
*/
|
||||
StateException(const StateException& exception);
|
||||
|
||||
~StateException() AUD_NOEXCEPT;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
92
blender-5.2.0/extern/audaspace/include/IReader.h
vendored
Normal file
92
blender-5.2.0/extern/audaspace/include/IReader.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file IReader.h
|
||||
* @ingroup general
|
||||
* The IReader interface.
|
||||
*/
|
||||
|
||||
#include "respec/Specification.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* @interface IReader
|
||||
* This class represents a sound source as stream or as buffer which can be read
|
||||
* for example by another reader, a device or whatever.
|
||||
*/
|
||||
class AUD_API IReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the reader.
|
||||
*/
|
||||
virtual ~IReader() {}
|
||||
|
||||
/**
|
||||
* Tells whether the source provides seeking functionality or not.
|
||||
* \warning This doesn't mean that the seeking always has to succeed.
|
||||
* \return Always returns true for readers of buffering types.
|
||||
*/
|
||||
virtual bool isSeekable() const=0;
|
||||
|
||||
/**
|
||||
* Seeks to a specific position in the source.
|
||||
* \param position The position to seek for measured in samples. To get
|
||||
* from a given time to the samples you simply have to multiply the
|
||||
* time value in seconds with the sample rate of the reader.
|
||||
* \warning This may work or not, depending on the actual reader.
|
||||
*/
|
||||
virtual void seek(int position)=0;
|
||||
|
||||
/**
|
||||
* Returns an approximated length of the source in samples.
|
||||
* \return The length as sample count. May be negative if unknown.
|
||||
*/
|
||||
virtual int getLength() const=0;
|
||||
|
||||
/**
|
||||
* Returns the position of the source as a sample count value.
|
||||
* \return The current position in the source. A negative value indicates
|
||||
* that the position is unknown.
|
||||
* \warning The value returned doesn't always have to be correct for readers,
|
||||
* especially after seeking.
|
||||
*/
|
||||
virtual int getPosition() const=0;
|
||||
|
||||
/**
|
||||
* Returns the specification of the reader.
|
||||
* \return The Specs structure.
|
||||
*/
|
||||
virtual Specs getSpecs() const=0;
|
||||
|
||||
/**
|
||||
* Request to read the next length samples out of the source.
|
||||
* The buffer supplied has the needed size.
|
||||
* \param[in,out] length The count of samples that should be read. Shall
|
||||
* contain the real count of samples after reading, in case
|
||||
* there were only fewer samples available.
|
||||
* A smaller value also indicates the end of the reader.
|
||||
* \param[out] eos End of stream, whether the end is reached or not.
|
||||
* \param[in] buffer The pointer to the buffer to read into.
|
||||
*/
|
||||
virtual void read(int& length, bool& eos, sample_t* buffer)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
57
blender-5.2.0/extern/audaspace/include/ISound.h
vendored
Normal file
57
blender-5.2.0/extern/audaspace/include/ISound.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file ISound.h
|
||||
* @ingroup general
|
||||
* The ISound interface.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* @interface ISound
|
||||
* This class represents a type of sound source and saves the necessary values
|
||||
* for it. It is able to create a reader that is actually usable for playback
|
||||
* of the respective sound source through the factory method createReader.
|
||||
*/
|
||||
class AUD_API ISound
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the sound.
|
||||
*/
|
||||
virtual ~ISound() {}
|
||||
|
||||
/**
|
||||
* Creates a reader for playback of the sound source.
|
||||
* \return A pointer to an IReader object or nullptr if there has been an
|
||||
* error.
|
||||
* \exception Exception An exception may be thrown if there has been
|
||||
* a more unexpected error during reader creation.
|
||||
*/
|
||||
virtual std::shared_ptr<IReader> createReader()=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
165
blender-5.2.0/extern/audaspace/include/devices/DeviceManager.h
vendored
Normal file
165
blender-5.2.0/extern/audaspace/include/devices/DeviceManager.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file DeviceManager.h
|
||||
* @ingroup devices
|
||||
* The DeviceManager class.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IDevice;
|
||||
class IDeviceFactory;
|
||||
class ICaptureDeviceFactory;
|
||||
class I3DDevice;
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* This class manages all device plugins and maintains a device if asked to do so.
|
||||
*
|
||||
* This enables applications to access their output device without having to carry
|
||||
* it through the whole application.
|
||||
*/
|
||||
class AUD_API DeviceManager
|
||||
{
|
||||
private:
|
||||
static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
|
||||
|
||||
static std::shared_ptr<IDevice> m_device;
|
||||
static std::unordered_map<std::string, std::shared_ptr<ICaptureDeviceFactory>> m_capture_factories;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
DeviceManager(const DeviceManager&) = delete;
|
||||
DeviceManager& operator=(const DeviceManager&) = delete;
|
||||
DeviceManager() = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Registers a device factory.
|
||||
*
|
||||
* This method is mostly used by plugin developers to add their device implementation
|
||||
* for general use by the library end users.
|
||||
* @param name A representative name for the device.
|
||||
* @param factory The factory that creates the device.
|
||||
*/
|
||||
static void registerDevice(const std::string &name, std::shared_ptr<IDeviceFactory> factory);
|
||||
|
||||
/**
|
||||
* Returns the factory for a specific device.
|
||||
* @param name The representative name of the device.
|
||||
* @return The factory if it was found, or nullptr otherwise.
|
||||
*/
|
||||
static std::shared_ptr<IDeviceFactory> getDeviceFactory(const std::string &name);
|
||||
|
||||
/**
|
||||
* Returns the default device based on the priorities of the registered factories.
|
||||
* @return The default device or nullptr if no factory has been registered.
|
||||
*/
|
||||
static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
|
||||
|
||||
|
||||
/**
|
||||
* Sets a device that should be handled by the manager.
|
||||
*
|
||||
* If a device is currently being handled it will be released.
|
||||
* @param device The device the manager should take care of.
|
||||
*/
|
||||
static void setDevice(std::shared_ptr<IDevice> device);
|
||||
|
||||
/**
|
||||
* Opens a device which will then be handled by the manager.
|
||||
*
|
||||
* If a device is currently being handled it will be released.
|
||||
* @param name The representative name of the device.
|
||||
*/
|
||||
static void openDevice(const std::string &name);
|
||||
|
||||
/**
|
||||
* Opens the default device which will then be handled by the manager.
|
||||
*
|
||||
* The device to open is selected based on the priority of the registered factories.
|
||||
* If a device is currently being handled it will be released.
|
||||
*/
|
||||
static void openDefaultDevice();
|
||||
|
||||
/**
|
||||
* Releases the currently handled device.
|
||||
*/
|
||||
static void releaseDevice();
|
||||
|
||||
/**
|
||||
* Returns the currently handled device.
|
||||
* @return The handled device or nullptr if no device has been registered.
|
||||
*/
|
||||
static std::shared_ptr<IDevice> getDevice();
|
||||
|
||||
/**
|
||||
* Returns the currently handled 3D device.
|
||||
* @return The handled device or nullptr if no device has been registered
|
||||
* or the registered device is not an I3DDevice.
|
||||
*/
|
||||
static std::shared_ptr<I3DDevice> get3DDevice();
|
||||
|
||||
/**
|
||||
* Returns a list of available devices.
|
||||
* @return A list of strings with the names of available devices.
|
||||
*/
|
||||
static std::vector<std::string> getAvailableDeviceNames();
|
||||
|
||||
/**
|
||||
* Returns a list of available capture devices.
|
||||
* @return A list of strings with the names of available capture devices.
|
||||
*/
|
||||
static std::vector<std::string> getAvailableCaptureDeviceNames();
|
||||
|
||||
/**
|
||||
* Returns the factory for a specific capture device.
|
||||
* @param name The representative name of the capture device.
|
||||
* @return The factory if it was found, or nullptr otherwise.
|
||||
*/
|
||||
static std::shared_ptr<ICaptureDeviceFactory> getCaptureDeviceFactory(const std::string& name);
|
||||
|
||||
/**
|
||||
* Registers a capture device factory.
|
||||
* @param name A representative name for the capture device.
|
||||
* @param factory The factory that creates the capture reader.
|
||||
*/
|
||||
static void registerCaptureDevice(const std::string& name, std::shared_ptr<ICaptureDeviceFactory> factory);
|
||||
|
||||
/**
|
||||
* Opens an input capture reader.
|
||||
* @param name The capture device name.
|
||||
* @param specs The desired specification.
|
||||
* @param buffersize The capture buffer size in samples.
|
||||
*/
|
||||
static std::shared_ptr<IReader> openCaptureDevice(const std::string& name,
|
||||
Specs specs,
|
||||
int buffersize = AUD_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
142
blender-5.2.0/extern/audaspace/include/devices/I3DDevice.h
vendored
Normal file
142
blender-5.2.0/extern/audaspace/include/devices/I3DDevice.h
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file I3DDevice.h
|
||||
* @ingroup devices
|
||||
* Defines the I3DDevice interface as well as the different distance models.
|
||||
*/
|
||||
|
||||
#include "util/Math3D.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Possible distance models for the 3D device.
|
||||
*
|
||||
* The distance models supported are the same as documented in the [OpenAL Specification](http://openal.org/).
|
||||
*/
|
||||
enum DistanceModel
|
||||
{
|
||||
DISTANCE_MODEL_INVALID = 0,
|
||||
DISTANCE_MODEL_INVERSE,
|
||||
DISTANCE_MODEL_INVERSE_CLAMPED,
|
||||
DISTANCE_MODEL_LINEAR,
|
||||
DISTANCE_MODEL_LINEAR_CLAMPED,
|
||||
DISTANCE_MODEL_EXPONENT,
|
||||
DISTANCE_MODEL_EXPONENT_CLAMPED
|
||||
};
|
||||
|
||||
/**
|
||||
* @interface I3DDevice
|
||||
* The I3DDevice interface represents an output device for 3D sound.
|
||||
*
|
||||
* The interface has been modelled after the OpenAL 1.1 API,
|
||||
* see the [OpenAL Specification](http://openal.org/) for lots of details.
|
||||
*/
|
||||
class AUD_API I3DDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Retrieves the listener location.
|
||||
* \return The listener location.
|
||||
*/
|
||||
virtual Vector3 getListenerLocation() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener location.
|
||||
* \param location The new location.
|
||||
* \note The location is not updated with the velocity and
|
||||
* remains constant until the next call of this method.
|
||||
*/
|
||||
virtual void setListenerLocation(const Vector3& location)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the listener velocity.
|
||||
* \return The listener velocity.
|
||||
*/
|
||||
virtual Vector3 getListenerVelocity() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener velocity.
|
||||
* \param velocity The new velocity.
|
||||
* \note This velocity does not change the position of the listener
|
||||
* over time, it is simply used for the calculation of the doppler effect.
|
||||
*/
|
||||
virtual void setListenerVelocity(const Vector3& velocity)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the listener orientation.
|
||||
* \return The listener orientation as quaternion.
|
||||
*/
|
||||
virtual Quaternion getListenerOrientation() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener orientation.
|
||||
* \param orientation The new orientation as quaternion.
|
||||
* \note The coordinate system used is right handed and the listener
|
||||
* by default is oriented looking in the negative z direction with the
|
||||
* positive y axis as up direction.
|
||||
*/
|
||||
virtual void setListenerOrientation(const Quaternion& orientation)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the speed of sound.
|
||||
* This value is needed for doppler effect calculation.
|
||||
* \return The speed of sound.
|
||||
*/
|
||||
virtual float getSpeedOfSound() const=0;
|
||||
|
||||
/**
|
||||
* Sets the speed of sound.
|
||||
* This value is needed for doppler effect calculation.
|
||||
* \param speed The new speed of sound.
|
||||
*/
|
||||
virtual void setSpeedOfSound(float speed)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the doppler factor.
|
||||
* This value is a scaling factor for the velocity vectors of sources and
|
||||
* listener which is used while calculating the doppler effect.
|
||||
* \return The doppler factor.
|
||||
*/
|
||||
virtual float getDopplerFactor() const=0;
|
||||
|
||||
/**
|
||||
* Sets the doppler factor.
|
||||
* This value is a scaling factor for the velocity vectors of sources and
|
||||
* listener which is used while calculating the doppler effect.
|
||||
* \param factor The new doppler factor.
|
||||
*/
|
||||
virtual void setDopplerFactor(float factor)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the distance model.
|
||||
* \return The distance model.
|
||||
*/
|
||||
virtual DistanceModel getDistanceModel() const=0;
|
||||
|
||||
/**
|
||||
* Sets the distance model.
|
||||
* \param model distance model.
|
||||
*/
|
||||
virtual void setDistanceModel(DistanceModel model)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
232
blender-5.2.0/extern/audaspace/include/devices/I3DHandle.h
vendored
Normal file
232
blender-5.2.0/extern/audaspace/include/devices/I3DHandle.h
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file I3DHandle.h
|
||||
* @ingroup devices
|
||||
* The I3DHandle interface.
|
||||
*/
|
||||
|
||||
#include "util/Math3D.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* @interface I3DHandle
|
||||
* The I3DHandle interface represents a playback handle for 3D sources.
|
||||
* If the playback IDevice class also implements the I3DDevice interface
|
||||
* then all playback IHandle instances also implement this interface.
|
||||
*
|
||||
* The interface has been modelled after the OpenAL 1.1 API,
|
||||
* see the [OpenAL Specification](http://openal.org/) for lots of details.
|
||||
*/
|
||||
class AUD_API I3DHandle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the handle.
|
||||
*/
|
||||
virtual ~I3DHandle() {}
|
||||
|
||||
/**
|
||||
* Retrieves the location of the source.
|
||||
* \return The location.
|
||||
*/
|
||||
virtual Vector3 getLocation()=0;
|
||||
|
||||
/**
|
||||
* Sets the location of the source.
|
||||
* \param location The new location.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The location is not updated with the velocity and
|
||||
* remains constant until the next call of this method.
|
||||
*/
|
||||
virtual bool setLocation(const Vector3& location)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the velocity of the source.
|
||||
* \return The velocity.
|
||||
*/
|
||||
virtual Vector3 getVelocity()=0;
|
||||
|
||||
/**
|
||||
* Sets the velocity of the source.
|
||||
* \param velocity The new velocity.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This velocity does not change the position of the listener
|
||||
* over time, it is simply used for the calculation of the doppler effect.
|
||||
*/
|
||||
virtual bool setVelocity(const Vector3& velocity)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the orientation of the source.
|
||||
* \return The orientation as quaternion.
|
||||
*/
|
||||
virtual Quaternion getOrientation()=0;
|
||||
|
||||
/**
|
||||
* Sets the orientation of the source.
|
||||
* \param orientation The new orientation as quaternion.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The coordinate system used is right handed and the source
|
||||
* by default is oriented looking in the negative z direction with the
|
||||
* positive y axis as up direction.
|
||||
* \note This setting currently only affects sounds with non-default cone settings.
|
||||
*/
|
||||
virtual bool setOrientation(const Quaternion& orientation)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the source location, velocity and orientation are relative
|
||||
* to the listener.
|
||||
* \return Whether the source is relative.
|
||||
*/
|
||||
virtual bool isRelative()=0;
|
||||
|
||||
/**
|
||||
* Sets whether the source location, velocity and orientation are relative
|
||||
* to the listener.
|
||||
* \param relative Whether the source is relative.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The default value is true as this setting is used to play sounds ordinarily without 3D.
|
||||
*/
|
||||
virtual bool setRelative(bool relative)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the maximum volume of a source.
|
||||
* \return The maximum volume.
|
||||
*/
|
||||
virtual float getVolumeMaximum()=0;
|
||||
|
||||
/**
|
||||
* Sets the maximum volume of a source.
|
||||
* \param volume The new maximum volume.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setVolumeMaximum(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the minimum volume of a source.
|
||||
* \return The minimum volume.
|
||||
*/
|
||||
virtual float getVolumeMinimum()=0;
|
||||
|
||||
/**
|
||||
* Sets the minimum volume of a source.
|
||||
* \param volume The new minimum volume.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setVolumeMinimum(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the maximum distance of a source.
|
||||
* If a source is further away from the reader than this distance, the
|
||||
* volume will automatically be set to 0.
|
||||
* \return The maximum distance.
|
||||
*/
|
||||
virtual float getDistanceMaximum()=0;
|
||||
|
||||
/**
|
||||
* Sets the maximum distance of a source.
|
||||
* If a source is further away from the reader than this distance, the
|
||||
* volume will automatically be set to 0.
|
||||
* \param distance The new maximum distance.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setDistanceMaximum(float distance)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the reference distance of a source.
|
||||
* \return The reference distance.
|
||||
*/
|
||||
virtual float getDistanceReference()=0;
|
||||
|
||||
/**
|
||||
* Sets the reference distance of a source.
|
||||
* \param distance The new reference distance.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setDistanceReference(float distance)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the attenuation of a source.
|
||||
* \return The attenuation.
|
||||
*/
|
||||
virtual float getAttenuation()=0;
|
||||
|
||||
/**
|
||||
* Sets the attenuation of a source.
|
||||
* This value is used for distance calculation.
|
||||
* \param factor The new attenuation.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setAttenuation(float factor)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the outer opening angle of the cone of a source.
|
||||
* \return The outer angle of the cone.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual float getConeAngleOuter()=0;
|
||||
|
||||
/**
|
||||
* Sets the outer opening angle of the cone of a source.
|
||||
* \param angle The new outer angle of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual bool setConeAngleOuter(float angle)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the inner opening angle of the cone of a source.
|
||||
* The volume inside this cone is unaltered.
|
||||
* \return The inner angle of the cone.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual float getConeAngleInner()=0;
|
||||
|
||||
/**
|
||||
* Sets the inner opening angle of the cone of a source.
|
||||
* The volume inside this cone is unaltered.
|
||||
* \param angle The new inner angle of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual bool setConeAngleInner(float angle)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the outer volume of the cone of a source.
|
||||
* The volume between inner and outer angle is interpolated between inner
|
||||
* volume and this value.
|
||||
* \return The outer volume of the cone.
|
||||
* \note The general volume of the handle still applies on top of this.
|
||||
*/
|
||||
virtual float getConeVolumeOuter()=0;
|
||||
|
||||
/**
|
||||
* Sets the outer volume of the cone of a source.
|
||||
* The volume between inner and outer angle is interpolated between inner
|
||||
* volume and this value.
|
||||
* \param volume The new outer volume of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The general volume of the handle still applies on top of this.
|
||||
*/
|
||||
virtual bool setConeVolumeOuter(float volume)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
46
blender-5.2.0/extern/audaspace/include/devices/ICaptureDeviceFactory.h
vendored
Normal file
46
blender-5.2.0/extern/audaspace/include/devices/ICaptureDeviceFactory.h
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ICaptureDeviceFactory.h
|
||||
* @ingroup devices
|
||||
* The ICaptureDeviceFactory interface.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* @interface ICaptureDeviceFactory
|
||||
* The ICaptureDeviceFactory interface opens an input capture device.
|
||||
*/
|
||||
class AUD_API ICaptureDeviceFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the capture device factory.
|
||||
*/
|
||||
virtual ~ICaptureDeviceFactory() {}
|
||||
|
||||
/**
|
||||
* Opens an audio capture device.
|
||||
* \param specs The desired specification.
|
||||
* \param buffersize The capture buffer size in samples.
|
||||
* \exception Exception Thrown if the audio device cannot be opened.
|
||||
*/
|
||||
virtual std::shared_ptr<IReader> openDevice(Specs specs, int buffersize)=0;
|
||||
|
||||
/**
|
||||
* Sets a name for the capture device.
|
||||
* \param name The internal name for the capture device.
|
||||
*/
|
||||
virtual void setName(const std::string &name)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
130
blender-5.2.0/extern/audaspace/include/devices/IDevice.h
vendored
Normal file
130
blender-5.2.0/extern/audaspace/include/devices/IDevice.h
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file IDevice.h
|
||||
* @ingroup devices
|
||||
* The IDevice interface.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "respec/Specification.h"
|
||||
#include "util/ILockable.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IHandle;
|
||||
class IReader;
|
||||
class ISound;
|
||||
|
||||
/**
|
||||
* @interface IDevice
|
||||
* The IDevice interface represents an output device for sound sources.
|
||||
* Output devices may be several backends such as platform independand like
|
||||
* SDL or OpenAL or platform specific like ALSA, but they may also be
|
||||
* files, RAM buffers or other types of streams.
|
||||
* \warning Thread safety must be insured so that no reader is being called
|
||||
* twice at the same time.
|
||||
*/
|
||||
class IDevice : public ILockable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the device.
|
||||
*/
|
||||
virtual ~IDevice() {}
|
||||
|
||||
/**
|
||||
* Returns the specification of the device.
|
||||
*/
|
||||
virtual DeviceSpecs getSpecs() const=0;
|
||||
|
||||
/**
|
||||
* Plays a sound source.
|
||||
* \param reader The reader to play.
|
||||
* \param keep When keep is true the sound source will not be deleted but
|
||||
* set to paused when its end has been reached.
|
||||
* \return Returns a handle with which the playback can be controlled.
|
||||
* This is nullptr if the sound couldn't be played back.
|
||||
* \exception Exception Thrown if there's an unexpected (from the
|
||||
* device side) error during creation of the reader.
|
||||
*/
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false)=0;
|
||||
|
||||
/**
|
||||
* Plays a sound source.
|
||||
* \param sound The sound to create the reader for the sound source.
|
||||
* \param keep When keep is true the sound source will not be deleted but
|
||||
* set to paused when its end has been reached.
|
||||
* \return Returns a handle with which the playback can be controlled.
|
||||
* This is nullptr if the sound couldn't be played back.
|
||||
* \exception Exception Thrown if there's an unexpected (from the
|
||||
* device side) error during creation of the reader.
|
||||
*/
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false)=0;
|
||||
|
||||
/**
|
||||
* Stops all playing sounds.
|
||||
*/
|
||||
virtual void stopAll()=0;
|
||||
|
||||
/**
|
||||
* Locks the device.
|
||||
* Used to make sure that between lock and unlock, no buffers are read, so
|
||||
* that it is possible to start, resume, pause, stop or seek several
|
||||
* playback handles simultaneously.
|
||||
* \warning Make sure the locking time is as small as possible to avoid
|
||||
* playback delays that result in unexpected noise and cracks.
|
||||
*/
|
||||
virtual void lock()=0;
|
||||
|
||||
/**
|
||||
* Unlocks the previously locked device.
|
||||
*/
|
||||
virtual void unlock()=0;
|
||||
|
||||
/**
|
||||
* Retrieves the overall device volume.
|
||||
* \return The overall device volume.
|
||||
*/
|
||||
virtual float getVolume() const=0;
|
||||
|
||||
/**
|
||||
* Sets the overall device volume.
|
||||
* \param volume The overall device volume.
|
||||
*/
|
||||
virtual void setVolume(float volume) = 0;
|
||||
|
||||
/**
|
||||
* The syncFunction is called when a synchronization event happens.
|
||||
* The function awaits three parameters. The first one is a user defined
|
||||
* pointer, the second informs about whether playback is on and the third
|
||||
* is the current playback time in seconds.
|
||||
*/
|
||||
typedef void (*syncFunction)(void*, int, float);
|
||||
|
||||
virtual void seekSynchronizer(double time) = 0;
|
||||
virtual double getSynchronizerPosition() = 0;
|
||||
virtual void playSynchronizer() = 0;
|
||||
virtual void stopSynchronizer() = 0;
|
||||
virtual void setSyncCallback(syncFunction function, void* data) = 0;
|
||||
virtual int isSynchronizerPlaying() = 0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
77
blender-5.2.0/extern/audaspace/include/devices/IDeviceFactory.h
vendored
Normal file
77
blender-5.2.0/extern/audaspace/include/devices/IDeviceFactory.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file IDeviceFactory.h
|
||||
* @ingroup devices
|
||||
* The IDeviceFactory interface.
|
||||
*/
|
||||
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* @interface IDeviceFactory
|
||||
* The IDeviceFactory interface opens an output device.
|
||||
*/
|
||||
class AUD_API IDeviceFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the device factory.
|
||||
*/
|
||||
virtual ~IDeviceFactory() {}
|
||||
|
||||
/**
|
||||
* Opens an audio device for playback.
|
||||
* \exception Exception Thrown if the audio device cannot be opened.
|
||||
*/
|
||||
virtual std::shared_ptr<IDevice> openDevice()=0;
|
||||
|
||||
/**
|
||||
* Returns the priority of the device to be the default device for a system.
|
||||
* The higher the priority the more likely it is for this device to be used as the default device.
|
||||
* \return Priority to be the default device.
|
||||
*/
|
||||
virtual int getPriority()=0;
|
||||
|
||||
/**
|
||||
* Sets the wanted device specifications for opening the device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
virtual void setSpecs(DeviceSpecs specs)=0;
|
||||
|
||||
/**
|
||||
* Sets the size for the internal playback buffers.
|
||||
* The bigger the buffersize, the less likely clicks happen,
|
||||
* but the latency increases too.
|
||||
* \param buffersize The size of the internal buffer.
|
||||
*/
|
||||
virtual void setBufferSize(int buffersize)=0;
|
||||
|
||||
/**
|
||||
* Sets a name for the device.
|
||||
* \param name The internal name for the device.
|
||||
*/
|
||||
virtual void setName(const std::string &name)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
189
blender-5.2.0/extern/audaspace/include/devices/IHandle.h
vendored
Normal file
189
blender-5.2.0/extern/audaspace/include/devices/IHandle.h
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file IHandle.h
|
||||
* @ingroup devices
|
||||
* Defines the IHandle interface as well as possible states of the handle.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/// Status of a playback handle.
|
||||
enum Status
|
||||
{
|
||||
STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
|
||||
STATUS_PLAYING, /// Sound is playing.
|
||||
STATUS_PAUSED, /// Sound is being paused.
|
||||
STATUS_STOPPED /// Sound is stopped but kept in the device.
|
||||
};
|
||||
|
||||
/**
|
||||
* The stopCallback is called when a handle reaches the end of the stream and
|
||||
* thus gets stopped. A user defined pointer is supplied to the callback.
|
||||
*/
|
||||
typedef void (*stopCallback)(void*);
|
||||
|
||||
/**
|
||||
* @interface IHandle
|
||||
* The IHandle interface represents a playback handles of a specific device.
|
||||
*/
|
||||
class AUD_API IHandle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the handle.
|
||||
*/
|
||||
virtual ~IHandle() {}
|
||||
|
||||
/**
|
||||
* Pauses a played back sound.
|
||||
* \return
|
||||
* - true if the sound has been paused.
|
||||
* - false if the sound isn't playing back or the handle is invalid.
|
||||
*/
|
||||
virtual bool pause()=0;
|
||||
|
||||
/**
|
||||
* Resumes a paused sound.
|
||||
* \return
|
||||
* - true if the sound has been resumed.
|
||||
* - false if the sound isn't paused or the handle is invalid.
|
||||
*/
|
||||
virtual bool resume()=0;
|
||||
|
||||
/**
|
||||
* Stops a played back or paused sound. The handle is definitely invalid
|
||||
* afterwards.
|
||||
* \return
|
||||
* - true if the sound has been stopped.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool stop()=0;
|
||||
|
||||
/**
|
||||
* Gets the behaviour of the device for a played back sound when the sound
|
||||
* doesn't return any more samples.
|
||||
* \return
|
||||
* - true if the source will be paused when it's end is reached
|
||||
* - false if the handle won't kept or is invalid.
|
||||
*/
|
||||
virtual bool getKeep()=0;
|
||||
|
||||
/**
|
||||
* Sets the behaviour of the device for a played back sound when the sound
|
||||
* doesn't return any more samples.
|
||||
* \param keep True when the source should be paused and not deleted.
|
||||
* \return
|
||||
* - true if the behaviour has been changed.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setKeep(bool keep)=0;
|
||||
|
||||
/**
|
||||
* Seeks in a played back sound.
|
||||
* \param position The new position from where to play back, in seconds.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
* \warning Whether the seek works or not depends on the sound source.
|
||||
*/
|
||||
virtual bool seek(double position)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the current playback position of a sound.
|
||||
* \return The playback position in seconds, or 0.0 if the handle is
|
||||
* invalid.
|
||||
*/
|
||||
virtual double getPosition()=0;
|
||||
|
||||
/**
|
||||
* Returns the status of a played back sound.
|
||||
* \return
|
||||
* - STATUS_INVALID if the sound has stopped or the handle is
|
||||
*. invalid
|
||||
* - STATUS_PLAYING if the sound is currently played back.
|
||||
* - STATUS_PAUSED if the sound is currently paused.
|
||||
* - STATUS_STOPPED if the sound finished playing and is still
|
||||
* kept in the device.
|
||||
* \see Status
|
||||
*/
|
||||
virtual Status getStatus()=0;
|
||||
|
||||
/**
|
||||
* Retrieves the volume of a playing sound.
|
||||
* \return The volume.
|
||||
*/
|
||||
virtual float getVolume()=0;
|
||||
|
||||
/**
|
||||
* Sets the volume of a playing sound.
|
||||
* \param volume The volume.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setVolume(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the pitch of a playing sound.
|
||||
* \return The pitch.
|
||||
*/
|
||||
virtual float getPitch()=0;
|
||||
|
||||
/**
|
||||
* Sets the pitch of a playing sound.
|
||||
* \param pitch The pitch.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setPitch(float pitch)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the loop count of a playing sound.
|
||||
* A negative value indicates infinity.
|
||||
* \return The remaining loop count.
|
||||
*/
|
||||
virtual int getLoopCount()=0;
|
||||
|
||||
/**
|
||||
* Sets the loop count of a playing sound.
|
||||
* A negative value indicates infinity.
|
||||
* \param count The new loop count.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setLoopCount(int count)=0;
|
||||
|
||||
/**
|
||||
* Sets the callback function that's called when the end of a playing sound
|
||||
* is reached.
|
||||
* \param callback The callback function.
|
||||
* \param data The data that should be passed to the callback function.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
131
blender-5.2.0/extern/audaspace/include/devices/MixingThreadDevice.h
vendored
Normal file
131
blender-5.2.0/extern/audaspace/include/devices/MixingThreadDevice.h
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file MixingThreadDevice.h
|
||||
* @ingroup device
|
||||
* The MixingThreadDevice class.
|
||||
*/
|
||||
|
||||
#include <condition_variable>
|
||||
#include <thread>
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
#include "util/RingBuffer.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device extends the SoftwareDevice with code for running mixing in a separate thread.
|
||||
*/
|
||||
class AUD_PLUGIN_API MixingThreadDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
volatile bool m_playback{false};
|
||||
|
||||
/**
|
||||
* The deinterleaving buffer.
|
||||
*/
|
||||
Buffer m_mixingBuffer;
|
||||
|
||||
/**
|
||||
* The mixing ring buffer.
|
||||
*/
|
||||
RingBuffer m_ringBuffer;
|
||||
|
||||
/**
|
||||
* Whether the device is valid.
|
||||
*/
|
||||
bool m_valid{false};
|
||||
|
||||
/**
|
||||
* The mixing thread.
|
||||
*/
|
||||
std::thread m_mixingThread;
|
||||
|
||||
/**
|
||||
* Mutex for mixing.
|
||||
*/
|
||||
std::mutex m_mixingLock;
|
||||
|
||||
/**
|
||||
* Condition for mixing.
|
||||
*/
|
||||
std::condition_variable m_mixingCondition;
|
||||
|
||||
/**
|
||||
* Updates the ring buffer.
|
||||
*/
|
||||
AUD_LOCAL void updateRingBuffer();
|
||||
|
||||
// delete copy constructor and operator=
|
||||
MixingThreadDevice(const MixingThreadDevice&) = delete;
|
||||
MixingThreadDevice& operator=(const MixingThreadDevice&) = delete;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Starts the streaming thread.
|
||||
* @param buffersize Size of the ring buffer in bytes.
|
||||
*/
|
||||
void startMixingThread(size_t buffersize);
|
||||
|
||||
/**
|
||||
* Notify the mixing thread.
|
||||
*/
|
||||
void notifyMixingThread();
|
||||
|
||||
/**
|
||||
* Get ring buffer for reading.
|
||||
*/
|
||||
inline RingBuffer& getRingBuffer()
|
||||
{
|
||||
return m_ringBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the thread is running or not.
|
||||
*/
|
||||
inline bool isMixingThreadRunning()
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
virtual void playing(bool playing);
|
||||
|
||||
/**
|
||||
* Called every iteration in the mixing thread before mixing.
|
||||
*/
|
||||
virtual void preMixingWork(bool playing);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
MixingThreadDevice();
|
||||
|
||||
/**
|
||||
* Stops all playback and notifies the mixing thread to stop.
|
||||
* \warning The device has to be unlocked to not run into a deadlock.
|
||||
*/
|
||||
void stopMixingThread();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
102
blender-5.2.0/extern/audaspace/include/devices/NULLDevice.h
vendored
Normal file
102
blender-5.2.0/extern/audaspace/include/devices/NULLDevice.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file NULLDevice.h
|
||||
* @ingroup devices
|
||||
* The NULLDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/IDevice.h"
|
||||
#include "devices/IHandle.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* This device plays nothing.
|
||||
* It is similar to the linux device /dev/null.
|
||||
*/
|
||||
class AUD_API NULLDevice : public IDevice
|
||||
{
|
||||
private:
|
||||
class AUD_LOCAL NULLHandle : public IHandle
|
||||
{
|
||||
private:
|
||||
// delete copy constructor and operator=
|
||||
NULLHandle(const NULLHandle&) = delete;
|
||||
NULLHandle& operator=(const NULLHandle&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
NULLHandle();
|
||||
|
||||
virtual ~NULLHandle() {}
|
||||
virtual bool pause();
|
||||
virtual bool resume();
|
||||
virtual bool stop();
|
||||
virtual bool getKeep();
|
||||
virtual bool setKeep(bool keep);
|
||||
virtual bool seek(double position);
|
||||
virtual double getPosition();
|
||||
virtual Status getStatus();
|
||||
virtual float getVolume();
|
||||
virtual bool setVolume(float volume);
|
||||
virtual float getPitch();
|
||||
virtual bool setPitch(float pitch);
|
||||
virtual int getLoopCount();
|
||||
virtual bool setLoopCount(int count);
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
|
||||
};
|
||||
|
||||
// delete copy constructor and operator=
|
||||
NULLDevice(const NULLDevice&) = delete;
|
||||
NULLDevice& operator=(const NULLDevice&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new NULLDevice.
|
||||
*/
|
||||
NULLDevice();
|
||||
|
||||
virtual ~NULLDevice();
|
||||
|
||||
virtual DeviceSpecs getSpecs() const;
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
virtual void setVolume(float volume);
|
||||
|
||||
virtual void seekSynchronizer(double time);
|
||||
virtual double getSynchronizerPosition();
|
||||
virtual void playSynchronizer();
|
||||
virtual void stopSynchronizer();
|
||||
virtual void setSyncCallback(syncFunction function, void* data);
|
||||
virtual int isSynchronizerPlaying();
|
||||
|
||||
/**
|
||||
* Registers this plugin.
|
||||
*/
|
||||
static void registerPlugin();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
82
blender-5.2.0/extern/audaspace/include/devices/ReadDevice.h
vendored
Normal file
82
blender-5.2.0/extern/audaspace/include/devices/ReadDevice.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file ReadDevice.h
|
||||
* @ingroup devices
|
||||
* The ReadDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device enables to let the user read raw data out of it.
|
||||
*/
|
||||
class AUD_API ReadDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether the device is currently playing back.
|
||||
*/
|
||||
bool m_playing;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
ReadDevice(const ReadDevice&) = delete;
|
||||
ReadDevice& operator=(const ReadDevice&) = delete;
|
||||
|
||||
protected:
|
||||
virtual void AUD_LOCAL playing(bool playing);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new read device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
ReadDevice(DeviceSpecs specs);
|
||||
|
||||
/**
|
||||
* Creates a new read device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
ReadDevice(Specs specs);
|
||||
|
||||
/**
|
||||
* Closes the device.
|
||||
*/
|
||||
virtual ~ReadDevice();
|
||||
|
||||
/**
|
||||
* Reads the next bytes into the supplied buffer.
|
||||
* \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.
|
||||
*/
|
||||
bool read(data_t* buffer, int length);
|
||||
|
||||
/**
|
||||
* Changes the output specification.
|
||||
* \param specs The new audio data specification.
|
||||
*/
|
||||
void changeSpecs(Specs specs);
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
384
blender-5.2.0/extern/audaspace/include/devices/SoftwareDevice.h
vendored
Normal file
384
blender-5.2.0/extern/audaspace/include/devices/SoftwareDevice.h
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file SoftwareDevice.h
|
||||
* @ingroup devices
|
||||
* The SoftwareDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/IDevice.h"
|
||||
#include "devices/IHandle.h"
|
||||
#include "devices/I3DDevice.h"
|
||||
#include "devices/I3DHandle.h"
|
||||
#include "util/Buffer.h"
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class Mixer;
|
||||
class PitchReader;
|
||||
class ResampleReader;
|
||||
class ChannelMapperReader;
|
||||
|
||||
/**
|
||||
* The software device is a generic device with software mixing.
|
||||
* It is a base class for all software mixing classes.
|
||||
* Classes implementing this have to:
|
||||
* - Implement the playing function.
|
||||
* - Prepare the m_specs, m_mixer variables.
|
||||
* - Call the create and destroy functions.
|
||||
* - Call the mix function to retrieve their audio data.
|
||||
*/
|
||||
class AUD_API SoftwareDevice : public IDevice, public I3DDevice
|
||||
{
|
||||
protected:
|
||||
/// Saves the data for playback.
|
||||
class AUD_API SoftwareHandle : public IHandle, public I3DHandle
|
||||
{
|
||||
private:
|
||||
// delete copy constructor and operator=
|
||||
SoftwareHandle(const SoftwareHandle&) = delete;
|
||||
SoftwareHandle& operator=(const SoftwareHandle&) = delete;
|
||||
|
||||
public:
|
||||
/// The reader source.
|
||||
std::shared_ptr<IReader> m_reader;
|
||||
|
||||
/// The pitch reader in between.
|
||||
std::shared_ptr<PitchReader> m_pitch;
|
||||
|
||||
/// The resample reader in between.
|
||||
std::shared_ptr<ResampleReader> m_resampler;
|
||||
|
||||
/// The channel mapper reader in between.
|
||||
std::shared_ptr<ChannelMapperReader> m_mapper;
|
||||
|
||||
/// Whether the source is being read for the first time.
|
||||
bool m_first_reading;
|
||||
|
||||
/// Whether to keep the source if end of it is reached.
|
||||
bool m_keep;
|
||||
|
||||
/// The user set pitch of the source.
|
||||
float m_user_pitch;
|
||||
|
||||
/// The user set volume of the source.
|
||||
float m_user_volume;
|
||||
|
||||
/// The user set panning for non-3D sources
|
||||
float m_user_pan;
|
||||
|
||||
/// The calculated final volume of the source.
|
||||
float m_volume;
|
||||
|
||||
/// The previous calculated final volume of the source.
|
||||
float m_old_volume;
|
||||
|
||||
/// The loop count of the source.
|
||||
int m_loopcount;
|
||||
|
||||
/// Location in 3D Space.
|
||||
Vector3 m_location;
|
||||
|
||||
/// Velocity in 3D Space.
|
||||
Vector3 m_velocity;
|
||||
|
||||
/// Orientation in 3D Space.
|
||||
Quaternion m_orientation;
|
||||
|
||||
/// Whether the position to the listener is relative or absolute
|
||||
bool m_relative;
|
||||
|
||||
/// Maximum volume.
|
||||
float m_volume_max;
|
||||
|
||||
/// Minimum volume.
|
||||
float m_volume_min;
|
||||
|
||||
/// Maximum distance.
|
||||
float m_distance_max;
|
||||
|
||||
/// Reference distance;
|
||||
float m_distance_reference;
|
||||
|
||||
/// Attenuation
|
||||
float m_attenuation;
|
||||
|
||||
/// Cone outer angle.
|
||||
float m_cone_angle_outer;
|
||||
|
||||
/// Cone inner angle.
|
||||
float m_cone_angle_inner;
|
||||
|
||||
/// Cone outer volume.
|
||||
float m_cone_volume_outer;
|
||||
|
||||
/// Rendering flags
|
||||
int m_flags;
|
||||
|
||||
/// The stop callback.
|
||||
stopCallback m_stop;
|
||||
|
||||
/// Stop callback data.
|
||||
void* m_stop_data;
|
||||
|
||||
/// Current status of the handle
|
||||
Status m_status;
|
||||
|
||||
/// Own device.
|
||||
SoftwareDevice* m_device;
|
||||
|
||||
/**
|
||||
* This method is for internal use only.
|
||||
* @param keep Whether the sound should be marked stopped or paused.
|
||||
* @return Whether the action succeeded.
|
||||
*/
|
||||
bool pause(bool keep);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new software handle.
|
||||
* \param device The device this handle is from.
|
||||
* \param reader The reader to play.
|
||||
* \param pitch The pitch reader.
|
||||
* \param resampler The resampling reader.
|
||||
* \param mapper The channel mapping reader.
|
||||
* \param keep Whether to keep the handle when the sound ends.
|
||||
*/
|
||||
SoftwareHandle(SoftwareDevice* device, std::shared_ptr<IReader> reader, std::shared_ptr<PitchReader> pitch, std::shared_ptr<ResampleReader> resampler, std::shared_ptr<ChannelMapperReader> mapper, bool keep);
|
||||
|
||||
/**
|
||||
* Updates the handle's playback parameters.
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the readers.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(Specs specs);
|
||||
|
||||
virtual ~SoftwareHandle() {}
|
||||
virtual bool pause();
|
||||
virtual bool resume();
|
||||
virtual bool stop();
|
||||
virtual bool getKeep();
|
||||
virtual bool setKeep(bool keep);
|
||||
virtual bool seek(double position);
|
||||
virtual double getPosition();
|
||||
virtual Status getStatus();
|
||||
virtual float getVolume();
|
||||
virtual bool setVolume(float volume);
|
||||
virtual float getPitch();
|
||||
virtual bool setPitch(float pitch);
|
||||
virtual int getLoopCount();
|
||||
virtual bool setLoopCount(int count);
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
|
||||
|
||||
virtual Vector3 getLocation();
|
||||
virtual bool setLocation(const Vector3& location);
|
||||
virtual Vector3 getVelocity();
|
||||
virtual bool setVelocity(const Vector3& velocity);
|
||||
virtual Quaternion getOrientation();
|
||||
virtual bool setOrientation(const Quaternion& orientation);
|
||||
virtual bool isRelative();
|
||||
virtual bool setRelative(bool relative);
|
||||
virtual float getVolumeMaximum();
|
||||
virtual bool setVolumeMaximum(float volume);
|
||||
virtual float getVolumeMinimum();
|
||||
virtual bool setVolumeMinimum(float volume);
|
||||
virtual float getDistanceMaximum();
|
||||
virtual bool setDistanceMaximum(float distance);
|
||||
virtual float getDistanceReference();
|
||||
virtual bool setDistanceReference(float distance);
|
||||
virtual float getAttenuation();
|
||||
virtual bool setAttenuation(float factor);
|
||||
virtual float getConeAngleOuter();
|
||||
virtual bool setConeAngleOuter(float angle);
|
||||
virtual float getConeAngleInner();
|
||||
virtual bool setConeAngleInner(float angle);
|
||||
virtual float getConeVolumeOuter();
|
||||
virtual bool setConeVolumeOuter(float volume);
|
||||
};
|
||||
|
||||
/**
|
||||
* The specification of the device.
|
||||
*/
|
||||
DeviceSpecs m_specs;
|
||||
|
||||
/**
|
||||
* The mixer.
|
||||
*/
|
||||
std::shared_ptr<Mixer> m_mixer;
|
||||
|
||||
/**
|
||||
* Resampling quality.
|
||||
*/
|
||||
ResampleQuality m_quality;
|
||||
|
||||
/**
|
||||
* Initializes member variables.
|
||||
*/
|
||||
void create();
|
||||
|
||||
/**
|
||||
* Uninitializes member variables.
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Mixes the next samples into the buffer.
|
||||
* \param buffer The target buffer.
|
||||
* \param length The length in samples to be filled.
|
||||
*/
|
||||
void mix(data_t* buffer, int length);
|
||||
|
||||
/**
|
||||
* This function tells the device, to start or pause playback.
|
||||
* \param playing True if device should playback.
|
||||
* \note This method is only called when the device is locked.
|
||||
*/
|
||||
virtual void playing(bool playing)=0;
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the device.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(Specs specs);
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the device.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(DeviceSpecs specs);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
SoftwareDevice();
|
||||
|
||||
private:
|
||||
/**
|
||||
* The reading buffer.
|
||||
*/
|
||||
Buffer m_buffer;
|
||||
|
||||
/**
|
||||
* The list of sounds that are currently playing.
|
||||
*/
|
||||
std::list<std::shared_ptr<SoftwareHandle> > m_playingSounds;
|
||||
|
||||
/**
|
||||
* The list of sounds that are currently paused.
|
||||
*/
|
||||
std::list<std::shared_ptr<SoftwareHandle> > m_pausedSounds;
|
||||
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
bool m_playback;
|
||||
|
||||
/**
|
||||
* The mutex for locking.
|
||||
*/
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
/**
|
||||
* The overall volume of the device.
|
||||
*/
|
||||
float m_volume;
|
||||
|
||||
/// Listener location.
|
||||
Vector3 m_location;
|
||||
|
||||
/// Listener velocity.
|
||||
Vector3 m_velocity;
|
||||
|
||||
/// Listener orientation.
|
||||
Quaternion m_orientation;
|
||||
|
||||
/// Speed of Sound.
|
||||
float m_speed_of_sound;
|
||||
|
||||
/// Doppler factor.
|
||||
float m_doppler_factor;
|
||||
|
||||
/// Distance model.
|
||||
DistanceModel m_distance_model;
|
||||
|
||||
/// Rendering flags
|
||||
int m_flags;
|
||||
|
||||
/// Synchronizer.
|
||||
uint64_t m_synchronizerPosition{0};
|
||||
int m_synchronizerState{0};
|
||||
|
||||
// delete copy constructor and operator=
|
||||
SoftwareDevice(const SoftwareDevice&) = delete;
|
||||
SoftwareDevice& operator=(const SoftwareDevice&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Sets the panning of a specific handle.
|
||||
* \param handle The handle to set the panning from.
|
||||
* \param pan The new panning value, should be in the range [-2, 2].
|
||||
*/
|
||||
static void setPanning(IHandle* handle, float pan);
|
||||
|
||||
/**
|
||||
* Sets the resampling quality.
|
||||
* \param quality Resampling quality vs performance setting.
|
||||
*/
|
||||
void setQuality(ResampleQuality quality);
|
||||
|
||||
virtual DeviceSpecs getSpecs() const;
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
virtual void setVolume(float volume);
|
||||
|
||||
virtual Vector3 getListenerLocation() const;
|
||||
virtual void setListenerLocation(const Vector3& location);
|
||||
virtual Vector3 getListenerVelocity() const;
|
||||
virtual void setListenerVelocity(const Vector3& velocity);
|
||||
virtual Quaternion getListenerOrientation() const;
|
||||
virtual void setListenerOrientation(const Quaternion& orientation);
|
||||
virtual float getSpeedOfSound() const;
|
||||
virtual void setSpeedOfSound(float speed);
|
||||
virtual float getDopplerFactor() const;
|
||||
virtual void setDopplerFactor(float factor);
|
||||
virtual DistanceModel getDistanceModel() const;
|
||||
virtual void setDistanceModel(DistanceModel model);
|
||||
|
||||
virtual void seekSynchronizer(double time);
|
||||
virtual double getSynchronizerPosition();
|
||||
virtual void playSynchronizer();
|
||||
virtual void stopSynchronizer();
|
||||
virtual void setSyncCallback(syncFunction function, void* data);
|
||||
virtual int isSynchronizerPlaying();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
95
blender-5.2.0/extern/audaspace/include/devices/ThreadedDevice.h
vendored
Normal file
95
blender-5.2.0/extern/audaspace/include/devices/ThreadedDevice.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file ThreadedDevice.h
|
||||
* @ingroup plugin
|
||||
* The ThreadedDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device extends the SoftwareDevice with code for running mixing in a separate thread.
|
||||
*/
|
||||
class AUD_PLUGIN_API ThreadedDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
bool m_playing;
|
||||
|
||||
/**
|
||||
* Whether the current playback should stop.
|
||||
*/
|
||||
bool m_stop;
|
||||
|
||||
/**
|
||||
* The streaming thread.
|
||||
*/
|
||||
std::thread m_thread;
|
||||
|
||||
/**
|
||||
* Starts the streaming thread.
|
||||
*/
|
||||
AUD_LOCAL void start();
|
||||
|
||||
/**
|
||||
* Streaming thread main function.
|
||||
*/
|
||||
AUD_LOCAL virtual void runMixingThread()=0;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
ThreadedDevice(const ThreadedDevice&) = delete;
|
||||
ThreadedDevice& operator=(const ThreadedDevice&) = delete;
|
||||
|
||||
protected:
|
||||
virtual void playing(bool playing);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
ThreadedDevice();
|
||||
|
||||
/**
|
||||
* Indicates that the mixing thread should be stopped.
|
||||
* \return Whether the mixing thread should be stopping.
|
||||
* \warning For thread safety, the device needs to be locked, when this method is called.
|
||||
*/
|
||||
inline bool shouldStop() { return m_stop; }
|
||||
|
||||
/**
|
||||
* This method needs to be called when the mixing thread is stopping.
|
||||
* \warning For thread safety, the device needs to be locked, when this method is called.
|
||||
*/
|
||||
inline void doStop() { m_stop = m_playing = false; }
|
||||
|
||||
/**
|
||||
* Stops all playback and notifies the mixing thread to stop.
|
||||
* \warning The device has to be unlocked to not run into a deadlock.
|
||||
*/
|
||||
void stopMixingThread();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
93
blender-5.2.0/extern/audaspace/include/file/File.h
vendored
Normal file
93
blender-5.2.0/extern/audaspace/include/file/File.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file File.h
|
||||
* @ingroup file
|
||||
* The File class.
|
||||
*/
|
||||
|
||||
#include "ISound.h"
|
||||
#include "FileInfo.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class Buffer;
|
||||
|
||||
/**
|
||||
* The File sound tries to read a sound file via all available file inputs
|
||||
* that have been registered in the FileManager class.
|
||||
*/
|
||||
class AUD_API File : public ISound
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The filename of the sound source file.
|
||||
*/
|
||||
std::string m_filename;
|
||||
|
||||
/**
|
||||
* The buffer to read from.
|
||||
*/
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
|
||||
/**
|
||||
* The index of the stream within the file if it contains multiple.
|
||||
* The first audio stream in the file has index 0 and the index increments by one
|
||||
* for every other audio stream in the file. Other types of streams in the file
|
||||
* do not count.
|
||||
*/
|
||||
int m_stream;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
File(const File&) = delete;
|
||||
File& operator=(const File&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new sound.
|
||||
* The file is read from the file system using the given path.
|
||||
* \param filename The sound file path.
|
||||
* \param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
*/
|
||||
File(const std::string &filename, int stream = 0);
|
||||
|
||||
/**
|
||||
* Creates a new sound.
|
||||
* The file is read from memory using the supplied buffer.
|
||||
* \param buffer The buffer to read from.
|
||||
* \param size The size of the buffer.
|
||||
* \param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
*/
|
||||
File(const data_t* buffer, int size, int stream = 0);
|
||||
|
||||
/**
|
||||
* Queries the streams of the file.
|
||||
* \return A vector with as many streams as there are in the file.
|
||||
* \exception Exception Thrown if the file specified cannot be read.
|
||||
*/
|
||||
std::vector<StreamInfo> queryStreams();
|
||||
|
||||
virtual std::shared_ptr<IReader> createReader();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
42
blender-5.2.0/extern/audaspace/include/file/FileInfo.h
vendored
Normal file
42
blender-5.2.0/extern/audaspace/include/file/FileInfo.h
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file FileInfo.h
|
||||
* @ingroup file
|
||||
* The FileInfo data structures.
|
||||
*/
|
||||
|
||||
#include "respec/Specification.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/// Specification of a sound source.
|
||||
struct StreamInfo
|
||||
{
|
||||
/// Start time in seconds.
|
||||
double start;
|
||||
|
||||
/// Duration in seconds. May be estimated or 0 if unknown.
|
||||
double duration;
|
||||
|
||||
/// Audio data parameters.
|
||||
DeviceSpecs specs;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
116
blender-5.2.0/extern/audaspace/include/file/FileManager.h
vendored
Normal file
116
blender-5.2.0/extern/audaspace/include/file/FileManager.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file FileManager.h
|
||||
* @ingroup file
|
||||
* The FileManager class.
|
||||
*/
|
||||
|
||||
#include "FileInfo.h"
|
||||
#include "respec/Specification.h"
|
||||
#include "IWriter.h"
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IFileInput;
|
||||
class IFileOutput;
|
||||
class IReader;
|
||||
class Buffer;
|
||||
|
||||
/**
|
||||
* The FileManager manages all file input and output plugins.
|
||||
*/
|
||||
class AUD_API FileManager
|
||||
{
|
||||
private:
|
||||
static std::list<std::shared_ptr<IFileInput>>& inputs();
|
||||
static std::list<std::shared_ptr<IFileOutput>>& outputs();
|
||||
|
||||
// delete copy constructor and operator=
|
||||
FileManager(const FileManager&) = delete;
|
||||
FileManager& operator=(const FileManager&) = delete;
|
||||
FileManager() = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Registers a file input used to create an IReader to read from a file.
|
||||
* @param input The IFileInput to register.
|
||||
*/
|
||||
static void registerInput(std::shared_ptr<IFileInput> input);
|
||||
|
||||
/**
|
||||
* Registers a file output used to create an IWriter to write to a file.
|
||||
* @param output The IFileOutput to register.
|
||||
*/
|
||||
static void registerOutput(std::shared_ptr<IFileOutput> output);
|
||||
|
||||
/**
|
||||
* Creates a file reader for the given filename if a registed IFileInput is able to read it.
|
||||
* @param filename The path to the file.
|
||||
* @param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
* @return The reader created.
|
||||
* @exception Exception If no file input can read the file an exception is thrown.
|
||||
*/
|
||||
static std::shared_ptr<IReader> createReader(const std::string &filename, int stream = 0);
|
||||
|
||||
/**
|
||||
* Creates a file reader for the given buffer if a registed IFileInput is able to read it.
|
||||
* @param buffer The buffer to read the file from.
|
||||
* @param stream The index of the audio stream within the file if it contains multiple audio streams.
|
||||
* @return The reader created.
|
||||
* @exception Exception If no file input can read the file an exception is thrown.
|
||||
*/
|
||||
static std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer, int stream = 0);
|
||||
|
||||
/**
|
||||
* Queries the streams of a sound file.
|
||||
* \param filename Path to the file to be read.
|
||||
* \return A vector with as many streams as there are in the file.
|
||||
* \exception Exception Thrown if the file specified cannot be read.
|
||||
*/
|
||||
static std::vector<StreamInfo> queryStreams(const std::string &filename);
|
||||
|
||||
/**
|
||||
* Queries the streams of a sound file.
|
||||
* \param buffer The in-memory file buffer.
|
||||
* \return A vector with as many streams as there are in the file.
|
||||
* \exception Exception Thrown if the file specified cannot be read.
|
||||
*/
|
||||
static std::vector<StreamInfo> queryStreams(std::shared_ptr<Buffer> buffer);
|
||||
|
||||
/**
|
||||
* Creates a file writer that writes a sound to the given file path.
|
||||
* Existing files will be overwritten.
|
||||
* @param filename The file path to write to.
|
||||
* @param specs The output specification.
|
||||
* @param format The container format for the file.
|
||||
* @param codec The codec used inside the container.
|
||||
* @param bitrate The bitrate to write with.
|
||||
* @return A writer that creates the file.
|
||||
* @exception Exception If no file output can write the file with the given specification an exception is thrown.
|
||||
*/
|
||||
static std::shared_ptr<IWriter> createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user