美文网首页
MTK Android tinycap录制音频

MTK Android tinycap录制音频

作者: 招金 | 来源:发表于2021-12-20 14:04 被阅读0次

由于项目需要,需要绕开MTK android架构的录音方式,并且能用tinycap录音。如果正常开机,使用tinycap录音
tinycap /sdcard/aud-test.wav -D 0 -d 1 -c 2 -b 16 -r 16000
所录音的声音是mute的。原因是我们需要用tinymix设置相关的音频控件。
下面是如果确定需要设置哪些控件的方法。

编译出tinycap和tinymix

tinycap和tinymix 是tinyalsa下的可执行程序,源码在external\tinyalsa下
我们只需要在device.mk 内添加

PRODUCT_PACKAGES += tinycap
PRODUCT_PACKAGES += tinymix

编译即可

确认那些控件需要打开

1.在开机后,有root权限的情况,执行tinymix,得到控件状态。

tb8163p3_64_bsp:/ # tinymix
tinymix
Mixer name: 'mt-snd-card'
Number of controls: 63
ctl     type    num     name                                     value

0       ENUM    1       Audio_Amp_R_Switch                       Off
1       ENUM    1       Audio_Amp_L_Switch                       Off
2       ENUM    1       Voice_Amp_Switch                         Off
3       ENUM    1       Speaker_Amp_Switch                       Off
4       ENUM    1       Headset_Speaker_Amp_Switch               Off
5       ENUM    1       Ext_Speaker_Amp_Switch                   Off
6       ENUM    1       Headphone_Speaker_Mux                    Speaker
7       ENUM    1       Headset_PGAL_GAIN                        (null)
8       ENUM    1       Headset_PGAR_GAIN                        (null)
9       ENUM    1       Handset_PGA_GAIN                         -21Db
10      ENUM    1       Lineout_PGAR_GAIN                        0Db
11      ENUM    1       Lineout_PGAL_GAIN                        0Db
12      ENUM    1       Ext_Amp_Gain                             6dB
13      ENUM    1       AUD_CLK_BUF_Switch                       Off
14      ENUM    1       Audio_Preamp1_Switch                     OPEN
15      ENUM    1       Audio_Preamp2_Switch                     OPEN
16      ENUM    1       Audio_ADC_1_Switch                       Off
17      ENUM    1       Audio_ADC_2_Switch                       Off
18      ENUM    1       Audio_ADC_3_Switch                       Off
19      ENUM    1       Audio_ADC_4_Switch                       Off
20      ENUM    1       Audio_PGA1_Setting                       12Db
21      ENUM    1       Audio_PGA2_Setting                       12Db
22      ENUM    1       Audio_PGA3_Setting                       -6Db
23      ENUM    1       Audio_PGA4_Setting                       -6Db
24      ENUM    1       Audio_MicSource1_Setting                 ADC1
25      ENUM    1       Audio_MicSource2_Setting                 ADC1
26      ENUM    1       Audio_MicSource3_Setting                 ADC1
27      ENUM    1       Audio_MicSource4_Setting                 ADC1
28      ENUM    1       Audio_MIC1_Mode_Select                   ACCMODE
29      ENUM    1       Audio_MIC2_Mode_Select                   ACCMODE
30      ENUM    1       Audio_MIC3_Mode_Select                   ACCMODE
31      ENUM    1       Audio_MIC4_Mode_Select                   ACCMODE
32      ENUM    1       SineTable_DL_DAC                         Off
33      ENUM    1       SineTable_UL_ADC                         Off
34      ENUM    1       Codec_Loopback_Setting                   OFF
35      ENUM    1       Speech_MD_USAGE                          Off
36      ENUM    1       Audio_Hdmi_SideGen_Switch                Off
37      ENUM    1       AP_Loopback_Select                       AP_LOOPBACK_NONE
38      ENUM    1       Audio_i2s0_SideGen_Switch                Off
39      ENUM    1       Audio_i2s0_hd_Switch                     Off
40      ENUM    1       Audio_ExtCodec_EchoRef_Switch            Off
41      INT     1       Audio Mrgrx Volume                       65536
42      ENUM    1       cmb stub Audio Control                   CMB_STUB_AIF_3
43      ENUM    1       Audio_I2S0dl1_hd_Switch                  Off
44      ENUM    1       Audio_FMTX_hd_Switch                     On
45      ENUM    1       Audio_SideGen_Switch                     OFF
46      ENUM    1       Audio_SideGen_SampleRate                 48K
47      ENUM    1       Audio_SideGen_Amplitude                  1/128
48      ENUM    1       Audio_Sidetone_Switch                    Off
49      ENUM    1       Audio_Mode_Switch                        Normal_Mode
50      INT     1       Audio IRQ1 CNT                           0
51      INT     1       Audio IRQ2 CNT                           0
52      INT     1       Audio HPL Offset                         314
53      INT     1       Audio HPR Offset                         312
54      ENUM    1       Audio_Debug_Setting                      Off
55      ENUM    1       Audio_Ipoh_Setting                       Off
56      ENUM    1       Audio_I2S1_Setting                       Off
57      ENUM    1       Audio_HPL_Calibration                    false
58      ENUM    1       Audio_HPR_Calibration                    false
59      ENUM    1       Pmic_Anc_Switch                          ANCON
60      INT     1       Audio HP ImpeDance Setting               16
61      INT     1       Audio FM I2S Volume                      65536
62      ENUM    1       I2S low Jitter function                  Off

