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

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

?? gus_wave.c

?? LINUX1.0源代碼,代碼條理清晰
?? C
?? 第 1 頁 / 共 5 頁
字號(hào):

/* 
 * sound/gus_wave.c
 * 
 * Driver for the Gravis UltraSound wave table synth.
 * 
 * Copyright by Hannu Savolainen 1993
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer. 2.
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * 
 */

#include "sound_config.h"
#include <linux/ultrasound.h>
#include "gus_hw.h"

#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS)

#define MAX_SAMPLE	128
#define MAX_PATCH	256

struct voice_info
  {
    unsigned long   orig_freq;
    unsigned long   current_freq;
    unsigned long   mode;
    int             bender;
    int             bender_range;
    int             panning;
    int             midi_volume;
    unsigned int    initial_volume;
    unsigned int    current_volume;
    int             loop_irq_mode, loop_irq_parm;
#define LMODE_FINISH		1
#define LMODE_PCM		2
#define LMODE_PCM_STOP		3
    int             volume_irq_mode, volume_irq_parm;
#define VMODE_HALT		1
#define VMODE_ENVELOPE		2
#define VMODE_START_NOTE	3

    int             env_phase;
    unsigned char   env_rate[6];
    unsigned char   env_offset[6];

    /* 
     * Volume computation parameters for gus_adagio_vol()
     */
    int             main_vol, expression_vol, patch_vol;

    /* Variables for "Ultraclick" removal */
    int             dev_pending, note_pending, volume_pending, sample_pending;
    char            kill_pending;
    long            offset_pending;

  };

extern int      gus_base;
extern int      gus_irq, gus_dma;
extern char    *snd_raw_buf[MAX_DSP_DEV][DSP_BUFFCOUNT];
extern unsigned long snd_raw_buf_phys[MAX_DSP_DEV][DSP_BUFFCOUNT];
extern int      snd_raw_count[MAX_DSP_DEV];
static long     gus_mem_size = 0;
static long     free_mem_ptr = 0;
static int      gus_busy = 0;
static int      nr_voices = 0;
static int      gus_devnum = 0;
static int      volume_base, volume_scale, volume_method;
static int	gus_line_vol = 100, gus_mic_vol = 0;
static int	gus_recmask = SOUND_MASK_MIC;
static int	recording_active = 0;

#define VOL_METHOD_ADAGIO	1
int             gus_wave_volume = 60;
int             gus_pcm_volume = 80;
static unsigned char mix_image = 0x00;

/* 
 * Current version of this driver doesn't allow synth and PCM functions
 * at the same time. The active_device specifies the active driver
 */
static int      active_device = 0;

#define GUS_DEV_WAVE		1	/* 
					 * * * Wave table synth   */
#define GUS_DEV_PCM_DONE	2	/* 
					 * * * PCM device, transfer done   */
#define GUS_DEV_PCM_CONTINUE	3	/* 
					 * * * PCM device, transfer the
					 * second * * * chn   */

static int      gus_sampling_speed;
static int      gus_sampling_channels;
static int      gus_sampling_bits;

DEFINE_WAIT_QUEUE (dram_sleeper, dram_sleep_flag);

/* 
 * Variables and buffers for PCM output
 */
#define MAX_PCM_BUFFERS		(32*MAX_REALTIME_FACTOR)	/* 
								 * * * Don't
								 * * * change 
								 * 
								 */

static int      pcm_bsize,	/* 
				 * Current blocksize 
				 */
                pcm_nblk,	/* 
				 * Current # of blocks 
				 */
                pcm_banksize;	/* 

				 * 
				 * *  * * # bytes allocated for channels   */
static int      pcm_datasize[MAX_PCM_BUFFERS];	/* 

						 * 
						 * *  * * Actual # of bytes
						 * in blk  *  */
static volatile int pcm_head, pcm_tail, pcm_qlen;	/* 

							 * 
							 * *  * * DRAM queue
							 *  */
static volatile int pcm_active;
static int      pcm_opened = 0;
static int      pcm_current_dev;
static int      pcm_current_block;
static unsigned long pcm_current_buf;
static int      pcm_current_count;
static int      pcm_current_intrflag;

struct voice_info voices[32];

