26

Re: TDA7461

на плюс питания кинуть?

27

Re: TDA7461

Лучше +5 В от ардуино через резистор 4,7-10к

28

Re: TDA7461

подключил, пропал гул, звук ели слышен, скорей всего с выводов acout нету звука, поскольку если на  acin подать звук напрямую то он начитает петь во всю громкость.

29

Re: TDA7461

26 вывод должен быть конденсатор к GND 10 мкФ
14 вывод должен быть конденсатор к GND 220 мкФ

30

Re: TDA7461

[видео]

31

Re: TDA7461

всю подключено с завода как в даташите, проверил

32

Re: TDA7461

tda.setSoftmute(1, 0, 1, 0, 0, 0);   

так установлено?

33

Re: TDA7461

tda.setBassTrebConf(0, 0, 0, 0, 0);
// int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
// int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
// int bass_q = 0...3 >>> 1, 1.25, 1.5, 2
// bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
// bool ac_coupling = 0...1 >>> For External Connection...Internally Connection
попробуйте так

  tda.setBassTrebConf(0, 0, 0, 0, 1);

34

Re: TDA7461

можете ли вы дать свой телеграм или другое средство связи, там подробнее все опишу. И дело лучше и быстрее пойдет

35

Re: TDA7461

все параметры менял, ничего не помогло. Проблема  в том что нету звука на ножках ACOUT. Нужно искать почему

36

Re: TDA7461

Перепроверил всю библиотеку, ошибок не нашел. Перевел весь даташит, не могу понять почему не работает.
Пока идей нет, буду думать.
Но все же скорее всего один или несколько из параметров не дает возможность запустить звук.

37 (2024-02-15 01:04:50 отредактировано vladbuharkin20)

Re: TDA7461

я так полагаю что дело в этом узле. Где-то здесь блокируется сигнал.
http://forum.rcl-radio.ru/uploads/images/2024/02/1e5733092c8830fb4b023e431a4d115d.png

38

Re: TDA7461

tda.setInput(0, 1, 3, 15);
// int source = 0...7 >>> CD
//                        Cassette
//                        Phone
//                        AM
//                        Stereo Decoder
//                        Input FM
//                        Mute
//                        AC inputs 
// bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff   
// int am_fm = 0...3 >>> AM mono
//                       AM stereo
//                       AM through Stereo decoder
//                       FM- Stereo decoder
// int in_gain = 0...15 >>>  14...0 dB step 2 dB

39

Re: TDA7461

tda.setSoftmute(1, 0, 0, 0, 0, 3);   
// int mute = 0...1 >>> Softmute = Enable...Disable
// int mute_time 0...3 >> Mute time = 0.48, 0.96, 40.4, 324 ms
// bool stereo_dec = 0...1 >>> Stereo decoder softmute influence = off...on
// bool beep = 0...1 >>> Beep Frequency = 600 Hz...1.2 kHz
// bool mixing_0 = 0...1 >>> Mix-Source = Beep...Phone
// bool mixing_1 = 0...3 >>> Full Mix Signal
//                           Source -12 dB + Mix-Signal -2.5 dB
//                           Source -6 dB + Mix-Signal -6 dB
//                           Full Source

40

Re: TDA7461

tda.setBassTreb(0, 0);
// int bass = -14...14 >>> -14...+14 dB step 2 dB
// int treb = -14...14 >>> -14...+14 dB step 2 dB

tda.setBassTreb(14, 0);
// int bass = -14...14 >>> -14...+14 dB step 2 dB
// int treb = -14...14 >>> -14...+14 dB step 2 dB

41

Re: TDA7461

void setup(){
  Serial.begin(9600);
  Wire.begin();
}

void loop(){
  audio();
  delay(1000);
}

поменять на

void setup(){
  delay(300);
  Serial.begin(9600);
  Wire.begin();
audio();
}

void loop(){
 
  delay(1000);
}

42

