新手上路
- 积分
- 38
- 金钱
- 38
- 注册时间
- 2012-8-22
- 在线时间
- 1 小时
|
是这样的,一端用vs1053录音,然后不储存,录到什么直接用2.4G模块发送出去<br />
另一端接收并解码就好了。<br />
<div>//新录音模式</div>
<div>void Record_init(void)</div>
<div>{</div>
<div>// Kick vs10xx into action!</div>
<div> VS_Soft_Reset();</div>
<div> VS_WR_Cmd(SPI_CLOCKF,0x0000); //XTAL(12.288M) = 0X0000; 2*12.288M = 0X4430;</div>
<div> VS_WR_Cmd(SPI_BASS, 0x0000); //</div>
<div> VS_WR_Cmd(SPI_MODE, 0x1800); // MIC ,录音激活</div>
<div> VS_WR_Cmd(SPI_AICTRL0, 0x0006); // 分配值= 0,则代表默认为12 /* Div -> 12=8kHz 8=12kHz 6=16kHz */</div>
<div> // 采样率8000; 12288000/256*6 = 8000</div>
<div> VS_WR_Cmd(SPI_AICTRL1, 0x0000); // 自动增益</div>
<div> VS_WR_Cmd(SPI_AICTRL2, 0x1000); // 自动增益的最大值</div>
<div>//SPI_AICTRL3</div>
<div>//0BXXXX, X 1 1 0;</div>
<div>//SPI_AICTRL3.2 0 ---IMA ADPCM ; 1 ---线性 ADPCM</div>
<div>//SPI_AICTRL3.1&0 0 ---- 联合立体声 00 </div>
<div>// 1 ---- 双声道 01</div>
<div>// 2 ---- 左通道 10</div>
<div>// 3 ---- 右通道 11</div>
<div> VS_WR_Cmd(SPI_AICTRL3, 0x0005); // 线性ADPCM 双声道</div>
<div> VS_WR_Cmd(SPI_MODE, 0x3844); // MIC ,线路激活0X3804</div>
<div>//delay_ms(10); </div>
<div>// Vs1053WriteRegister(SPI_CLOCKF,0x98,0x00); </div>
<div>//Delay_ms(100); ; while(!DREQ);</div>
<div> //write 1053 patch</div>
<div>VS_WR_Cmd(SPI_WRAMADDR, 0x8010); // 0X8010</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3E12); // 0X3E12</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xB817);//0XB817</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3E14);//0X3E14</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xF812);//0XF812</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3E01);//0X3E01</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xB811);//0XB811</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x0007);//0X0007</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x9717);//0X9717</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x0020);//0X0020</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xFFD2);//0XFFD2</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x0030);//0X0030</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x11D1);//0X11D1</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3111);//0X3111</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x8024);//0X8024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3704);//0X3704</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xC024);//0XC024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3B81);//0X3B81</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x8024);//0X8024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3101);//0X3101</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x8024);//0X8024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3B81);//0X3B81</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x8024);//0X8024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x3F04);//0X3F04</div>
<div>VS_WR_Cmd(SPI_WRAM, 0xC024);//0XC024</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x2808);//0X2808</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x4800);//0X4800</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x36F1);//0X36F1</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x9811);//0X9811</div>
<div>VS_WR_Cmd(SPI_WRAMADDR, 0x8028);//0X8028</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x2A00);//0X2A00</div>
<div>VS_WR_Cmd(SPI_WRAM, 0x040E);//0X040E</div>
<div>}</div>
<div><br />
</div>
<div>//录音代码</div>
<div>void Rec_Mode(u16 agc) </div>
<div>{ </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>//如果是IMA ADPCM,采样率计算公式如下: </div>
<div> //采样率=CLKI/256*d; </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>//假设d=0,并2倍频,外部晶振为12.288M.那么Fc=(2*12288000)/256*6=16Khz </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>//如果是线性PCM,采样率直接就写采样值 </div>
<div> VS_WR_Cmd(SPI_BASS,0x0000); </div>
<div> VS_WR_Cmd(SPI_AICTRL0,16000); //设置采样率,设置为8Khz </div>
<div> VS_WR_Cmd(SPI_AICTRL1,agc); //设置增益,0,自动增益.1024相当于1倍,512相当于0.5倍,最大值65535=64倍 </div>
<div> VS_WR_Cmd(SPI_AICTRL2,0); //设置增益最大值,0,代表最大值65536=64X </div>
<div> VS_WR_Cmd(SPI_AICTRL3,4); //左通道(MIC单声道输入) </div>
<div> VS_WR_Cmd(SPI_CLOCKF,0X2000); //设置VS10XX的时钟,MULT:2倍频;ADD:不允许;CLK:12.288Mhz </div>
<div> VS_WR_Cmd(SPI_MODE,0x3804); //MIC,录音激活 </div>
<div> delay_ms(5); //等待至少1.35ms </div>
<div>// VS_Load_Patch((u16*)wav_plugin,40);//VS1053的WAV录音需要plugin </div>
<div>} <br />
<br />
尝试了使用两种录音模式, 有plugin的录音效果明显要好(听输出的回音)<br />
但是现在另一端接收到的都是杂音。。不知道是不是RIFF头文件不配套的问题。我找不到配套的只能搜到plugin或RIFF<br />
现在已知是模块都是好的,2.4G是可以发送接收的,可以正常播放mp3和wav。<br />
发送端就是读256字节发送一次,接收端先自动载入RIFF头,然后接收到直接spi再给1053。<br />
<br />
<br />
<br />
<br />
</div> |
|