static int      freq_div_table[] =
{
  44100,			/* 
				 * 14 
				 */
  41160,			/* 
				 * 15 
				 */
  38587,			/* 
				 * 16 
				 */
  36317,			/* 
				 * 17 
				 */
  34300,			/* 
				 * 18 
				 */
  32494,			/* 
				 * 19 
				 */
  30870,			/* 
				 * 20 
				 */
  29400,			/* 
				 * 21 
				 */
  28063,			/* 
				 * 22 
				 */
  26843,			/* 
				 * 23 
				 */
  25725,			/* 
				 * 24 
				 */
  24696,			/* 
				 * 25 
				 */
  23746,			/* 
				 * 26 
				 */
  22866,			/* 
				 * 27 
				 */
  22050,			/* 
				 * 28 
				 */
  21289,			/* 
				 * 29 
				 */
  20580,			/* 
				 * 30 
				 */
  19916,			/* 
				 * 31 
				 */
  19293				/* 
				 * 32 
				 */
};

static struct patch_info *samples;
static long     sample_ptrs[MAX_SAMPLE + 1];
static int      sample_map[32];
static int      free_sample;


static int      patch_table[MAX_PATCH];
static int      patch_map[32];

static struct synth_info gus_info =
{"Gravis UltraSound", 0, SYNTH_TYPE_SAMPLE, SAMPLE_TYPE_GUS, 0, 16, 0, MAX_PATCH};

static void     gus_poke (long addr, unsigned char data);
static void     compute_and_set_volume (int voice, int volume, int ramp_time);
extern unsigned short gus_adagio_vol (int vel, int mainv, int xpn, int voicev);
static void     compute_volume (int voice, int volume);
static void     do_volume_irq (int voice);
static void	set_input_volumes(void);

#define	INSTANT_RAMP		-1	/* 
					 * * * Dont use ramping   */
#define FAST_RAMP		0	/* 
					 * * * Fastest possible ramp   */

static void
reset_sample_memory (void)
{
  int             i;

  for (i = 0; i <= MAX_SAMPLE; i++)
    sample_ptrs[i] = -1;
  for (i = 0; i < 32; i++)
    sample_map[i] = -1;
  for (i = 0; i < 32; i++)
    patch_map[i] = -1;

  gus_poke (0, 0);		/* 
				 * Put silence here 
				 */
  gus_poke (1, 0);

  free_mem_ptr = 2;
  free_sample = 0;

  for (i = 0; i < MAX_PATCH; i++)
    patch_table[i] = -1;
}

void
gus_delay (void)
{
  int             i;

  for (i = 0; i < 7; i++)
    INB (u_DRAMIO);
}

static void
gus_poke (long addr, unsigned char data)
{
  unsigned long   flags;

  DISABLE_INTR (flags);
  OUTB (0x43, u_Command);
  OUTB (addr & 0xff, u_DataLo);
  OUTB ((addr >> 8) & 0xff, u_DataHi);

  OUTB (0x44, u_Command);
  OUTB ((addr >> 16) & 0xff, u_DataHi);
  OUTB (data, u_DRAMIO);
  RESTORE_INTR (flags);
}

static unsigned char
gus_peek (long addr)
{
  unsigned long   flags;
  unsigned char   tmp;

  DISABLE_INTR (flags);
  OUTB (0x43, u_Command);
  OUTB (addr & 0xff, u_DataLo);
  OUTB ((addr >> 8) & 0xff, u_DataHi);

  OUTB (0x44, u_Command);
  OUTB ((addr >> 16) & 0xff, u_DataHi);
  tmp = INB (u_DRAMIO);
  RESTORE_INTR (flags);

  return tmp;
}

void
gus_write8 (int reg, unsigned int data)
{
  unsigned long   flags;

  DISABLE_INTR (flags);

  OUTB (reg, u_Command);
  OUTB ((unsigned char) (data & 0xff), u_DataHi);

  RESTORE_INTR (flags);
}

unsigned char
gus_read8 (int reg)
{
  unsigned long   flags;
  unsigned char   val;

  DISABLE_INTR (flags);
  OUTB (reg | 0x80, u_Command);
  val = INB (u_DataHi);
  RESTORE_INTR (flags);

  return val;
}

unsigned char
gus_look8 (int reg)
{
  unsigned long   flags;
  unsigned char   val;

  DISABLE_INTR (flags);
  OUTB (reg, u_Command);
  val = INB (u_DataHi);
  RESTORE_INTR (flags);

  return val;
}

