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

📄 adin_mic_o2.c

📁 about sound recognition.i want to downlod
💻 C
字号:
/** * @file   adin_mic_o2.c * @author Akinobu LEE * @date   Sun Feb 13 18:42:22 2005 *  * <JA> * @brief  マイク掐蜗 (SGI IRIX) * * SGI IRIX のマイク掐蜗を蝗脱する你レベル不兰掐蜗簇眶ですˉ * IRIXマシンではデフォルトでこれが蝗脱されますˉ * * SGI O2 Workstation (IRIX6.3) で瓢侯澄千をしていますˉ * * 弹瓢稿オ〖ディオ掐蜗はマイクに极瓢弄に磊り仑わりますが· * ボリュ〖ムは极瓢拇泪されませんˉapanelコマンドで侍庞拇泪してくださいˉ  * </JA> * <EN> * @brief  Microphone input on SGI IRIX machine * * Low level I/O functions for microphone input on a SGI IRIX machine. * This file is used as default on IRIX machines. * * Tested on IRIX 6.3, SGI O2 Workstation. * * The microphone input device will be automatically selected by Julius * on startup.  Please note that the recoding volue will not be * altered by Julius, and appropriate value should be set by another tool * such as apanel. * </EN> * * $Revision: 1.3 $ *  *//* * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology * All rights reserved */#include <sent/stddefs.h>#include <sent/adin.h>/* sound header */#include <audio.h>static ALconfig ac;		///< Local port settingsstatic ALport aport;		///< Audio port/**  * Initialize global audio interface to use microphone input. *  * @param rate [in] sampling rate in Hz *  * @return TRUE on success, FALSE on failure. */static booleanadin_o2_setup_global(double rate){  int device;  ALpv setPVbuf[4];  setPVbuf[0].param   = AL_INTERFACE;  setPVbuf[0].value.i = alGetResourceByName(AL_SYSTEM, "Microphone", AL_INTERFACE_TYPE);  setPVbuf[1].param   = AL_MASTER_CLOCK;  setPVbuf[1].value.i = AL_CRYSTAL_MCLK_TYPE;  setPVbuf[2].param   = AL_RATE;  setPVbuf[2].value.ll= alDoubleToFixed(rate);  device = alGetResourceByName(AL_SYSTEM, "Microphone", AL_DEVICE_TYPE);  if (alSetParams(device, setPVbuf, 3) < 0) {    return FALSE;  } else {    return TRUE;  }}/**  * Device initialization: check device capability and open for recording. *  * @param sfreq [in] required sampling frequency. * @param dummy [in] a dummy data *  * @return TRUE on success, FALSE on failure. */booleanadin_mic_standby(int sfreq, void *dummy){  long rate;  long prec = AL_SAMPLE_16;  long encd = AL_SAMPFMT_TWOSCOMP;  long chan = AL_MONO;  /* global setup */  rate = sfreq;  if (adin_o2_setup_global((double)rate) == FALSE) { /* failed */    j_printerr("cannot setup microphone device (global)\n");    return(FALSE);  }  /* local parameter setup */  if ((ac = ALnewconfig()) == 0) {    j_printerr("cannot config microphone device (local)\n");    return(FALSE);  }  ALsetqueuesize(ac, rate * 2 * 1); /* 2 sec. of mono. */  ALsetwidth(ac, prec);  ALsetchannels(ac, chan);  ALsetsampfmt(ac, encd);  j_printf("local microphone port successfully initialized\n");  return(TRUE);}  /**  * Start recording. *  * @return TRUE on success, FALSE on failure. */booleanadin_mic_start(){  /* open audio port */  aport = ALopenport("mic","r",ac);  if (aport == (ALport)(0)) {    j_printerr("cannot open microphone audio port for reading\n");    return(FALSE);  }  return(TRUE);}/**  * Stop recording. *  * @return TRUE on success, FALSE on failure. */booleanadin_mic_stop(){  /* close audio port */  ALcloseport(aport);  return(TRUE);}/** * @brief  Read samples from device *  * Try to read @a sampnum samples and returns actual number of recorded * samples currently available.  This function will block until * at least one sample can be obtained. *  * @param buf [out] samples obtained in this function * @param sampnum [in] wanted number of samples to be read *  * @return actural number of read samples, -2 if an error occured. */intadin_mic_read(SP16 *buf, int sampnum){  long cnt;  cnt = ALgetfilled(aport);	/* get samples currently stored in queue */  if (cnt > sampnum) cnt = sampnum;  if (ALreadsamps(aport, buf, cnt) < 0) { /* get them */    j_printerr("Error: failed to read sample\n");    return(-2);			/* return negative on error */  }  return cnt;}

⌨️ 快捷键说明

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