Skip to content

Commit

Permalink
Merge pull request #759 from edge-classic/compile-time-sound-formats
Browse files Browse the repository at this point in the history
Make most sound/music formats compile-time options
  • Loading branch information
dashodanger authored Dec 22, 2024
2 parents de4cf13 + c9cef35 commit dd950a6
Show file tree
Hide file tree
Showing 25 changed files with 3,410 additions and 3,304 deletions.
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ option(EDGE_SANITIZE "Enable code sanitizing" OFF)
option(EDGE_PROFILING "Enable Profiling" OFF)
option(EDGE_COAL_SUPPORT "Enable support for COAL scripting" ON)
option(EDGE_DEHACKED_SUPPORT "Enable support for Dehacked patch conversion" ON)
option(EDGE_DOOM_SFX_SUPPORT "Enable support for Doom/PC Speaker sound format" ON)
option(EDGE_FLAC_SUPPORT "Enable support for FLAC music format" ON)
option(EDGE_IMF_SUPPORT "Enable support for IMF music format" ON)
option(EDGE_MP3_SUPPORT "Enable support for MP3 music format" ON)
option(EDGE_MUS_SUPPORT "Enable support for MUS MIDI format" ON)
option(EDGE_OGG_SUPPORT "Enable support for OGG music format" ON)
option(EDGE_RAD_SUPPORT "Enable support for Reality Adlib Tracker v2 music" ON)
option(EDGE_SID_SUPPORT "Enable support for C64 SID music" ON)
option(EDGE_TRACKER_SUPPORT "Enable support for Tracker music (MOD/XM/S3M/IT)" ON)
option(EDGE_XMI_SUPPORT "Enable support for XMI MIDI format" ON)
option(EDGE_VWAD_SUPPORT "Enable support for k8vavoom VWAD archives" ON)
option(EDGE_WAV_SUPPORT "Enable support for WAV sound format" ON)

include("${CMAKE_SOURCE_DIR}/cmake/EDGEClassic.cmake")

Expand Down Expand Up @@ -151,9 +162,53 @@ if (EDGE_DEHACKED_SUPPORT)
add_definitions(-DEDGE_DEHACKED_SUPPORT)
endif()

if (EDGE_DOOM_SFX_SUPPORT)
add_definitions(-DEDGE_DOOM_SFX_SUPPORT)
endif()

if (EDGE_FLAC_SUPPORT)
add_definitions(-DEDGE_FLAC_SUPPORT)
endif()

if (EDGE_IMF_SUPPORT)
add_definitions(-DEDGE_IMF_SUPPORT)
endif()

if (EDGE_MP3_SUPPORT)
add_definitions(-DEDGE_MP3_SUPPORT)
endif()

if (EDGE_MUS_SUPPORT)
add_definitions(-DEDGE_MUS_SUPPORT)
endif()

if (EDGE_OGG_SUPPORT)
add_definitions(-DEDGE_OGG_SUPPORT)
endif()

if (EDGE_RAD_SUPPORT)
add_definitions(-DEDGE_RAD_SUPPORT)
endif()

if (EDGE_SID_SUPPORT)
add_definitions(-DEDGE_SID_SUPPORT)
endif()

if (EDGE_TRACKER_SUPPORT)
add_definitions(-DEDGE_TRACKER_SUPPORT)
endif()

if (EDGE_VWAD_SUPPORT)
add_definitions(-DEDGE_VWAD_SUPPORT)
endif()

if (EDGE_XMI_SUPPORT)
add_definitions(-DEDGE_XMI_SUPPORT)
endif()

if (EDGE_WAV_SUPPORT)
add_definitions(-DEDGE_WAV_SUPPORT)
endif()

