mirror of https://github.com/stella-emu/stella.git
Added a volume setting function which allows the generated sample's
volume to be controlled. There's some code for the Mac which will need to be updated for this to work in that environment. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@259 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e08568a3d1
commit
69df04607e
|
@ -108,6 +108,7 @@ static uint8 AUDV[2]; /* AUDVx (19, 1A) */
|
|||
|
||||
static uint8 Outvol[2]; /* last output volume for each channel */
|
||||
|
||||
static uint32 volume; /* output sample volume percentage */
|
||||
|
||||
/* Initialze the bit patterns for the polynomials. */
|
||||
|
||||
|
@ -195,6 +196,8 @@ void Tia_sound_init (uint16 sample_freq, uint16 playback_freq)
|
|||
P5[chan] = 0;
|
||||
P9[chan] = 0;
|
||||
}
|
||||
|
||||
volume = 100;
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,7 +602,7 @@ void Tia_process (register unsigned char *buffer, register uint16 n)
|
|||
#ifdef MAC_OSX
|
||||
*(buffer++) = (outvol_0 + outvol_1)/2 + 128;
|
||||
#else
|
||||
*(buffer++) = outvol_0 + outvol_1;
|
||||
*(buffer++) = ((((uint32)outvol_0 + (uint32)outvol_1) * volume) / 100);
|
||||
#endif
|
||||
/* and indicate one less byte to process */
|
||||
n--;
|
||||
|
@ -613,7 +616,6 @@ void Tia_process (register unsigned char *buffer, register uint16 n)
|
|||
Outvol[1] = outvol_1;
|
||||
Div_n_cnt[0] = div_n_cnt0;
|
||||
Div_n_cnt[1] = div_n_cnt1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -665,6 +667,23 @@ void Tia_set_registers (unsigned char reg1, unsigned char reg2, unsigned char re
|
|||
AUDV[1] = reg6;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module: Tia_volume() */
|
||||
/* Purpose: Set volume to the specified percentage */
|
||||
/* */
|
||||
/* Author: Bradford W. Mott */
|
||||
/* Date: June 12, 2004 */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
void Tia_volume (unsigned int percent)
|
||||
{
|
||||
if((percent >= 0) && (percent <= 100))
|
||||
{
|
||||
volume = percent;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -52,6 +52,8 @@ void Tia_get_registers (unsigned char *reg1, unsigned char *reg2, unsigned char
|
|||
void Tia_set_registers (unsigned char reg1, unsigned char reg2, unsigned char reg3,
|
||||
unsigned char reg4, unsigned char reg5, unsigned char reg6);
|
||||
|
||||
void Tia_volume (unsigned int percent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue