remotes/1734709060101541481/main
cosmonaut 2021-10-29 02:36:36 -07:00
parent 250d54f2d9
commit 4ccbf5c79e
4 changed files with 162 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vscode
.vs
visualc/x64
build/

135
CMakeLists.txt Normal file
View File

@ -0,0 +1,135 @@
# CMake Project for FAudioGMS
cmake_minimum_required(VERSION 2.8.12)
project(FAudioGMS C)
#Options
option(BUILD_SHARED_LIBS "Build shared library" ON)
SET(LIB_MAJOR_VERSION "0")
SET(LIB_MINOR_VERSION "2")
SET(LIB_REVISION "0")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
# Build Type
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
# By default, we use Release
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE
)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "RelWithDebInfo"
)
endif()
# Platform Flags
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
set(LOBJC "objc")
elseif(WIN32)
# "FAudioGMS.dll", not "libFAudioGMS.dll"
set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif()
# Source lists
add_library(FAudioGMS
#Public header
src/FAudioGMS.h
#Source files
lib/dr_wav.h
src/FAudioGMS.c
)
# FAudio Source lists
add_library(FAudio STATIC
# Public Headers
lib/FAudio/include/F3DAudio.h
lib/FAudio/include/FACT3D.h
lib/FAudio/include/FACT.h
lib/FAudio/include/FAPOBase.h
lib/FAudio/include/FAPOFX.h
lib/FAudio/include/FAPO.h
lib/FAudio/include/FAudioFX.h
lib/FAudio/include/FAudio.h
# Internal Headers
lib/FAudio/src/FACT_internal.h
lib/FAudio/src/FAudio_internal.h
lib/FAudio/src/stb.h
lib/FAudio/src/stb_vorbis.h
# Source Files
lib/FAudio/src/F3DAudio.c
lib/FAudio/src/FACT3D.c
lib/FAudio/src/FACT.c
lib/FAudio/src/FACT_internal.c
lib/FAudio/src/FAPOBase.c
lib/FAudio/src/FAPOFX.c
lib/FAudio/src/FAPOFX_echo.c
lib/FAudio/src/FAPOFX_eq.c
lib/FAudio/src/FAPOFX_masteringlimiter.c
lib/FAudio/src/FAPOFX_reverb.c
lib/FAudio/src/FAudio.c
lib/FAudio/src/FAudioFX_reverb.c
lib/FAudio/src/FAudioFX_volumemeter.c
lib/FAudio/src/FAudio_internal.c
lib/FAudio/src/FAudio_internal_simd.c
lib/FAudio/src/FAudio_operationset.c
lib/FAudio/src/FAudio_platform_sdl2.c
lib/FAudio/src/FAudio_platform_win32.c
)
# Build flags
if(NOT MSVC)
set_property(TARGET FAudioGMS PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic")
set_property(TARGET FAudio PROPERTY COMPILE_FLAGS "-fPIC")
endif()
# includes
target_include_directories(FAudioGMS PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/FAudio/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL/include>
)
target_include_directories(FAudio PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/FAudio/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL/include>
)
# Soname
set_target_properties(FAudioGMS PROPERTIES OUTPUT_NAME "FAudioGMS"
VERSION ${LIB_VERSION}
SOVERSION ${LIB_MAJOR_VERSION}
)
# Internal Dependencies
target_link_libraries(FAudioGMS PRIVATE FAudio ${LOBJC})
# SDL2 Dependency
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(FAudioGMS PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_include_directories(FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(FAudioGMS PUBLIC ${SDL2_LIBRARIES})
else()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if (TARGET SDL2::SDL2)
message(STATUS "using TARGET SDL2::SDL2")
target_link_libraries(FAudioGMS PUBLIC SDL2::SDL2)
target_link_libraries(FAudio PUBLIC SDL2::SDL2)
elseif (TARGET SDL2)
message(STATUS "using TARGET SDL2")
target_link_libraries(FAudioGMS PUBLIC SDL2)
target_link_libraries(FAudio PUBLIC SDL2)
else()
message(STATUS "no TARGET SDL2::SDL2, or SDL2, using variables")
target_include_directories(FAudioGMS PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_include_directories(FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(FAudioGMS PUBLIC ${SDL2_LIBRARIES})
endif()
endif()

View File

@ -46,6 +46,24 @@ I will not be supporting 32-bit Windows. Catch up to 2004 and switch to 64-bit.
FAudioGMS depends on FAudio (obviously) and SDL2. We avoid directly depending on the C runtime.
## Building
### Windows
Open the project contained in the `visualc` directory in Visual Studio and build.
### OSX/Linux
```sh
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -S . -B ./build
cd ./build
make
```
### Console Platforms
You will need to show proof of NDA to obtain SDL source for your platform.
## License
This library is licensed under the zlib license. See LICENSE file for details.

View File

@ -692,7 +692,7 @@ static FAudioGMS_SoundInstance* FAudioGMS_INTERNAL_SoundInstance_CreateFromStati
double FAudioGMS_StaticSound_CreateSoundInstance(double staticSoundID)
{
RETURN_ON_NULL_DEVICE()
RETURN_ON_NULL_DEVICE(-1.0)
FAudioGMS_StaticSound* staticSound = FAudioGMS_INTERNAL_LookupStaticSound((uint32_t)staticSoundID);
if (staticSound != NULL)
@ -1078,9 +1078,9 @@ void FAudioGMS_SoundInstance_Set3DVelocity(double soundInstanceID, double xVeloc
return;
}
instance->emitter->Velocity.x;
instance->emitter->Velocity.y;
instance->emitter->Velocity.z;
instance->emitter->Velocity.x = xVelocity;
instance->emitter->Velocity.y = yVelocity;
instance->emitter->Velocity.z = zVelocity;
}
}
@ -1196,7 +1196,7 @@ double FAudioGMS_SoundInstance_GetTrackPositionInSeconds(double soundInstanceID)
uint32_t sampleFrame = instance->handle->src.curBufferOffset / sizeof(float);
return sampleFrame / instance->format.nSamplesPerSec;
}
else
else
{
Log("Invalid sound instance!");
return -1.0;
@ -1443,7 +1443,7 @@ void FAudioGMS_SoundInstance_SetEffectGain(double soundInstanceID, double effect
{
RETURN_ON_NULL_DEVICE()
FAudioGMS_SoundInstance *instance = FAudioGMS_INTERNAL_LookupSoundInstance((uint32_t)soundInstanceID);
if (instance != NULL)
{
FAudioGMS_INTERNAL_SoundInstance_SetEffectGain(instance, effectGain);
@ -1475,7 +1475,7 @@ static FAudioEffectChain* FAudioGMS_INTERNAL_CreateFAudioEffectChain(FAudioGMS_E
default:
Log("Unknown effect type! Something is very wrong!");
return;
return NULL;
}
}
@ -1554,13 +1554,12 @@ void FAudioGMS_SoundInstance_SetEffectChain(double soundInstanceID, double effec
FAPOBase_Release((FAPOBase*)fAudioEffectChain->pEffectDescriptors[i].pEffect);
}
SDL_free(fAudioEffectChain->pEffectDescriptors);
SDL_free(fAudioEffectChain);
SDL_free(fAudioEffectChain);
}
}
static void FAudioGMS_INTERNAL_EffectChain_Destroy(FAudioGMS_EffectChain *effectChain)
{
uint32_t i;
if (effectChain != NULL)
{
device->effectChains[effectChain->id] = NULL;