mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Revert "- don't let the Timidity++ player directly access the CVARs."
This reverts commit 8f7a503561
.
# Conflicts:
# src/sound/timiditypp/playmidi.cpp
Something in here wasn't working as intended, and since it needs better synchronization let's redo it entirely.
This commit is contained in:
parent
36e8358763
commit
47dbbeb65a
7 changed files with 31 additions and 79 deletions
|
@ -101,24 +101,6 @@ CUSTOM_CVAR (Int, timidity_frequency, 44100, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
self = 65000;
|
||||
}
|
||||
|
||||
// These two need a music restart.
|
||||
CUSTOM_CVAR(Bool, timidity_surround_chorus, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, timidity_modulation_envelope, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// TimidityPPMIDIDevice Constructor
|
||||
|
|
|
@ -183,27 +183,27 @@ void Effect::effect_left_right_delay(int32_t *buff, int32_t count)
|
|||
void Effect::do_effect(int32_t *buf, int32_t count)
|
||||
{
|
||||
int32_t nsamples = count * 2;
|
||||
int reverb_level = (reverb->timidity_reverb < 0)
|
||||
? -reverb->timidity_reverb & 0x7f : DEFAULT_REVERB_SEND_LEVEL;
|
||||
int reverb_level = (timidity_reverb < 0)
|
||||
? -timidity_reverb & 0x7f : DEFAULT_REVERB_SEND_LEVEL;
|
||||
|
||||
/* for static reverb / chorus level */
|
||||
if (reverb->timidity_reverb == 2 || reverb->timidity_reverb == 4
|
||||
|| (reverb->timidity_reverb < 0 && !(reverb->timidity_reverb & 0x80))
|
||||
if (timidity_reverb == 2 || timidity_reverb == 4
|
||||
|| (timidity_reverb < 0 && !(timidity_reverb & 0x80))
|
||||
|| timidity_chorus < 0)
|
||||
{
|
||||
reverb->set_dry_signal(buf, nsamples);
|
||||
/* chorus sounds horrible
|
||||
* if applied globally on top of channel chorus
|
||||
*/
|
||||
if (reverb->timidity_reverb == 2 || reverb->timidity_reverb == 4
|
||||
|| (reverb->timidity_reverb < 0 && !(reverb->timidity_reverb & 0x80)))
|
||||
if (timidity_reverb == 2 || timidity_reverb == 4
|
||||
|| (timidity_reverb < 0 && !(timidity_reverb & 0x80)))
|
||||
reverb->set_ch_reverb(buf, nsamples, reverb_level);
|
||||
reverb->mix_dry_signal(buf, nsamples);
|
||||
/* chorus sounds horrible
|
||||
* if applied globally on top of channel chorus
|
||||
*/
|
||||
if (reverb->timidity_reverb == 2 || reverb->timidity_reverb == 4
|
||||
|| (reverb->timidity_reverb < 0 && !(reverb->timidity_reverb & 0x80)))
|
||||
if (timidity_reverb == 2 || timidity_reverb == 4
|
||||
|| (timidity_reverb < 0 && !(timidity_reverb & 0x80)))
|
||||
reverb->do_ch_reverb(buf, nsamples);
|
||||
}
|
||||
/* L/R Delay */
|
||||
|
|
|
@ -26,12 +26,9 @@ class Effect
|
|||
Reverb *reverb;
|
||||
|
||||
public:
|
||||
int timidity_chorus;
|
||||
|
||||
Effect(Reverb *_reverb, int chorus)
|
||||
Effect(Reverb *_reverb)
|
||||
{
|
||||
reverb = _reverb;
|
||||
timidity_chorus = chorus;
|
||||
init_effect();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,17 @@ CVAR(Bool, timidity_portamento, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
* reverb=4 "global" new reverb 4
|
||||
* reverb=4,n set reverb level to n (-1 to -127) - 384
|
||||
*/
|
||||
CVAR(Int, timidity_reverb, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
static bool mustinitreverb;
|
||||
CUSTOM_CVAR(Int, timidity_reverb, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
mustinitreverb = true; // this needs to reallocate some buffers
|
||||
}
|
||||
CVAR(Int, timidity_chorus, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_surround_chorus, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_channel_pressure, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Int, timidity_lpf_def, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_temper_control, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_modulation_envelope, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_overlap_voice_allow, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_drum_effect, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, timidity_pan_delay, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -114,6 +120,7 @@ Player::Player(int freq, Instruments *instr)
|
|||
const int CONTROLS_PER_SECOND = 1000;
|
||||
const int MAX_CONTROL_RATIO = 255;
|
||||
|
||||
mustinitreverb = false;
|
||||
memset(this, 0, sizeof(*this));
|
||||
|
||||
playback_rate = freq;
|
||||
|
@ -131,9 +138,9 @@ Player::Player(int freq, Instruments *instr)
|
|||
new_midi_file_info();
|
||||
init_mblock(&playmidi_pool);
|
||||
|
||||
reverb = new Reverb(timidity_reverb);
|
||||
reverb = new Reverb;
|
||||
reverb->init_effect_status(play_system_mode);
|
||||
effect = new Effect(reverb, timidity_chorus);
|
||||
effect = new Effect(reverb);
|
||||
|
||||
|
||||
mixer = new Mixer(this);
|
||||
|
@ -5015,31 +5022,12 @@ void Player::do_compute_data(int32_t count)
|
|||
int Player::compute_data(float *buffer, int32_t count)
|
||||
{
|
||||
if (count == 0) return RC_OK;
|
||||
|
||||
timidity_modulation_wheel = ::timidity_modulation_wheel;
|
||||
timidity_portamento = ::timidity_portamento;
|
||||
timidity_chorus = ::timidity_chorus;
|
||||
timidity_channel_pressure = ::timidity_chorus;
|
||||
timidity_lpf_def = ::timidity_lpf_def;
|
||||
timidity_temper_control = ::timidity_temper_control;
|
||||
timidity_overlap_voice_allow = ::timidity_overlap_voice_allow;
|
||||
timidity_drum_effect = ::timidity_drum_effect;
|
||||
timidity_pan_delay = ::timidity_pan_delay;
|
||||
timidity_drum_power = ::timidity_drum_power;
|
||||
timidity_key_adjust = ::timidity_key_adjust;
|
||||
timidity_tempo_adjust = ::timidity_tempo_adjust;
|
||||
std::atomic_thread_fence(std::memory_order_acq_rel);
|
||||
effect->timidity_chorus = timidity_chorus;
|
||||
|
||||
if (::timidity_reverb != timidity_reverb)
|
||||
if (mustinitreverb)
|
||||
{
|
||||
timidity_reverb = ::timidity_reverb;
|
||||
std::atomic_thread_fence(std::memory_order_acq_rel);
|
||||
reverb->timidity_reverb = timidity_reverb;
|
||||
|
||||
// If the reverb mode has changed some buffers need to be reallocated before doing any sound generation.
|
||||
reverb->free_effect_buffers();
|
||||
reverb->init_reverb();
|
||||
mustinitreverb = false;
|
||||
}
|
||||
|
||||
buffer_pointer = common_buffer;
|
||||
|
|
|
@ -512,24 +512,6 @@ class Effect;
|
|||
class Player
|
||||
{
|
||||
public:
|
||||
|
||||
bool timidity_modulation_wheel = true;
|
||||
bool timidity_portamento = true;
|
||||
int timidity_reverb = 0;
|
||||
int timidity_chorus = 0;
|
||||
bool timidity_surround_chorus = false;
|
||||
bool timidity_channel_pressure = false;
|
||||
bool timidity_temper_control = true;
|
||||
bool timidity_modulation_envelope = true;
|
||||
bool timidity_overlap_voice_allow = true;
|
||||
bool timidity_drum_effect = false;
|
||||
bool timidity_pan_delay = false;
|
||||
int timidity_lpf_def = true;
|
||||
float timidity_drum_power = 1.0;
|
||||
int timidity_key_adjust = 0;
|
||||
float timidity_tempo_adjust = 1;
|
||||
|
||||
|
||||
Channel channel[MAX_CHANNELS];
|
||||
Voice voice[max_voices];
|
||||
ChannelBitMask default_drumchannel_mask;
|
||||
|
|
|
@ -692,16 +692,13 @@ class Reverb
|
|||
void do_xg_auto_wah_od(int32_t *buf, int32_t count, EffectList *ef);
|
||||
|
||||
public:
|
||||
int timidity_reverb;
|
||||
|
||||
Reverb(int reverb)
|
||||
Reverb()
|
||||
{
|
||||
// Make sure that this starts out with all zeros.
|
||||
memset(this, 0, sizeof(*this));
|
||||
REV_INP_LEV = 1.0;
|
||||
direct_bufsize = sizeof(direct_buffer);
|
||||
reverb_effect_bufsize = sizeof(reverb_effect_buffer);
|
||||
timidity_reverb = reverb;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#ifndef TIMIDITY_H_INCLUDED
|
||||
#define TIMIDITY_H_INCLUDED 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include "c_cvars.h"
|
||||
#include "controls.h"
|
||||
#include "mblock.h"
|
||||
|
@ -37,9 +36,16 @@
|
|||
#pragma warning(disable:4244) // double->float truncation occurs so often in here that it's pointless to fix it all.
|
||||
#endif
|
||||
|
||||
EXTERN_CVAR(Bool, timidity_surround_chorus)
|
||||
EXTERN_CVAR(Bool, timidity_modulation_envelope)
|
||||
|
||||
EXTERN_CVAR(Bool, timidity_modulation_wheel)
|
||||
EXTERN_CVAR(Bool, timidity_portamento)
|
||||
EXTERN_CVAR(Int, timidity_reverb)
|
||||
EXTERN_CVAR(Int, timidity_chorus)
|
||||
EXTERN_CVAR(Bool, timidity_surround_chorus)
|
||||
EXTERN_CVAR(Bool, timidity_channel_pressure)
|
||||
EXTERN_CVAR(Int, timidity_lpf_def)
|
||||
EXTERN_CVAR(Bool, timidity_temper_control)
|
||||
EXTERN_CVAR(Bool, timidity_modulation_envelope)
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue