亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? es5506.c

?? 十七種模擬器源代碼 非常有用的作課程設(shè)計(jì)不可缺少的
?? C
?? 第 1 頁 / 共 4 頁
字號:
/********************************************************************************************** * *   Ensoniq ES5505/6 driver *   by Aaron Giles * **********************************************************************************************/#include <stdio.h>#include <stdlib.h>#include <math.h>#include "sasound.h"#include "driver.h"#include "adpcm.h"//#define DUMP 1/**********************************************************************************************     CONSTANTS***********************************************************************************************/#define BACKEND_INTERPOLATE		1#define LOG_COMMANDS			0#define MAX_SAMPLE_CHUNK		10000#define ULAW_MAXBITS			8#define FRAC_BITS				14#define FRAC_ONE				(1 << FRAC_BITS)#define FRAC_MASK				(FRAC_ONE - 1)#define CONTROL_BS1				0x8000#define CONTROL_BS0				0x4000#define CONTROL_CMPD			0x2000#define CONTROL_CA2				0x1000#define CONTROL_CA1				0x0800#define CONTROL_CA0				0x0400#define CONTROL_LP4				0x0200#define CONTROL_LP3				0x0100#define CONTROL_IRQ				0x0080#define CONTROL_DIR				0x0040#define CONTROL_IRQE			0x0020#define CONTROL_BLE				0x0010#define CONTROL_LPE				0x0008#define CONTROL_LEI				0x0004#define CONTROL_STOP1			0x0002#define CONTROL_STOP0			0x0001#define CONTROL_BSMASK			(CONTROL_BS1 | CONTROL_BS0)#define CONTROL_CAMASK			(CONTROL_CA2 | CONTROL_CA1 | CONTROL_CA0)#define CONTROL_LPMASK			(CONTROL_LP4 | CONTROL_LP3)#define CONTROL_LOOPMASK		(CONTROL_BLE | CONTROL_LPE)#define CONTROL_STOPMASK		(CONTROL_STOP1 | CONTROL_STOP0)/**********************************************************************************************     INTERNAL DATA STRUCTURES***********************************************************************************************//* struct describing a single playing voice */struct ES5506Voice{	/* external state */	UINT32		control;				/* control register */	UINT32		freqcount;				/* frequency count register */	UINT32		start;					/* start register */	UINT32		lvol;					/* left volume register */	UINT32		end;					/* end register */	UINT32		lvramp;					/* left volume ramp register */	UINT32		accum;					/* accumulator register */	UINT32		rvol;					/* right volume register */	UINT32		rvramp;					/* right volume ramp register */	UINT32		ecount;					/* envelope count register */	UINT32		k2;						/* k2 register */	UINT32		k2ramp;					/* k2 ramp register */	UINT32		k1;						/* k1 register */	UINT32		k1ramp;					/* k1 ramp register */	INT32		o4n1;					/* filter storage O4(n-1) */	INT32		o3n1;					/* filter storage O3(n-1) */	INT32		o3n2;					/* filter storage O3(n-2) */	INT32		o2n1;					/* filter storage O2(n-1) */	INT32		o2n2;					/* filter storage O2(n-2) */	INT32		o1n1;					/* filter storage O1(n-1) */	UINT32		exbank;					/* external address bank */	/* internal state */	UINT8		index;					/* index of this voice */	UINT8		filtcount;				/* filter count */};struct ES5506Chip{	int			stream;					/* which stream are we using */	UINT16 *	region_base[4];			/* pointer to the base of the region */	UINT32 		write_latch;			/* currently accumulated data for write */	UINT32 		read_latch;				/* currently accumulated data for read */	double 		master_clock;			/* master clock frequency */	void 		(*irq_callback)(int);	/* IRQ callback */	UINT16		(*port_read)(void);		/* input port read */	UINT8 		current_page;			/* current register page */	UINT8		active_voices;			/* number of active voices */	UINT8		mode;					/* MODE register */	UINT8		wst;					/* W_ST register */	UINT8		wend;					/* W_END register */	UINT8		lrend;					/* LR_END register */	UINT8		irqv;					/* IRQV register */	INT32		output_step;			/* step value for frequency conversion */	INT32		output_pos;				/* current fractional position */	INT32		last_lsample;			/* last sample output */	INT32		last_rsample;			/* last sample output */	INT32		curr_lsample;			/* current sample target */	INT32		curr_rsample;			/* current sample target */	struct 		ES5506Voice voice[32];	/* the 32 voices */};/**********************************************************************************************     GLOBALS***********************************************************************************************/static struct ES5506Chip es5506[MAX_ES5506];static INT32 *accumulator;static INT32 *scratch;static INT16 *ulaw_lookup;static UINT16 *volume_lookup;static FILE *eslog;/**********************************************************************************************     update_irq_state -- update the IRQ state***********************************************************************************************/INLINE static void update_irq_state(struct ES5506Chip *chip){#if 0	int irq_bits = chip->status_register & chip->irq_mask;	/* always off if the enable is off */	if (!chip->irq_enable)		irq_bits = 0;	/* update the state if changed */	if (irq_bits && !chip->irq_state)	{		chip->irq_state = 1;		if (chip->irq_callback)			(*chip->irq_callback)(1);	}	else if (!irq_bits && chip->irq_state)	{		chip->irq_state = 0;		if (chip->irq_callback)			(*chip->irq_callback)(0);	}#endif}/**********************************************************************************************     compute_tables -- compute static tables***********************************************************************************************/static int compute_tables(void){	int i;		/* allocate ulaw lookup table */	if (!ulaw_lookup)		ulaw_lookup = malloc(sizeof(ulaw_lookup[0]) << ULAW_MAXBITS);	if (!ulaw_lookup)		return 0;		/* generate ulaw lookup table */	for (i = 0; i < (1 << ULAW_MAXBITS); i++)	{		UINT16 rawval = (i << (16 - ULAW_MAXBITS)) | (1 << (15 - ULAW_MAXBITS));		UINT8 exponent = rawval >> 13;		UINT32 mantissa = (rawval << 3) & 0xffff;				if (exponent == 0)			ulaw_lookup[i] = (INT16)mantissa >> 7;		else		{			mantissa = (mantissa >> 1) | (~mantissa & 0x8000);			ulaw_lookup[i] = (INT16)mantissa >> (7 - exponent);		}	}	/* allocate volume lookup table */	if (!volume_lookup)		volume_lookup = malloc(sizeof(volume_lookup[0]) * 4096);	if (!volume_lookup)		return 0;		/* generate ulaw lookup table */	for (i = 0; i < 4096; i++)	{		UINT8 exponent = i >> 8;		UINT32 mantissa = (i & 0xff) | 0x100;				volume_lookup[i] = (mantissa << 11) >> (20 - exponent);	}	return 1;}/**********************************************************************************************     interpolate     backend_interpolate -- interpolate between two samples***********************************************************************************************/#define interpolate(sample1, sample2, accum)										\		(sample1 * (INT32)(0x800 - (voice->accum & 0x7ff)) + 						\		 sample2 * (INT32)(voice->accum & 0x7ff)) >> 11;#if BACKEND_INTERPOLATE#define backend_interpolate(sample1, sample2, position)								\		(sample1 * (INT32)(FRAC_ONE - position) + 									\		 sample2 * (INT32)position) >> FRAC_BITS;#else#define backend_interpolate(sample1, sample2, position)	sample1#endif/**********************************************************************************************     apply_filters -- apply the 4-pole digital filter to the sample***********************************************************************************************/#define apply_filters(voice, sample)															\do																								\{																								\	/* pole 1 is always low-pass using K1 */													\	sample = ((INT32)(voice->k1 >> 2) * (sample - voice->o1n1) / 16384) + voice->o1n1;			\	voice->o1n1 = sample;																		\																								\	/* pole 2 is always low-pass using K1 */													\	sample = ((INT32)(voice->k1 >> 2) * (sample - voice->o2n1) / 16384) + voice->o2n1;			\	voice->o2n2 = voice->o2n1;																	\	voice->o2n1 = sample;																		\																								\	/* remaining poles depend on the current filter setting */									\	switch (voice->control & CONTROL_LPMASK)													\	{																							\		case 0:																					\			/* pole 3 is high-pass using K2 */													\			sample = sample - voice->o2n2 + ((INT32)(voice->k2 >> 2) * voice->o3n1) / 32768 + voice->o3n1 / 2; \			voice->o3n2 = voice->o3n1;															\			voice->o3n1 = sample;																\																								\			/* pole 4 is high-pass using K2 */													\			sample = sample - voice->o3n2 + ((INT32)(voice->k2 >> 2) * voice->o4n1) / 32768 + voice->o4n1 / 2; \			voice->o4n1 = sample;																\			break;																				\																								\		case CONTROL_LP3:																		\			/* pole 3 is low-pass using K1 */													\			sample = ((INT32)(voice->k1 >> 2) * (sample - voice->o3n1) / 16384) + voice->o3n1;	\			voice->o3n2 = voice->o3n1;															\			voice->o3n1 = sample;																\																								\			/* pole 4 is high-pass using K2 */													\			sample = sample - voice->o3n2 + ((INT32)(voice->k2 >> 2) * voice->o4n1) / 32768 + voice->o4n1 / 2; \			voice->o4n1 = sample;																\			break;																				\																								\		case CONTROL_LP4:																		\			/* pole 3 is low-pass using K2 */													\			sample = ((INT32)(voice->k2 >> 2) * (sample - voice->o3n1) / 16384) + voice->o3n1;	\			voice->o3n2 = voice->o3n1;															\			voice->o3n1 = sample;																\																								\			/* pole 4 is low-pass using K2 */													\			sample = ((INT32)(voice->k2 >> 2) * (sample - voice->o4n1) / 16384) + voice->o4n1;	\			voice->o4n1 = sample;																\			break;																				\																								\		case CONTROL_LP4 | CONTROL_LP3:															\			/* pole 3 is low-pass using K1 */													\			sample = ((INT32)(voice->k1 >> 2) * (sample - voice->o3n1) / 16384) + voice->o3n1;	\			voice->o3n2 = voice->o3n1;															\			voice->o3n1 = sample;																\																								\			/* pole 4 is low-pass using K2 */													\			sample = ((INT32)(voice->k2 >> 2) * (sample - voice->o4n1) / 16384) + voice->o4n1;	\			voice->o4n1 = sample;																\			break;																				\	}																							\} while (0)/**********************************************************************************************     update_envelopes -- update the envelopes***********************************************************************************************/#define update_envelopes(voice, samples)											\do																					\{																					\	int count = (samples > 1 && samples > voice->ecount) ? voice->ecount : samples;	\																					\	/* decrement the envelope counter */											\	voice->ecount -= count;															\																					\	/* ramp left volume */															\	if (voice->lvramp)																\	{																				\		voice->lvol += (INT8)voice->lvramp * count;									\		if ((INT32)voice->lvol < 0) voice->lvol = 0;								\		else if (voice->lvol > 0xffff) voice->lvol = 0xffff;						\	}																				\																					\	/* ramp right volume */															\	if (voice->rvramp)																\	{																				\		voice->rvol += (INT8)voice->rvramp * count;									\		if ((INT32)voice->rvol < 0) voice->rvol = 0;								\		else if (voice->rvol > 0xffff) voice->rvol = 0xffff;						\	}																				\																					\	/* ramp k1 filter constant */													\	if (voice->k1ramp && ((INT32)voice->k1ramp >= 0 || !(voice->filtcount & 7)))	\	{																				\		voice->k1 += (INT8)voice->k1ramp * count;									\		if ((INT32)voice->k1 < 0) voice->k1 = 0;									\		else if (voice->k1 > 0xffff) voice->k1 = 0xffff;							\	}																				\																					\	/* ramp k2 filter constant */													\	if (voice->k2ramp && ((INT32)voice->k2ramp >= 0 || !(voice->filtcount & 7)))	\	{																				\		voice->k2 += (INT8)voice->k2ramp * count;									\		if ((INT32)voice->k2 < 0) voice->k2 = 0;									\		else if (voice->k2 > 0xffff) voice->k2 = 0xffff;							\	}																				\																					\	/* update the filter constant counter */										\	voice->filtcount += count;														\																					\} while (0)/**********************************************************************************************     check_for_end_forward     check_for_end_reverse -- check for loop end and loop appropriately***********************************************************************************************/#define check_for_end_forward(voice, accum)											\do																					\{																					\	/* are we past the end? */														\	if (accum > voice->end && !(voice->control & CONTROL_LEI))					\	{																				\		/* generate interrupt */													\		voice->control |= CONTROL_IRQ;												\																					\		/* handle the different types of looping */									\		switch (voice->control & CONTROL_LOOPMASK)									\		{																			\			/* non-looping */														\			case 0:																	\				voice->control |= CONTROL_STOP0;									\				goto alldone;														\																					\			/* uni-directional looping */											\			case CONTROL_LPE:														\				accum = voice->start + (accum - voice->end);						\				break;																\																					\			/* trans-wave looping */												\			case CONTROL_BLE:														\				accum = voice->start + (accum - voice->end);						\				voice->control = (voice->control & ~CONTROL_LOOPMASK) | CONTROL_LEI;\				break;																\																					\			/* bi-directional looping */											\			case CONTROL_LPE | CONTROL_BLE:											\				accum = voice->end - (accum - voice->end);							\				voice->control ^= CONTROL_DIR;										\				goto reverse;														\		}																			\	}																				\} while (0)#define check_for_end_reverse(voice, accum)											\do																					\{																					\	/* are we past the end? */														\	if (accum < voice->start && !(voice->control & CONTROL_LEI))					\	{																				\		/* generate interrupt */													\		voice->control |= CONTROL_IRQ;												\																					\		/* handle the different types of looping */									\		switch (voice->control & CONTROL_LOOPMASK)									\		{																			\			/* non-looping */														\			case 0:																	\				voice->control |= CONTROL_STOP0;									\				goto alldone;														\																					\			/* uni-directional looping */											\			case CONTROL_LPE:														\				accum = voice->end - (voice->start - accum);						\				break;																\																					\			/* trans-wave looping */												\			case CONTROL_BLE:														\				accum = voice->end - (voice->start - accum);						\				voice->control = (voice->control & ~CONTROL_LOOPMASK) | CONTROL_LEI;\				break;																\																					\			/* bi-directional looping */											\			case CONTROL_LPE | CONTROL_BLE:											\				accum = voice->start + (voice->start - accum);						\				voice->control ^= CONTROL_DIR;										\				goto reverse;														\		}																			\	}																				\} while (0)/**********************************************************************************************     generate_dummy -- generate nothing, just apply envelopes***********************************************************************************************/static void generate_dummy(struct ES5506Voice *voice, UINT16 *base, INT32 *lbuffer, INT32 *rbuffer, int samples){	UINT32 freqcount = voice->freqcount;	UINT32 accum = voice->accum;	/* outer loop, in case we switch directions */	while (samples > 0 && !(voice->control & CONTROL_STOPMASK))	{reverse:		/* two cases: first case is forward direction */		if (!(voice->control & CONTROL_DIR))		{			/* loop while we still have samples to generate */			while (samples--)			{				/* fetch two samples */				accum += freqcount;				/* update filters/volumes */				if (voice->ecount != 0)					update_envelopes(voice, 1);								/* check for loop end */				check_for_end_forward(voice, accum);			}		}		/* two cases: second case is backward direction */		else		{			/* loop while we still have samples to generate */			while (samples--)			{				/* fetch two samples */				accum -= freqcount;								/* update filters/volumes */				if (voice->ecount != 0)					update_envelopes(voice, 1);								/* check for loop end */				check_for_end_reverse(voice, accum);			}		}	}	/* if we stopped, process any additional envelope */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产普通话蜜臀| 亚洲欧洲99久久| 国产日韩欧美精品一区| 在线免费观看一区| 国产精品羞羞答答xxdd| 亚洲成人免费视频| 国产欧美综合在线观看第十页| 欧美日韩国产欧美日美国产精品| 国产99久久久精品| 久色婷婷小香蕉久久| 午夜在线电影亚洲一区| 1024成人网| 亚洲国产精品ⅴa在线观看| 91精品国产综合久久精品图片| 91影院在线免费观看| 国产激情视频一区二区三区欧美 | 欧美刺激脚交jootjob| 91视频在线看| 高清不卡在线观看| 国精产品一区一区三区mba桃花 | 成人avav影音| 国产美女av一区二区三区| 免费一级片91| 日韩高清在线观看| 日韩精品亚洲一区二区三区免费| 亚洲欧美视频在线观看| 中文欧美字幕免费| 久久精品国产精品青草| 亚洲高清三级视频| 亚洲韩国一区二区三区| 亚洲综合一二区| 一区二区三区精品视频在线| 中文字幕亚洲在| 国产精品久久久久一区| 国产精品灌醉下药二区| 国产精品毛片高清在线完整版| 亚洲国产精品高清| 日本一区二区成人| 国产精品久久久久久久久搜平片| 国产午夜亚洲精品羞羞网站| 国产欧美日本一区视频| 国产精品久久久99| 亚洲男人的天堂一区二区| 亚洲欧美日韩中文播放| 亚洲欧美欧美一区二区三区| 一区二区在线免费观看| 亚洲国产日产av| 人人爽香蕉精品| 激情偷乱视频一区二区三区| 国产**成人网毛片九色| 99久久婷婷国产综合精品电影| 99国产精品视频免费观看| 91高清视频免费看| 欧美人狂配大交3d怪物一区| 欧美一级生活片| 国产欧美一区二区三区沐欲| 国产精品色一区二区三区| 亚洲欧美日韩久久| 日韩精品久久久久久| 老汉av免费一区二区三区| 国产成人精品影院| 91啦中文在线观看| 日韩欧美在线网站| 中文字幕 久热精品 视频在线 | 91在线观看成人| 精品视频在线免费观看| 欧美一区二区三区四区久久| 人人狠狠综合久久亚洲| 国产69精品久久久久777| 91网上在线视频| 欧美一级专区免费大片| 国产精品美女久久久久久2018| 亚洲精品久久久久久国产精华液| 日韩av电影免费观看高清完整版 | 亚洲成a人v欧美综合天堂下载| 老司机精品视频在线| 成人免费毛片app| 3751色影院一区二区三区| 久久免费精品国产久精品久久久久| 国产精品久久久一本精品| 日韩**一区毛片| 成人开心网精品视频| 欧美福利一区二区| 国产精品三级视频| 人禽交欧美网站| 色噜噜狠狠色综合中国| 久久久三级国产网站| 亚洲成人激情自拍| 成人av资源下载| 精品国产乱子伦一区| 一区二区三区不卡在线观看| 国产一区二区三区在线观看精品| 在线观看一区二区视频| 欧美精品一区二区高清在线观看 | 亚洲一区二区三区中文字幕在线| 精品一区二区在线视频| 欧洲视频一区二区| 日本一区二区在线不卡| 久草在线在线精品观看| 欧美日韩dvd在线观看| 亚洲日本va午夜在线影院| 精品在线播放午夜| 欧美日韩www| 一区二区三区中文字幕精品精品 | 亚洲电影欧美电影有声小说| 国产一区二区毛片| 欧美精品亚洲二区| 亚洲精品一卡二卡| 成人av在线资源网| 国产亚洲人成网站| 另类小说一区二区三区| 9191久久久久久久久久久| 一区二区在线观看视频在线观看| 国产精品一区一区三区| 日韩一级精品视频在线观看| 图片区小说区国产精品视频| 欧美中文字幕不卡| 亚洲美腿欧美偷拍| 91美女在线观看| 亚洲男人的天堂在线aⅴ视频| 成人国产在线观看| 欧美高清一级片在线观看| 国产综合色视频| 久久蜜桃av一区二区天堂| 久久超级碰视频| 欧美精品一区二区三| 韩国毛片一区二区三区| 日韩欧美一二区| 精品一区二区三区免费毛片爱 | 国产精品网站导航| 懂色av噜噜一区二区三区av| 国产亚洲欧美一区在线观看| 国产麻豆日韩欧美久久| 欧美激情在线免费观看| 国产91对白在线观看九色| 中文欧美字幕免费| 99久久精品免费观看| 亚洲少妇中出一区| 一本色道久久综合狠狠躁的推荐| 亚洲精品少妇30p| 欧美午夜在线观看| 亚洲第一综合色| 欧美一区二区三区的| 蜜桃精品视频在线| 国产午夜精品一区二区三区四区| 国产福利91精品| 中文字幕中文在线不卡住| 99国产精品国产精品毛片| 一区二区在线观看视频 | 欧美精品一区二区三区一线天视频| 国产一区视频导航| 中文字幕亚洲电影| 精品视频色一区| 国内精品国产成人国产三级粉色| 久久午夜国产精品| 99久久精品免费看| 亚欧色一区w666天堂| 精品国产一区二区三区av性色| 国产丝袜美腿一区二区三区| av亚洲精华国产精华精| 亚洲成人你懂的| 久久综合精品国产一区二区三区 | 日韩一二三区不卡| 国产精品99久久久久久久女警 | 91视频观看视频| 午夜精品久久久久久久久| 久久综合色播五月| 欧美优质美女网站| 国产在线精品视频| 一区二区三区免费看视频| 日韩一区二区三区在线视频| 国产成人免费9x9x人网站视频| 亚洲免费av在线| 久久亚洲捆绑美女| 欧美一卡二卡三卡| 中文av一区二区| 91国偷自产一区二区三区观看| 天天色天天爱天天射综合| 国产日韩av一区| 欧美日韩激情一区| 福利电影一区二区| 亚洲bdsm女犯bdsm网站| 欧美国产日韩一二三区| 欧美美女视频在线观看| 成人白浆超碰人人人人| 美女视频黄 久久| 一区二区三区四区精品在线视频 | 国产精品一区二区久久不卡| 亚洲视频在线一区观看| 精品三级av在线| 欧美色爱综合网| 99精品欧美一区| 精久久久久久久久久久| 亚洲国产精品久久一线不卡| 欧美国产禁国产网站cc| 欧美大肚乱孕交hd孕妇| 欧美色综合久久| 波多野结衣亚洲一区| 激情综合色播激情啊| 午夜不卡av在线|