void
gus_write16 (int reg, unsigned int data)
{
  unsigned long   flags;

  DISABLE_INTR (flags);

  OUTB (reg, u_Command);

  OUTB ((unsigned char) (data & 0xff), u_DataLo);
  OUTB ((unsigned char) ((data >> 8) & 0xff), u_DataHi);

  RESTORE_INTR (flags);
}

unsigned short
gus_read16 (int reg)
{
  unsigned long   flags;
  unsigned char   hi, lo;

  DISABLE_INTR (flags);

  OUTB (reg | 0x80, u_Command);

  lo = INB (u_DataLo);
  hi = INB (u_DataHi);

  RESTORE_INTR (flags);

  return ((hi << 8) & 0xff00) | lo;
}

void
gus_write_addr (int reg, unsigned long address, int is16bit)
{
  unsigned long   hold_address;

  if (is16bit)
    {
      /* 
       * Special processing required for 16 bit patches
       */

      hold_address = address;
      address = address >> 1;
      address &= 0x0001ffffL;
      address |= (hold_address & 0x000c0000L);
    }

  gus_write16 (reg, (unsigned short) ((address >> 7) & 0xffff));
  gus_write16 (reg + 1, (unsigned short) ((address << 9) & 0xffff));
}

static void
gus_select_voice (int voice)
{
  if (voice < 0 || voice > 31)
    return;

  OUTB (voice, u_Voice);
}

static void
gus_select_max_voices (int nvoices)
{
  if (nvoices < 14)
    nvoices = 14;
  if (nvoices > 32)
    nvoices = 32;

  nr_voices = nvoices;

  gus_write8 (0x0e, (nvoices - 1) | 0xc0);
}

static void
gus_voice_on (unsigned int mode)
{
  gus_write8 (0x00, (unsigned char) (mode & 0xfc));
  gus_delay ();
  gus_write8 (0x00, (unsigned char) (mode & 0xfc));
}

static void
gus_voice_off (void)
{
  gus_write8 (0x00, gus_read8 (0x00) | 0x03);
}

static void
gus_voice_mode (unsigned int m)
{
  unsigned char   mode = (unsigned char) (m & 0xff);

  gus_write8 (0x00, (gus_read8 (0x00) & 0x03) | (mode & 0xfc));		/* 
									 * Don't 
									 * start 
									 * or 
									 * stop
									 * *
									 * voice 
									 */
  gus_delay ();
  gus_write8 (0x00, (gus_read8 (0x00) & 0x03) | (mode & 0xfc));
}

static void
gus_voice_freq (unsigned long freq)
{
  unsigned long   divisor = freq_div_table[nr_voices - 14];
  unsigned short  fc;

  fc = (unsigned short) (((freq << 9) + (divisor >> 1)) / divisor);
  fc = fc << 1;

  gus_write16 (0x01, fc);
}

static void
gus_voice_volume (unsigned int vol)
{
  gus_write8 (0x0d, 0x03);	/* 
				 * Stop ramp before setting volume 
				 */
  gus_write16 (0x09, (unsigned short) (vol << 4));
}

static void
gus_voice_balance (unsigned int balance)
{
  gus_write8 (0x0c, (unsigned char) (balance & 0xff));
}

static void
gus_ramp_range (unsigned int low, unsigned int high)
{
  gus_write8 (0x07, (unsigned char) ((low >> 4) & 0xff));
  gus_write8 (0x08, (unsigned char) ((high >> 4) & 0xff));
}

static void
gus_ramp_rate (unsigned int scale, unsigned int rate)
{
  gus_write8 (0x06, (unsigned char) (((scale & 0x03) << 6) | (rate & 0x3f)));
}

static void
gus_rampon (unsigned int m)
{
  unsigned char   mode = (unsigned char) (m & 0xff);

  gus_write8 (0x0d, mode & 0xfc);
  gus_delay ();
  gus_write8 (0x0d, mode & 0xfc);
}

static void
gus_ramp_mode (unsigned int m)
{
  unsigned char   mode = (unsigned char) (m & 0xff);

  gus_write8 (0x0d, (gus_read8 (0x0d) & 0x03) | (mode & 0xfc));		/* 
									 * Don't 
									 * start 
									 * or 
									 * stop
									 * *
									 * ramping 
									 */
  gus_delay ();
  gus_write8 (0x0d, (gus_read8 (0x0d) & 0x03) | (mode & 0xfc));
}

