diff options
-rw-r--r-- | src/chips/dosbox/dbopl.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/chips/dosbox/dbopl.cpp b/src/chips/dosbox/dbopl.cpp index 903c1bb..3b0d73d 100644 --- a/src/chips/dosbox/dbopl.cpp +++ b/src/chips/dosbox/dbopl.cpp @@ -219,6 +219,29 @@ static const Bit8u KslShiftTable[4] = { 31,1,2,0 }; +// Pan law table +static Bit16u PanLawTable[] = +{ + 65535, 65529, 65514, 65489, 65454, 65409, 65354, 65289, + 65214, 65129, 65034, 64929, 64814, 64689, 64554, 64410, + 64255, 64091, 63917, 63733, 63540, 63336, 63123, 62901, + 62668, 62426, 62175, 61914, 61644, 61364, 61075, 60776, + 60468, 60151, 59825, 59489, 59145, 58791, 58428, 58057, + 57676, 57287, 56889, 56482, 56067, 55643, 55211, 54770, + 54320, 53863, 53397, 52923, 52441, 51951, 51453, 50947, + 50433, 49912, 49383, 48846, 48302, 47750, 47191, + 46340, /* Center left */ + 46340, /* Center right */ + 45472, 44885, 44291, 43690, 43083, 42469, 41848, 41221, + 40588, 39948, 39303, 38651, 37994, 37330, 36661, 35986, + 35306, 34621, 33930, 33234, 32533, 31827, 31116, 30400, + 29680, 28955, 28225, 27492, 26754, 26012, 25266, 24516, + 23762, 23005, 22244, 21480, 20713, 19942, 19169, 18392, + 17613, 16831, 16046, 15259, 14469, 13678, 12884, 12088, + 11291, 10492, 9691, 8888, 8085, 7280, 6473, 5666, + 4858, 4050, 3240, 2431, 1620, 810, 0 +}; + //Generate a table index and table shift value using input value from a selected rate static void EnvelopeSelect( Bit8u val, Bit8u& index, Bit8u& shift ) { if ( val < 13 * 4 ) { //Rate 0 - 12 @@ -758,8 +781,8 @@ void Channel::WriteC0(const Chip* chip, Bit8u val) { } void Channel::WritePan(Bit8u val) { - panLeft = (Bit16u)(cos((float)val * (PI / 2.0f / 127.0f)) * 65535.0f); - panRight = (Bit16u)(sin((float)val * (PI / 2.0f / 127.0f)) * 65535.0f); + panLeft = PanLawTable[val & 0x7F]; + panRight = PanLawTable[0x7F - (val & 0x7F)]; } void Channel::UpdateSynth( const Chip* chip ) { |