Re: TDA7461

Отключение тон компенсации

     tda.setLoudness(0, 1, 0, 0);
// int loud_att = 0...15 >>> 0...-15 dB
// bool loud_filter = 0...1 >>> on...off
// bool loud_f = 0...1 >>> 200...400 Hz
// bool loud_q = 0...1 >>> low...normal

43

Re: TDA7461

tda.setBassTrebConf(0, 0, 0, 1, 1);
// int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
// int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
// int bass_q = 0...3 >>> 1, 1.25, 1.5, 2
// bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
// bool ac_coupling = 0...1 >>> For External Connection...Internally Connection

44

Re: TDA7461

http://rcl-radio.ru/?p=62674

45

Re: TDA7461

///  Input selector         
     tda.setInput(0, 0, 0, 0);
// int source = 0...7 >>> CD
//                        Cassette
//                        Phone
//                        AM
//                        Stereo Decoder
//                        Input FM
//                        Mute
//                        AC inputs 
// bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff   
// int am_fm = 0...3 >>> AM mono
//                       AM stereo
//                       AM through Stereo decoder
//                       FM- Stereo decoder
// int in_gain = 0...15 >>>  14...0 dB step 2 dB

надо поменять вот этот параметр - bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff

46

Re: TDA7461

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <MsTimer2.h>
#include <Encoder.h>
#include <EEPROM.h>
#include <TDA7461.h>

#define MUTE 10
#define SW 4 //кнопка на энкодере

TDA7461 tda;

Encoder myEnc( 3, 2 ); //CLK, DT encoder connection

LiquidCrystal_I2C lcd(0x27, 16, 2); // Set Alamat I2C LCD dan type LCD

byte a3[ 8 ] = { 0b00000, 0b00000, 0b00000, 0b11011, 0b11011, 0b00000, 0b00000, 0b00000 };

unsigned long newPosition, time, oldPosition = - 999;
int  menu, w, vol, loud, vol_d, z, bass, bass_d, treb, treb_d, in , mute, m;


// constants won't change. They're used here to set pin numbers:
//const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int SHORT_PRESS_TIME = 500; // 1000 milliseconds
const int LONG_PRESS_TIME  = 500; // 1000 milliseconds

// Variables will change:
int lastState = HIGH;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;
bool gantian;


void setup( ) {
  tda.setSoftmute(0, 2, 0, 0, 0, 3);
  delay(300);
  Serial.begin(9600);
  Wire.begin();
audio();
  Serial.begin( 9600 );
  Wire.begin( );
  lcd.begin( 16, 2 );
  //lcd.begin();
  lcd.backlight();
  lcd.createChar( 2, a3 );
  

  pinMode( SW, INPUT_PULLUP); // ENCODER BUTTON
  pinMode( MUTE, INPUT_PULLUP ); // MUTE

  MsTimer2::set( 1, to_Timer );
  MsTimer2::start();

  vol = EEPROM.read( 0 ) - 31;
  bass = EEPROM.read( 1 ) - 10;
  treb = EEPROM.read( 2 ) - 8;
  in = EEPROM.read( 7 );
  loud = EEPROM.read ( 9 );

  for ( z = 0 ; z <= 3; z++ ) {
    //tea.setBallance( z, 0 );
  }
 

  lcd.setCursor( 1, 0);
  lcd.print("-= WELCOME =-");
  lcd.setCursor( 0, 1);
  lcd.print("> VlAD ver:1.1 <");
  delay(2000);
  tda.setSoftmute(1, 2, 0, 0, 0, 3);
  lcd.clear( );
}

void to_Timer ( ) {
  newPosition = myEnc.read ( ) / 2 ;
}

