diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4a67740f1..714c6e757 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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) - Changed the internal Timidity player so that it uses timidity_mastervolume because it has the same sound volume issues as the external one. diff --git a/src/files.cpp b/src/files.cpp index fd017658e..d7ff7875a 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -90,6 +90,8 @@ bool FileReader::Open (const char *filename) { File = fopen (filename, "rb"); if (File == NULL) return false; + FilePos = 0; + StartPos = 0; CloseOnDestruct = true; Length = CalcFileLen(); return true; @@ -141,13 +143,12 @@ long FileReader::Read (void *buffer, long len) char *FileReader::Gets(char *strbuf, int len) { - if (FilePos + len > StartPos + Length) - { - len = Length - FilePos + StartPos; - } if (len <= 0) return 0; char *p = fgets(strbuf, len, File); - FilePos += len; + if (p != NULL) + { + FilePos = ftell(File) - StartPos; + } return p; } diff --git a/src/oplsynth/music_opl_mididevice.cpp b/src/oplsynth/music_opl_mididevice.cpp index a0e401151..0273af663 100644 --- a/src/oplsynth/music_opl_mididevice.cpp +++ b/src/oplsynth/music_opl_mididevice.cpp @@ -223,7 +223,7 @@ int OPLMIDIDevice::Resume() { if (!Started) { - if (Stream->Play(true, 1, false)) + if (Stream->Play(true, 1)) { Started = true; BlockForStats = this; diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 75c4df13f..e1a1c1fe6 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -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_output_format, "PCM-16", 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 ------------------------------------------------ @@ -302,7 +302,7 @@ public: } } - bool Play(bool looping, float volume, bool normalize) + bool Play(bool looping, float volume) { FMOD_RESULT result; @@ -322,14 +322,6 @@ public: reverb.Room = -10000; 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); return true; } @@ -636,9 +628,9 @@ bool FMODSoundRenderer::Init() { initflags |= FMOD_INIT_SOFTWARE_HRTF; } - if (snd_dspnet) + if (snd_profile) { - initflags |= FMOD_INIT_ENABLE_DSPNET; + initflags |= FMOD_INIT_ENABLE_PROFILE; } for (;;) { diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 3bb9bae5c..35a6f5547 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -53,7 +53,7 @@ public: 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 SetVolume (float volume) = 0; virtual bool SetPaused (bool paused) = 0; diff --git a/src/sound/music_midi_timidity.cpp b/src/sound/music_midi_timidity.cpp index 4ea8deb5e..5a6ad3542 100644 --- a/src/sound/music_midi_timidity.cpp +++ b/src/sound/music_midi_timidity.cpp @@ -94,7 +94,7 @@ void TimiditySong::Play (bool looping) { if (m_Stream != NULL) { - if (m_Stream->Play (true, timidity_mastervolume, false)) + if (m_Stream->Play (true, timidity_mastervolume)) { m_Status = STATE_Playing; } diff --git a/src/sound/music_mus_opl.cpp b/src/sound/music_mus_opl.cpp index 52f8d68ed..cc8bd5bf6 100644 --- a/src/sound/music_mus_opl.cpp +++ b/src/sound/music_mus_opl.cpp @@ -60,7 +60,7 @@ void OPLMUSSong::Play (bool looping) Music->SetLooping (looping); 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; } diff --git a/src/sound/music_stream.cpp b/src/sound/music_stream.cpp index b76a5fede..0c4e039ed 100644 --- a/src/sound/music_stream.cpp +++ b/src/sound/music_stream.cpp @@ -5,7 +5,7 @@ void StreamSong::Play (bool looping) m_Status = STATE_Stopped; m_Looping = looping; - if (m_Stream->Play (m_Looping, 1, false)) + if (m_Stream->Play (m_Looping, 1)) { m_Status = STATE_Playing; m_LastPos = 0; diff --git a/src/sound/music_timidity_mididevice.cpp b/src/sound/music_timidity_mididevice.cpp index e20a4ed03..382b4a8f2 100644 --- a/src/sound/music_timidity_mididevice.cpp +++ b/src/sound/music_timidity_mididevice.cpp @@ -205,7 +205,7 @@ int TimidityMIDIDevice::Resume() { if (!Started) { - if (Stream->Play(true, timidity_mastervolume, false)) + if (Stream->Play(true, timidity_mastervolume)) { Started = true; return 0; diff --git a/src/timidity/common.cpp b/src/timidity/common.cpp index f306abfb8..8579780e3 100644 --- a/src/timidity/common.cpp +++ b/src/timidity/common.cpp @@ -120,7 +120,7 @@ void *safe_malloc(size_t count) void *p; 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))) { @@ -128,7 +128,7 @@ void *safe_malloc(size_t count) } else { - I_Error("Timidity: Couldn't malloc %d bytes.", count); + I_Error("Timidity: Couldn't malloc %u bytes.", count); } return 0; // Unreachable. } diff --git a/src/timidity/playmidi.cpp b/src/timidity/playmidi.cpp index 2b6d7ed58..ca35be26a 100644 --- a/src/timidity/playmidi.cpp +++ b/src/timidity/playmidi.cpp @@ -272,7 +272,7 @@ void Renderer::reset_midi() 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; int s, i; @@ -288,6 +288,17 @@ void Renderer::select_sample(int v, Instrument *ip) } 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 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; InstrumentLayer *nlp, *bestvel; @@ -358,7 +369,7 @@ void Renderer::select_stereo_samples(int v, InstrumentLayer *lp) { ip->sample = ip->right_sample; ip->samples = ip->right_samples; - select_sample(v, ip); + select_sample(v, ip, vel); voice[v].right_sample = voice[v].sample; } else @@ -367,7 +378,7 @@ void Renderer::select_stereo_samples(int v, InstrumentLayer *lp) } ip->sample = ip->left_sample; 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--) { - if (i != j && (voice[i].status & VOICE_FREE)) + if (i != j && (voice[i].status == VOICE_FREE)) { return i; } @@ -497,7 +508,9 @@ void Renderer::kill_others(int i) 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 (voice[i].channel != voice[j].channel) continue; 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 chan = voice[v].channel; + // [RH] Don't do the other clones. + if (clone_type != STEREO_CLONE) + { + return; + } + if (clone_type == STEREO_CLONE) { 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; voice[w].clone_voice = v; voice[w].clone_type = clone_type; - - voice[w].sample = voice[v].right_sample; voice[w].velocity = vel; 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 panrequest = voice[v].panning; + voice[w].sample = voice[v].right_sample; if (variationbank == 3) { 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); } - select_stereo_samples(i, lp); + select_stereo_samples(i, lp, this_velocity); played_note = voice[i].sample->note_to_use; @@ -1151,7 +1169,9 @@ void Renderer::note_on(int chan, int note, int vel) i = voices; 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)) { v = voice[i].left_mix; diff --git a/src/timidity/timidity.cpp b/src/timidity/timidity.cpp index cdc6f5472..19fd0cdda 100644 --- a/src/timidity/timidity.cpp +++ b/src/timidity/timidity.cpp @@ -456,7 +456,7 @@ Renderer::Renderer(float sample_rate) if (def_instr_name.IsNotEmpty()) set_default_instrument(def_instr_name); - voices = MAX_VOICES;//DEFAULT_VOICES; + voices = DEFAULT_VOICES; memset(voice, 0, sizeof(voice)); memset(drumvolume, 0, sizeof(drumvolume)); memset(drumpanpot, 0, sizeof(drumpanpot)); diff --git a/src/timidity/timidity.h b/src/timidity/timidity.h index 3470b656c..4ba2233bb 100644 --- a/src/timidity/timidity.h +++ b/src/timidity/timidity.h @@ -498,10 +498,7 @@ tables.h #define sine(x) (sin((2*PI/1024.0) * (x))) #define note_to_freq(x) (float(8175.7989473096690661233836992789 * pow(2.0, (x) / 12.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 calc_vol(x) (pow(2.0,((x)*6.0 - 6.0))) #define XMAPMAX 800 @@ -581,8 +578,8 @@ struct Renderer void reset_controllers(int chan); void reset_midi(); - void select_sample(int voice, Instrument *instr); - void select_stereo_samples(int voice, InstrumentLayer *layer); + void select_sample(int voice, Instrument *instr, int vel); + void select_stereo_samples(int voice, InstrumentLayer *layer, int vel); void recompute_freq(int voice); void kill_note(int voice);