- Move panning volume calculation out of the OPL chips and into the player.

SVN r3948 (trunk)
This commit is contained in:
Randy Heit 2012-11-09 04:53:31 +00:00
parent 064ef07b76
commit b513931473
5 changed files with 1454 additions and 1454 deletions

File diff suppressed because it is too large Load diff

View file

@ -223,7 +223,7 @@ public:
void Reset();
void Update(float* sndptr, int numsamples);
void WriteReg(int idx, int val);
void SetPanning(int c, int pan);
void SetPanning(int c, float left, float right);
DBOPL(bool stereo);
};

View file

@ -127,7 +127,6 @@ typedef signed int INT32; /* signed 32bit */
#endif
#define CENTER_PANNING_POWER 0.70710678118 /* [RH] volume at center for EQP */
#define HALF_PI (PI/2)
#define FREQ_SH 16 /* 16.16 fixed point (frequency calculations) */
#define EG_SH 16 /* 16.16 fixed point (EG timing) */
@ -1587,13 +1586,10 @@ public:
}
/* [RH] Full support for MIDI panning */
void SetPanning(int c, int pan)
void SetPanning(int c, float left, float right)
{
// This is the MIDI-recommended pan formula. 0 and 1 are
// both hard left so that 64 can be perfectly center.
double level = (pan <= 1) ? 0 : (pan - 1) / 126.0;
Chip.P_CH[c].LeftVol = (float)cos(HALF_PI * level);
Chip.P_CH[c].RightVol = (float)sin(HALF_PI * level);
Chip.P_CH[c].LeftVol = left;
Chip.P_CH[c].RightVol = right;
}

View file

@ -45,6 +45,8 @@
#include "opl.h"
#include "c_cvars.h"
#define HALF_PI (PI*0.5)
EXTERN_CVAR(Int, opl_core)
OPLio::~OPLio()
@ -260,7 +262,13 @@ void OPLio::OPLwritePan(uint channel, struct OPL2instrument *instr, int pan)
int which = channel / chanper;
if (chips[which] != NULL)
{
chips[which]->SetPanning(channel % chanper, pan + 64);
// This is the MIDI-recommended pan formula. 0 and 1 are
// both hard left so that 64 can be perfectly center.
// (Note that the 'pan' passed to this function is the
// MIDI pan position, subtracted by 64.)
double level = (pan <= -63) ? 0 : (pan + 64 - 1) / 126.0;
chips[which]->SetPanning(channel % chanper,
(float)cos(HALF_PI * level), (float)sin(HALF_PI * level));
}
}
}

View file

@ -14,7 +14,7 @@ public:
virtual void Reset() = 0;
virtual void WriteReg(int reg, int v) = 0;
virtual void Update(float *buffer, int length) = 0;
virtual void SetPanning(int c, int pan) = 0;
virtual void SetPanning(int c, float left, float right) = 0;
virtual FString GetVoiceString() { return FString(); }
};