void loop ( ) {


  // read the state of the switch/button:
  currentState = digitalRead(SW);

  if (lastState == HIGH && currentState == LOW)       // button is pressed
    pressedTime = millis();
  else if (lastState == LOW && currentState == HIGH) { // button is released
    releasedTime = millis();

    long pressDuration = releasedTime - pressedTime;

    if ( pressDuration < SHORT_PRESS_TIME ) {
      menu ++;  // menu
      cl( );
      myEnc.write ( 0 );
      time = millis ( );
      w = 1;
      if ( menu > 4 ) {
        menu = 0 ;
      }
      Serial.println("A short press is detected");
    }

    if ( pressDuration > LONG_PRESS_TIME ) {
      mute++;  // mute
      if ( mute > 1 ) {
        mute = 0 ;
      }
      audio ( ) ;
      cl ( ) ;
    }
    if ( mute == 1 ) {
      m = 1 ;  // mute

      lcd.setCursor( 12, 0);
      lcd.print("MUTE");
      lcd.setCursor( 0, 0);
      lcd.print( "VOLUME ") ;
      lcd.print( "0") ;
      lcd.setCursor( 1, 1);
      lcd.print("x");
      lcd.setCursor( 0, 1);
      lcd.write(( uint8_t ) 3);
      for ( z = 3 ; z <= 15; z++ ) {

      }
      menu = 100 ;
    }
    if ( mute == 0 && m == 1 ) {
      cl ( );
      menu = 0 ;
      m = 0 ;
      Serial.println("A long press is detected");
    }
  } 
  lastState = currentState;
/////////////////////////////////////////////////////////////////////////////////////////(ГРОМКОСТЬ 111-0)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( menu == 0 ) {
    
    if  ( newPosition != oldPosition )  {
      oldPosition = newPosition;
      vol = vol - newPosition;
      myEnc.write ( 0 );
      newPosition = 0;
      cl ( ) ;
      time = millis ( );
      w = 1 ;
      if ( vol > 111 ) {
        vol = 111 ;
      }
      if ( vol < 0 ) {
        vol = 0 ;
      }
      audio ( ) ;
    }

    lcd.setCursor( 7 , 0 );
    lcd.print( vol  );
    lcd.setCursor( 0 , 0 );
    lcd.print( "VOLUME" );
    lcd.setCursor( 11 , 0 );
    lcd.print( !vol ) ;
    lcd.print( "dB" ) ;
  }
/////////////////////////////////////////////////////////////////////////////////////////(ВЧ. НАСТРОЙКИ 0-14)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( menu == 1 ) {
    if  ( newPosition != oldPosition )  {
      oldPosition = newPosition;
      bass = bass + newPosition;
      myEnc.write ( 0 );
      newPosition = 0;
      lcd.clear();
      time = millis();
      w = 1 ;
      if ( bass > 14 ) {
        bass = 14 ;
      }
      if ( bass < -14 ) {
        bass = -14 ;
      }
      audio ( ) ;
    }
    lcd. setCursor ( 0, 0 ) ;
    lcd. print ( "BASS " ) ;
    lcd.print( bass  );
  }
/////////////////////////////////////////////////////////////////////////////////////////(НЧ. НАСТРОЙКИ 0-14)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( menu == 2 ) {
    if  ( newPosition != oldPosition )  {
      oldPosition = newPosition;
      treb = treb + newPosition;
      myEnc.write( 0 );
      newPosition = 0;
      lcd.clear();
      time = millis();
      w = 1;
      if ( treb > 14 ) {
        treb = 14;
      }
      if ( treb <  -14 ) {
        treb =  -14;
      }
      audio();
    }

    lcd.setCursor( 0 , 0 );
    lcd.print("TRBL ");
    lcd.print( treb  );
   Serial.println(treb);
  }
