voicecontrolgain.c 1.34 KB
/*---------------------------------------------------------------------
 	Copyright (C) 1998 Nintendo.
 	
 	File		voicecontrolgain.c
 	Coded    by	Koji Mitsunari.	May 16, 1998.
 	Modified by	Koji Mitsunari.	Jun 22, 1998
 	Comments	Gain control at Voice Recognition System 
   
 	$Id: voicecontrolgain.c,v 1.1.1.1 2002/05/02 03:28:44 blythe Exp $
   ---------------------------------------------------------------------*/
/**************************************************************************
 *
 *  $Revision: 1.1.1.1 $
 *  $Date: 2002/05/02 03:28:44 $
 *  $Source: 
 *
 **************************************************************************/

#include "osint.h"
#include "controller.h"
#include "siint.h"

s32
osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital) {
  s32		ret;
  u8		cmd;
  static u8	digital_table[]={
    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0
  };

  /*--- アナログゲイン調整 ---*/
  if (analog == 0) {
    cmd = 0x18;
  } else {
    cmd = 0x98;
  }

  if ((ret = __osVoiceSetADConverter(hd->__mq, hd->__channel, cmd)) != 0 ) {
    return(ret);
  }
   
  /*--- デジタルゲイン調整 ---*/
  if (digital < 8 && digital >= 0) {
    cmd = 2 + digital_table[digital];
  } else {
    return(CONT_ERR_INVALID);
  }
  
  if ((ret = __osVoiceSetADConverter(hd->__mq, hd->__channel, cmd)) != 0 ) {
    return(ret);
  }
  return(ret);
}