mirror of
https://github.com/ZDoom/ZMusic.git
synced 2025-03-19 09:01:48 +00:00
- conditionalize the configuration depending on available content, so that the lite variant also builds successfully.
This commit is contained in:
parent
a4eae42ec5
commit
c1bbdcc849
7 changed files with 50 additions and 18 deletions
|
@ -232,7 +232,7 @@ struct Callbacks
|
|||
|
||||
|
||||
#ifndef ZMUSIC_INTERNAL
|
||||
#define DLL_IMPORT // _declspec(dllimport)
|
||||
#define DLL_IMPORT _declspec(dllimport)
|
||||
// Note that the internal 'class' definitions are not C compatible!
|
||||
typedef struct { int zm1; } *ZMusic_MidiSource;
|
||||
typedef struct { int zm2; } *ZMusic_MusicStream;
|
||||
|
|
|
@ -118,8 +118,8 @@ set( all_files
|
|||
)
|
||||
|
||||
add_library( zmusic SHARED ${all_files} )
|
||||
add_definitions(-DZMUSIC_LITE)
|
||||
add_library( zmusiclite SHARED ${all_files} )
|
||||
target_compile_definitions(zmusiclite PRIVATE ZMUSIC_LITE=1)
|
||||
|
||||
if( MSVC )
|
||||
option( GENERATE_MAPFILE "Generate .map file for debugging." OFF )
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
#include "zmusic_internal.h"
|
||||
#include "streamsource.h"
|
||||
#include "zmusic/sounddecoder.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "fileio.h"
|
||||
#include "zmusic/midiconfig.h"
|
||||
|
||||
|
||||
#ifdef HAVE_OPL
|
||||
//==========================================================================
|
||||
//
|
||||
// OPL file played by a software OPL2 synth and streamed through the sound system
|
||||
|
@ -149,3 +149,4 @@ StreamSource *OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config)
|
|||
{
|
||||
return new OPLMUSSong(reader, config);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -115,20 +115,26 @@ DLL_EXPORT void ZMusic_SetCallbacks(const Callbacks* cb)
|
|||
|
||||
DLL_EXPORT void ZMusic_SetGenMidi(const uint8_t* data)
|
||||
{
|
||||
#ifdef HAVE_OPL
|
||||
memcpy(oplConfig.OPLinstruments, data, 175 * 36);
|
||||
oplConfig.genmidiset = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
DLL_EXPORT void ZMusic_SetWgOpn(const void* data, unsigned len)
|
||||
{
|
||||
#ifdef HAVE_OPN
|
||||
opnConfig.default_bank.resize(len);
|
||||
memcpy(opnConfig.default_bank.data(), data, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
DLL_EXPORT void ZMusic_SetDmxGus(const void* data, unsigned len)
|
||||
{
|
||||
#ifdef HAVE_GUS
|
||||
gusConfig.dmxgus.resize(len);
|
||||
memcpy(gusConfig.dmxgus.data(), data, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
int ZMusic_EnumerateMidiDevices()
|
||||
|
@ -238,6 +244,8 @@ void ChangeAndReturn(valtype &variable, valtype value, valtype *realv)
|
|||
#define FLUID_CHORUS_MOD_TRIANGLE 1
|
||||
#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE
|
||||
|
||||
#ifdef HAVE_TIMIDITY
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Timidity++ uses a static global set of configuration variables.
|
||||
|
@ -284,6 +292,7 @@ static void TimidityPlus_SetReverb()
|
|||
else value = (mode - 1) * -128 - level;
|
||||
ChangeVarSync(TimidityPlus::timidity_reverb, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -299,6 +308,7 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
default:
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
case zmusic_adl_chips_count:
|
||||
ChangeAndReturn(adlConfig.adl_chips_count, value, pRealValue);
|
||||
return devType() == MDEV_ADL;
|
||||
|
@ -326,6 +336,7 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
case zmusic_adl_volume_model:
|
||||
ChangeAndReturn(adlConfig.adl_volume_model, value, pRealValue);
|
||||
return devType() == MDEV_ADL;
|
||||
#endif
|
||||
|
||||
case zmusic_fluid_reverb:
|
||||
if (currSong != NULL)
|
||||
|
@ -413,6 +424,7 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
ChangeAndReturn(fluidConfig.fluid_chorus_type, value, pRealValue);
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_OPL
|
||||
case zmusic_opl_numchips:
|
||||
if (value <= 0)
|
||||
value = 1;
|
||||
|
@ -434,7 +446,8 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
case zmusic_opl_fullpan:
|
||||
ChangeAndReturn(oplConfig.fullpan, value, pRealValue);
|
||||
return false;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_OPN
|
||||
case zmusic_opn_chips_count:
|
||||
ChangeAndReturn(opnConfig.opn_chips_count, value, pRealValue);
|
||||
return devType() == MDEV_OPN;
|
||||
|
@ -454,7 +467,8 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
case zmusic_opn_use_custom_bank:
|
||||
ChangeAndReturn(opnConfig.opn_use_custom_bank, value, pRealValue);
|
||||
return devType() == MDEV_OPN;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_GUS
|
||||
case zmusic_gus_dmxgus:
|
||||
ChangeAndReturn(gusConfig.gus_dmxgus, value, pRealValue);
|
||||
return devType() == MDEV_GUS;
|
||||
|
@ -466,7 +480,8 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
case zmusic_gus_memsize:
|
||||
ChangeAndReturn(gusConfig.gus_memsize, value, pRealValue);
|
||||
return devType() == MDEV_GUS && gusConfig.gus_dmxgus;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_TIMIDITY
|
||||
case zmusic_timidity_modulation_wheel:
|
||||
ChangeVarSync(TimidityPlus::timidity_modulation_wheel, value);
|
||||
if (pRealValue) *pRealValue = value;
|
||||
|
@ -542,7 +557,8 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
ChangeVarSync(TimidityPlus::timidity_key_adjust, value);
|
||||
if (pRealValue) *pRealValue = value;
|
||||
return false;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_WILDMIDI
|
||||
case zmusic_wildmidi_reverb:
|
||||
if (currSong != NULL)
|
||||
currSong->ChangeSettingInt("wildmidi.reverb", value);
|
||||
|
@ -556,7 +572,7 @@ DLL_EXPORT bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int
|
|||
wildMidiConfig.enhanced_resampling = value;
|
||||
if (pRealValue) *pRealValue = value;
|
||||
return false;
|
||||
|
||||
#endif
|
||||
case zmusic_snd_midiprecache:
|
||||
ChangeAndReturn(miscConfig.snd_midiprecache, value, pRealValue);
|
||||
return false;
|
||||
|
@ -720,6 +736,7 @@ DLL_EXPORT bool ChangeMusicSettingFloat(EFloatConfigKey key, MusInfo* currSong,
|
|||
ChangeAndReturn(fluidConfig.fluid_chorus_depth, value, pRealValue);
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_TIMIDITY
|
||||
case zmusic_timidity_drum_power:
|
||||
if (value < 0) value = 0;
|
||||
else if (value > MAX_AMPLIFICATION / 100.f) value = MAX_AMPLIFICATION / 100.f;
|
||||
|
@ -740,6 +757,7 @@ DLL_EXPORT bool ChangeMusicSettingFloat(EFloatConfigKey key, MusInfo* currSong,
|
|||
ChangeVarSync(TimidityPlus::min_sustain_time, value);
|
||||
if (pRealValue) *pRealValue = value;
|
||||
return false;
|
||||
#endif
|
||||
|
||||
case zmusic_gme_stereodepth:
|
||||
if (currSong != nullptr)
|
||||
|
@ -775,39 +793,47 @@ DLL_EXPORT bool ChangeMusicSettingString(EStringConfigKey key, MusInfo* currSong
|
|||
default:
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
case zmusic_adl_custom_bank:
|
||||
adlConfig.adl_custom_bank = value;
|
||||
return devType() == MDEV_ADL;
|
||||
|
||||
#endif
|
||||
case zmusic_fluid_lib:
|
||||
fluidConfig.fluid_lib = value;
|
||||
return false; // only takes effect for next song.
|
||||
|
||||
case zmusic_fluid_patchset:
|
||||
fluidConfig.fluid_patchset = value;
|
||||
#ifdef HAVE_TIMIDITY
|
||||
if (timidityConfig.timidity_config.empty()) timidityConfig.timidity_config = value; // Also use for Timidity++ if nothing has been set.
|
||||
#endif
|
||||
return devType() == MDEV_FLUIDSYNTH;
|
||||
|
||||
#ifdef HAVE_OPN
|
||||
case zmusic_opn_custom_bank:
|
||||
opnConfig.opn_custom_bank = value;
|
||||
return devType() == MDEV_OPN && opnConfig.opn_use_custom_bank;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_GUS
|
||||
case zmusic_gus_config:
|
||||
gusConfig.gus_config = value;
|
||||
return devType() == MDEV_GUS;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_GUS
|
||||
case zmusic_gus_patchdir:
|
||||
gusConfig.gus_patchdir = value;
|
||||
return devType() == MDEV_GUS && gusConfig.gus_dmxgus;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_TIMIDITY
|
||||
case zmusic_timidity_config:
|
||||
timidityConfig.timidity_config = value;
|
||||
return devType() == MDEV_TIMIDITY;
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_WILDMIDI
|
||||
case zmusic_wildmidi_config:
|
||||
wildMidiConfig.config = value;
|
||||
return devType() == MDEV_TIMIDITY;
|
||||
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -235,14 +235,18 @@ static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EMidiD
|
|||
// Check for various raw OPL formats
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_OPL
|
||||
if (
|
||||
(id[0] == MAKE_ID('R', 'A', 'W', 'A') && id[1] == MAKE_ID('D', 'A', 'T', 'A')) || // Rdos Raw OPL
|
||||
(id[0] == MAKE_ID('D', 'B', 'R', 'A') && id[1] == MAKE_ID('W', 'O', 'P', 'L')) || // DosBox Raw OPL
|
||||
(id[0] == MAKE_ID('A', 'D', 'L', 'I') && *((uint8_t*)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
||||
{
|
||||
streamsource = OPL_OpenSong(reader, &oplConfig);
|
||||
|
||||
}
|
||||
else if ((id[0] == MAKE_ID('R', 'I', 'F', 'F') && id[2] == MAKE_ID('C', 'D', 'X', 'A')))
|
||||
else
|
||||
#endif
|
||||
if ((id[0] == MAKE_ID('R', 'I', 'F', 'F') && id[2] == MAKE_ID('C', 'D', 'X', 'A')))
|
||||
{
|
||||
streamsource = XA_OpenSong(reader); // this takes over the reader.
|
||||
reader = nullptr; // We do not own this anymore.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#define ZMUSIC_INTERNAL
|
||||
|
||||
#define DLL_EXPORT // __declspec(dllexport)
|
||||
#define DLL_IMPORT
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#define DLL_IMPORT __declspec(dllexport) // without this the compiler complains.
|
||||
typedef class MIDISource *ZMusic_MidiSource;
|
||||
typedef class MusInfo *ZMusic_MusicStream;
|
||||
|
||||
|
@ -10,7 +10,7 @@ typedef class MusInfo *ZMusic_MusicStream;
|
|||
// Lite only uses FluidSynth for MIDI playback and is licensed under the LGPL v2.1
|
||||
// Full uses all MIDI synths and is licensed under the GPL v3.
|
||||
|
||||
#ifndef LITE
|
||||
#ifndef ZMUSIC_LITE
|
||||
#define HAVE_GUS // legally viable but not really useful
|
||||
#define HAVE_TIMIDITY // GPL v2.0
|
||||
#define HAVE_OPL // GPL v3.0
|
||||
|
|
Loading…
Reference in a new issue