Use resid submodule from libsidplayfp (#6883)

This commit is contained in:
saker
2023-09-23 19:33:20 -04:00
committed by GitHub
parent f0aa2862d7
commit 49c713df5b
7 changed files with 108 additions and 63 deletions

6
.gitmodules vendored
View File

@@ -40,9 +40,9 @@
[submodule "plugins/CarlaBase/carla"]
path = plugins/CarlaBase/carla
url = https://github.com/falktx/carla
[submodule "plugins/Sid/resid"]
path = plugins/Sid/resid
url = https://github.com/simonowen/resid
[submodule "plugins/Sid/resid/resid"]
path = plugins/Sid/resid/resid
url = https://github.com/libsidplayfp/resid
[submodule "src/3rdparty/jack2"]
path = src/3rdparty/jack2
url = https://github.com/jackaudio/jack2

View File

@@ -77,6 +77,7 @@ OPTION(WANT_SOUNDIO "Include libsoundio support" ON)
OPTION(WANT_SDL "Include SDL (Simple DirectMedia Layer) support" ON)
OPTION(WANT_SF2 "Include SoundFont2 player plugin" ON)
OPTION(WANT_GIG "Include GIG player plugin" ON)
option(WANT_SID "Include Sid instrument" ON)
OPTION(WANT_STK "Include Stk (Synthesis Toolkit) support" ON)
OPTION(WANT_SWH "Include Steve Harris's LADSPA plugins" ON)
OPTION(WANT_TAP "Include Tom's Audio Processing LADSPA plugins" ON)
@@ -211,6 +212,13 @@ CHECK_CXX_SOURCE_COMPILES(
LMMS_HAVE_SF_COMPLEVEL
)
# check for perl
if(LMMS_BUILD_APPLE)
# Prefer system perl over Homebrew, MacPorts, etc
set(Perl_ROOT "/usr/bin")
endif()
find_package(Perl)
IF(WANT_LV2)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LV2 lv2)
@@ -273,11 +281,6 @@ ELSE(WANT_CMT)
ENDIF(WANT_CMT)
IF(WANT_SWH)
IF(LMMS_BUILD_APPLE)
# Prefer system perl over Homebrew, MacPorts, etc
SET(Perl_ROOT "/usr/bin")
ENDIF()
FIND_PACKAGE(Perl)
IF(PERL_FOUND)
SET(LMMS_HAVE_SWH TRUE)
SET(STATUS_SWH "OK")
@@ -349,6 +352,16 @@ IF(WANT_SDL AND NOT LMMS_HAVE_SDL2)
ENDIF()
ENDIF()
# check for Sid
if(WANT_SID)
if(PERL_FOUND)
set(LMMS_HAVE_SID TRUE)
set(STATUS_SID "OK")
else()
set(STATUS_SID "not found, please install perl if you require the Sid instrument")
endif()
endif()
# check for Stk
IF(WANT_STK)
FIND_PACKAGE(STK)
@@ -816,6 +829,7 @@ MESSAGE(
"* ZynAddSubFX instrument : ${STATUS_ZYN}\n"
"* Carla Patchbay & Rack : ${STATUS_CARLA}\n"
"* SoundFont2 player : ${STATUS_FLUIDSYNTH}\n"
"* Sid instrument : ${STATUS_SID}\n"
"* Stk Mallets : ${STATUS_STK}\n"
"* VST-instrument hoster : ${STATUS_VST}\n"
"* VST-effect hoster : ${STATUS_VST}\n"

View File

@@ -1,51 +1,14 @@
INCLUDE(BuildPlugin)
INCLUDE_DIRECTORIES(resid)
if(NOT LMMS_HAVE_SID)
return()
endif()
BUILD_PLUGIN(sid
SidInstrument.cpp
SidInstrument.h
resid/envelope.h
resid/extfilt.h
resid/filter.h
resid/pot.h
resid/siddefs.h
resid/sid.h
resid/spline.h
resid/voice.h
resid/wave.h
resid/envelope.cc
resid/extfilt.cc
resid/filter.cc
resid/pot.cc
resid/sid.cc
resid/version.cc
resid/voice.cc
resid/wave6581_PS_.cc
resid/wave6581_PST.cc
resid/wave6581_P_T.cc
resid/wave6581__ST.cc
resid/wave8580_PS_.cc
resid/wave8580_PST.cc
resid/wave8580_P_T.cc
resid/wave8580__ST.cc
resid/wave.cc
MOCFILES SidInstrument.h
EMBEDDED_RESOURCES *.png)
# Parse VERSION
FILE(READ "resid/CMakeLists.txt" lines)
STRING(REGEX MATCH "set\\(MAJOR_VER [A-Za-z0-9_]*\\)" MAJOR_RAW ${lines})
STRING(REGEX MATCH "set\\(MINOR_VER [A-Za-z0-9_]*\\)" MINOR_RAW ${lines})
STRING(REGEX MATCH "set\\(PATCH_VER [A-Za-z0-9_]*\\)" PATCH_RAW ${lines})
SEPARATE_ARGUMENTS(MAJOR_RAW)
SEPARATE_ARGUMENTS(MINOR_RAW)
SEPARATE_ARGUMENTS(PATCH_RAW)
LIST(GET MAJOR_RAW 1 MAJOR_RAW)
LIST(GET MINOR_RAW 1 MINOR_RAW)
LIST(GET PATCH_RAW 1 PATCH_RAW)
STRING(REPLACE ")" "" MAJOR_VER "${MAJOR_RAW}")
STRING(REPLACE ")" "" MINOR_VER "${MINOR_RAW}")
STRING(REPLACE ")" "" PATCH_VER "${PATCH_RAW}")
TARGET_COMPILE_DEFINITIONS(sid PRIVATE VERSION="${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}")
add_subdirectory(resid)
target_link_libraries(sid resid)

View File

@@ -239,7 +239,7 @@ f_cnt_t SidInstrument::desiredReleaseFrames() const
static int sid_fillbuffer(unsigned char* sidreg, SID *sid, int tdelta, short *ptr, int samples)
static int sid_fillbuffer(unsigned char* sidreg, reSID::SID *sid, int tdelta, short *ptr, int samples)
{
int tdelta2;
int result;
@@ -302,9 +302,9 @@ void SidInstrument::playNote( NotePlayHandle * _n,
if (!_n->m_pluginData)
{
SID *sid = new SID();
sid->set_sampling_parameters( clockrate, SAMPLE_FAST, samplerate );
sid->set_chip_model( MOS8580 );
auto sid = new reSID::SID();
sid->set_sampling_parameters(clockrate, reSID::SAMPLE_FAST, samplerate);
sid->set_chip_model(reSID::MOS8580);
sid->enable_filter( true );
sid->reset();
_n->m_pluginData = sid;
@@ -312,7 +312,7 @@ void SidInstrument::playNote( NotePlayHandle * _n,
const fpp_t frames = _n->framesLeftForCurrentPeriod();
const f_cnt_t offset = _n->noteOffset();
SID *sid = static_cast<SID *>( _n->m_pluginData );
auto sid = static_cast<reSID::SID*>(_n->m_pluginData);
int delta_t = clockrate * frames / samplerate + 4;
// avoid variable length array for msvc compat
auto buf = reinterpret_cast<short*>(_working_buffer + offset);
@@ -325,20 +325,20 @@ void SidInstrument::playNote( NotePlayHandle * _n,
if( (ChipModel)m_chipModel.value() == ChipModel::MOS6581 )
{
sid->set_chip_model( MOS6581 );
sid->set_chip_model(reSID::MOS6581);
}
else
{
sid->set_chip_model( MOS8580 );
sid->set_chip_model(reSID::MOS8580);
}
// voices
reg8 data8 = 0;
reg8 data16 = 0;
reg8 base = 0;
reSID::reg8 data8 = 0;
reSID::reg16 data16 = 0;
size_t base = 0;
float freq = 0.0;
float note = 0.0;
for( reg8 i = 0 ; i < 3 ; ++i )
for (size_t i = 0; i < 3; ++i)
{
base = i*7;
// freq ( Fn = Fout / Fclk * 16777216 ) + coarse detuning
@@ -436,7 +436,7 @@ void SidInstrument::playNote( NotePlayHandle * _n,
void SidInstrument::deleteNotePluginData( NotePlayHandle * _n )
{
delete static_cast<SID *>( _n->m_pluginData );
delete static_cast<reSID::SID*>(_n->m_pluginData);
}

View File

@@ -0,0 +1,68 @@
# These are the defaults
set(RESID_INLINING 1)
set(RESID_INLINE inline)
set(RESID_BRANCH_HINTS 1)
set(NEW_8580_FILTER 0)
set(HAVE_BOOL 1)
set(HAVE_LOG1P 1)
if(CMAKE_CXX_COMPILER_ID MATCHES "GCC|Clang")
set(HAVE_BUILTIN_EXPECT 1)
else()
set(HAVE_BUILTIN_EXPECT 0)
endif()
configure_file(resid/siddefs.h.in resid/siddefs.h @ONLY)
add_library(resid_objects OBJECT
resid/sid.cc
resid/voice.cc
resid/wave.cc
resid/envelope.cc
resid/filter.cc
resid/dac.cc
resid/extfilt.cc
resid/pot.cc
resid/version.cc
)
target_include_directories(resid_objects PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/resid"
"${CMAKE_CURRENT_BINARY_DIR}/resid"
)
target_compile_definitions(resid_objects PUBLIC VERSION="1.0")
set(RESID_WAVES
wave6581_PST
wave6581_PS_
wave6581_P_T
wave6581__ST
wave8580_PST
wave8580_PS_
wave8580_P_T
wave8580__ST
)
set(RESID_SAMP2SRC_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/resid/samp2src.pl)
foreach(WAVE_DATA IN LISTS RESID_WAVES)
set(WAVE_DATA_IN ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA}.dat)
set(WAVE_SRC_OUT ${CMAKE_CURRENT_BINARY_DIR}/resid/${WAVE_DATA}.h)
set(WAVE_COMMAND
"${PERL_EXECUTABLE}"
"${RESID_SAMP2SRC_SCRIPT}"
"${WAVE_DATA}"
"${WAVE_DATA_IN}"
"${WAVE_SRC_OUT}"
)
add_custom_command(OUTPUT ${WAVE_SRC_OUT} COMMAND ${WAVE_COMMAND} VERBATIM)
target_sources(resid_objects PUBLIC ${WAVE_SRC_OUT})
endforeach()
# TODO CMake 3.12: Use target_link_libraries() to propagate usage requirements directly to sid plugin
add_library(resid INTERFACE)
target_sources(resid INTERFACE $<TARGET_OBJECTS:resid_objects>)
get_target_property(resid_includes resid_objects INCLUDE_DIRECTORIES)
target_include_directories(resid INTERFACE ${resid_includes})