/////////////////////////////////////////////////////////////////////////////////////////(LOUDNESS)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( menu == 3 ) {
    if ( newPosition != oldPosition )  {
      oldPosition = newPosition;
      loud = loud + newPosition;
      myEnc.write( 0 );
      newPosition = 0;
      lcd.clear ( );
      time = millis ( );
      w = 1;
      if ( loud > 1 ) {
        loud = 0;
      }
      if ( loud < 0 ) {
        loud = 1;
        
      }
    }
    lcd.setCursor(2, 0);
    lcd.print("-=LOUDNESS=-");
    if (loud == 1) {
      lcd.setCursor(5, 1);
      lcd.print(">> ON");
    }
    else {
      lcd.setCursor(5, 1);
      lcd.print("OFF <<");
    }
    audio ( );
  }
/////////////////////////////////////////////////////////////////////////////////////////(ВХОДЫ АУДИО 1-7)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( menu == 4 ) {
    if ( newPosition != oldPosition )  {
      oldPosition = newPosition;
      in = in + newPosition;
      myEnc.write( 0 );
      newPosition = 0;
      lcd.clear ( );
      time = millis ( );
      w = 1;
      if ( in > 7 ) {
        in = 0;
      }
      if ( in < 0 ) {
        in = 7;
      }
    }
    lcd.setCursor(0, 0);
    lcd.print("Source Selector:");
    lcd.setCursor(0, 1);
    lcd.print(in);
    if (in == 0){
    lcd.setCursor(2, 1);
      lcd.print("CD"); 
    }
    if (in == 1){
    lcd.setCursor(2, 1);
      lcd.print("CASSETTE"); 
    }
    if (in == 2){
    lcd.setCursor(2, 1);
      lcd.print("PHONE");
    }
    if (in == 3){
    lcd.setCursor(2, 1);
      lcd.print("AM");
    }
    if (in == 4){
    lcd.setCursor(2, 1);
      lcd.print("STEREO DEC");
    }
    if (in == 5){
    lcd.setCursor(2, 1);
      lcd.print("INPUT FM");
    }
    if (in == 6){
    lcd.setCursor(2, 1);
      lcd.print("MUTE");
    }
     if (in == 7){
    lcd.setCursor(2, 1);
      lcd.print("AC IN");
    }
    audio ( );
  }


  if ( millis() - time > 10000  && w == 1 ) {
    EEPROM.update( 0, vol + 31 );
    EEPROM.update( 1, bass + 10);
    EEPROM.update( 2, bass + 8 );
    EEPROM.update( 7, in );
    EEPROM.update( 9, loud );
    cl ( );
    menu = 0;
    w = 0;
  }
}

void cl ( ) {
  delay ( 10 ) ;
  lcd.clear ( ) ;
}

