mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2026-05-06 07:56:46 -04:00
Replace libspeexdsp with custom linear resampling (#26011)
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
#
|
|
||||||
# - Find speexdsp libraries
|
|
||||||
#
|
|
||||||
# SPEEXDSP_INCLUDE_DIRS - where to find speexdsp headers.
|
|
||||||
# SPEEXDSP_LIBRARIES - List of libraries when using speexdsp.
|
|
||||||
# SPEEXDSP_FOUND - True if speexdsp is found.
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(PC_SPEEXDSP QUIET speexdsp)
|
|
||||||
|
|
||||||
find_path(SPEEXDSP_INCLUDE_DIR
|
|
||||||
NAMES
|
|
||||||
speex/speex_resampler.h
|
|
||||||
HINTS
|
|
||||||
${PC_SPEEXDSP_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(SPEEXDSP_LIBRARY
|
|
||||||
NAMES
|
|
||||||
speexdsp
|
|
||||||
HINTS
|
|
||||||
${PC_SPEEXDSP_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(SpeexDSP
|
|
||||||
REQUIRED_VARS SPEEXDSP_LIBRARY SPEEXDSP_INCLUDE_DIR
|
|
||||||
VERSION_VAR PC_SPEEXDSP_VERSION)
|
|
||||||
|
|
||||||
if(SPEEXDSP_FOUND)
|
|
||||||
set(SPEEXDSP_LIBRARIES ${SPEEXDSP_LIBRARY})
|
|
||||||
set(SPEEXDSP_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR})
|
|
||||||
set(SPEEX_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR})
|
|
||||||
else()
|
|
||||||
set(SPEEXDSP_LIBRARIES)
|
|
||||||
set(SPEEXDSP_INCLUDE_DIRS)
|
|
||||||
set(SPEEX_INCLUDE_DIRS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
mark_as_advanced(SPEEXDSP_LIBRARIES SPEEXDSP_INCLUDE_DIRS SPEEX_INCLUDE_DIRS)
|
|
||||||
Vendored
+1
-1
@@ -4,7 +4,7 @@ Section: misc
|
|||||||
Priority: optional
|
Priority: optional
|
||||||
Standards-Version: 3.9.2
|
Standards-Version: 3.9.2
|
||||||
Multi-Arch: same
|
Multi-Arch: same
|
||||||
Build-Depends: debhelper (>= 9), cmake (>= 3.8), libsdl2-dev, g++ (>= 4:10), pkg-config, nlohmann-json3-dev (>= 3.9.0), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0), libflac-dev, libvorbis-dev, libzstd-dev
|
Build-Depends: debhelper (>= 9), cmake (>= 3.8), libsdl2-dev, g++ (>= 4:10), pkg-config, nlohmann-json3-dev (>= 3.9.0), libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0), libflac-dev, libvorbis-dev, libzstd-dev
|
||||||
|
|
||||||
Package: openrct2
|
Package: openrct2
|
||||||
Architecture: any
|
Architecture: any
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
- Improved: [#21753] Tracked rides with cheated powered launch mode can change powered launch speed without extra cheats.
|
- Improved: [#21753] Tracked rides with cheated powered launch mode can change powered launch speed without extra cheats.
|
||||||
- Improved: [#25526] When a shop item cannot be recoloured, show a preview of the building instead.
|
- Improved: [#25526] When a shop item cannot be recoloured, show a preview of the building instead.
|
||||||
- Improved: [#25941] The command line sprite build command is now faster.
|
- Improved: [#25941] The command line sprite build command is now faster.
|
||||||
|
- Change: [#26011] Audio resampling no longer depends on the third-party library libspeexdsp.
|
||||||
- Fix: [#14686, #23996, #25981] Preview images from different windows overwrite each other when using OpenGL.
|
- Fix: [#14686, #23996, #25981] Preview images from different windows overwrite each other when using OpenGL.
|
||||||
- Fix: [#15128, #15626, #16331, #17443, #18626, #21597, #24175, #24971, #25963] Crash when loading corrupted RCT2/RCT1 save files with duplicate entity indices.
|
- Fix: [#15128, #15626, #16331, #17443, #18626, #21597, #24175, #24971, #25963] Crash when loading corrupted RCT2/RCT1 save files with duplicate entity indices.
|
||||||
- Fix: [#25237] Wrong colours on the Knight costume.
|
- Fix: [#25237] Wrong colours on the Knight costume.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Last updated: 2025-08-04
|
Last updated: 2026-02-15
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +146,6 @@ duktape | MIT licence.
|
|||||||
libcURL | MIT (or Modified BSD-style) licence.
|
libcURL | MIT (or Modified BSD-style) licence.
|
||||||
libicu | Unicode licence.
|
libicu | Unicode licence.
|
||||||
libpng | libpng licence.
|
libpng | libpng licence.
|
||||||
libspeex | BSD-style licence.
|
|
||||||
libzip | BSD 3 clause licence.
|
libzip | BSD 3 clause licence.
|
||||||
nlohmann-json | MIT licence.
|
nlohmann-json | MIT licence.
|
||||||
OpenSSL | OpenSSL licence.
|
OpenSSL | OpenSSL licence.
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalDependencies Condition="'$(Breakpad)'=='true' and ('$(Platform)'=='Win32' or '$(Platform)'=='x64')">libbreakpadd.lib;libbreakpad_clientd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies Condition="'$(Breakpad)'=='true' and ('$(Platform)'=='Win32' or '$(Platform)'=='x64')">libbreakpadd.lib;libbreakpad_clientd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalDependencies>bz2d.lib;discord-rpc.lib;flac.lib;freetyped.lib;libpng16d.lib;ogg.lib;speexdsp.lib;SDL2-staticd.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlibd.lib;zstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>bz2d.lib;discord-rpc.lib;flac.lib;freetyped.lib;libpng16d.lib;ogg.lib;SDL2-staticd.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlibd.lib;zstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release' or '$(Configuration)'=='ReleaseLTCG'">
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release' or '$(Configuration)'=='ReleaseLTCG'">
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalDependencies Condition="'$(Breakpad)'=='true' and ('$(Platform)'=='Win32' or '$(Platform)'=='x64')">libbreakpad.lib;libbreakpad_client.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies Condition="'$(Breakpad)'=='true' and ('$(Platform)'=='Win32' or '$(Platform)'=='x64')">libbreakpad.lib;libbreakpad_client.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalDependencies>bz2.lib;discord-rpc.lib;flac.lib;freetype.lib;libpng16.lib;ogg.lib;speexdsp.lib;SDL2-static.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlib.lib;zstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>bz2.lib;discord-rpc.lib;flac.lib;freetype.lib;libpng16.lib;ogg.lib;SDL2-static.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlib.lib;zstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ mkdir -p build
|
|||||||
cd build
|
cd build
|
||||||
|
|
||||||
START_DIR=$(pwd)
|
START_DIR=$(pwd)
|
||||||
SPEEXDSP_ROOT=/ext/speexdsp
|
|
||||||
ICU_ROOT=/ext/icu/icu4c/source
|
ICU_ROOT=/ext/icu/icu4c/source
|
||||||
LIBZIP_ROOT=/ext/libzip
|
LIBZIP_ROOT=/ext/libzip
|
||||||
ZSTD_ROOT=/ext/zstd
|
ZSTD_ROOT=/ext/zstd
|
||||||
@@ -22,8 +21,6 @@ emcmake cmake ../ \
|
|||||||
-DDISABLE_DISCORD_RPC=ON \
|
-DDISABLE_DISCORD_RPC=ON \
|
||||||
-DCMAKE_SYSTEM_NAME=Emscripten \
|
-DCMAKE_SYSTEM_NAME=Emscripten \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DSPEEXDSP_INCLUDE_DIR="$SPEEXDSP_ROOT/include/" \
|
|
||||||
-DSPEEXDSP_LIBRARY="$SPEEXDSP_ROOT/libspeexdsp/.libs/libspeexdsp.a" \
|
|
||||||
-DICU_INCLUDE_DIR="$ICU_ROOT/common" \
|
-DICU_INCLUDE_DIR="$ICU_ROOT/common" \
|
||||||
-DICU_DATA_LIBRARIES=$ICU_ROOT/lib/libicuuc.so \
|
-DICU_DATA_LIBRARIES=$ICU_ROOT/lib/libicuuc.so \
|
||||||
-DICU_DT_LIBRARY_RELEASE="$ICU_ROOT/stubdata/libicudata.so" \
|
-DICU_DT_LIBRARY_RELEASE="$ICU_ROOT/stubdata/libicudata.so" \
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ ExternalProject_Add(libs
|
|||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}freetype${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}freetype${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}png16${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}png16${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}speexdsp${CMAKE_SHARED_LIBRARY_SUFFIX}
|
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ssl${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ssl${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icudata${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icudata${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icui18n${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icui18n${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
@@ -76,7 +75,6 @@ add_custom_command(TARGET libs POST_BUILD
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libfreetype.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libfreetype.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libpng16.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libpng16.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libSDL2.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libSDL2.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libspeexdsp.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libssl.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libssl.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libz.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libz.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libzstd.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/libzstd.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||||
@@ -118,12 +116,6 @@ set_target_properties(SDL2main PROPERTIES IMPORTED_LOCATION
|
|||||||
)
|
)
|
||||||
add_dependencies(SDL2main libs)
|
add_dependencies(SDL2main libs)
|
||||||
|
|
||||||
add_library(speexdsp SHARED IMPORTED)
|
|
||||||
set_target_properties(speexdsp PROPERTIES IMPORTED_LOCATION
|
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}speexdsp${CMAKE_SHARED_LIBRARY_SUFFIX}
|
|
||||||
)
|
|
||||||
add_dependencies(speexdsp libs)
|
|
||||||
|
|
||||||
add_library(icu STATIC IMPORTED)
|
add_library(icu STATIC IMPORTED)
|
||||||
set_target_properties(icu PROPERTIES IMPORTED_LOCATION
|
set_target_properties(icu PROPERTIES IMPORTED_LOCATION
|
||||||
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icui18n${CMAKE_SHARED_LIBRARY_SUFFIX}
|
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}icui18n${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
@@ -207,9 +199,6 @@ add_definitions(-DDISABLE_DISCORD_RPC -DDISABLE_OPENGL -DGL_GLEXT_PROTOTYPES -D_
|
|||||||
# Enable scripting
|
# Enable scripting
|
||||||
add_definitions(-DENABLE_SCRIPTING)
|
add_definitions(-DENABLE_SCRIPTING)
|
||||||
|
|
||||||
# Fix SpeexDSP compilation
|
|
||||||
add_definitions(-DHAVE_STDINT_H)
|
|
||||||
|
|
||||||
# -Werror -Wall
|
# -Werror -Wall
|
||||||
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Wundef -Wmissing-declarations -Winit-self -Wno-unknown-pragmas -Wno-unused-function -Wno-missing-braces ")
|
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Wundef -Wmissing-declarations -Winit-self -Wno-unknown-pragmas -Wno-unused-function -Wno-missing-braces ")
|
||||||
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-comment -Wshadow -Wmissing-declarations -Wnonnull")
|
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-comment -Wshadow -Wmissing-declarations -Wnonnull")
|
||||||
@@ -261,7 +250,7 @@ add_library(openrct2 SHARED ${LIBOPENRCT2_SOURCES})
|
|||||||
target_link_libraries(openrct2 android stdc++ log dl SDL2 png z zstd icu icuuc icudata crypto ssl freetype)
|
target_link_libraries(openrct2 android stdc++ log dl SDL2 png z zstd icu icuuc icudata crypto ssl freetype)
|
||||||
|
|
||||||
add_library(openrct2-ui SHARED ${OPENRCT2_GUI_SOURCES})
|
add_library(openrct2-ui SHARED ${OPENRCT2_GUI_SOURCES})
|
||||||
target_link_libraries(openrct2-ui openrct2 android stdc++ GLESv1_CM GLESv2 SDL2main speexdsp brotlicommon brotlidec bz2 freetype ogg vorbis vorbisfile FLAC)
|
target_link_libraries(openrct2-ui openrct2 android stdc++ GLESv1_CM GLESv2 SDL2main brotlicommon brotlidec bz2 freetype ogg vorbis vorbisfile FLAC)
|
||||||
|
|
||||||
add_executable(openrct2-cli ${OPENRCT2_CLI_SOURCES})
|
add_executable(openrct2-cli ${OPENRCT2_CLI_SOURCES})
|
||||||
target_link_libraries(openrct2-cli openrct2 android stdc++ GLESv1_CM GLESv2)
|
target_link_libraries(openrct2-cli openrct2 android stdc++ GLESv1_CM GLESv2)
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ public class GameActivity extends SDLActivity {
|
|||||||
protected String[] getLibraries() {
|
protected String[] getLibraries() {
|
||||||
return new String[]{
|
return new String[]{
|
||||||
"c++_shared",
|
"c++_shared",
|
||||||
"speexdsp",
|
|
||||||
"bz2",
|
"bz2",
|
||||||
"freetype",
|
"freetype",
|
||||||
"z",
|
"z",
|
||||||
|
|||||||
@@ -13,20 +13,10 @@ if (EMSCRIPTEN)
|
|||||||
set(SHARED_FLAGS "-fexceptions")
|
set(SHARED_FLAGS "-fexceptions")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS} -sEXPORTED_FUNCTIONS=${EMSCRIPTEN_EXPORTED_FUNCTIONS} --js-library ${ROOT_DIR}/emscripten/deps.js")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS} -sEXPORTED_FUNCTIONS=${EMSCRIPTEN_EXPORTED_FUNCTIONS} --js-library ${ROOT_DIR}/emscripten/deps.js")
|
||||||
find_package(SpeexDSP REQUIRED)
|
|
||||||
elseif (MSVC)
|
elseif (MSVC)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_library(SPEEX_LDFLAGS libspeexdsp)
|
|
||||||
if (NOT DISABLE_FLAC)
|
|
||||||
find_library(SPEEX_LDFLAGS libflac)
|
|
||||||
endif ()
|
|
||||||
if (NOT DISABLE_VORBIS)
|
|
||||||
find_library(SPEEX_LDFLAGS libogg)
|
|
||||||
find_library(SPEEX_LDFLAGS libvorbis)
|
|
||||||
endif ()
|
|
||||||
else ()
|
else ()
|
||||||
PKG_CHECK_MODULES(SDL2 REQUIRED IMPORTED_TARGET sdl2)
|
PKG_CHECK_MODULES(SDL2 REQUIRED IMPORTED_TARGET sdl2)
|
||||||
PKG_CHECK_MODULES(SPEEX REQUIRED IMPORTED_TARGET speexdsp)
|
|
||||||
if (NOT DISABLE_FLAC)
|
if (NOT DISABLE_FLAC)
|
||||||
PKG_CHECK_MODULES(FLAC REQUIRED IMPORTED_TARGET flac)
|
PKG_CHECK_MODULES(FLAC REQUIRED IMPORTED_TARGET flac)
|
||||||
endif ()
|
endif ()
|
||||||
@@ -67,17 +57,14 @@ ipo_set_target_properties(openrct2)
|
|||||||
# mingw builds cannot use the PkgConfig imported targets
|
# mingw builds cannot use the PkgConfig imported targets
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
target_link_libraries(openrct2 "libopenrct2"
|
target_link_libraries(openrct2 "libopenrct2"
|
||||||
${SPEEXDSP_LIBRARIES}
|
|
||||||
${ICU_DATA_LIBRARIES}
|
${ICU_DATA_LIBRARIES}
|
||||||
${ICU_DT_LIBRARY_RELEASE})
|
${ICU_DT_LIBRARY_RELEASE})
|
||||||
elseif (NOT MSVC AND NOT WIN32)
|
elseif (NOT MSVC AND NOT WIN32)
|
||||||
target_link_libraries(openrct2 "libopenrct2"
|
target_link_libraries(openrct2 "libopenrct2"
|
||||||
PkgConfig::SDL2
|
PkgConfig::SDL2)
|
||||||
PkgConfig::SPEEX)
|
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(openrct2 "libopenrct2"
|
target_link_libraries(openrct2 "libopenrct2"
|
||||||
${SDL2_LDFLAGS}
|
${SDL2_LDFLAGS})
|
||||||
${SPEEX_LDFLAGS})
|
|
||||||
endif ()
|
endif ()
|
||||||
target_link_platform_libraries(openrct2)
|
target_link_platform_libraries(openrct2)
|
||||||
|
|
||||||
@@ -109,7 +96,6 @@ endif ()
|
|||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
target_include_directories(openrct2 PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
|
target_include_directories(openrct2 PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
|
||||||
${SPEEX_INCLUDE_DIRS}
|
|
||||||
${OGG_INCLUDE_DIRS}
|
${OGG_INCLUDE_DIRS}
|
||||||
${VORBIS_INCLUDE_DIRS}
|
${VORBIS_INCLUDE_DIRS}
|
||||||
${FLAC_INCLUDE_DIRS})
|
${FLAC_INCLUDE_DIRS})
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <openrct2/audio/AudioSource.h>
|
#include <openrct2/audio/AudioSource.h>
|
||||||
#include <speex/speex_resampler.h>
|
|
||||||
|
|
||||||
namespace OpenRCT2::Audio
|
namespace OpenRCT2::Audio
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,6 @@ namespace OpenRCT2::Audio
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
AudioSource_* _source = nullptr;
|
AudioSource_* _source = nullptr;
|
||||||
SpeexResamplerState* _resampler = nullptr;
|
|
||||||
|
|
||||||
MixerGroup _group = MixerGroup::Sound;
|
MixerGroup _group = MixerGroup::Sound;
|
||||||
double _rate = 0;
|
double _rate = 0;
|
||||||
@@ -52,30 +50,11 @@ namespace OpenRCT2::Audio
|
|||||||
AudioChannelImpl::SetPan(0.5f);
|
AudioChannelImpl::SetPan(0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
~AudioChannelImpl() override
|
|
||||||
{
|
|
||||||
if (_resampler != nullptr)
|
|
||||||
{
|
|
||||||
speex_resampler_destroy(_resampler);
|
|
||||||
_resampler = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] IAudioSource* GetSource() const override
|
[[nodiscard]] IAudioSource* GetSource() const override
|
||||||
{
|
{
|
||||||
return _source;
|
return _source;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] SpeexResamplerState* GetResampler() const override
|
|
||||||
{
|
|
||||||
return _resampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetResampler(SpeexResamplerState* value) override
|
|
||||||
{
|
|
||||||
_resampler = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] MixerGroup GetGroup() const override
|
[[nodiscard]] MixerGroup GetGroup() const override
|
||||||
{
|
{
|
||||||
return _group;
|
return _group;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct SDL_RWops;
|
struct SDL_RWops;
|
||||||
using SpeexResamplerState = struct SpeexResamplerState_;
|
|
||||||
|
|
||||||
namespace OpenRCT2::Audio
|
namespace OpenRCT2::Audio
|
||||||
{
|
{
|
||||||
@@ -25,8 +24,6 @@ namespace OpenRCT2::Audio
|
|||||||
struct ISDLAudioChannel : public IAudioChannel
|
struct ISDLAudioChannel : public IAudioChannel
|
||||||
{
|
{
|
||||||
[[nodiscard]] virtual AudioFormat GetFormat() const = 0;
|
[[nodiscard]] virtual AudioFormat GetFormat() const = 0;
|
||||||
[[nodiscard]] virtual SpeexResamplerState* GetResampler() const = 0;
|
|
||||||
virtual void SetResampler(SpeexResamplerState* value) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace AudioChannel
|
namespace AudioChannel
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <speex/speex_resampler.h>
|
|
||||||
|
|
||||||
using namespace OpenRCT2::Audio;
|
using namespace OpenRCT2::Audio;
|
||||||
|
|
||||||
@@ -124,6 +123,7 @@ const AudioFormat& AudioMixer::GetFormat() const
|
|||||||
return _outputFormat;
|
return _outputFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length)
|
void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length)
|
||||||
{
|
{
|
||||||
UpdateAdjustedSound();
|
UpdateAdjustedSound();
|
||||||
@@ -156,6 +156,7 @@ void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::UpdateAdjustedSound()
|
void AudioMixer::UpdateAdjustedSound()
|
||||||
{
|
{
|
||||||
// Did the volume level get changed? Recalculate level in this case.
|
// Did the volume level get changed? Recalculate level in this case.
|
||||||
@@ -171,6 +172,7 @@ void AudioMixer::UpdateAdjustedSound()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t length)
|
void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t length)
|
||||||
{
|
{
|
||||||
int32_t outputByteRate = _outputFormat.GetByteRate();
|
int32_t outputByteRate = _outputFormat.GetByteRate();
|
||||||
@@ -236,8 +238,7 @@ void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t len
|
|||||||
outRate = _outputFormat.freq * (1 / rate);
|
outRate = _outputFormat.freq * (1 / rate);
|
||||||
}
|
}
|
||||||
_effectBuffer.resize(length);
|
_effectBuffer.resize(length);
|
||||||
bufferLen = ApplyResample(
|
bufferLen = ApplyResample(buffer, static_cast<int32_t>(bufferLen / outputByteRate), numSamples, inRate, outRate);
|
||||||
channel, buffer, static_cast<int32_t>(bufferLen / outputByteRate), numSamples, inRate, outRate);
|
|
||||||
buffer = _effectBuffer.data();
|
buffer = _effectBuffer.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,30 +257,60 @@ void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t len
|
|||||||
/**
|
/**
|
||||||
* Resample the given buffer into _effectBuffer.
|
* Resample the given buffer into _effectBuffer.
|
||||||
* Assumes that srcBuffer is the same format as _outputFormat.
|
* Assumes that srcBuffer is the same format as _outputFormat.
|
||||||
|
*
|
||||||
|
* TODO: investigate replacing this with OpenAL (#26035)
|
||||||
*/
|
*/
|
||||||
size_t AudioMixer::ApplyResample(
|
size_t AudioMixer::ApplyResample(const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate)
|
||||||
ISDLAudioChannel* channel, const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate)
|
|
||||||
{
|
{
|
||||||
int32_t outputByteRate = _outputFormat.GetByteRate();
|
// Prevent buffer underread in inner loop
|
||||||
|
if (srcSamples < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Create resampler
|
const int channels = _outputFormat.channels;
|
||||||
SpeexResamplerState* resampler = channel->GetResampler();
|
const int bytesPerFrame = channels * sizeof(int16_t);
|
||||||
if (resampler == nullptr)
|
|
||||||
|
const int16_t* src = static_cast<const int16_t*>(srcBuffer);
|
||||||
|
int16_t* dst = reinterpret_cast<int16_t*>(_effectBuffer.data());
|
||||||
|
|
||||||
|
double ratio = static_cast<double>(inRate) / static_cast<double>(outRate);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < dstSamples; ++i)
|
||||||
{
|
{
|
||||||
resampler = speex_resampler_init(_outputFormat.channels, _outputFormat.freq, _outputFormat.freq, 0, nullptr);
|
double srcPos = i * ratio;
|
||||||
channel->SetResampler(resampler);
|
int32_t index = static_cast<int32_t>(srcPos);
|
||||||
|
double frac = srcPos - index;
|
||||||
|
|
||||||
|
// Clamp to avoid reading past end
|
||||||
|
if (index >= srcSamples - 1)
|
||||||
|
{
|
||||||
|
index = srcSamples - 2;
|
||||||
|
frac = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int ch = 0; ch < channels; ++ch)
|
||||||
|
{
|
||||||
|
int32_t baseIndex = index * channels + ch;
|
||||||
|
|
||||||
|
int16_t s1 = src[baseIndex];
|
||||||
|
int16_t s2 = src[baseIndex + channels];
|
||||||
|
|
||||||
|
// Linear interpolation
|
||||||
|
double sample = (1.0 - frac) * s1 + frac * s2;
|
||||||
|
|
||||||
|
// Clamp to int16 range
|
||||||
|
if (sample > 32767.0)
|
||||||
|
sample = 32767.0;
|
||||||
|
if (sample < -32768.0)
|
||||||
|
sample = -32768.0;
|
||||||
|
|
||||||
|
dst[i * channels + ch] = static_cast<int16_t>(sample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
speex_resampler_set_rate(resampler, inRate, outRate);
|
|
||||||
|
|
||||||
uint32_t inLen = srcSamples;
|
return dstSamples * bytesPerFrame;
|
||||||
uint32_t outLen = dstSamples;
|
|
||||||
speex_resampler_process_interleaved_int(
|
|
||||||
resampler, static_cast<const spx_int16_t*>(srcBuffer), &inLen, reinterpret_cast<spx_int16_t*>(_effectBuffer.data()),
|
|
||||||
&outLen);
|
|
||||||
|
|
||||||
return outLen * outputByteRate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize)
|
void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize)
|
||||||
{
|
{
|
||||||
if (channel->GetPan() != 0.5f && _outputFormat.channels == 2)
|
if (channel->GetPan() != 0.5f && _outputFormat.channels == 2)
|
||||||
@@ -296,6 +327,7 @@ void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len)
|
int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len)
|
||||||
{
|
{
|
||||||
float volumeAdjust = _volume;
|
float volumeAdjust = _volume;
|
||||||
@@ -347,6 +379,7 @@ int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size
|
|||||||
return mixVolume;
|
return mixVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length)
|
void AudioMixer::EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length)
|
||||||
{
|
{
|
||||||
const float dt = 1.0f / static_cast<float>(length * 2.0f);
|
const float dt = 1.0f / static_cast<float>(length * 2.0f);
|
||||||
@@ -364,6 +397,7 @@ void AudioMixer::EffectPanS16(const IAudioChannel* channel, int16_t* data, int32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::EffectPanU8(const IAudioChannel* channel, uint8_t* data, int32_t length)
|
void AudioMixer::EffectPanU8(const IAudioChannel* channel, uint8_t* data, int32_t length)
|
||||||
{
|
{
|
||||||
float volumeL = channel->GetVolumeL();
|
float volumeL = channel->GetVolumeL();
|
||||||
@@ -379,6 +413,7 @@ void AudioMixer::EffectPanU8(const IAudioChannel* channel, uint8_t* data, int32_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::EffectFadeS16(int16_t* data, int32_t length, int32_t startvolume, int32_t endvolume)
|
void AudioMixer::EffectFadeS16(int16_t* data, int32_t length, int32_t startvolume, int32_t endvolume)
|
||||||
{
|
{
|
||||||
static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2");
|
static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2");
|
||||||
@@ -392,6 +427,7 @@ void AudioMixer::EffectFadeS16(int16_t* data, int32_t length, int32_t startvolum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate replacing this with OpenAL (#26035)
|
||||||
void AudioMixer::EffectFadeU8(uint8_t* data, int32_t length, int32_t startvolume, int32_t endvolume)
|
void AudioMixer::EffectFadeU8(uint8_t* data, int32_t length, int32_t startvolume, int32_t endvolume)
|
||||||
{
|
{
|
||||||
static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2");
|
static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2");
|
||||||
|
|||||||
@@ -69,9 +69,7 @@ namespace OpenRCT2::Audio
|
|||||||
* Resample the given buffer into _effectBuffer.
|
* Resample the given buffer into _effectBuffer.
|
||||||
* Assumes that srcBuffer is the same format as _outputFormat.
|
* Assumes that srcBuffer is the same format as _outputFormat.
|
||||||
*/
|
*/
|
||||||
size_t ApplyResample(
|
size_t ApplyResample(const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate);
|
||||||
ISDLAudioChannel* channel, const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate,
|
|
||||||
int32_t outRate);
|
|
||||||
void ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize);
|
void ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize);
|
||||||
int32_t ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len);
|
int32_t ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len);
|
||||||
static void EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length);
|
static void EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length);
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ if (EMSCRIPTEN)
|
|||||||
set(SHARED_FLAGS "-fexceptions")
|
set(SHARED_FLAGS "-fexceptions")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS}")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS}")
|
||||||
find_package(SpeexDSP REQUIRED)
|
|
||||||
elseif (MSVC)
|
elseif (MSVC)
|
||||||
find_package(png 1.6 REQUIRED)
|
find_package(png 1.6 REQUIRED)
|
||||||
find_package(zlib REQUIRED)
|
find_package(zlib REQUIRED)
|
||||||
|
|||||||
Reference in New Issue
Block a user