voicecontrolgain.c
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------------------
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);
}