void audio ( ) {
tda.setInput(in, 1, 3, 0);
tda.setLoudness(0, loud, 0, 0); 
tda.setVolume(vol, 0);
tda.setBassTreb(bass, treb);
tda.attLF(4); // int 0...31 >>> 0...-50 dB
tda.attRF(0);
tda.setBassTrebConf(3, 0, 0, 0, 1);
//1.   int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
//2.   int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
//3.   int bass_q = 0...3 >>> 1, 1.25, 1.5, 2 
//4.   bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
//5.   bool ac_coupling = 0...1 >>> For External Connection...Internally Connection
tda.setStereo(0, 0, 0, 1, 1, 0);
//1.   bool std = 0..1 >>> STD unmuted...muted
//2.   int in_gain_dec = 0...3 >>> IN-Gain 11, 8.5, 6, 3.5 dB
//3.   bool dec = 0...1 >>> Stereo decoder Unmuted with Stdec. 
//4.   Stereo decoder Unmuted whichever is the selected source.
//5.   bool mono_stereo = 0...1 >>> Forced mono...Mono/stereo switch automatically
//6.   bool pilot = 0...1 >>> Pilot threshold high...low
//7.   bool emp = 0...1 >>> De-emphasis 50...75 μs
   ///  Noise blanker
tda.setBlanker(0, 0, 0, 3);
//1.   int threshold_0 = 0...7 >>> Low threshold 65, 60, 55, 50, 45, 40, 35, 30 mV
//2.   int threshold_1 = 0...3 >>> Noise controlled threshold 320, 260, 200, 140 mV
//3.   bool blank = 0...1 >>> Noise blanker off...on
//4.   int over = 0...3 >>> Over deviation adjust 2.8V, 2.0V, 1.2V, off
             /// Field strength control
tda.setField(3, 0, 0, 0, 0);
//1.   int adj = 0...3 >>> Noise blanker Field strength Adj 2.3V, 1.8V, 1.3V, off
//2.   int vsbl = 0...3 >>> VSBL at 33%, 42%, 50%, 58%
//3.   int vhch = 0...3 >>> VHCH at 42%, 50%, 58%, 66%
//4.   bool vhcl = 0...1 >>> VHCL at 17%, 33%
//5.   bool cut = 0...1 >>> High cut OFF...ON
     /// Configuration
 tda.setConf(0, 0, 1, 3);
//1.   int rez = 0...3 >>> infinite, 56kOm, 33kOm, 18kOm
//2.   int band_gain = 0...3 >>> 6, 16, 12, 18 dB
//3.   bool mult = 0...1 >>> Multipath detector internal influence On...Off
//4.   int mult_gain = 0...3 >>> Gain = 7.6 dB 4.6 dB, 0 dB, Off
     /// Stereo decoder adjustment
tda.setSDecoder(4, 0, 1);
//1.   int compens = 0...7 >>> not...31%
//2.   int level_gain = 0...15 >>> 0...10 dB step 0.66dB
//3.   bool temp = 0...1 >>> TC = 0...16.7 mV/K (3300 ppm)
tda.setTest(0b11111110);  
}

47

Re: TDA7461

Пока небольшой тестовый скетч, регулировка громкости, тембра и входа

Пока по входу не будет решен вопрос, нет смысла дописывать скетч.

#define CLK    9 // CLK ENCODER
#define DT     8 // DT  ENCODER
#define SW     10 // SW  ENCODER

#define IN     2  // BUTTON INPUT

#include <Wire.h> 
#include <EEPROM.h>
#include <Encoder.h>               // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip
#include <MsTimer2.h>              // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip
#include <LiquidCrystal_I2C.h>     //  http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <TDA7461.h>
  TDA7461 tda;
  LiquidCrystal_I2C lcd(0x27,16,2); 
  Encoder myEnc(CLK, DT);

  byte a1[8] = {0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
  byte a2[8] = {0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
  byte a3[8] = {0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};  
  long times,oldPosition  = -999,newPosition;
  int vol,vol_d,menu,z,z0,z1,bass,treb,in,gain0,gain1,gain2,gain3,gain4,gain5;
  bool w,w1,www;
  

void setup(){ 
 Wire.begin();Serial.begin(9600);
 lcd.init();lcd.backlight();
 MsTimer2::set(1, to_Timer);MsTimer2::start();
 pinMode(IN,INPUT_PULLUP); 
 lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
 lcd.setCursor(4,0);lcd.print("TDA7461");
 delay(2000);lcd.clear();
 vol = EEPROM.read(0);bass = EEPROM.read(1)-7;treb = EEPROM.read(2)-7;
 gain1 = EEPROM.read(3);gain2 = EEPROM.read(4);gain3 = EEPROM.read(5);gain4 = EEPROM.read(6);gain5 = EEPROM.read(7);
 audio();
}

void loop(){
  if(digitalRead(SW)==LOW){menu++;if(menu>2){menu=0;}lcd.clear();times=millis();w=1;w1=1;www=1;delay(200);}
  if(digitalRead(IN)==LOW){in++;menu=10;if(in>4){in=0;}lcd.clear();times=millis();tda.setInput(in, 0, 0, gain0); w=1;w1=1;www=1;delay(200);}

/////////////// VOLUME /////////////////////////////////////////////////////////
 if(menu==0){
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   vol=vol+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w1=1;vol_func();tda.setVolume(vol, 1);}
   
   if(w1==1){
    vol_d=map(vol,111,0,0,48);
   for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}w1=0;
     lcd.setCursor(0,0);lcd.print("VOLUME ");
     lcd.setCursor(13,0);lcd.print(111-vol);lcd.print(" ");}
 }
////////////// BASS /////////////////////////////////////////////////////////
  if(menu==1){
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   bass=bass-newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w1=1;bass_func();tda.setBassTreb(bass, treb);}
  
   if(w1==1){
   for(z=0,z0=0,z1=0;z<=(bass*2+14+1);z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(F("   "));}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}w1=0;
   lcd.setCursor(0,0);lcd.print(F("BASS    "));
   if(bass>=0){lcd.print(F("+"));}lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print(F("dB"));}
  }
