- fixed setup for Timidity++ playback frequency.

This commit is contained in:
Christoph Oelckers 2018-03-06 19:51:53 +01:00
parent 4b7e57b007
commit 4d4edcfbfb
3 changed files with 15 additions and 11 deletions

View file

@ -115,6 +115,8 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args)
delete instruments;
instruments = nullptr;
}
TimidityPlus::set_playback_rate(timidity_frequency);
SampleRate = timidity_frequency;
if (instruments == nullptr)
{
instruments = new TimidityPlus::Instruments;
@ -126,7 +128,7 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args)
}
if (instruments != nullptr)
{
Renderer = new TimidityPlus::Player(timidity_frequency, instruments);
Renderer = new TimidityPlus::Player(instruments);
}
else
{
@ -158,7 +160,6 @@ TimidityPPMIDIDevice::~TimidityPPMIDIDevice ()
int TimidityPPMIDIDevice::Open(MidiCallback callback, void *userdata)
{
int ret = OpenStream(2, 0, callback, userdata);
if (ret == 0 && Renderer != nullptr)
{

View file

@ -181,8 +181,8 @@ 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 = 44;
int32_t playback_rate = 44100;
int32_t control_ratio = 22;
int32_t playback_rate = 22050;
#define PLAY_INTERLEAVE_SEC 1.0
#define PORTAMENTO_TIME_TUNING (1.0 / 5000.0)
@ -195,20 +195,24 @@ int32_t playback_rate = 44100;
#define DEFAULT_AMPLIFICATION 70
#define VIBRATO_DEPTH_MAX 384 /* 600 cent */
Player::Player(int freq, Instruments *instr)
void set_playback_rate(int freq)
{
const int CONTROLS_PER_SECOND = 1000;
const int MAX_CONTROL_RATIO = 255;
last_reverb_setting = timidity_reverb;
memset(this, 0, sizeof(*this));
playback_rate = freq;
control_ratio = playback_rate / CONTROLS_PER_SECOND;
if (control_ratio < 1)
control_ratio = 1;
else if (control_ratio > MAX_CONTROL_RATIO)
control_ratio = MAX_CONTROL_RATIO;
}
Player::Player(Instruments *instr)
{
last_reverb_setting = timidity_reverb;
memset(this, 0, sizeof(*this));
// init one-time global stuff - this should go to the device class once it exists.
instruments = instr;

View file

@ -519,8 +519,6 @@ public:
ChannelBitMask drumchannel_mask;
ChannelBitMask drumchannels;
double *vol_table;
int playback_rate;
int control_ratio;
// make this private later
Instruments *instruments;
@ -696,7 +694,7 @@ private:
public:
Player(int freq, Instruments *);
Player(Instruments *);
~Player();
bool ISDRUMCHANNEL(int c)
@ -741,6 +739,7 @@ public:
};
void free_gauss_table(void);
void set_playback_rate(int freq);
}