add_subdirectory(libraries)
add_subdirectory(source_files)
12 changes: 9 additions & 3 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_subdirectory(almostequals)
add_subdirectory(crsid)
if (EDGE_SID_SUPPORT)
add_subdirectory(crsid)
endif()
add_subdirectory(dr_libs)
add_subdirectory(fmmidi)
if (NOT EDGE_GL_ES2)
Expand All @@ -8,9 +10,13 @@ else()
add_subdirectory(gl4es)
endif()
add_subdirectory(hmm)
add_subdirectory(ibxm)
if (EDGE_TRACKER_SUPPORT)
add_subdirectory(ibxm)
endif()
add_subdirectory(libemidi)
add_subdirectory(libRAD)
if (EDGE_IMF_SUPPORT OR EDGE_RAD_SUPPORT)
add_subdirectory(libRAD)
endif()
if (EDGE_VWAD_SUPPORT)
add_subdirectory(libvwad)
endif()
Expand Down
17 changes: 12 additions & 5 deletions libraries/dr_libs/dr_libs.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#if EDGE_WAV_SUPPORT
#define DR_WAV_NO_STDIO
#define DR_WAV_IMPLEMENTATION
#define DR_FLAC_NO_STDIO
#define DR_FLAC_NO_CRC
#define DR_FLAC_IMPLEMENTATION
#include "dr_wav.h"
#endif

#if EDGE_MP3_SUPPORT
#define DR_MP3_NO_STDIO
#define DR_MP3_IMPLEMENTATION
#include "dr_mp3.h"
#endif

#if EDGE_FLAC_SUPPORT
#define DR_FLAC_NO_STDIO
#define DR_FLAC_NO_CRC
#define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h"
#include "dr_mp3.h"
#include "dr_wav.h"
#endif
9 changes: 7 additions & 2 deletions libraries/libRAD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
# libRAD
##########################################

set (LIBRAD_SOURCES opal.cpp)

if (EDGE_RAD_SUPPORT)
set (LIBRAD_SOURCES ${LIBRAD_SOURCES} radplay.cpp)
endif()

add_library(
libRAD
opal.cpp
radplay.cpp
${LIBRAD_SOURCES}
)

target_include_directories(libRAD PUBLIC ./)
41 changes: 38 additions & 3 deletions source_files/ddf/ddf_playlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,50 @@ static PlaylistEntry *dynamic_plentry;

PlaylistEntryContainer playlist;

static std::vector<std::string> supported_music_types;

static void InitializeMusicTypes()
{
supported_music_types.push_back("UNKNOWN");
supported_music_types.push_back("MIDI");
#if EDGE_MUS_SUPPORT
supported_music_types.push_back("MUS");
#endif
#if EDGE_OGG_SUPPORT
supported_music_types.push_back("OGG");
#endif
#if EDGE_MP3_SUPPORT
supported_music_types.push_back("MP3");
#endif
#if EDGE_SID_SUPPORT
supported_music_types.push_back("SID");
#endif
#if EDGE_FLAC_SUPPORT
supported_music_types.push_back("FLAC");
#endif
#if EDGE_TRACKER_SUPPORT
supported_music_types.push_back("TRACKER");
#endif
#if EDGE_RAD_SUPPORT
supported_music_types.push_back("RAD");
#endif
#if EDGE_IMF_SUPPORT
supported_music_types.push_back("IMF280");
supported_music_types.push_back("IMF560");
supported_music_types.push_back("IMF700");
#endif
}