////////////// TREB /////////////////////////////////////////////////////////
  if(menu==2){
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   treb=treb-newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w1=1;treb_func();tda.setBassTreb(bass, treb);}
  
   if(w1==1){
   for(z=0,z0=0,z1=0;z<=(treb*2+14+1);z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(F("   "));}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}w1=0;
   lcd.setCursor(0,0);lcd.print(F("TREBLE  "));
   if(treb>=0){lcd.print(F("+"));}lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print(F("dB"));}
  }  

///// INPUT GAIN
if(menu==10){ 
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     case 4: gain0 = gain5;break;
     }
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0-newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     case 3: gain4 = gain0;break;
     case 4: gain5 = gain0;break;
     }
 
  if(www==1){www=0;tda.setInput(in, 0, 0, gain0);}
  lcd.setCursor(4,0);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(3,1);lcd.print("GAIN ");lcd.print(gain0*2);lcd.print(" ");lcd.setCursor(10,1);lcd.print("dB ");
   }  
  
//////// EEPROM //////////////////////////////////////////////////
  if(millis()-times>5000 && w==1){
    EEPROM.update(0,vol);EEPROM.update(1,bass+7);EEPROM.update(2,treb+7);
    EEPROM.update(3,gain1);EEPROM.update(4,gain2);EEPROM.update(5,gain3);EEPROM.update(6,gain4);EEPROM.update(7,gain5);
  w=0;menu=0;w1=1;lcd.clear();}
   
} 

void vol_func(){if(vol>111){vol=111;}if(vol<0){vol=0;}}
void gain_func(){if(gain0>7){gain0=7;}if(gain0<0){gain0=0;}}
void bass_func(){if(bass>7){bass=7;}if(bass<-7){bass=-7;}}
void treb_func(){if(treb>7){treb=7;}if(treb<-7){treb=-7;}}