static void
gus_rampoff (void)
{
  gus_write8 (0x0d, 0x03);
}

static void
gus_set_voice_pos (int voice, long position)
{
  int             sample_no;

  if ((sample_no = sample_map[voice]) != -1)
    if (position < samples[sample_no].len)
      if (voices[voice].volume_irq_mode == VMODE_START_NOTE)
	voices[voice].offset_pending = position;
      else
	gus_write_addr (0x0a, sample_ptrs[sample_no] + position,
			samples[sample_no].mode & WAVE_16_BITS);
}

static void
gus_voice_init (int voice)
{
  unsigned long   flags;

  DISABLE_INTR (flags);
  gus_select_voice (voice);
  gus_voice_volume (0);
  gus_write_addr (0x0a, 0, 0);	/* 
				 * Set current position to 0 
				 */
  gus_write8 (0x00, 0x03);	/* 
				 * Voice off 
				 */
  gus_write8 (0x0d, 0x03);	/* 
				 * Ramping off 
				 */
  RESTORE_INTR (flags);

}

static void
gus_voice_init2 (int voice)
{
  voices[voice].panning = 0;
  voices[voice].mode = 0;
  voices[voice].orig_freq = 20000;
  voices[voice].current_freq = 20000;
  voices[voice].bender = 0;
  voices[voice].bender_range = 200;
  voices[voice].initial_volume = 0;
  voices[voice].current_volume = 0;
  voices[voice].loop_irq_mode = 0;
  voices[voice].loop_irq_parm = 0;
  voices[voice].volume_irq_mode = 0;
  voices[voice].volume_irq_parm = 0;
  voices[voice].env_phase = 0;
  voices[voice].main_vol = 127;
  voices[voice].patch_vol = 127;
  voices[voice].expression_vol = 127;
  voices[voice].sample_pending = -1;
}

