⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pokeysnd.c

📁 wince下著名的视频播放器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
				/* if the output is pure or the output is poly5 and the poly5 bit */				/* is set */				if ((audc & NOTPOLY5) || bit5[P5]) {					/* if the PURETONE bit is set */					if (audc & PURETONE) {						/* then simply toggle the output */						toggle = TRUE;					}					/* otherwise if POLY4 is selected */					else if (audc & POLY4) {						/* then compare to the poly4 bit */						toggle = (bit4[P4] == !(*out_ptr));					}					else {						/* if 9-bit poly is selected on this chip */						if (AUDCTL[next_event >> 2] & POLY9) {							/* compare to the poly9 bit */							toggle = ((poly9_lookup[P9] & 1) == !(*out_ptr));						}						else {							/* otherwise compare to the poly17 bit */							toggle = (((poly17_lookup[P17 >> 3] >> (P17 & 7)) & 1) == !(*out_ptr));						}					}				}			}			/* check channel 1 filter (clocked by channel 3) */			if ( AUDCTL[next_event >> 2] & CH1_FILTER) {				/* if we're processing channel 3 */				if ((next_event & 0x03) == CHAN3) {					/* check output of channel 1 on same chip */					if (Outvol[next_event & 0xfd]) {						/* if on, turn it off */						Outvol[next_event & 0xfd] = 0;#ifdef STEREO_SOUND#ifdef __PLUS						if (stereo_enabled && (next_event & 0x04))#else						if ((next_event & 0x04))#endif							cur_val2 -= AUDV[next_event & 0xfd];						else#endif /* STEREO_SOUND */							cur_val -= AUDV[next_event & 0xfd];					}				}			}			/* check channel 2 filter (clocked by channel 4) */			if ( AUDCTL[next_event >> 2] & CH2_FILTER) {				/* if we're processing channel 4 */				if ((next_event & 0x03) == CHAN4) {					/* check output of channel 2 on same chip */					if (Outvol[next_event & 0xfd]) {						/* if on, turn it off */						Outvol[next_event & 0xfd] = 0;#ifdef STEREO_SOUND#ifdef __PLUS						if (stereo_enabled && (next_event & 0x04))#else						if ((next_event & 0x04))#endif							cur_val2 -= AUDV[next_event & 0xfd];						else#endif /* STEREO_SOUND */							cur_val -= AUDV[next_event & 0xfd];					}				}			}			/* if the current output bit has changed */			if (toggle) {				if (*out_ptr) {					/* remove this channel from the signal */#ifdef STEREO_SOUND#ifdef __PLUS					if (stereo_enabled && (next_event & 0x04))#else					if ((next_event & 0x04))#endif						cur_val2 -= AUDV[next_event];					else#endif /* STEREO_SOUND */						cur_val -= AUDV[next_event];					/* and turn the output off */					*out_ptr = 0;				}				else {					/* turn the output on */					*out_ptr = 1;					/* and add it to the output signal */#ifdef STEREO_SOUND#ifdef __PLUS					if (stereo_enabled && (next_event & 0x04))#else					if ((next_event & 0x04))#endif						cur_val2 += AUDV[next_event];					else#endif /* STEREO_SOUND */						cur_val += AUDV[next_event];				}			}		}		else {					/* otherwise we're processing a sample */			/* adjust the sample counter - note we're using the 24.8 integer			   which includes an 8 bit fraction for accuracy */			int iout;#ifdef STEREO_SOUND			int iout2;#endif#ifdef INTERPOLATE_SOUND			if (cur_val != last_val) {				if (*Samp_n_cnt < Samp_n_max) {		/* need interpolation */					iout = (cur_val * (*Samp_n_cnt) +							last_val * (Samp_n_max - *Samp_n_cnt))						/ Samp_n_max;				}				else					iout = cur_val;				last_val = cur_val;			}			else				iout = cur_val;#ifdef STEREO_SOUND#ifdef __PLUS		if (stereo_enabled)#endif			if (cur_val2 != last_val2) {				if (*Samp_n_cnt < Samp_n_max) {		/* need interpolation */					iout2 = (cur_val2 * (*Samp_n_cnt) +							last_val2 * (Samp_n_max - *Samp_n_cnt))						/ Samp_n_max;				}				else					iout2 = cur_val2;				last_val2 = cur_val2;			}			else				iout2 = cur_val2;#endif  /* STEREO_SOUND */#else   /* INTERPOLATE_SOUND */			iout = cur_val;#ifdef STEREO_SOUND#ifdef __PLUS		if (stereo_enabled)#endif			iout2 = cur_val2;#endif  /* STEREO_SOUND */#endif  /* INTERPOLATE_SOUND */#ifdef VOL_ONLY_SOUND#ifdef __PLUS			if (g_Sound.nDigitized)#endif			{				if (sampbuf_rptr != sampbuf_ptr) {					int l;					if (sampbuf_cnt[sampbuf_rptr] > 0)						sampbuf_cnt[sampbuf_rptr] -= 1280;					while ((l = sampbuf_cnt[sampbuf_rptr]) <= 0) {						sampout = sampbuf_val[sampbuf_rptr];						sampbuf_rptr++;						if (sampbuf_rptr >= SAMPBUF_MAX)							sampbuf_rptr = 0;						if (sampbuf_rptr != sampbuf_ptr)							sampbuf_cnt[sampbuf_rptr] += l;						else							break;					}				}				iout += sampout;#ifdef STEREO_SOUND#ifdef __PLUS				if (stereo_enabled)#endif				{					if (sampbuf_rptr2 != sampbuf_ptr2) {						int l;						if (sampbuf_cnt2[sampbuf_rptr2] > 0)							sampbuf_cnt2[sampbuf_rptr2] -= 1280;						while ((l = sampbuf_cnt2[sampbuf_rptr2]) <= 0) {							sampout2 = sampbuf_val2[sampbuf_rptr2];							sampbuf_rptr2++;							if (sampbuf_rptr2 >= SAMPBUF_MAX)								sampbuf_rptr2 = 0;							if (sampbuf_rptr2 != sampbuf_ptr2)								sampbuf_cnt2[sampbuf_rptr2] += l;							else								break;						}					}					iout2 += sampout2;				}#endif  /* STEREO_SOUND */			}#endif  /* VOL_ONLY_SOUND */#ifdef CLIP_SOUND			if (iout > SAMP_MAX) {	/* then check high limit */				*buffer++ = (uint8) SAMP_MAX;	/* and limit if greater */			}			else if (iout < SAMP_MIN) {		/* else check low limit */				*buffer++ = (uint8) SAMP_MIN;	/* and limit if less */			}			else {				/* otherwise use raw value */				*buffer++ = (uint8) iout;			}#ifdef STEREO_SOUND#ifdef __PLUS			if (stereo_enabled) {				if (iout2 > SAMP_MAX)					*buffer++ = (uint8) SAMP_MAX;				else if (iout2 < SAMP_MIN)					*buffer++ = (uint8) SAMP_MIN;				else					*buffer++ = (uint8) iout2;			}#else /* __PLUS */			if (Num_pokeys > 1) {				if ((stereo_enabled ? iout2 : iout) > SAMP_MAX) {	/* then check high limit */					*buffer++ = (uint8) SAMP_MAX;	/* and limit if greater */				}				else if ((stereo_enabled ? iout2 : iout) < SAMP_MIN) {		/* else check low limit */					*buffer++ = (uint8) SAMP_MIN;	/* and limit if less */				}				else {				/* otherwise use raw value */					*buffer++ = (uint8) (stereo_enabled ? iout2 : iout);				}			}#endif /* __PLUS */#endif /* STEREO_SOUND */#else /* CLIP_SOUND */			*buffer++ = (uint8) iout;	/* clipping not selected, use value */#ifdef STEREO_SOUND			if (Num_pokeys > 1)#ifdef ASAP				*buffer++ = (uint8) iout2;#else				*buffer++ = (uint8) (stereo_enabled ? iout2 : iout);#endif#endif /* STEREO_SOUND */#endif /* CLIP_SOUND */#ifdef WORDS_BIGENDIAN			*(Samp_n_cnt + 1) += Samp_n_max;#else			*Samp_n_cnt += Samp_n_max;#endif			/* and indicate one less byte in the buffer */			n--;#ifdef STEREO_SOUND#ifdef __PLUS			if (stereo_enabled)#endif			if (Num_pokeys > 1)				n--;#endif		}	}#ifdef VOL_ONLY_SOUND#ifdef __PLUS	if (g_Sound.nDigitized)#endif	{		if (sampbuf_rptr == sampbuf_ptr)			sampbuf_last = cpu_clock;#ifdef STEREO_SOUND#ifdef __PLUS	if (stereo_enabled)#endif		if (sampbuf_rptr2 == sampbuf_ptr2)			sampbuf_last2 = cpu_clock;#endif /* STEREO_SOUND */	}#endif  /* VOL_ONLY_SOUND */}#ifdef SERIO_SOUNDstatic void Update_serio_sound_rf(int out, UBYTE data){#ifdef VOL_ONLY_SOUND#ifdef __PLUS	if (g_Sound.nDigitized) {#endif	int bits, pv, future;	if (!serio_sound_enabled) return;	pv = 0;	future = 0;	bits = (data << 1) | 0x200;	while (bits)	{		sampbuf_lastval -= pv;		pv = (bits & 0x01) * AUDV[3];	/* FIXME!!! - set volume from AUDV */		sampbuf_lastval += pv;	sampbuf_val[sampbuf_ptr] = sampbuf_lastval;	sampbuf_cnt[sampbuf_ptr] =		(cpu_clock + future-sampbuf_last) * 128 * samp_freq / 178979;	sampbuf_last = cpu_clock + future;	sampbuf_ptr++;	if (sampbuf_ptr >= SAMPBUF_MAX )		sampbuf_ptr = 0;	if (sampbuf_ptr == sampbuf_rptr ) {		sampbuf_rptr++;		if (sampbuf_rptr >= SAMPBUF_MAX)			sampbuf_rptr = 0;	}		/* 1789790/19200 = 93 */		future += 93;	/* ~ 19200 bit/s - FIXME!!! set speed form AUDF [2] ??? */		bits >>= 1;	}	sampbuf_lastval -= pv;#ifdef __PLUS	}#endif#endif  /* VOL_ONLY_SOUND */}#endif /* SERIO_SOUND */static void Pokey_process_16(void *sndbuffer, unsigned sndn){	uint16 *buffer = (uint16 *) sndbuffer;	int i;	Pokey_process_8(buffer, sndn);	for (i = sndn - 1; i >= 0; i--) {		int smp = ((int) (((uint8 *) buffer)[i]) - 0x80) * 0x100;		if (smp > 32767)			smp = 32767;		else if (smp < -32768)			smp = -32768;		buffer[i] = smp;	}}#ifdef CONSOLE_SOUNDstatic void Update_consol_sound_rf(int set){#ifdef VOL_ONLY_SOUND	static int prev_atari_speaker = 0;	static unsigned int prev_cpu_clock = 0;	int d;#ifdef __PLUS	if (!g_Sound.nDigitized)		return;#endif	if (!console_sound_enabled)		return;	if (!set && samp_consol_val == 0)		return;	sampbuf_lastval -= samp_consol_val;	if (prev_atari_speaker != atari_speaker) {		samp_consol_val = atari_speaker * 8 * 4;	/* gain */		prev_cpu_clock = cpu_clock;	}	else if (!set) {		d = cpu_clock - prev_cpu_clock;		if (d < 114) {			sampbuf_lastval += samp_consol_val;			return;		}		while (d >= 114 /* CPUL */) {			samp_consol_val = samp_consol_val * 99 / 100;			d -= 114;		}		prev_cpu_clock = cpu_clock - d;	}	sampbuf_lastval += samp_consol_val;	prev_atari_speaker = atari_speaker;	sampbuf_val[sampbuf_ptr] = sampbuf_lastval;	sampbuf_cnt[sampbuf_ptr] =		(cpu_clock - sampbuf_last) * 128 * samp_freq / 178979;	sampbuf_last = cpu_clock;	sampbuf_ptr++;	if (sampbuf_ptr >= SAMPBUF_MAX)		sampbuf_ptr = 0;	if (sampbuf_ptr == sampbuf_rptr) {		sampbuf_rptr++;		if (sampbuf_rptr >= SAMPBUF_MAX)			sampbuf_rptr = 0;	}#endif  /* VOL_ONLY_SOUND */}#endif /* CONSOLE_SOUND */#ifdef VOL_ONLY_SOUNDstatic void Update_vol_only_sound_rf(void){#ifdef CONSOLE_SOUND	Update_consol_sound(0);	/* mmm */#endif /* CONSOLE_SOUND */}#endif  /* VOL_ONLY_SOUND */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -