mirror of
https://github.com/holub/mame
synced 2025-05-23 22:20:01 +03:00
added damping and pseudoreverb
This commit is contained in:
parent
e818d68438
commit
12336b62a2
@ -55,6 +55,12 @@
|
|||||||
June 4, 2003 - Changed to dual-license with LGPL for use in OpenMSX.
|
June 4, 2003 - Changed to dual-license with LGPL for use in OpenMSX.
|
||||||
OpenMSX contributed a bugfix where looped samples were
|
OpenMSX contributed a bugfix where looped samples were
|
||||||
not being addressed properly, causing pitch fluctuation.
|
not being addressed properly, causing pitch fluctuation.
|
||||||
|
......
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
- accurate timing of envelopes
|
||||||
|
- LFO (vibrato, tremolo)
|
||||||
|
- integrate YMF262
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
@ -131,7 +137,7 @@ typedef struct
|
|||||||
UINT32 romsize;
|
UINT32 romsize;
|
||||||
int clock;
|
int clock;
|
||||||
|
|
||||||
INT32 volume[256*4]; // precalculated attenuation values with some marging for enveloppe and pan levels
|
INT32 volume[256*4]; // precalculated attenuation values with some margin for envelope and pan levels
|
||||||
int pan_left[16],pan_right[16]; // pan volume offsets
|
int pan_left[16],pan_right[16]; // pan volume offsets
|
||||||
INT32 mix_level[8];
|
INT32 mix_level[8];
|
||||||
|
|
||||||
@ -235,9 +241,14 @@ static void ymf278b_envelope_next(YMF278BSlot *slot)
|
|||||||
slot->env_step++;
|
slot->env_step++;
|
||||||
if(slot->DL)
|
if(slot->DL)
|
||||||
{
|
{
|
||||||
int rate = ymf278b_compute_rate(slot, slot->D1R);
|
int rate;
|
||||||
LOG(("YMF278B: Decay step 1, dl=%d, val = %d rate = %d, delay = %g\n", slot->DL, slot->D1R, rate, ymf278_compute_decay_rate(rate)*1000.0));
|
// rate override with damping/pseudo reverb
|
||||||
|
// NOTE: pseudo reverb starts at 0dB here, but should start at -18dB (which is actually between D1 and D2)
|
||||||
|
if (slot->DAMP) rate = 63;
|
||||||
|
else if (slot->PRVB) rate = 5;
|
||||||
|
else rate = ymf278b_compute_rate(slot, slot->D1R);
|
||||||
|
|
||||||
|
LOG(("YMF278B: Decay step 1, dl=%d, val = %d rate = %d, delay = %g\n", slot->DL, slot->D1R, rate, ymf278_compute_decay_rate(rate)*1000.0));
|
||||||
if(rate<4)
|
if(rate<4)
|
||||||
slot->env_vol_step = 0;
|
slot->env_vol_step = 0;
|
||||||
else
|
else
|
||||||
@ -249,7 +260,11 @@ static void ymf278b_envelope_next(YMF278BSlot *slot)
|
|||||||
if(slot->env_step == 2)
|
if(slot->env_step == 2)
|
||||||
{
|
{
|
||||||
// Decay 2
|
// Decay 2
|
||||||
int rate = ymf278b_compute_rate(slot, slot->D2R);
|
int rate;
|
||||||
|
// rate override with damping/pseudo reverb
|
||||||
|
if (slot->DAMP) rate = 63;
|
||||||
|
else if (slot->PRVB) rate = 5;
|
||||||
|
else rate = ymf278b_compute_rate(slot, slot->D2R);
|
||||||
|
|
||||||
LOG(("YMF278B: Decay step 2, val = %d, rate = %d, delay = %g, current vol = %d\n", slot->D2R, rate, ymf278_compute_decay_rate(rate)*1000.0, slot->env_vol >> 23));
|
LOG(("YMF278B: Decay step 2, val = %d, rate = %d, delay = %g, current vol = %d\n", slot->D2R, rate, ymf278_compute_decay_rate(rate)*1000.0, slot->env_vol >> 23));
|
||||||
if(rate<4)
|
if(rate<4)
|
||||||
@ -273,7 +288,11 @@ static void ymf278b_envelope_next(YMF278BSlot *slot)
|
|||||||
if(slot->env_step == 4)
|
if(slot->env_step == 4)
|
||||||
{
|
{
|
||||||
// Release
|
// Release
|
||||||
int rate = ymf278b_compute_rate(slot, slot->RR);
|
int rate;
|
||||||
|
// rate override with damping/pseudo reverb
|
||||||
|
if (slot->DAMP) rate = 63;
|
||||||
|
else if (slot->PRVB) rate = 5;
|
||||||
|
else rate = ymf278b_compute_rate(slot, slot->RR);
|
||||||
|
|
||||||
LOG(("YMF278B: Release, val = %d, rate = %d, delay = %g\n", slot->RR, rate, ymf278_compute_decay_rate(rate)*1000.0));
|
LOG(("YMF278B: Release, val = %d, rate = %d, delay = %g\n", slot->RR, rate, ymf278_compute_decay_rate(rate)*1000.0));
|
||||||
if(rate<4)
|
if(rate<4)
|
||||||
@ -598,7 +617,7 @@ static void ymf278b_C_w(YMF278BChip *chip, UINT8 reg, UINT8 data, int init)
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
slot->pan = data&0xf;
|
slot->pan = data&0xf;
|
||||||
slot->DAMP = data&0x40;
|
slot->DAMP = (data&0x40)>>6;
|
||||||
if (data & 0x80)
|
if (data & 0x80)
|
||||||
{
|
{
|
||||||
unsigned int step;
|
unsigned int step;
|
||||||
@ -944,7 +963,7 @@ static DEVICE_START( ymf278b )
|
|||||||
chip->pan_right[i] = i < 8 ? 0 : i < 10 ? 256 : (16-i)*8;
|
chip->pan_right[i] = i < 8 ? 0 : i < 10 ? 256 : (16-i)*8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mixing levels, units are -3dB, and add some marging to avoid clipping
|
// Mixing levels, units are -3dB, and add some margin to avoid clipping
|
||||||
for(i=0; i<7; i++)
|
for(i=0; i<7; i++)
|
||||||
chip->mix_level[i] = chip->volume[8*i+8];
|
chip->mix_level[i] = chip->volume[8*i+8];
|
||||||
chip->mix_level[7] = 0;
|
chip->mix_level[7] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user