static void
step_envelope (int voice)
{
  unsigned        vol, prev_vol, phase;
  unsigned char   rate;

  if (voices[voice].mode & WAVE_SUSTAIN_ON && voices[voice].env_phase == 2)
    {
      gus_rampoff ();

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美精品区一区二区三区| 亚洲国产va精品久久久不卡综合| 日韩欧美www| 欧美日韩国产综合一区二区三区| 在线观看不卡一区| 在线免费观看日本欧美| 色婷婷av一区| 欧美三级电影一区| 欧美日韩不卡在线| 欧美精品v日韩精品v韩国精品v| 欧美三级资源在线| 67194成人在线观看| 欧美精品18+| 精品乱人伦小说| 久久精品亚洲麻豆av一区二区 | 欧美午夜在线一二页| 一本一本大道香蕉久在线精品| 91黄视频在线观看| 欧美日本在线看| 日韩欧美你懂的| 国产午夜精品一区二区三区视频| 国产欧美日韩亚州综合 | 国产91色综合久久免费分享| 国产91综合网| 色天使色偷偷av一区二区| 在线视频你懂得一区二区三区| 欧美三级在线视频| 欧美一级二级三级蜜桃| 久久久亚洲高清| 亚洲日穴在线视频| 五月婷婷欧美视频| 狠狠色丁香九九婷婷综合五月| 国产成人精品免费在线| 色偷偷久久人人79超碰人人澡| 欧美理论在线播放| 久久久久久久久久久久久夜| 一色桃子久久精品亚洲| 日韩激情中文字幕| 国产精品一区二区视频| 99re视频精品| 日韩一区和二区| 国产精品免费网站在线观看| 亚洲成人一区二区在线观看| 精品一区二区久久| 色婷婷综合视频在线观看| 91精品国产综合久久国产大片| 久久久久久久久久久电影| 亚洲一区影音先锋| 国产精品一级黄| 欧美午夜电影网| 国产亚洲一二三区| 亚洲第一搞黄网站| 国产成人免费xxxxxxxx| 欧美日韩一区三区| 欧美国产日韩一二三区| 午夜精品免费在线观看| 北条麻妃国产九九精品视频| 这里只有精品99re| 亚洲视频在线观看三级| 日韩电影在线免费看| 成人av资源在线观看| 日韩精品在线一区| 亚洲综合小说图片| 成人高清视频免费观看| 日韩欧美成人午夜| 亚洲成a天堂v人片| av电影天堂一区二区在线| 日韩精品影音先锋| 天天操天天干天天综合网| av网站一区二区三区| 久久一留热品黄| 天天做天天摸天天爽国产一区| 99这里只有精品| 久久婷婷一区二区三区| 日韩av高清在线观看| 色哟哟一区二区三区| 国产精品久久久久久户外露出| 另类小说欧美激情| 欧美男男青年gay1069videost| 日韩理论在线观看| 国产99一区视频免费| 精品国产露脸精彩对白| 天天免费综合色| 欧美视频三区在线播放| 亚洲少妇屁股交4| 国产盗摄一区二区| 亚洲精品在线观| 另类综合日韩欧美亚洲| 在线播放91灌醉迷j高跟美女| 伊人一区二区三区| 97se亚洲国产综合在线| 国产精品污www在线观看| 国产精品一区二区三区四区| 精品国产一区二区国模嫣然| 日本午夜精品视频在线观看| 在线视频综合导航| 一区二区三区资源| 欧洲亚洲精品在线| 一区二区三区四区在线免费观看| 91麻豆免费视频| 亚洲欧美日韩一区二区 | 国产精品美女视频| 波多野结衣精品在线| 国产色综合久久| 丁香激情综合国产| 国产精品拍天天在线| 丁香网亚洲国际| 国产精品久久久久久久久搜平片| 成人手机在线视频| 国产精品麻豆视频| 99久久国产综合精品色伊| 亚洲乱码中文字幕| 欧美日韩国产小视频| 视频一区免费在线观看| 日韩一区二区三区免费看 | 不卡的av在线| 一区二区三区中文字幕精品精品 | 久久亚洲捆绑美女| 国产一区视频导航| 国产午夜精品福利| 91亚洲男人天堂| 亚洲国产一区二区视频| 91精品久久久久久久99蜜桃 | 欧美色欧美亚洲另类二区| 性感美女久久精品| 日韩视频在线你懂得| 国产乱人伦精品一区二区在线观看 | 黄色资源网久久资源365| 久久九九99视频| 成人av电影在线网| 一区二区三区在线免费视频| 欧美美女一区二区在线观看| 久久精品国产77777蜜臀| 中文字幕av一区二区三区免费看| bt7086福利一区国产| 亚洲国产视频在线| 精品成人免费观看| 99久久精品一区| 日日夜夜精品视频天天综合网| 精品国产一区二区在线观看| eeuss国产一区二区三区| 日韩有码一区二区三区| 国产日韩影视精品| 在线观看一区二区精品视频| 麻豆专区一区二区三区四区五区| 国产亚洲欧美日韩俺去了| 色噜噜狠狠一区二区三区果冻| 日韩 欧美一区二区三区| 中文字幕久久午夜不卡| 欧美人牲a欧美精品| 国产成人免费视频精品含羞草妖精| 樱桃国产成人精品视频| xf在线a精品一区二区视频网站| www.日韩精品| 麻豆精品视频在线观看| 最新国产精品久久精品| 欧美一区二区在线免费观看| 国产91在线看| 美女视频网站久久| 一级女性全黄久久生活片免费| 欧美sm美女调教| 在线亚洲+欧美+日本专区| 国产精品乡下勾搭老头1| 亚洲第一狼人社区| 国产精品福利在线播放| 日韩午夜激情电影| 在线看国产一区| 国产成人在线免费观看| 日韩在线观看一区二区| 亚洲欧美一区二区久久 | 日韩黄色片在线观看| 国产精品免费免费| 亚洲精品在线免费观看视频| 欧美性大战久久久久久久 | 91精品国产品国语在线不卡| 9人人澡人人爽人人精品| 国产一区二区精品久久91| 丝袜亚洲精品中文字幕一区| 亚洲天堂av一区| 国产亚洲精品中文字幕| 日韩亚洲电影在线| 欧美日韩国产高清一区二区三区 | 国产麻豆精品在线| 日本中文字幕一区二区视频| 亚洲另类中文字| 中文欧美字幕免费| 久久久亚洲午夜电影| 欧美一级片在线观看| 欧美日韩中文字幕精品| 色天天综合色天天久久| 99久久精品国产一区二区三区| 国产风韵犹存在线视精品| 狠狠狠色丁香婷婷综合久久五月| 日韩电影在线看| 日韩av在线播放中文字幕| 亚洲电影在线播放| 亚洲一区二区三区四区在线| 亚洲乱码日产精品bd| 亚洲色欲色欲www| 亚洲男人天堂av网|