2.开启录音机。执行tinymix,得到录音状态下控件情况

tb8163p3_64_bsp:/ # tinymix
tinymix
Mixer name: 'mt-snd-card'
Number of controls: 63
ctl     type    num     name                                     value

0       ENUM    1       Audio_Amp_R_Switch                       Off
1       ENUM    1       Audio_Amp_L_Switch                       Off
2       ENUM    1       Voice_Amp_Switch                         Off
3       ENUM    1       Speaker_Amp_Switch                       Off
4       ENUM    1       Headset_Speaker_Amp_Switch               Off
5       ENUM    1       Ext_Speaker_Amp_Switch                   Off
6       ENUM    1       Headphone_Speaker_Mux                    Speaker
7       ENUM    1       Headset_PGAL_GAIN                        (null)
8       ENUM    1       Headset_PGAR_GAIN                        (null)
9       ENUM    1       Handset_PGA_GAIN                         -21Db
10      ENUM    1       Lineout_PGAR_GAIN                        8Db
11      ENUM    1       Lineout_PGAL_GAIN                        8Db
12      ENUM    1       Ext_Amp_Gain                             6dB
13      ENUM    1       AUD_CLK_BUF_Switch                       Off
14      ENUM    1       Audio_Preamp1_Switch                     IN_ADC1
15      ENUM    1       Audio_Preamp2_Switch                     IN_ADC3
16      ENUM    1       Audio_ADC_1_Switch                       On
17      ENUM    1       Audio_ADC_2_Switch                       On
18      ENUM    1       Audio_ADC_3_Switch                       Off
19      ENUM    1       Audio_ADC_4_Switch                       Off
20      ENUM    1       Audio_PGA1_Setting                       18Db
21      ENUM    1       Audio_PGA2_Setting                       18Db
22      ENUM    1       Audio_PGA3_Setting                       -6Db
23      ENUM    1       Audio_PGA4_Setting                       -6Db
24      ENUM    1       Audio_MicSource1_Setting                 ADC1
25      ENUM    1       Audio_MicSource2_Setting                 ADC1
26      ENUM    1       Audio_MicSource3_Setting                 ADC1
27      ENUM    1       Audio_MicSource4_Setting                 ADC1
28      ENUM    1       Audio_MIC1_Mode_Select                   ACCMODE
29      ENUM    1       Audio_MIC2_Mode_Select                   ACCMODE
30      ENUM    1       Audio_MIC3_Mode_Select                   ACCMODE
31      ENUM    1       Audio_MIC4_Mode_Select                   ACCMODE
32      ENUM    1       SineTable_DL_DAC                         Off
33      ENUM    1       SineTable_UL_ADC                         Off
34      ENUM    1       Codec_Loopback_Setting                   OFF
35      ENUM    1       Speech_MD_USAGE                          Off
36      ENUM    1       Audio_Hdmi_SideGen_Switch                Off
37      ENUM    1       AP_Loopback_Select                       AP_LOOPBACK_NONE
38      ENUM    1       Audio_i2s0_SideGen_Switch                Off
39      ENUM    1       Audio_i2s0_hd_Switch                     Off
40      ENUM    1       Audio_ExtCodec_EchoRef_Switch            Off
41      INT     1       Audio Mrgrx Volume                       65536
42      ENUM    1       cmb stub Audio Control                   CMB_STUB_AIF_3
43      ENUM    1       Audio_I2S0dl1_hd_Switch                  Off
44      ENUM    1       Audio_FMTX_hd_Switch                     On
45      ENUM    1       Audio_SideGen_Switch                     OFF
46      ENUM    1       Audio_SideGen_SampleRate                 48K
47      ENUM    1       Audio_SideGen_Amplitude                  1/128
48      ENUM    1       Audio_Sidetone_Switch                    Off
49      ENUM    1       Audio_Mode_Switch                        Normal_Mode
50      INT     1       Audio IRQ1 CNT                           2048
51      INT     1       Audio IRQ2 CNT                           960
52      INT     1       Audio HPL Offset                         314
53      INT     1       Audio HPR Offset                         312
54      ENUM    1       Audio_Debug_Setting                      Off
55      ENUM    1       Audio_Ipoh_Setting                       Off
56      ENUM    1       Audio_I2S1_Setting                       Off
57      ENUM    1       Audio_HPL_Calibration                    false
58      ENUM    1       Audio_HPR_Calibration                    false
59      ENUM    1       Pmic_Anc_Switch                          ANCON
60      INT     1       Audio HP ImpeDance Setting               16
61      INT     1       Audio FM I2S Volume                      65536
62      ENUM    1       I2S low Jitter function                  Off

比较不同处


1639979583(1).png

经过分析,主要是ctl id 14 15 16 17 20 21需要在录音时候打开。

由上述分析后,我们只需要切换14 15 16 17 20 21即可录音

1.执行如下命令

设置adc

tinymix 14 1
tinymix 15 3

开启adc

tinymix 16 1
tinymix 17 1

设置增益

tinymix 20 4
tinymix 21 4
2.tinycap录音
tinycap /sdcard/aud-test.wav -D 0 -d 1 -c 2 -b 16 -r 16000

OK~

相关文章

网友评论

      本文标题:MTK Android tinycap录制音频

      本文链接:https://www.haomeiwen.com/subject/edczfrtx.html