//
// DDFMusicParseInfo
//
// Parses the music information given.
//
static void DDFMusicParseInfo(const char *info)
{
static const char *const musstrtype[] = {"UNKNOWN", "MIDI", "MUS", "OGG", "MP3", "SID", "FLAC",
"IBXM", "RAD", "IMF280", "IMF560", "IMF700", nullptr};
if (supported_music_types.empty())
InitializeMusicTypes();

static const char *const musinftype[] = {"UNKNOWN", "LUMP", "FILE", "PACK", nullptr};

char charbuff[256];
Expand Down Expand Up @@ -60,7 +95,7 @@ static void DDFMusicParseInfo(const char *info)
charbuff[i] = 0;

i = kDDFMusicUnknown;
while (i != kTotalDDFMusicTypes && epi::StringCaseCompareASCII(charbuff, musstrtype[i]) != 0)
while (i != kTotalDDFMusicTypes && epi::StringCaseCompareASCII(charbuff, supported_music_types[i]) != 0)
i++;

if (i == kTotalDDFMusicTypes)
Expand Down
16 changes: 16 additions & 0 deletions source_files/ddf/ddf_playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,32 @@ enum DDFMusicType
{
kDDFMusicUnknown = 0,
kDDFMusicMIDI,
#if EDGE_MUS_SUPPORT
kDDFMusicMUS,
#endif
#if EDGE_OGG_SUPPORT
kDDFMusicOGG,
#endif
#if EDGE_MP3_SUPPORT
kDDFMusicMP3,
#endif
#if EDGE_SID_SUPPORT
kDDFMusicSID,
#endif
#if EDGE_FLAC_SUPPORT
kDDFMusicFLAC,
#endif
#if EDGE_TRACKER_SUPPORT
kDDFMusicIBXM,
#endif
#if EDGE_RAD_SUPPORT
kDDFMusicRAD,
#endif
#if EDGE_IMF_SUPPORT
kDDFMusicIMF280,
kDDFMusicIMF560,
kDDFMusicIMF700,
#endif
kTotalDDFMusicTypes
};

Expand Down
58 changes: 48 additions & 10 deletions source_files/edge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,11 @@ set (EDGE_SOURCE_FILES
s_blit.cc
s_cache.cc
s_sound.cc
s_mp3.cc
s_music.cc
s_ogg.cc
s_emidi.cc
s_tsf.cc
s_fmm.cc
s_ibxm.cc
s_imf.cc
s_rad.cc
s_sid.cc
s_wav.cc
s_flac.cc
sv_chunk.cc
sv_glob.cc
sv_level.cc
Expand Down Expand Up @@ -128,6 +121,42 @@ if (EDGE_DEHACKED_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} l_deh.cc)
endif()

if (EDGE_DOOM_SFX_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_doom.cc)
endif()

if (EDGE_FLAC_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_flac.cc)
endif()

if (EDGE_IMF_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_imf.cc)
endif()

if (EDGE_MP3_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_mp3.cc)
endif()

if (EDGE_OGG_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_ogg.cc)
endif()

if (EDGE_RAD_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_rad.cc)
endif()

if (EDGE_SID_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_sid.cc)
endif()

if (EDGE_TRACKER_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_ibxm.cc)
endif()

if (EDGE_WAV_SUPPORT)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} s_wav.cc)
endif()

if (EMSCRIPTEN)
set (EDGE_SOURCE_FILES ${EDGE_SOURCE_FILES} i_web.cc)
else()
Expand All @@ -141,13 +170,10 @@ set (EDGE_LINK_LIBRARIES
edge_tracy
${SDL2_LIBRARIES}
almostequals
crsid
dr_libs
fmmidi
HandmadeMath
ibxm
libemidi
libRAD
lua
miniz
pl_mpeg
Expand All @@ -165,6 +191,18 @@ if (EDGE_DEHACKED_SUPPORT)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} edge_deh)
endif()

if (EDGE_IMF_SUPPORT OR EDGE_RAD_SUPPORT)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} libRAD)
endif()

if (EDGE_SID_SUPPORT)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} crsid)
endif()

if (EDGE_TRACKER_SUPPORT)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} ibxm)
endif()

if (EDGE_VWAD_SUPPORT)
set (EDGE_LINK_LIBRARIES ${EDGE_LINK_LIBRARIES} libvwad)
endif()
Expand Down
2 changes: 2 additions & 0 deletions source_files/edge/m_option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ static OptionMenuItem soundoptions[] = {
{kOptionMenuItemTypeSwitch, "MIDI Player", "TinySoundFont/FMMIDI/Emu de MIDI (OPLL Mode)/Emu de MIDI (SCC-PSG Mode)", 4, &var_midi_player, OptionMenuChangeMidiPlayer,
nullptr},
{kOptionMenuItemTypeFunction, "TinySoundFont Bank", nullptr, 0, nullptr, OptionMenuChangeSoundfont, nullptr},
#if EDGE_DOOM_SFX_SUPPORT
{kOptionMenuItemTypeBoolean, "PC Speaker Mode", YesNo, 2, &pc_speaker_mode, OptionMenuChangePCSpeakerMode,
"Music will be Off while this is enabled"},
#endif
{kOptionMenuItemTypePlain, "", nullptr, 0, nullptr, nullptr, nullptr},
{kOptionMenuItemTypeBoolean, "Dynamic Reverb", YesNo, 2, &dynamic_reverb, nullptr, nullptr},
{kOptionMenuItemTypePlain, "", nullptr, 0, nullptr, nullptr, nullptr},
Expand Down
Loading

0 comments on commit dd950a6

Please sign in to comment.