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

Thread: Problem changing AudioMixer4 gain in library

Threaded View

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    6

    Problem changing AudioMixer4 gain in library

    Hi,
    I am attempting to make a device that plays back multiple wav files and runs them through effects.

    I also want to use a seven segment display as an interface and to have a few encoders control multiple parameters. To handle all these states I am using the automaton library by tinkerspy: https://github.com/tinkerspy/Automaton

    I made some proof of concept sketches to familiarize myself with the audio library, and I was able to control AudioMixer4 objects using pots with no problem.

    In my current code, I am trying to split different parts of the program into different state machine libraries. One of the machines I am trying to build is a volume controller that will control either master volume (sgtl5000_1.volume()) or different instance of the wav player's volume by changing the appropriate mixer gain.

    When I split things up, controlling the sgtl5000 works, but controlling mixer gain does not.
    I have tried setting up and including the mixers every way that I can think of, but even when it compiles and runs, none of the commands to the mixers in Atm_master_vol.cpp have any effect.

    I did something similar to the Atm_master_vol.setVolume in an earlier sketch this way, and it worked:

    void SetMasterVolume(int level) {
    // read the knob position for master volume(analog input A2)
    float vol = (float)level / 1280.0;
    sgtl5000_1.volume(vol);
    //Serial.print("volume = ");
    //Serial.println(vol);
    }

    void SetFeedbackLevel(int level) {
    // uncomment for A3 knob to control the feedback level
    float feedback = (float)level / 1050.0;
    mixer2.gain(1, feedback);
    }

    however when i try to do it in the library, only the sgtl5000 volume control is working. I have sgtl5000 and the AudioMixer4 objects declared the same way in audio_system_mix.h.

    //audio_system_mix.h
    #pragma once
    //#include "audio_system.h"
    //#include <Audio.h>
    //audio library
    static AudioMixer4 mixer2; //xy=568,393
    static AudioMixer4 mixer1; //xy=575,263
    static AudioMixer4 mixer4; //xy=760,403
    static AudioMixer4 mixer3; //xy=765,263
    static AudioControlSGTL5000 sgtl5000_1; //xy=744,575

    Can you please help me understand why i can change the sftl5000 volume and not mixer3 or mixer4 .gain?



    Thank you!

    Full source can be found here: https://github.com/radiorpl/Atm_bira_teensy
    Last edited by radiorpl; 08-07-2017 at 03:26 AM.

Tags for this Thread

Posting Permissions

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