void audio(){
  ///  Input selector          
     tda.setInput(in, 0, 0, gain0); 
// int source = 0...7 >>> CD
//                        Cassette
//                        Phone
//                        AM
//                        Stereo Decoder
//                        Input FM
//                        Mute
//                        AC inputs  
// bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff   
// int am_fm = 0...3 >>> AM mono
//                       AM stereo
//                       AM through Stereo decoder
//                       FM- Stereo decoder
// int in_gain = 0...7 >>>  14...0 dB step 2 dB
     ///  Loudness         
     tda.setLoudness(0, 0, 0, 0); 
// int loud_att = 0...15 >>> 0...-15 dB
// bool loud_filter = 0...1 >>> on...off
// bool loud_f = 0...1 >>> 200...400 Hz
// bool loud_q = 0...1 >>> low...normal
     ///   Mute, Beep and Mixing        
     tda.setSoftmute(1, 0, 1, 0, 0, 3);    
// int mute = 0...1 >>> Softmute = Enable...Disable 
// int mute_time 0...3 >> Mute time = 0.48, 0.96, 40.4, 324 ms
// bool stereo_dec = 0...1 >>> Stereo decoder softmute influence = off...on
// bool beep = 0...1 >>> Beep Frequency = 600 Hz...1.2 kHz
// bool mixing_0 = 0...1 >>> Mix-Source = Beep...Phone
// bool mixing_1 = 0...3 >>> Full Mix Signal
//                           Source -12 dB + Mix-Signal -2.5 dB
//                           Source -6 dB + Mix-Signal -6 dB
//                           Full Source
     ///   Volume       
     tda.setVolume(vol, 1); 
// int vol = 0...111 >>> +32...-79 dB
// bool soft_step = 0...1 >>> Soft step volume = off...on
     ///   Bass and treble attenuation       
     tda.setBassTreb(bass, treb); 
// int bass = -14...14 >>> -14...+14 dB step 2 dB
// int treb = -14...14 >>> -14...+14 dB step 2 dB
     ///   Bass and treble filter characteristics      
     tda.setBassTrebConf(0, 0, 0, 0, 0);
// int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
// int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
// int bass_q = 0...3 >>> 1, 1.25, 1.5, 2 
// bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
// bool ac_coupling = 0...1 >>> For External Connection...Internally Connection
     /// ATT (LF, LR, RF, RR)
     tda.attLF(0); // int 0...31 >>> 0...-50 dB
     tda.attLR(0); // int 0...31 >>> 0...-50 dB
     tda.attRF(0); // int 0...31 >>> 0...-50 dB
     tda.attRR(0); // int 0...31 >>> 0...-50 dB
     ///  Stereo decoder
     tda.setStereo(0, 0, 0, 1, 1, 0);
// bool std = 0..1 >>> STD unmuted...muted
// int in_gain_dec = 0...3 >>> IN-Gain 11, 8.5, 6, 3.5 dB
// bool dec = 0...1 >>> Stereo decoder Unmuted with Stdec. 
//                      Stereo decoder Unmuted whichever is the selected source.
// bool mono_stereo = 0...1 >>> Forced mono...Mono/stereo switch automatically
// bool pilot = 0...1 >>> Pilot threshold high...low
// bool emp = 0...1 >>> De-emphasis 50...75 μs
     ///  Noise blanker
     tda.setBlanker(0, 0, 0, 3);
// int threshold_0 = 0...7 >>> Low threshold 65, 60, 55, 50, 45, 40, 35, 30 mV
// int threshold_1 = 0...3 >>> Noise controlled threshold 320, 260, 200, 140 mV
// bool blank = 0...1 >>> Noise blanker off...on
// int over = 0...3 >>> Over deviation adjust 2.8V, 2.0V, 1.2V, off
     /// Field strength control
     tda.setField(3, 0, 0, 0, 0);
// int adj = 0...3 >>> Noise blanker Field strength Adj 2.3V, 1.8V, 1.3V, off
// int vsbl = 0...3 >>> VSBL at 33%, 42%, 50%, 58%
// int vhch = 0...3 >>> VHCH at 42%, 50%, 58%, 66%
// bool vhcl = 0...1 >>> VHCL at 17%, 33%
// bool cut = 0...1 >>> High cut OFF...ON
     /// Configuration
     tda.setConf(0, 0, 1, 3);
// int rez = 0...3 >>> infinite, 56kOm, 33kOm, 18kOm
// int band_gain = 0...3 >>> 6, 16, 12, 18 dB
// bool mult = 0...1 >>> Multipath detector internal influence On...Off
// int mult_gain = 0...3 >>> Gain = 7.6 dB 4.6 dB, 0 dB, Off
     /// Stereo decoder adjustment
     tda.setSDecoder(0,0, 1);
// int compens = 0...7 >>> not...31%
// int level_gain = 0...15 >>> 0...10 dB step 0.66dB
// bool temp = 0...1 >>> TC = 0...16.7 mV/K (3300 ppm)
     /// Testing
     tda.setTest(0b11111110);
// default test = 0b11111110 (Table 25)
  }
 
void to_Timer(){newPosition = myEnc.read()/4;}