AudioStream: Swap to shared soundtouch library
Yay licensing requirements.
This commit is contained in:
@ -208,7 +208,7 @@ if(WIN32)
|
||||
#set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations")
|
||||
|
||||
set(DEPS_TO_COPY cpuinfo.dll discord-rpc.dll freetype.dll harfbuzz.dll libjpeg.dll libpng16.dll libsharpyuv.dll libwebp.dll
|
||||
SDL2.dll shaderc_shared.dll spirv-cross-c-shared.dll zlib1.dll zstd.dll)
|
||||
SDL2.dll shaderc_shared.dll soundtouch.dll spirv-cross-c-shared.dll zlib1.dll zstd.dll)
|
||||
foreach(DEP ${DEPS_TO_COPY})
|
||||
list(APPEND DEP_BINS "${CMAKE_PREFIX_PATH}/bin/${DEP}")
|
||||
endforeach()
|
||||
|
||||
@ -73,7 +73,7 @@ target_precompile_headers(util PRIVATE "pch.h")
|
||||
target_include_directories(util PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(util PUBLIC common simpleini imgui)
|
||||
target_link_libraries(util PRIVATE libchdr JPEG::JPEG PNG::PNG WebP::libwebp ZLIB::ZLIB soundtouch xxhash Zstd::Zstd reshadefx)
|
||||
target_link_libraries(util PRIVATE libchdr JPEG::JPEG PNG::PNG WebP::libwebp ZLIB::ZLIB SoundTouch::SoundTouchDLL xxhash Zstd::Zstd reshadefx)
|
||||
|
||||
if(ENABLE_X11)
|
||||
target_compile_definitions(util PRIVATE "-DENABLE_X11=1")
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
#include "common/small_string.h"
|
||||
#include "common/timer.h"
|
||||
|
||||
#include "SoundTouch.h"
|
||||
#include "soundtouch/SoundTouch.h"
|
||||
#include "soundtouch/SoundTouchDLL.h"
|
||||
|
||||
#ifndef __ANDROID__
|
||||
#include "freesurround_decoder.h"
|
||||
@ -505,9 +506,9 @@ void AudioStream::EmptyBuffer()
|
||||
|
||||
if (IsStretchEnabled())
|
||||
{
|
||||
m_soundtouch->clear();
|
||||
soundtouch_clear(m_soundtouch);
|
||||
if (m_parameters.stretch_mode == AudioStretchMode::TimeStretch)
|
||||
m_soundtouch->setTempo(m_nominal_rate);
|
||||
soundtouch_setTempo(m_soundtouch, m_nominal_rate);
|
||||
}
|
||||
|
||||
m_wpos.store(m_rpos.load(std::memory_order_acquire), std::memory_order_release);
|
||||
@ -517,9 +518,9 @@ void AudioStream::SetNominalRate(float tempo)
|
||||
{
|
||||
m_nominal_rate = tempo;
|
||||
if (m_parameters.stretch_mode == AudioStretchMode::Resample)
|
||||
m_soundtouch->setRate(tempo);
|
||||
soundtouch_setRate(m_soundtouch, tempo);
|
||||
else if (m_parameters.stretch_mode == AudioStretchMode::TimeStretch && m_stretch_inactive)
|
||||
m_soundtouch->setTempo(tempo);
|
||||
soundtouch_setTempo(m_soundtouch, tempo);
|
||||
}
|
||||
|
||||
void AudioStream::SetStretchMode(AudioStretchMode mode)
|
||||
@ -703,21 +704,21 @@ void AudioStream::StretchAllocate()
|
||||
if (m_parameters.stretch_mode == AudioStretchMode::Off)
|
||||
return;
|
||||
|
||||
m_soundtouch = std::make_unique<soundtouch::SoundTouch>();
|
||||
m_soundtouch->setSampleRate(m_sample_rate);
|
||||
m_soundtouch->setChannels(m_internal_channels);
|
||||
m_soundtouch = soundtouch_createInstance();
|
||||
soundtouch_setSampleRate(m_soundtouch, m_sample_rate);
|
||||
soundtouch_setChannels(m_soundtouch, m_internal_channels);
|
||||
|
||||
m_soundtouch->setSetting(SETTING_USE_QUICKSEEK, m_parameters.stretch_use_quickseek);
|
||||
m_soundtouch->setSetting(SETTING_USE_AA_FILTER, m_parameters.stretch_use_aa_filter);
|
||||
soundtouch_setSetting(m_soundtouch, SETTING_USE_QUICKSEEK, m_parameters.stretch_use_quickseek);
|
||||
soundtouch_setSetting(m_soundtouch, SETTING_USE_AA_FILTER, m_parameters.stretch_use_aa_filter);
|
||||
|
||||
m_soundtouch->setSetting(SETTING_SEQUENCE_MS, m_parameters.stretch_sequence_length_ms);
|
||||
m_soundtouch->setSetting(SETTING_SEEKWINDOW_MS, m_parameters.stretch_seekwindow_ms);
|
||||
m_soundtouch->setSetting(SETTING_OVERLAP_MS, m_parameters.stretch_overlap_ms);
|
||||
soundtouch_setSetting(m_soundtouch, SETTING_SEQUENCE_MS, m_parameters.stretch_sequence_length_ms);
|
||||
soundtouch_setSetting(m_soundtouch, SETTING_SEEKWINDOW_MS, m_parameters.stretch_seekwindow_ms);
|
||||
soundtouch_setSetting(m_soundtouch, SETTING_OVERLAP_MS, m_parameters.stretch_overlap_ms);
|
||||
|
||||
if (m_parameters.stretch_mode == AudioStretchMode::Resample)
|
||||
m_soundtouch->setRate(m_nominal_rate);
|
||||
soundtouch_setRate(m_soundtouch, m_nominal_rate);
|
||||
else
|
||||
m_soundtouch->setTempo(m_nominal_rate);
|
||||
soundtouch_setTempo(m_soundtouch, m_nominal_rate);
|
||||
|
||||
m_stretch_reset = STRETCH_RESET_THRESHOLD;
|
||||
m_stretch_inactive = false;
|
||||
@ -731,17 +732,21 @@ void AudioStream::StretchAllocate()
|
||||
|
||||
void AudioStream::StretchDestroy()
|
||||
{
|
||||
m_soundtouch.reset();
|
||||
if (m_soundtouch)
|
||||
{
|
||||
soundtouch_destroyInstance(m_soundtouch);
|
||||
m_soundtouch = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioStream::StretchWriteBlock(const float* block)
|
||||
{
|
||||
if (IsStretchEnabled())
|
||||
{
|
||||
m_soundtouch->putSamples(block, CHUNK_SIZE);
|
||||
soundtouch_putSamples(m_soundtouch, block, CHUNK_SIZE);
|
||||
|
||||
u32 tempProgress;
|
||||
while (tempProgress = m_soundtouch->receiveSamples(m_float_buffer.get(), CHUNK_SIZE), tempProgress != 0)
|
||||
while (tempProgress = soundtouch_receiveSamples(m_soundtouch, m_float_buffer.get(), CHUNK_SIZE), tempProgress != 0)
|
||||
{
|
||||
FloatChunkToS16(m_staging_buffer.get(), m_float_buffer.get(), tempProgress * m_internal_channels);
|
||||
InternalWriteFrames(m_staging_buffer.get(), tempProgress);
|
||||
@ -865,7 +870,7 @@ void AudioStream::UpdateStretchTempo()
|
||||
iterations++;
|
||||
}
|
||||
|
||||
m_soundtouch->setTempo(tempo);
|
||||
soundtouch_setTempo(m_soundtouch, tempo);
|
||||
|
||||
if (m_stretch_reset >= STRETCH_RESET_THRESHOLD)
|
||||
m_stretch_reset = 0;
|
||||
|
||||
@ -279,7 +279,7 @@ private:
|
||||
std::atomic<u32> m_rpos{0};
|
||||
std::atomic<u32> m_wpos{0};
|
||||
|
||||
std::unique_ptr<soundtouch::SoundTouch> m_soundtouch;
|
||||
void* m_soundtouch = nullptr;
|
||||
|
||||
u32 m_target_buffer_size = 0;
|
||||
u32 m_stretch_reset = STRETCH_RESET_THRESHOLD;
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DepsIncludeDir)SDL2</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);cpuinfo.lib;freetype.lib;libjpeg.lib;libpng16.lib;libwebp.lib;SDL2.lib;zlib.lib;zstd.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);cpuinfo.lib;freetype.lib;libjpeg.lib;libpng16.lib;libwebp.lib;SDL2.lib;soundtouch.lib;zlib.lib;zstd.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@ -41,6 +41,7 @@
|
||||
<DepsDLLs Include="$(DepsBinDir)libwebp.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)SDL2.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)shaderc_shared.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)soundtouch.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)spirv-cross-c-shared.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)zlib1.dll" />
|
||||
<DepsDLLs Include="$(DepsBinDir)zstd.dll" />
|
||||
|
||||
Reference in New Issue
Block a user