TI中文支持网
TI专业的中文技术问题搜集分享网站

aic3204的声音播放测试怎么调节播放音量

这是一段1KHz的正弦波音频信号,播放的时候声音太大,怎么调节音量大小,可不可以不减小幅值在程序里调


#include "stdio.h" #include "evm5517.h" extern Int16 AIC3204_rset( Uint16 regnum, Uint16 regval); #define Xmit 0x20 /* * * aic3204_tone_headphone( ) *Output a 1 kHz tone through the STEREO OUT jack * */ Int16 aic3204_tone_headphone( ) {/* Pre-generated sine wave data, 16-bit signed samples */Int16 sinetable[48] = {0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x76ef,0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c};Int16 j, i = 0;Int16 sample;/* Configure AIC3204 */AIC3204_rset( 0, 0x00 );// Select page 0AIC3204_rset( 1, 0x01 );// Reset codecAIC3204_rset( 0, 0x01 );// Point to page 1AIC3204_rset( 1, 0x08 );// Disable crude AVDD generation from DVDDAIC3204_rset( 2, 0x00 );// Enable Analog Blocks/* PLL and Clocks config and Power Up */AIC3204_rset( 0, 0x00 );// Select page 0AIC3204_rset( 27, 0x00 );// BCLK and WCLK is set as i/p to AIC3204(Slave)AIC3204_rset( 4, 0x07 );// PLL setting: PLLCLK <- BCLK and CODEC_CLKIN <-PLL CLKAIC3204_rset( 6, 0x08 );// PLL setting: JAIC3204_rset( 7, 0 );// PLL setting: HI_BYTE(D)AIC3204_rset( 8, 0 );// PLL setting: LO_BYTE(D)/* For 48 KHz sampling */AIC3204_rset( 5, 0x92 );// PLL setting: Power up PLL, P=1 and R=2AIC3204_rset( 13, 0x00 );// Hi_Byte(DOSR) for DOSR = 128 decimal or 0x0080 DAC oversampplingAIC3204_rset( 14, 0x80 );// Lo_Byte(DOSR) for DOSR = 128 decimal or 0x0080AIC3204_rset( 20, 0x80 );// AOSR for AOSR = 128 decimal or 0x0080 for decimation filters 1 to 6AIC3204_rset( 11, 0x88 );// Power up NDAC and set NDAC value to 8AIC3204_rset( 12, 0x82 );// Power up MDAC and set MDAC value to 2AIC3204_rset( 18, 0x88 );// Power up NADC and set NADC value to 8AIC3204_rset( 19, 0x82 );// Power up MADC and set MADC value to 2/* DAC ROUTING and Power Up */AIC3204_rset( 0, 0x01 );// Select page 1AIC3204_rset( 12, 0x08 );// LDAC AFIR routed to HPLAIC3204_rset( 13, 0x08 );// RDAC AFIR routed to HPRAIC3204_rset( 0, 0x00 );// Select page 0AIC3204_rset( 64, 0x02 );// Left vol=right volAIC3204_rset( 65, 0x00 );// Left DAC gain to 0dB VOL; Right tracks LeftAIC3204_rset( 63, 0xd4 );// Power up left,right data paths and set channelAIC3204_rset( 0, 0x01 );// Select page 1AIC3204_rset( 16, 0x06 );// Unmute HPL , 6dB gainAIC3204_rset( 17, 0x06 );// Unmute HPR , 6dB gainAIC3204_rset( 9, 0x30 );// Power up HPL,HPRAIC3204_rset( 0, 0x00 );// Select page 0EVM5517_wait( 500 );// Wait/* ADC ROUTING and Power Up */AIC3204_rset( 0, 0x01 );// Select page 1AIC3204_rset( 52, 0x0C );// STEREO 1 Jack// IN2_L to LADC_P through 40 kohmAIC3204_rset( 55, 0x0C );// IN2_R to RADC_P through 40 kohmmAIC3204_rset( 54, 0x03 );// CM_1 (common mode) to LADC_M through 40 kohmAIC3204_rset( 57, 0xC0 );// CM_1 (common mode) to RADC_M through 40 kohmAIC3204_rset( 59, 0x00 );// MIC_PGA_L unmuteAIC3204_rset( 60, 0x00 );// MIC_PGA_R unmuteAIC3204_rset( 0, 0x00 );// Select page 0AIC3204_rset( 81, 0xc0 );// Powerup Left and Right ADCAIC3204_rset( 82, 0x00 );// Unmute Left and Right ADCAIC3204_rset( 0, 0x00 );EVM5517_wait( 200 );// Wait/* I2S settings */I2S0_SRGR = 0x0015;I2S0_ICMR = 0x0028;// Enable interruptsI2S0_CR= 0x8012;// 16-bit word, Master, enable I2S/* Play Tone */for ( i = 0 ; i < 5 ; i++ ){for ( j = 0 ; j < 1000 ; j++ ){for ( sample = 0 ; sample < 48 ; sample++ ){I2S0_W0_MSW_W = (sinetable[sample]/5) ; // Send left sampleI2S0_W0_LSW_W = 0;I2S0_W1_MSW_W = (sinetable[sample]/5) ; // Send right sampleI2S0_W1_LSW_W = 0;while((Xmit & I2S0_IR) == 0);// Wait for interrupt}}}/* Disble I2S */I2S0_CR = 0x00;return 0; }

Shine:

应该有个volume参数可以调节,具体建议到音频论坛咨询。

赞(0)
未经允许不得转载:TI中文支持网 » aic3204的声音播放测试怎么调节播放音量
分享到: 更多 (0)