⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quantfiltcoeftest.c

📁 CHP 3 - Real-Time Digital Signal Processing: Implementations and Applications, Second Edition by Sen
💻 C
字号:
// 
//  Project: Experiment 3.6.3 Quantization Filter Coefficients - Chapter 3 
//  File name: quantFiltCoefTest.c   
//
//  Description: This function controls the quantization filter coefficients experiment
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//


#include "quantFiltCoefcfg.h"
#include "dsk5510.h"
#include "dsk5510_aic23.h"

// Codec configuration settings 
DSK5510_AIC23_Config config = { \
    0x0017,  /* 0 DSK5510_AIC23_LEFTINVOL  Left line input channel volume */ \
    0x0017,  /* 1 DSK5510_AIC23_RIGHTINVOL Right line input channel volume */\
    0x01f9,  /* 2 DSK5510_AIC23_LEFTHPVOL  Left channel headphone volume */  \
    0x01f9,  /* 3 DSK5510_AIC23_RIGHTHPVOL Right channel headphone volume */ \
    0x0011,  /* 4 DSK5510_AIC23_ANAPATH    Analog audio path control */      \
    0x0000,  /* 5 DSK5510_AIC23_DIGPATH    Digital audio path control */     \
    0x0000,  /* 6 DSK5510_AIC23_POWERDOWN  Power down control */             \
    0x0043,  /* 7 DSK5510_AIC23_DIGIF      Digital audio interface format */ \
    0x0081,  /* 8 DSK5510_AIC23_SAMPLERATE Sample rate control */            \
    0x0001   /* 9 DSK5510_AIC23_DIGACT     Digital interface activation */   \
};

#define QUANT_16BIT    0xFFFF
#define QUANT_12BIT    0xFFF0
#define QUANT_8BIT     0xFF00
#define QUANT_4BIT     0xF000

void  playAudio(unsigned short seconds, unsigned short sampleRate, short mask);
void  initIIR4(short);
short IIR4(short);

DSK5510_AIC23_CodecHandle hCodec;
    
void main()
{
  // Initialize the board support library, must be called first  
  DSK5510_init();

  // Start the codec  
  hCodec = DSK5510_AIC23_openCodec(0, &config);

  // Loop back line-in audio for 30 seconds at 48kHz sampling rate
  // No quantization
  initIIR4(0xFFFF);
  playAudio(30, 48000, QUANT_16BIT);
    
  // Loop back line-in audio for 30 seconds at 48kHz sampling rate
  // Quantization to 12-bits
  initIIR4(0xFFF0);    
  playAudio(30, 48000, QUANT_12BIT);

  // Loop back line-in audio for 30 seconds at 48kHz sampling rate
  // Quantization to 8-bits
  initIIR4(0xFF00);        
  playAudio(30, 48000, QUANT_8BIT);

  // Loop back line-in audio for 30 seconds at 48kHz sampling rate
  // Quantization to 4-bits
  initIIR4(0xF000);        
  playAudio(30, 48000, QUANT_4BIT);

  // Close the codec 
  DSK5510_AIC23_closeCodec(hCodec);
}

void playAudio(unsigned short seconds, unsigned short sampleRate, short mask)
{
  unsigned short i,j;
  short left,right;
    
  for (i = 0; i < seconds; i++)
  {
    for (j = 0; j < sampleRate; j++)
    {   
      // Read a sample from the left input channel 
      while (!DSK5510_AIC23_read16(hCodec, &left));
      // Read a sample from the right input channel 
      while (!DSK5510_AIC23_read16(hCodec, &right));   

      // Left channel is pass through
      // Right channel goes through IIR filter
      right = IIR4(right);

      // Write a sample to the left output channel 
      while (!DSK5510_AIC23_write16(hCodec, left));
      // Write a sample to the right output channel 
      while (!DSK5510_AIC23_write16(hCodec, right));
    }    
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -