mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- moved the CVars out of the Timidity++ backend.
This commit is contained in:
parent
cf6d0c3127
commit
98329311b4
3 changed files with 138 additions and 138 deletions
|
@ -43,6 +43,140 @@
|
|||
#include "timiditypp/instrum.h"
|
||||
#include "timiditypp/playmidi.h"
|
||||
|
||||
|
||||
|
||||
template<class T> void ChangeVarSync(T& var, T value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(TimidityPlus::CvarCritSec);
|
||||
var = value;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_modulation_wheel, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_modulation_wheel, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_portamento, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_portamento, *self);
|
||||
}
|
||||
/*
|
||||
* reverb=0 no reverb 0
|
||||
* reverb=1 old reverb 1
|
||||
* reverb=1,n set reverb level to n (-1 to -127)
|
||||
* reverb=2 "global" old reverb 2
|
||||
* reverb=2,n set reverb level to n (-1 to -127) - 128
|
||||
* reverb=3 new reverb 3
|
||||
* reverb=3,n set reverb level to n (-1 to -127) - 256
|
||||
* reverb=4 "global" new reverb 4
|
||||
* reverb=4,n set reverb level to n (-1 to -127) - 384
|
||||
*/
|
||||
EXTERN_CVAR(Int, timidity_reverb_level)
|
||||
EXTERN_CVAR(Int, timidity_reverb)
|
||||
|
||||
static void SetReverb()
|
||||
{
|
||||
int value = 0;
|
||||
int mode = timidity_reverb;
|
||||
int level = timidity_reverb_level;
|
||||
|
||||
if (mode == 0 || level == 0) value = mode;
|
||||
else value = (mode - 1) * -128 - level;
|
||||
ChangeVarSync(TimidityPlus::timidity_reverb, value);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_reverb, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 4) self = 0;
|
||||
else SetReverb();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_reverb_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 127) self = 0;
|
||||
else SetReverb();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_chorus, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_chorus, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_surround_chorus, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
ChangeVarSync(TimidityPlus::timidity_surround_chorus, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_channel_pressure, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_channel_pressure, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_lpf_def, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_lpf_def, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_temper_control, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_temper_control, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_modulation_envelope, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_modulation_envelope, *self);
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_overlap_voice_allow, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_overlap_voice_allow, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_drum_effect, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_drum_effect, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_pan_delay, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_pan_delay, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, timidity_drum_power, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) /* coef. of drum amplitude */
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
else if (self > MAX_AMPLIFICATION / 100.f) self = MAX_AMPLIFICATION / 100.f;
|
||||
ChangeVarSync(TimidityPlus::timidity_drum_power, *self);
|
||||
}
|
||||
CUSTOM_CVAR(Int, timidity_key_adjust, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < -24) self = -24;
|
||||
else if (self > 24) self = 24;
|
||||
ChangeVarSync(TimidityPlus::timidity_key_adjust, *self);
|
||||
}
|
||||
// For testing mainly.
|
||||
CUSTOM_CVAR(Float, timidity_tempo_adjust, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0.25) self = 0.25;
|
||||
else if (self > 10) self = 10;
|
||||
ChangeVarSync(TimidityPlus::timidity_tempo_adjust, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, min_sustain_time, 5000, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
ChangeVarSync(TimidityPlus::min_sustain_time, *self);
|
||||
}
|
||||
|
||||
|
||||
class TimidityPPMIDIDevice : public SoftSynthMIDIDevice
|
||||
{
|
||||
static TimidityPlus::Instruments *instruments;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <mutex>
|
||||
#include "timidity.h"
|
||||
#include "common.h"
|
||||
#include "instrum.h"
|
||||
|
@ -35,10 +34,8 @@
|
|||
#include "reverb.h"
|
||||
#include "freq.h"
|
||||
#include "quantity.h"
|
||||
#include "c_cvars.h"
|
||||
#include "tables.h"
|
||||
#include "effect.h"
|
||||
#include "i_musicinterns.h"
|
||||
|
||||
|
||||
namespace TimidityPlus
|
||||
|
@ -70,142 +67,7 @@ namespace TimidityPlus
|
|||
static bool opt_tva_release = false;
|
||||
static bool opt_insertion_effect = false;
|
||||
static bool opt_delay_control = false;
|
||||
}
|
||||
|
||||
template<class T> void ChangeVarSync(T&var, T value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(TimidityPlus::CvarCritSec);
|
||||
var = value;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_modulation_wheel, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_modulation_wheel, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_portamento, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_portamento, *self);
|
||||
}
|
||||
/*
|
||||
* reverb=0 no reverb 0
|
||||
* reverb=1 old reverb 1
|
||||
* reverb=1,n set reverb level to n (-1 to -127)
|
||||
* reverb=2 "global" old reverb 2
|
||||
* reverb=2,n set reverb level to n (-1 to -127) - 128
|
||||
* reverb=3 new reverb 3
|
||||
* reverb=3,n set reverb level to n (-1 to -127) - 256
|
||||
* reverb=4 "global" new reverb 4
|
||||
* reverb=4,n set reverb level to n (-1 to -127) - 384
|
||||
*/
|
||||
EXTERN_CVAR(Int, timidity_reverb_level)
|
||||
EXTERN_CVAR(Int, timidity_reverb)
|
||||
|
||||
static void SetReverb()
|
||||
{
|
||||
int value = 0;
|
||||
int mode = timidity_reverb;
|
||||
int level = timidity_reverb_level;
|
||||
|
||||
if (mode == 0 || level == 0) value = mode;
|
||||
else value = (mode - 1) * -128 - level;
|
||||
ChangeVarSync(TimidityPlus::timidity_reverb, value);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_reverb, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 4) self = 0;
|
||||
else SetReverb();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_reverb_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 127) self = 0;
|
||||
else SetReverb();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_chorus, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_chorus, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_surround_chorus, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
ChangeVarSync(TimidityPlus::timidity_surround_chorus, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_channel_pressure, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_channel_pressure, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, timidity_lpf_def, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_lpf_def, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_temper_control, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_temper_control, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_modulation_envelope, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_modulation_envelope, *self);
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_overlap_voice_allow, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_overlap_voice_allow, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_drum_effect, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_drum_effect, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_pan_delay, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
ChangeVarSync(TimidityPlus::timidity_pan_delay, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, timidity_drum_power, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) /* coef. of drum amplitude */
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
else if (self > MAX_AMPLIFICATION/100.f) self = MAX_AMPLIFICATION/100.f;
|
||||
ChangeVarSync(TimidityPlus::timidity_drum_power, *self);
|
||||
}
|
||||
CUSTOM_CVAR(Int, timidity_key_adjust, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < -24) self = -24;
|
||||
else if (self > 24) self = 24;
|
||||
ChangeVarSync(TimidityPlus::timidity_key_adjust, *self);
|
||||
}
|
||||
// For testing mainly.
|
||||
CUSTOM_CVAR(Float, timidity_tempo_adjust, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0.25) self = 0.25;
|
||||
else if (self > 10) self = 10;
|
||||
ChangeVarSync(TimidityPlus::timidity_tempo_adjust, *self);
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, min_sustain_time, 5000, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
ChangeVarSync(TimidityPlus::min_sustain_time, *self);
|
||||
}
|
||||
|
||||
|
||||
namespace TimidityPlus
|
||||
{
|
||||
|
||||
// These two variables need to remain global or things will get messy because they get accessed from non-class code.
|
||||
int32_t control_ratio = 22;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "controls.h"
|
||||
#include "mblock.h"
|
||||
#include <mutex>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -124,6 +125,7 @@
|
|||
namespace TimidityPlus
|
||||
{
|
||||
|
||||
extern std::mutex CvarCritSec;
|
||||
extern bool timidity_modulation_wheel;
|
||||
extern bool timidity_portamento;
|
||||
extern int timidity_reverb;
|
||||
|
@ -139,6 +141,8 @@ extern bool timidity_pan_delay;
|
|||
extern float timidity_drum_power;
|
||||
extern int timidity_key_adjust;
|
||||
extern float timidity_tempo_adjust;
|
||||
extern float min_sustain_time;
|
||||
extern int timidity_lpf_def;
|
||||
|
||||
extern int32_t playback_rate;
|
||||
extern int32_t control_ratio; // derived from playback_rate
|
||||
|
|
Loading…
Reference in a new issue