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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? adpcm.c

?? 著名ARC模擬器源碼,包括多個平臺
?? C
?? 第 1 頁 / 共 2 頁
字號:
/********************************************************************************************** * *   streaming ADPCM driver *   by Aaron Giles * *   Library to transcode from an ADPCM source to raw PCM. *   Written by Buffoni Mirko in 08/06/97 *   References: various sources and documents. * *	 HJB 08/31/98 *	 modified to use an automatically selected oversampling factor *	 for the current audio_sample_rate * *   Mish 21/7/99 *   Updated to allow multiple OKI chips with different sample rates * **********************************************************************************************/#include <stdio.h>#include <stdlib.h>#include <math.h>#include "loadroms.h"#include "driver.h"#include "adpcm.h"#include "sasound.h"#define MAX_SAMPLE_CHUNK	10000#define FRAC_BITS			14#define FRAC_ONE			(1 << FRAC_BITS)#define FRAC_MASK			(FRAC_ONE - 1)/* struct describing a single playing ADPCM voice */struct ADPCMVoice{	int stream;				/* which stream are we playing on? */	UINT8 playing;			/* 1 if we are actively playing */	UINT8 *region_base;		/* pointer to the base of the region */	UINT8 *base;			/* pointer to the base memory location */	UINT32 sample;			/* current sample number */	UINT32 count;			/* total samples to play */	UINT32 signal;			/* current ADPCM signal */	UINT32 step;			/* current ADPCM step */	UINT32 volume;			/* output volume */	INT16 last_sample;		/* last sample output */	INT16 curr_sample;		/* current sample target */	UINT32 source_step;		/* step value for frequency conversion */	UINT32 source_pos;		/* current fractional position */};/* array of ADPCM voices */static UINT8 num_voices;static struct ADPCMVoice adpcm[MAX_ADPCM];/* step size index shift table */static int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };/* lookup table for the precomputed difference */static int diff_lookup[49*16];/* volume lookup table */static UINT32 volume_table[16];/**********************************************************************************************     compute_tables -- compute the difference tables***********************************************************************************************/static void compute_tables(void){	/* nibble to bit map */	static int nbl2bit[16][4] =	{		{ 1, 0, 0, 0}, { 1, 0, 0, 1}, { 1, 0, 1, 0}, { 1, 0, 1, 1},		{ 1, 1, 0, 0}, { 1, 1, 0, 1}, { 1, 1, 1, 0}, { 1, 1, 1, 1},		{-1, 0, 0, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 0, 1, 1},		{-1, 1, 0, 0}, {-1, 1, 0, 1}, {-1, 1, 1, 0}, {-1, 1, 1, 1}	};	int step, nib;	/* loop over all possible steps */	for (step = 0; step <= 48; step++)	{		/* compute the step value */		int stepval = floor(16.0 * pow(11.0 / 10.0, (double)step));		/* loop over all nibbles and compute the difference */		for (nib = 0; nib < 16; nib++)		{			diff_lookup[step*16 + nib] = nbl2bit[nib][0] *				(stepval   * nbl2bit[nib][1] +				 stepval/2 * nbl2bit[nib][2] +				 stepval/4 * nbl2bit[nib][3] +				 stepval/8);		}	}	/* generate the OKI6295 volume table */	for (step = 0; step < 16; step++)	{		double out = 256.0;		int vol = step;		/* 3dB per step */		while (vol-- > 0)			out /= 1.412537545;	/* = 10 ^ (3/20) = 3dB */		volume_table[step] = (UINT32)out;	}}/**********************************************************************************************     generate_adpcm -- general ADPCM decoding routine***********************************************************************************************/static void generate_adpcm(struct ADPCMVoice *voice, INT16 *buffer, int samples){	/* if this voice is active */	if (voice->playing)	{		UINT8 *base = voice->base;		int sample = voice->sample;		int signal = voice->signal;		int count = voice->count;		int step = voice->step;		int val;		/* loop while we still have samples to generate */		while (samples)		{			/* compute the new amplitude and update the current step */			val = base[sample / 2] >> (((sample & 1) << 2) ^ 4);			signal += diff_lookup[step * 16 + (val & 15)];			/* clamp to the maximum */			if (signal > 2047)				signal = 2047;			else if (signal < -2048)				signal = -2048;			/* adjust the step size and clamp */			step += index_shift[val & 7];			if (step > 48)				step = 48;			else if (step < 0)				step = 0;			/* output to the buffer, scaling by the volume */			*buffer++ = signal * voice->volume / 16;			samples--;			/* next! */			if (++sample > count)			{				voice->playing = 0;				break;			}		}		/* update the parameters */		voice->sample = sample;		voice->signal = signal;		voice->step = step;	}	/* fill the rest with silence */	while (samples--)		*buffer++ = 0;}/**********************************************************************************************     adpcm_update -- update the sound chip so that it is in sync with CPU execution***********************************************************************************************/static void adpcm_update(int num, INT16 *buffer, int length){	struct ADPCMVoice *voice = &adpcm[num];	INT16 sample_data[MAX_SAMPLE_CHUNK], *curr_data = sample_data;	INT16 prev = voice->last_sample, curr = voice->curr_sample;	UINT32 final_pos;	UINT32 new_samples;	/* finish off the current sample */	if (voice->source_pos > 0)	{		/* interpolate */		while (length > 0 && voice->source_pos < FRAC_ONE)		{			*buffer++ = (((INT32)prev * (FRAC_ONE - voice->source_pos)) + ((INT32)curr * voice->source_pos)) >> FRAC_BITS;			voice->source_pos += voice->source_step;			length--;		}		/* if we're over, continue; otherwise, we're done */		if (voice->source_pos >= FRAC_ONE)			voice->source_pos -= FRAC_ONE;		else			return;	}	/* compute how many new samples we need */	final_pos = voice->source_pos + length * voice->source_step;	new_samples = (final_pos + FRAC_ONE - 1) >> FRAC_BITS;	if (new_samples > MAX_SAMPLE_CHUNK)		new_samples = MAX_SAMPLE_CHUNK;	/* generate them into our buffer */	generate_adpcm(voice, sample_data, new_samples);	prev = curr;	curr = *curr_data++;	/* then sample-rate convert with linear interpolation */	while (length > 0)	{		/* interpolate */		while (length > 0 && voice->source_pos < FRAC_ONE)		{			*buffer++ = (((INT32)prev * (FRAC_ONE - voice->source_pos)) + ((INT32)curr * voice->source_pos)) >> FRAC_BITS;			voice->source_pos += voice->source_step;			length--;		}		/* if we're over, grab the next samples */		if (voice->source_pos >= FRAC_ONE)		{			voice->source_pos -= FRAC_ONE;			prev = curr;			curr = *curr_data++;		}	}	/* remember the last samples */	voice->last_sample = prev;	voice->curr_sample = curr;}/**********************************************************************************************     ADPCM_sh_start -- start emulation of several ADPCM output streams***********************************************************************************************/void ADPCMSetBuffers(const struct ADPCMinterface *msound,UINT8 *region,int banksize) {  // Init 2 chips, or 1 chip with all voices in the same bank.  int i;  num_voices = (msound->num * MAX_OKIM6295_VOICES);  for (i = 0; i < num_voices; i++) {    adpcm[i].base =      adpcm[i].region_base = region+(i/MAX_OKIM6295_VOICES)*banksize;  }  }void ADPCMSetBuffersOne(const struct ADPCMinterface *msound,UINT8 *region,int banksize) {  // Init 1 chip, 1st bank only (wwfsstars...)  int i;  num_voices = (msound->num * MAX_OKIM6295_VOICES);  for (i = 0; i < num_voices; i++) {    adpcm[i].base =      adpcm[i].region_base = region+(i/(MAX_OKIM6295_VOICES/2))*banksize;  }  }static int old_bank;void OKIM6295_bankswitch(int which, int data) {  // I know : memcpy is slow... But for now it will do.  int bank = data & 0xf;  UINT8 *ADPCM = adpcm[which].region_base;  if (bank != old_bank) {    old_bank = bank;    memcpy(&ADPCM[0x30000], &ADPCM[0x40000 + (bank)*0x10000], 0x10000);  }}  int ADPCM_sh_start(const struct ADPCMinterface *intf){	char stream_name[40];	int i;	/* reset the ADPCM system */	num_voices = intf->num;	compute_tables();	/* initialize the voices */	memset(adpcm, 0, sizeof(adpcm));	for (i = 0; i < num_voices; i++)	{		/* generate the name and create the stream */		sprintf(stream_name, "ADPCM #%d", i);		adpcm[i].stream = stream_init(stream_name, audio_sample_rate, 16,i, adpcm_update);		/* volume setup */		stream_set_volume(adpcm[i].stream,intf->mixing_level[0]);				if (adpcm[i].stream == -1)			return 1;		/* initialize the rest of the structure */		if (intf->region) // If we have the info...		  adpcm[i].base = adpcm[i].region_base = load_region[intf->region];		adpcm[i].volume = 255;		adpcm[i].signal = -2;		if (audio_sample_rate)			adpcm[i].source_step = (UINT32)((double)intf->frequency * (double)FRAC_ONE / (double)audio_sample_rate);	}	/* success */	return 0;}/**********************************************************************************************     ADPCM_sh_stop -- stop emulation of several ADPCM output streams***********************************************************************************************/void ADPCM_sh_stop(void){}/**********************************************************************************************     ADPCM_sh_update -- update ADPCM streams***********************************************************************************************/void ADPCM_sh_update(void){}/**********************************************************************************************     ADPCM_play -- play data from a specific offset for a specific length***********************************************************************************************/void ADPCM_play(int num, int offset, int length){	struct ADPCMVoice *voice = &adpcm[num];	/* bail if we're not playing anything */	if (audio_sample_rate == 0)		return;	/* range check the numbers */	if (num >= num_voices)	{#ifdef RAINE_DEBUG	  fprintf(stderr,"error: ADPCM_trigger() called with channel = %d, but only %d channels allocated\n", num, num_voices);#endif	  	  return;	}	/* update the ADPCM voice */	stream_update(voice->stream, 0);		/* set up the voice to play this sample */	voice->playing = 1;	voice->base = &voice->region_base[offset];	voice->sample = 0;	voice->count = length;	/* also reset the ADPCM parameters */	voice->signal = -2;	voice->step = 0;}/**********************************************************************************************     ADPCM_play -- stop playback on an ADPCM data channel***********************************************************************************************/void ADPCM_stop(int num){	struct ADPCMVoice *voice = &adpcm[num];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲大型综合色站| 欧洲一区二区三区在线| 日本欧美一区二区三区| 国产精品九色蝌蚪自拍| 国产情人综合久久777777| 91精品国产欧美一区二区成人| 欧美在线视频你懂得| 欧美亚洲免费在线一区| 26uuu国产日韩综合| 日韩精品中文字幕在线不卡尤物 | 中文字幕+乱码+中文字幕一区| 精品国产污污免费网站入口 | 亚洲大片在线观看| 日本人妖一区二区| 国产一区免费电影| 国产成人在线影院| 色综合久久99| 欧美一区欧美二区| 国产日韩欧美制服另类| 综合久久久久综合| 免费人成在线不卡| 成人黄动漫网站免费app| 99久久精品费精品国产一区二区| 97精品国产97久久久久久久久久久久| 欧美少妇bbb| 欧美岛国在线观看| 日韩码欧中文字| 日韩精品乱码av一区二区| 久久电影网站中文字幕| 成人av电影在线网| 在线播放/欧美激情| 国产免费成人在线视频| 亚洲国产毛片aaaaa无费看| 麻豆国产91在线播放| 99久久婷婷国产| 91精品婷婷国产综合久久竹菊| 国产欧美精品在线观看| 亚洲福利一区二区| 高清免费成人av| 67194成人在线观看| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 日韩欧美第一区| 中文字幕在线观看一区二区| 免费成人在线播放| 日本高清无吗v一区| 久久久欧美精品sm网站| 天天综合网 天天综合色| 国产精品18久久久久| 欧美日韩mp4| 亚洲欧洲一区二区在线播放| 国内精品第一页| 欧美日本在线观看| 亚洲精品视频免费观看| 国产精品亚洲午夜一区二区三区| 欧美精品v日韩精品v韩国精品v| 中文字幕不卡在线| 国产精品88av| 国产精品超碰97尤物18| 国产精品77777竹菊影视小说| 制服丝袜激情欧洲亚洲| 亚洲成人在线观看视频| 91视视频在线直接观看在线看网页在线看 | 中文字幕av一区二区三区 | 久久久久久亚洲综合影院红桃| 亚洲电影在线免费观看| 色美美综合视频| 亚洲美女屁股眼交| 色琪琪一区二区三区亚洲区| 欧美国产精品一区二区| 粉嫩绯色av一区二区在线观看| 26uuu久久综合| 国产精品中文字幕欧美| 久久午夜电影网| 国产乱码精品一区二区三区五月婷| 欧美一级夜夜爽| 蜜桃视频一区二区| 欧美v日韩v国产v| 久久99精品久久久久久动态图 | 久久精品一二三| 国产精品99久久久久久似苏梦涵| 精品av久久707| 精品一区二区三区在线播放| 精品国产污网站| 国产九色sp调教91| 国产精品视频一二三| 成人av综合在线| 一区二区三区中文字幕精品精品| 日本国产一区二区| 日韩**一区毛片| 久久伊99综合婷婷久久伊| 成人性色生活片| 亚洲卡通动漫在线| 6080yy午夜一二三区久久| 激情综合一区二区三区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产美女精品一区二区三区| 国产欧美在线观看一区| 色综合久久六月婷婷中文字幕| 一级女性全黄久久生活片免费| 欧美日韩成人综合天天影院| 国产一区在线不卡| 日韩一区在线免费观看| 欧美精品一卡二卡| 国产精选一区二区三区| 亚洲伦在线观看| 日韩午夜激情免费电影| 成人av电影在线| 视频在线观看一区| 中文字幕成人av| 日韩一区二区三区在线视频| 成人性生交大片免费看中文 | 日韩一区二区三区电影在线观看 | 一本久久精品一区二区| 日本麻豆一区二区三区视频| 欧美国产在线观看| 在线91免费看| 色婷婷综合视频在线观看| 老司机免费视频一区二区| √…a在线天堂一区| 日韩免费观看高清完整版 | 成人午夜视频福利| 丝袜亚洲精品中文字幕一区| 中文字幕免费在线观看视频一区| 欧美精品一二三区| 色综合久久久久久久久久久| 国内精品不卡在线| 日av在线不卡| 亚洲国产一区二区视频| 国产精品国产三级国产| 久久伊99综合婷婷久久伊| 91精品久久久久久久久99蜜臂| 成人听书哪个软件好| 久久99久久精品| 麻豆国产精品官网| 视频一区国产视频| 玉米视频成人免费看| 中文字幕一区二区视频| 国产午夜精品久久| 久久无码av三级| 久久久一区二区三区| 精品日韩99亚洲| 日韩美女在线视频| 日韩免费看网站| 欧美va亚洲va在线观看蝴蝶网| 欧美老肥妇做.爰bbww| 欧美在线一二三四区| 一本一本大道香蕉久在线精品| 成人综合激情网| 丁香另类激情小说| 国产成人在线网站| 国产精品一线二线三线| 狂野欧美性猛交blacked| 日本特黄久久久高潮| 视频在线在亚洲| 美腿丝袜亚洲综合| 久久97超碰色| 国产乱码精品1区2区3区| 国产成人免费在线观看不卡| 国产乱码精品一区二区三区忘忧草| 国产精品一色哟哟哟| 成人黄页在线观看| 91猫先生在线| 91久久精品日日躁夜夜躁欧美| 91小宝寻花一区二区三区| 色婷婷国产精品| 在线综合亚洲欧美在线视频| 欧美一级一区二区| 国产免费观看久久| 一区二区三区不卡在线观看 | 欧美中文字幕一区二区三区亚洲| 99re这里都是精品| 欧美精品 国产精品| 精品奇米国产一区二区三区| 久久久五月婷婷| 亚洲卡通欧美制服中文| 日本va欧美va欧美va精品| 国产精品影视在线观看| 欧洲精品一区二区| 91麻豆精品国产91久久久使用方法| 精品人在线二区三区| 亚洲欧美日韩综合aⅴ视频| 奇米影视一区二区三区| 成人黄色在线看| 制服丝袜亚洲网站| 国产精品久久久久久久岛一牛影视 | 国产亚洲欧美中文| 夜色激情一区二区| 国产一区二区成人久久免费影院| 99久精品国产| 日韩一级精品视频在线观看| 国产精品免费视频网站| 日本一区中文字幕 | 亚洲在线免费播放| 国产一区二区美女| 欧美午夜宅男影院| 久久久不卡影院| 日韩福利视频网| 日本高清不卡视频| 久久综合久久综合九色| 午夜一区二区三区在线观看|