Тема: 5-и полосный эквалайзер TEA6360
http://rcl-radio.ru/wp-content/uploads/ … EA6360.pdf
FEATURES
• Monolithic integrated 5-band stereo equalizer circuit
• Five filters for each channel
• Centre frequency, bandwidth and maximum boost/cut
defined by external components
• Choise for variable or constant Q-factor via I2C software
• Defeat mode
• All stages are DC-coupled
• I
2C-bus control for all functions
• Two different modul addresses programmable.
1. Filter control with variable quality factor
2. Filter control with constant quality factor
3. Filter control with quasi-constant quality factor
test.ino
// pin 18 == GND
#include <TEA6360.h>
#include <Wire.h>
TEA6360 tea;
void setup(){
Wire.begin();
audio();
}
void loop(){}
void audio(){
// НОМЕР ПОЛОСЫ int 1...5, РЕЖИМ ФИЛЬТРА int 1...3, УСИЛЕНИЕ/ОСЛАБЛЕНИЕ 12 дБ шаг 2.4 дБ int -5...5
tea.setFilter(1,1,5);// 12 kHz
tea.setFilter(2,1,5);// 2,95 kHz
tea.setFilter(3,1,1);// 790 Hz
tea.setFilter(4,1,3);// 205 Hz
tea.setFilter(5,1,3);// 59 Hz
}
TEA6360.h
#ifndef TEA6360_H
#define TEA6360_H
#define TEA6360_address 0b1000010 // pin 18 gnd
#define F_1 0b00000000
#define F_2 0b00000001
#define F_3 0b00000010
#define F_4 0b00000011
#define F_5 0b00000100
#include <Arduino.h>
class TEA6360
{
public:
TEA6360();
void setFilter(int f, int filter, int gain); //1...5, 1...3, -5...0...+5
private:
void writeWire(char a, char b);
};
#endif //TEA6360_H
TEA6360.cp
#include <Arduino.h>
#include <Wire.h>
#include "TEA6360.h"
TEA6360::TEA6360(){
Wire.begin();
}
void TEA6360::setFilter(int f, int filter ,int gain){
switch(f){
case 1: f = F_1;break;
case 2: f = F_2;break;
case 3: f = F_3;break;
case 4: f = F_4;break;
case 5: f = F_5;break;
}
if(filter==3){
switch(gain){
case 5: gain = 0b01010000;break;
case 4: gain = 0b01010001;break;
case 3: gain = 0b01010010;break;
case 2: gain = 0b01000010;break;
case 1: gain = 0b00110010;break;
case 0: gain = 0b00000000;break;
case -1: gain = 0b00100011;break;
case -2: gain = 0b00100100;break;
case -3: gain = 0b00100101;break;
case -4: gain = 0b00010101;break;
case -5: gain = 0b00000101;break;
}}
if(filter==2){
switch(gain){
case 5: gain = 0b01010000;break;
case 4: gain = 0b01010001;break;
case 3: gain = 0b01010010;break;
case 2: gain = 0b01010011;break;
case 1: gain = 0b01010100;break;
case 0: gain = 0b00000000;break;
case -1: gain = 0b01000101;break;
case -2: gain = 0b00110101;break;
case -3: gain = 0b00100101;break;
case -4: gain = 0b00010101;break;
case -5: gain = 0b00000101;break;
}}
if(filter==1){
switch(gain){
case 5: gain = 0b01010000;break;
case 4: gain = 0b01000000;break;
case 3: gain = 0b00110000;break;
case 2: gain = 0b00010000;break;
case 1: gain = 0b00010000;break;
case 0: gain = 0b00000000;break;
case -1: gain = 0b00000001;break;
case -2: gain = 0b00000010;break;
case -3: gain = 0b00000011;break;
case -4: gain = 0b00000100;break;
case -5: gain = 0b00000101;break;
}}
writeWire(f, gain);
}
void TEA6360::writeWire(char a, char b){
Wire.beginTransmission(TEA6360_address);
Wire.write (a);
Wire.write (b);
Wire.endTransmission();
}
Библиотека протестирована