mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- Move panning volume calculation out of the OPL chips and into the player.
SVN r3948 (trunk)
This commit is contained in:
parent
064ef07b76
commit
b513931473
5 changed files with 1454 additions and 1454 deletions
File diff suppressed because it is too large
Load diff
|
@ -223,7 +223,7 @@ public:
|
||||||
void Reset();
|
void Reset();
|
||||||
void Update(float* sndptr, int numsamples);
|
void Update(float* sndptr, int numsamples);
|
||||||
void WriteReg(int idx, int val);
|
void WriteReg(int idx, int val);
|
||||||
void SetPanning(int c, int pan);
|
void SetPanning(int c, float left, float right);
|
||||||
|
|
||||||
DBOPL(bool stereo);
|
DBOPL(bool stereo);
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,6 @@ typedef signed int INT32; /* signed 32bit */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CENTER_PANNING_POWER 0.70710678118 /* [RH] volume at center for EQP */
|
#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 FREQ_SH 16 /* 16.16 fixed point (frequency calculations) */
|
||||||
#define EG_SH 16 /* 16.16 fixed point (EG timing) */
|
#define EG_SH 16 /* 16.16 fixed point (EG timing) */
|
||||||
|
@ -1587,13 +1586,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [RH] Full support for MIDI panning */
|
/* [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
|
Chip.P_CH[c].LeftVol = left;
|
||||||
// both hard left so that 64 can be perfectly center.
|
Chip.P_CH[c].RightVol = right;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include "opl.h"
|
#include "opl.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
|
|
||||||
|
#define HALF_PI (PI*0.5)
|
||||||
|
|
||||||
EXTERN_CVAR(Int, opl_core)
|
EXTERN_CVAR(Int, opl_core)
|
||||||
|
|
||||||
OPLio::~OPLio()
|
OPLio::~OPLio()
|
||||||
|
@ -260,7 +262,13 @@ void OPLio::OPLwritePan(uint channel, struct OPL2instrument *instr, int pan)
|
||||||
int which = channel / chanper;
|
int which = channel / chanper;
|
||||||
if (chips[which] != NULL)
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
virtual void Reset() = 0;
|
virtual void Reset() = 0;
|
||||||
virtual void WriteReg(int reg, int v) = 0;
|
virtual void WriteReg(int reg, int v) = 0;
|
||||||
virtual void Update(float *buffer, int length) = 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(); }
|
virtual FString GetVoiceString() { return FString(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue