Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Audio amplifier object library

  1. #1
    Junior Member
    Join Date
    May 2018
    Posts
    3

    Audio amplifier object library

    Hello

    I'm working on a simple equalizer sketch, using the chamberling filter and 2 biquad filters, and 3 amps... I'm using the "Audio System Design Tool" for "Teensy Audio Library" to make the conections betwen the components, as shown below

    Click image for larger version. 

Name:	eq.jpg 
Views:	36 
Size:	56.2 KB 
ID:	13744

    My problem is that the object "AudioAmplifier" does not exist on my audio libraries, I found the audio.h library on this link https://github.com/PaulStoffregen/Au...master/Audio.h and there is no "AudioAmplifier" included,

    where can I find this library or object? Is an actualization that I did not found, or it does not exist yet? I imagine that is easy to write this object library but I am new on arduino and I can't do this.

    PD: sorry for my english, my mother language is spanish. And I don't know why the wires doesn't appear on the "audio system design tool"

    And this is the code, I'm using a example audio sketch.

    Code:
    // Advanced Microcontroller-based Audio Workshop
    //
    // http://www.pjrc.com/store/audio_tutorial_kit.html
    // https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
    // 
    // Part 2-7: Filters
    
    #include <Bounce.h>
    
    
    ///////////////////////////////////
    // copy the Design Tool code here
    ///////////////////////////////////
    
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputI2S            i2s1; //xy=62,114
    AudioMixer4              mixer1; //xy=205,127
    AudioFilterStateVariable filter1;        //xy=359,72
    AudioFilterBiquad        biquad2; //xy=360,173
    AudioFilterBiquad        biquad1;        //xy=361,127
    AudioAmplifier           amp3; //xy=498,59
    AudioAmplifier           amp2; //xy=498,173
    AudioAmplifier           amp1;           //xy=499,127
    AudioMixer4              mixer2;         //xy=652,133
    AudioOutputI2S           i2s2;           //xy=792,135
    AudioConnection          patchCord1(i2s1, 0, mixer1, 0);
    AudioConnection          patchCord2(i2s1, 1, mixer1, 1);
    AudioConnection          patchCord3(mixer1, 0, filter1, 0);
    AudioConnection          patchCord4(mixer1, biquad1);
    AudioConnection          patchCord5(mixer1, biquad2);
    AudioConnection          patchCord6(filter1, 0, amp3, 0);
    AudioConnection          patchCord7(biquad2, amp2);
    AudioConnection          patchCord8(biquad1, amp1);
    AudioConnection          patchCord9(amp3, 0, mixer2, 0);
    AudioConnection          patchCord10(amp2, 0, mixer2, 2);
    AudioConnection          patchCord11(amp1, 0, mixer2, 1);
    AudioConnection          patchCord12(mixer2, 0, i2s2, 0);
    AudioConnection          patchCord13(mixer2, 0, i2s2, 1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=444,264
    // GUItool: end automatically generated code
    
    // Use these with the Teensy Audio Shield
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    
    // Use these with the Teensy 3.5 & 3.6 SD card
    //#define SDCARD_CS_PIN    BUILTIN_SDCARD
    //#define SDCARD_MOSI_PIN  11  // not actually used
    //#define SDCARD_SCK_PIN   13  // not actually used
    
    // Use these for the SD+Wiz820 or other adaptors
    //#define SDCARD_CS_PIN    4
    //#define SDCARD_MOSI_PIN  11
    //#define SDCARD_SCK_PIN   13
    
    int freq1 = 330;
    float q1 = 0.707;
    int freq2 = 1044;
    float q2 = 1044/2970;
    int freq3 = 3300;
    int a1history=0, a2history=0, a3history=0;
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(12);
      
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      delay(1000);
      
      filter1.frequency(freq1);
      filter1.resonance(q1);
      biquad1.setBandpass(0,freq2,q2);
      biquad2.setHighpass(0,freq3,q1);
      
      a1history = analogRead(A14);
      a2history = analogRead(A15);
      a3history = analogRead(A16);
    }
    
    void loop() {
    
      int a1 = analogRead(A14); //0 - 1023 analog read
      int a2 = analogRead(A15);
      int a3 = analogRead(A16);
      
      if (a1 > a1history + 10 || a1 < a1history - 10) {
        Serial.print("Ganancia a1 =");
        Serial.println(a1);
        a1history = a1;
        float gain1 = (float)a1 / 1024;
        amp3.gain(gain1);
      }
      if (a2 > a2history + 10 || a2 < a2history - 10) {
        Serial.print("Ganancia a2 =");
        Serial.println(a2);
        a2history = a2;
        float gain2 = (float)a2 / 1024;
        amp1.gain(gain2);
      }
      if (a1 > a3history + 10 || a3 < a3history - 10) {
        Serial.print("Ganancia a3 =");
        Serial.println(a3);
        a1history = a3;
        float gain3 = (float)a3 / 1024;
        amp2.gain(gain3);
      }
    }
    The error is:

    Code:
    Arduino:1.8.5 (Windows 10), TD: 1.41, Tarjeta:"Teensy 3.6, Serial, 180 MHz, Faster, US English"
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:27:1: error: 'AudioAmplifier' does not name a type
    
     AudioAmplifier           amp3; //xy=498,59
    
     ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:28:1: error: 'AudioAmplifier' does not name a type
    
     AudioAmplifier           amp2; //xy=498,173
    
     ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:29:1: error: 'AudioAmplifier' does not name a type
    
     AudioAmplifier           amp1;           //xy=499,127
    
     ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:37:49: error: 'amp3' was not declared in this scope
    
     AudioConnection          patchCord6(filter1, 0, amp3, 0);
    
                                                     ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:38:46: error: 'amp2' was not declared in this scope
    
     AudioConnection          patchCord7(biquad2, amp2);
    
                                                  ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:39:46: error: 'amp1' was not declared in this scope
    
     AudioConnection          patchCord8(biquad1, amp1);
    
                                                  ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:40:37: error: 'amp3' was not declared in this scope
    
     AudioConnection          patchCord9(amp3, 0, mixer2, 0);
    
                                         ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:41:38: error: 'amp2' was not declared in this scope
    
     AudioConnection          patchCord10(amp2, 0, mixer2, 2);
    
                                          ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:42:38: error: 'amp1' was not declared in this scope
    
     AudioConnection          patchCord11(amp1, 0, mixer2, 1);
    
                                          ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino: In function 'void loop()':
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:108:5: error: 'amp3' was not declared in this scope
    
         amp3.gain(gain1);
    
         ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:115:5: error: 'amp1' was not declared in this scope
    
         amp1.gain(gain2);
    
         ^
    
    C:\Users\jorge\Dropbox\IE0499 - Proyecto\Pruebas 1.2\6-Ecualizador_con_chamberlin\6-Ecualizador_con_chamberlin.ino:122:5: error: 'amp2' was not declared in this scope
    
         amp2.gain(gain3);
    
         ^
    
    Se encontraron múltiples librerías para "SD.h"
    Usado: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
     No usado: C:\Program Files (x86)\Arduino\libraries\SD
    Error compilando para la tarjeta Teensy 3.6.
    
    Este reporte podría tener más información con
    "Mostrar salida detallada durante la compilación"
    opción habilitada en Archivo -> Preferencias.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Quote Originally Posted by jorgeart17 View Post
    My problem is that the object "AudioAmplifier" does not exist on my audio libraries,
    So far it's only on github. You can get the ZIP file from github and use it to replace the copy in hardware/teensy/avr/libraries/Audio.

    I found the audio.h library on this link https://github.com/PaulStoffregen/Au...master/Audio.h and there is no "AudioAmplifier" included,
    It's defined within mixer.h.

    https://github.com/PaulStoffregen/Au...er/mixer.h#L68

  3. #3
    Junior Member
    Join Date
    May 2018
    Posts
    3
    Thank you very much, Paul... Teensy is amazing and it's great that you answer our doubts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •