mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-01-18 21:21:36 +00:00
- Changed FMOD_INIT_ENABLE_DSPNET use to its replacement from 4.14.00,
FMOD_INIT_ENABLE_PROFILE. Renamed the corresponding cvar to snd_profile. - Removed the normalize parameter from SoundStream::Play(). - Disabled the chorus and reverb effects added to SDL_mixer's Timidity, because they were probably never tested well, either. Thanks to the bug in vc_alloc(), they were never even activated. - Restored the exact frequency range search that was missing from SDL_mixer's verion of select_sample(). - Fixed: vc_alloc(), kill_others(), and note_on() treated Voice::status as a bit mask, when it's not. These were changes made to SDL_mixer's Timidity. - Restored the original Timidity volume equation. The other louder one was put in when I didn't realize all channels were mono and many notes sounded too quiet because they never completed their attack phase. - Fixed: FileReader::Gets() acted as if fgets() always read the maximum number of characters. - Fixed: FileReader::Open() did not set FilePos and StartPos to 0. SVN r908 (trunk)
This commit is contained in:
parent
c333a8ab82
commit
e7ff22457e
13 changed files with 70 additions and 42 deletions
|
@ -1,3 +1,21 @@
|
||||||
|
April 12, 2008
|
||||||
|
- Changed FMOD_INIT_ENABLE_DSPNET use to its replacement from 4.14.00,
|
||||||
|
FMOD_INIT_ENABLE_PROFILE. Renamed the corresponding cvar to snd_profile.
|
||||||
|
- Removed the normalize parameter from SoundStream::Play().
|
||||||
|
- Disabled the chorus and reverb effects added to SDL_mixer's Timidity,
|
||||||
|
because they were probably never tested well, either. Thanks to the bug
|
||||||
|
in vc_alloc(), they were never even activated.
|
||||||
|
- Restored the exact frequency range search that was missing from SDL_mixer's
|
||||||
|
verion of select_sample().
|
||||||
|
- Fixed: vc_alloc(), kill_others(), and note_on() treated Voice::status as a
|
||||||
|
bit mask, when it's not. These were changes made to SDL_mixer's Timidity.
|
||||||
|
- Restored the original Timidity volume equation. The other louder one was
|
||||||
|
put in when I didn't realize all channels were mono and many notes sounded
|
||||||
|
too quiet because they never completed their attack phase.
|
||||||
|
- Fixed: FileReader::Gets() acted as if fgets() always read the maximum
|
||||||
|
number of characters.
|
||||||
|
- Fixed: FileReader::Open() did not set FilePos and StartPos to 0.
|
||||||
|
|
||||||
April 12, 2008 (Changes by Graf Zahl)
|
April 12, 2008 (Changes by Graf Zahl)
|
||||||
- Changed the internal Timidity player so that it uses timidity_mastervolume
|
- Changed the internal Timidity player so that it uses timidity_mastervolume
|
||||||
because it has the same sound volume issues as the external one.
|
because it has the same sound volume issues as the external one.
|
||||||
|
|
|
@ -90,6 +90,8 @@ bool FileReader::Open (const char *filename)
|
||||||
{
|
{
|
||||||
File = fopen (filename, "rb");
|
File = fopen (filename, "rb");
|
||||||
if (File == NULL) return false;
|
if (File == NULL) return false;
|
||||||
|
FilePos = 0;
|
||||||
|
StartPos = 0;
|
||||||
CloseOnDestruct = true;
|
CloseOnDestruct = true;
|
||||||
Length = CalcFileLen();
|
Length = CalcFileLen();
|
||||||
return true;
|
return true;
|
||||||
|
@ -141,13 +143,12 @@ long FileReader::Read (void *buffer, long len)
|
||||||
|
|
||||||
char *FileReader::Gets(char *strbuf, int len)
|
char *FileReader::Gets(char *strbuf, int len)
|
||||||
{
|
{
|
||||||
if (FilePos + len > StartPos + Length)
|
|
||||||
{
|
|
||||||
len = Length - FilePos + StartPos;
|
|
||||||
}
|
|
||||||
if (len <= 0) return 0;
|
if (len <= 0) return 0;
|
||||||
char *p = fgets(strbuf, len, File);
|
char *p = fgets(strbuf, len, File);
|
||||||
FilePos += len;
|
if (p != NULL)
|
||||||
|
{
|
||||||
|
FilePos = ftell(File) - StartPos;
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ int OPLMIDIDevice::Resume()
|
||||||
{
|
{
|
||||||
if (!Started)
|
if (!Started)
|
||||||
{
|
{
|
||||||
if (Stream->Play(true, 1, false))
|
if (Stream->Play(true, 1))
|
||||||
{
|
{
|
||||||
Started = true;
|
Started = true;
|
||||||
BlockForStats = this;
|
BlockForStats = this;
|
||||||
|
|
|
@ -120,7 +120,7 @@ CVAR (String, snd_resampler, "Linear", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR (String, snd_speakermode, "Auto", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (String, snd_speakermode, "Auto", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR (String, snd_output_format, "PCM-16", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (String, snd_output_format, "PCM-16", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR (Bool, snd_dspnet, false, 0)
|
CVAR (Bool, snd_profile, false, 0)
|
||||||
|
|
||||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Play(bool looping, float volume, bool normalize)
|
bool Play(bool looping, float volume)
|
||||||
{
|
{
|
||||||
FMOD_RESULT result;
|
FMOD_RESULT result;
|
||||||
|
|
||||||
|
@ -322,14 +322,6 @@ public:
|
||||||
reverb.Room = -10000;
|
reverb.Room = -10000;
|
||||||
Channel->setReverbProperties(&reverb);
|
Channel->setReverbProperties(&reverb);
|
||||||
}
|
}
|
||||||
if (normalize)
|
|
||||||
{ // Attach a normalizer DSP unit to the channel.
|
|
||||||
result = Owner->Sys->createDSPByType(FMOD_DSP_TYPE_NORMALIZE, &DSP);
|
|
||||||
if (result == FMOD_OK)
|
|
||||||
{
|
|
||||||
Channel->addDSP(DSP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Channel->setPaused(false);
|
Channel->setPaused(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -636,9 +628,9 @@ bool FMODSoundRenderer::Init()
|
||||||
{
|
{
|
||||||
initflags |= FMOD_INIT_SOFTWARE_HRTF;
|
initflags |= FMOD_INIT_SOFTWARE_HRTF;
|
||||||
}
|
}
|
||||||
if (snd_dspnet)
|
if (snd_profile)
|
||||||
{
|
{
|
||||||
initflags |= FMOD_INIT_ENABLE_DSPNET;
|
initflags |= FMOD_INIT_ENABLE_PROFILE;
|
||||||
}
|
}
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
Loop = 16
|
Loop = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool Play (bool looping, float volume, bool normalize) = 0;
|
virtual bool Play (bool looping, float volume) = 0;
|
||||||
virtual void Stop () = 0;
|
virtual void Stop () = 0;
|
||||||
virtual void SetVolume (float volume) = 0;
|
virtual void SetVolume (float volume) = 0;
|
||||||
virtual bool SetPaused (bool paused) = 0;
|
virtual bool SetPaused (bool paused) = 0;
|
||||||
|
|
|
@ -94,7 +94,7 @@ void TimiditySong::Play (bool looping)
|
||||||
{
|
{
|
||||||
if (m_Stream != NULL)
|
if (m_Stream != NULL)
|
||||||
{
|
{
|
||||||
if (m_Stream->Play (true, timidity_mastervolume, false))
|
if (m_Stream->Play (true, timidity_mastervolume))
|
||||||
{
|
{
|
||||||
m_Status = STATE_Playing;
|
m_Status = STATE_Playing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ void OPLMUSSong::Play (bool looping)
|
||||||
Music->SetLooping (looping);
|
Music->SetLooping (looping);
|
||||||
Music->Restart ();
|
Music->Restart ();
|
||||||
|
|
||||||
if (m_Stream == NULL || m_Stream->Play (true, snd_musicvolume, false))
|
if (m_Stream == NULL || m_Stream->Play (true, snd_musicvolume))
|
||||||
{
|
{
|
||||||
m_Status = STATE_Playing;
|
m_Status = STATE_Playing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ void StreamSong::Play (bool looping)
|
||||||
m_Status = STATE_Stopped;
|
m_Status = STATE_Stopped;
|
||||||
m_Looping = looping;
|
m_Looping = looping;
|
||||||
|
|
||||||
if (m_Stream->Play (m_Looping, 1, false))
|
if (m_Stream->Play (m_Looping, 1))
|
||||||
{
|
{
|
||||||
m_Status = STATE_Playing;
|
m_Status = STATE_Playing;
|
||||||
m_LastPos = 0;
|
m_LastPos = 0;
|
||||||
|
|
|
@ -205,7 +205,7 @@ int TimidityMIDIDevice::Resume()
|
||||||
{
|
{
|
||||||
if (!Started)
|
if (!Started)
|
||||||
{
|
{
|
||||||
if (Stream->Play(true, timidity_mastervolume, false))
|
if (Stream->Play(true, timidity_mastervolume))
|
||||||
{
|
{
|
||||||
Started = true;
|
Started = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -120,7 +120,7 @@ void *safe_malloc(size_t count)
|
||||||
void *p;
|
void *p;
|
||||||
if (count > (1 << 21))
|
if (count > (1 << 21))
|
||||||
{
|
{
|
||||||
I_Error("Timidity: Tried allocating %d bytes. This must be a bug.", count);
|
I_Error("Timidity: Tried allocating %u bytes. This must be a bug.", count);
|
||||||
}
|
}
|
||||||
else if ((p = malloc(count)))
|
else if ((p = malloc(count)))
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ void *safe_malloc(size_t count)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
I_Error("Timidity: Couldn't malloc %d bytes.", count);
|
I_Error("Timidity: Couldn't malloc %u bytes.", count);
|
||||||
}
|
}
|
||||||
return 0; // Unreachable.
|
return 0; // Unreachable.
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ void Renderer::reset_midi()
|
||||||
reset_voices();
|
reset_voices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::select_sample(int v, Instrument *ip)
|
void Renderer::select_sample(int v, Instrument *ip, int vel)
|
||||||
{
|
{
|
||||||
float f, cdiff, diff, midfreq;
|
float f, cdiff, diff, midfreq;
|
||||||
int s, i;
|
int s, i;
|
||||||
|
@ -288,6 +288,17 @@ void Renderer::select_sample(int v, Instrument *ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
f = voice[v].orig_frequency;
|
f = voice[v].orig_frequency;
|
||||||
|
for (i = 0; i < s; i++)
|
||||||
|
{
|
||||||
|
if (sp->low_vel <= vel && sp->high_vel >= vel &&
|
||||||
|
sp->low_freq <= f && sp->high_freq >= f)
|
||||||
|
{
|
||||||
|
voice[v].sample = sp;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sp++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
No suitable sample found! We'll select the sample whose root
|
No suitable sample found! We'll select the sample whose root
|
||||||
frequency is closest to the one we want. (Actually we should
|
frequency is closest to the one we want. (Actually we should
|
||||||
|
@ -318,7 +329,7 @@ void Renderer::select_sample(int v, Instrument *ip)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::select_stereo_samples(int v, InstrumentLayer *lp)
|
void Renderer::select_stereo_samples(int v, InstrumentLayer *lp, int vel)
|
||||||
{
|
{
|
||||||
Instrument *ip;
|
Instrument *ip;
|
||||||
InstrumentLayer *nlp, *bestvel;
|
InstrumentLayer *nlp, *bestvel;
|
||||||
|
@ -358,7 +369,7 @@ void Renderer::select_stereo_samples(int v, InstrumentLayer *lp)
|
||||||
{
|
{
|
||||||
ip->sample = ip->right_sample;
|
ip->sample = ip->right_sample;
|
||||||
ip->samples = ip->right_samples;
|
ip->samples = ip->right_samples;
|
||||||
select_sample(v, ip);
|
select_sample(v, ip, vel);
|
||||||
voice[v].right_sample = voice[v].sample;
|
voice[v].right_sample = voice[v].sample;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -367,7 +378,7 @@ void Renderer::select_stereo_samples(int v, InstrumentLayer *lp)
|
||||||
}
|
}
|
||||||
ip->sample = ip->left_sample;
|
ip->sample = ip->left_sample;
|
||||||
ip->samples = ip->left_samples;
|
ip->samples = ip->left_samples;
|
||||||
select_sample(v, ip);
|
select_sample(v, ip, vel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -481,7 +492,7 @@ int Renderer::vc_alloc(int j)
|
||||||
|
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
if (i != j && (voice[i].status & VOICE_FREE))
|
if (i != j && (voice[i].status == VOICE_FREE))
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +508,9 @@ void Renderer::kill_others(int i)
|
||||||
|
|
||||||
while (j--)
|
while (j--)
|
||||||
{
|
{
|
||||||
if (voice[j].status & (VOICE_FREE|VOICE_OFF|VOICE_DIE)) continue;
|
if (voice[j].status == VOICE_FREE ||
|
||||||
|
voice[j].status == VOICE_OFF ||
|
||||||
|
voice[j].status == VOICE_DIE) continue;
|
||||||
if (i == j) continue;
|
if (i == j) continue;
|
||||||
if (voice[i].channel != voice[j].channel) continue;
|
if (voice[i].channel != voice[j].channel) continue;
|
||||||
if (voice[j].sample->note_to_use)
|
if (voice[j].sample->note_to_use)
|
||||||
|
@ -514,6 +527,12 @@ void Renderer::clone_voice(Instrument *ip, int v, int note, int vel, int clone_t
|
||||||
int w, played_note, chorus = 0, reverb = 0, milli;
|
int w, played_note, chorus = 0, reverb = 0, milli;
|
||||||
int chan = voice[v].channel;
|
int chan = voice[v].channel;
|
||||||
|
|
||||||
|
// [RH] Don't do the other clones.
|
||||||
|
if (clone_type != STEREO_CLONE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (clone_type == STEREO_CLONE)
|
if (clone_type == STEREO_CLONE)
|
||||||
{
|
{
|
||||||
if (!voice[v].right_sample && variationbank != 3) return;
|
if (!voice[v].right_sample && variationbank != 3) return;
|
||||||
|
@ -555,8 +574,6 @@ void Renderer::clone_voice(Instrument *ip, int v, int note, int vel, int clone_t
|
||||||
if (clone_type == STEREO_CLONE) voice[v].clone_voice = w;
|
if (clone_type == STEREO_CLONE) voice[v].clone_voice = w;
|
||||||
voice[w].clone_voice = v;
|
voice[w].clone_voice = v;
|
||||||
voice[w].clone_type = clone_type;
|
voice[w].clone_type = clone_type;
|
||||||
|
|
||||||
voice[w].sample = voice[v].right_sample;
|
|
||||||
voice[w].velocity = vel;
|
voice[w].velocity = vel;
|
||||||
|
|
||||||
milli = int(rate / 1000);
|
milli = int(rate / 1000);
|
||||||
|
@ -565,6 +582,7 @@ void Renderer::clone_voice(Instrument *ip, int v, int note, int vel, int clone_t
|
||||||
{
|
{
|
||||||
int left, right, leftpan, rightpan;
|
int left, right, leftpan, rightpan;
|
||||||
int panrequest = voice[v].panning;
|
int panrequest = voice[v].panning;
|
||||||
|
voice[w].sample = voice[v].right_sample;
|
||||||
if (variationbank == 3)
|
if (variationbank == 3)
|
||||||
{
|
{
|
||||||
voice[v].panning = 0;
|
voice[v].panning = 0;
|
||||||
|
@ -912,7 +930,7 @@ void Renderer::start_note(int ch, int this_note, int this_velocity, int i)
|
||||||
voice[i].orig_frequency = note_to_freq(this_note & 0x7F);
|
voice[i].orig_frequency = note_to_freq(this_note & 0x7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
select_stereo_samples(i, lp);
|
select_stereo_samples(i, lp, this_velocity);
|
||||||
|
|
||||||
played_note = voice[i].sample->note_to_use;
|
played_note = voice[i].sample->note_to_use;
|
||||||
|
|
||||||
|
@ -1151,7 +1169,9 @@ void Renderer::note_on(int chan, int note, int vel)
|
||||||
i = voices;
|
i = voices;
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
if ( (voice[i].status & ~(VOICE_ON | VOICE_DIE | VOICE_FREE)) &&
|
if ( (voice[i].status != VOICE_ON &&
|
||||||
|
voice[i].status != VOICE_DIE &&
|
||||||
|
voice[i].status != VOICE_FREE) &&
|
||||||
(!voice[i].clone_type))
|
(!voice[i].clone_type))
|
||||||
{
|
{
|
||||||
v = voice[i].left_mix;
|
v = voice[i].left_mix;
|
||||||
|
|
|
@ -456,7 +456,7 @@ Renderer::Renderer(float sample_rate)
|
||||||
if (def_instr_name.IsNotEmpty())
|
if (def_instr_name.IsNotEmpty())
|
||||||
set_default_instrument(def_instr_name);
|
set_default_instrument(def_instr_name);
|
||||||
|
|
||||||
voices = MAX_VOICES;//DEFAULT_VOICES;
|
voices = DEFAULT_VOICES;
|
||||||
memset(voice, 0, sizeof(voice));
|
memset(voice, 0, sizeof(voice));
|
||||||
memset(drumvolume, 0, sizeof(drumvolume));
|
memset(drumvolume, 0, sizeof(drumvolume));
|
||||||
memset(drumpanpot, 0, sizeof(drumpanpot));
|
memset(drumpanpot, 0, sizeof(drumpanpot));
|
||||||
|
|
|
@ -498,10 +498,7 @@ tables.h
|
||||||
|
|
||||||
#define sine(x) (sin((2*PI/1024.0) * (x)))
|
#define sine(x) (sin((2*PI/1024.0) * (x)))
|
||||||
#define note_to_freq(x) (float(8175.7989473096690661233836992789 * pow(2.0, (x) / 12.0)))
|
#define note_to_freq(x) (float(8175.7989473096690661233836992789 * pow(2.0, (x) / 12.0)))
|
||||||
|
#define calc_vol(x) (pow(2.0,((x)*6.0 - 6.0)))
|
||||||
// Use TiMidity++'s volume equation rather than TiMidity's, since it's louder.
|
|
||||||
//#define calc_vol(x) (pow(2.0,((x)*6.0 - 6.0)))
|
|
||||||
#define calc_vol(x) (pow((double)(x), (double)1.66096404744))
|
|
||||||
|
|
||||||
#define XMAPMAX 800
|
#define XMAPMAX 800
|
||||||
|
|
||||||
|
@ -581,8 +578,8 @@ struct Renderer
|
||||||
void reset_controllers(int chan);
|
void reset_controllers(int chan);
|
||||||
void reset_midi();
|
void reset_midi();
|
||||||
|
|
||||||
void select_sample(int voice, Instrument *instr);
|
void select_sample(int voice, Instrument *instr, int vel);
|
||||||
void select_stereo_samples(int voice, InstrumentLayer *layer);
|
void select_stereo_samples(int voice, InstrumentLayer *layer, int vel);
|
||||||
void recompute_freq(int voice);
|
void recompute_freq(int voice);
|
||||||
|
|
||||||
void kill_note(int voice);
|
void kill_note(int voice);
|
||||||
|
|
Loading…
Reference in a new issue