void beep_set_volume(int num, int volume) { struct beep_sound *info = sndti_token(SOUND_BEEP, num); stream_update(info->stream); volume = 100 * volume / 7; sndti_set_output_gain(SOUND_BEEP, num, 0, volume ); }
static WRITE8_HANDLER( ay8910_portA_0_w ) { float percent; /*There are three AY8910 chips and four(!) separate amplifiers on the board * Each of AY channels is hardware mapped in following way: * amplifier 0 gain x 1.00 <- AY0 CHA * amplifier 1 gain x 1.00 <- AY0 CHB + AY0 CHC + AY1 CHA + AY1 CHB * amplifier 2 gain x 4.54 (150K/33K) <- AY1 CHC + AY2 CHA * amplifier 3 gain x 4.54 (150K/33K) <- AY2 CHB + AY2 CHC * * Each of the amps has its own analog cuircit: * amp0, amp1 and amp2 are different from each other; amp3 is the same as amp2 * * Outputs of those amps are inputs to post amps, each having own cuircit * that is partially controlled by AY #0 port A. * PORT A BIT 0 - control postamp 0 (gain x10.0 | gain x 5.00) * PORT A BIT 1 - control postamp 1 (gain x4.54 | gain x 2.27) * PORT A BIT 2 - control postamp 2 (gain x1.00 | gain x 0.50) * PORT A BIT 3 - control postamp 3 (gain x1.00 | gain x 0.50) * * The "control" means assert/clear input pins on chip called 4066 (it is analog switch) * which results in volume gain (exactly 2 times). * I use mixer_set_volume() to emulate the effect. gain summary: port A control ON OFF amp0 = *1*10.0=10.0 *1*5.0 = 5.0 amp1 = *1*4.54=4.54 *1*2.27 = 2.27 amp2 = *4.54*1=4.54 *4.54*0.5= 2.27 amp3 = *4.54*1=4.54 *4.54*0.5= 2.27 */ /* bit0 - SOUND Chan#0 name=AY-3-8910 #0 Ch A bit1 - SOUND Chan#1 name=AY-3-8910 #0 Ch B bit1 - SOUND Chan#2 name=AY-3-8910 #0 Ch C bit1 - SOUND Chan#3 name=AY-3-8910 #1 Ch A bit1 - SOUND Chan#4 name=AY-3-8910 #1 Ch B bit2 - SOUND Chan#5 name=AY-3-8910 #1 Ch C bit2 - SOUND Chan#6 name=AY-3-8910 #2 Ch A bit3 - SOUND Chan#7 name=AY-3-8910 #2 Ch B bit3 - SOUND Chan#8 name=AY-3-8910 #2 Ch C */ if (gain_control == (data & 0x0f)) return; gain_control = data & 0x0f; /*popmessage("gain_ctrl = %2x",data&0x0f);*/ percent = (gain_control & 1) ? 1.0 : 0.50; sndti_set_output_gain(SOUND_AY8910, 0, 0, percent); //fixme: set_RC_filter(0,10000,100000000,0,10000); /* 10K, 10000pF = 0.010uF */ percent = (gain_control & 2) ? 0.45 : 0.23; sndti_set_output_gain(SOUND_AY8910, 0, 1, percent); sndti_set_output_gain(SOUND_AY8910, 0, 2, percent); sndti_set_output_gain(SOUND_AY8910, 1, 0, percent); sndti_set_output_gain(SOUND_AY8910, 1, 1, percent); //fixme: set_RC_filter(1,4700,100000000,0,4700); /* 4.7K, 4700pF = 0.0047uF */ //fixme: set_RC_filter(2,4700,100000000,0,4700); /* 4.7K, 4700pF = 0.0047uF */ //fixme: set_RC_filter(3,4700,100000000,0,4700); /* 4.7K, 4700pF = 0.0047uF */ //fixme: set_RC_filter(4,4700,100000000,0,4700); /* 4.7K, 4700pF = 0.0047uF */ percent = (gain_control & 4) ? 0.45 : 0.23; sndti_set_output_gain(SOUND_AY8910, 1, 2, percent); sndti_set_output_gain(SOUND_AY8910, 2, 0, percent); percent = (gain_control & 8) ? 0.45 : 0.23; sndti_set_output_gain(SOUND_AY8910, 2, 1, percent); sndti_set_output_gain(SOUND_AY8910, 2, 2, percent); }