audio library, volume doesn't affect

Status
Not open for further replies.

byungjun

Member
hello,

now i'm trying the examples while all the connection made including line-in/out and mic input.
everthing just works like charm but the volume doesn't affect any change.
even though i set it to 0, i still hear the sound as it was before.
am i missing something?
below is the example Pass Through Stereo code and i just changed the volume to be 0 but i still hear the sound coming from the line-in.

Code:
/*
 * A simple hardware test which receives audio from the audio shield
 * Line-In pins and send it to the Line-Out pins and headphone jack.
 *
 * This example code is in the public domain.
 */

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=200,69
AudioOutputI2S           i2s2;           //xy=365,94
AudioConnection          patchCord1(i2s1, 0, i2s2, 0);
AudioConnection          patchCord2(i2s1, 1, i2s2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=302,184
// GUItool: end automatically generated code


const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;


void setup() {
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(12);

  // Enable the audio shield, select input, and enable output
  sgtl5000_1.enable();
  sgtl5000_1.inputSelect(myInput);
  sgtl5000_1.volume(0);
}

elapsedMillis volmsec=0;

void loop() {
  /*
  // every 50 ms, adjust the volume
  if (volmsec > 50) {
    float vol = analogRead(15);
    vol = vol / 1023.0;
    //audioShield.volume(vol); // <-- uncomment if you have the optional
    volmsec = 0;               //     volume pot on your audio shield
  }
  */
}


best, jun
 
Last edited:
now i check that headphone-out is working fine as it should be.
but the line-outs doesn't get any change from ,
sgtl5000_1.volume(0);

jun
 
That is correct. if you look at the documentation,

volume(level);

Set the headphone volume level. Range is 0 to 1.0, but 0.8 corresponds to the maximum undistorted output for a full scale signal. Usually 0.5 is a comfortable listening level. The line level outputs are not changed by this function.

There isn't a corresponding function for line-out because line-out is expected to be at a standard level. You can make small adjustments using the lineOutLevel(both); function (see documentation link above). To vary the volume, use one channel of a mixer object and set the gain.
 
Status
Not open for further replies.
Back
Top