- Added a new cvar: midi_timiditylike. This re-enables TiMidity handling of

GUS patch flags, envelopes, and volume levels, while trying to be closer
  to TiMidity++ than original TiMidity.
- Renamed timidity_config and timidity_voices to midi_config and midi_voices
  respectively.


SVN r959 (trunk)
This commit is contained in:
Randy Heit 2008-05-10 01:35:50 +00:00
commit d4563767ee
7 changed files with 156 additions and 64 deletions

View file

@ -27,6 +27,9 @@
#include <math.h>
#include "timidity.h"
#include "c_cvars.h"
EXTERN_CVAR(Bool, midi_timiditylike)
namespace Timidity
{
@ -161,7 +164,16 @@ void Renderer::recompute_amp(Voice *v)
if (v->sample->type == INST_GUS)
{
v->attenuation = (vol_table[(chanvol * chanexpr) / 127] * vol_table[v->velocity]) * ((127 + 64) / 12419775.f);
if (midi_timiditylike)
{
v->attenuation = float(timidityxx_perceived_vol(v->velocity / 127.0) *
timidityxx_perceived_vol(chanvol / 127.0) *
timidityxx_perceived_vol(chanexpr / 127.0));
}
else
{
v->attenuation = (vol_table[(chanvol * chanexpr) / 127] * vol_table[v->velocity]) * ((127 + 64) / 12419775.f);
}
}
else
{
@ -190,7 +202,7 @@ void Renderer::compute_pan(double pan, int type, float &left_offset, float &righ
}
else
{
if (type == INST_GUS)
if (type == INST_GUS && !midi_timiditylike)
{
/* Original amp equation looks like this:
* calc_gf1_amp(atten + offset)
@ -209,8 +221,12 @@ void Renderer::compute_pan(double pan, int type, float &left_offset, float &righ
}
else
{
left_offset = (float)db_to_amp(-20 * log10(sqrt(1 - pan)));
right_offset = (float)db_to_amp(-20 * log10(sqrt(pan)));
/* I have no idea what equation, if any, will reproduce the sc_pan_table
* that TiMidity++ uses, so midi_timiditylike gets the same Equal Power
* Panning as SF2/DLS.
*/
left_offset = (float)sqrt(1 - pan);
right_offset = (float)sqrt(pan);
}
}
}
@ -548,7 +564,7 @@ void Renderer::finish_note(int i)
v->status &= ~VOICE_SUSTAINING;
v->status |= VOICE_RELEASING;
if (!(v->sample->modes & PATCH_NO_SRELEASE))
if (!(v->sample->modes & PATCH_NO_SRELEASE) || midi_timiditylike)
{
v->status &= ~VOICE_LPE; /* sampled release */
}