Sound Output despite sgtl5000.volume(0) ?

Status
Not open for further replies.
D

DeletedUser

Guest
Hi Folks,

I'm doing the initial bringup on a synth and a bug is bothering me. I want to sort it out before I proceed. I'm running Teensy 4.0 and an Audio Board Rev D.

The first thing I want to do is generate a sinewave and use a potentiometer to control the main output volume using sgtl5000.volume().

I noticed that I could never get the volume to go completely silent. I thought that maybe I had a mapping error, so I manually type sgtl5000.volume(0), but I still hear a sine wave.

Is this expected behavior, or do I have an interference problem inside my audio board?

Here is my example code. I hear a faint sinewave when I plug my open backed headphones into my audio board and run this program. Thank you for your help!

Code:
// Synth Bringup
// Chris, Praj, and Stefan

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

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=92,164
AudioOutputI2S           i2s1;           //xy=332.5714111328125,164.57143592834473
AudioConnection          patchCord1(waveform1, 0, i2s1, 0);
AudioConnection          patchCord2(waveform1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=171.71429443359375,261.71427059173584
// GUItool: end automatically generated code

//Main Output
float volumeFactor = 0.3;
float mainVolume = 1;

//hardware controls
int volumePin = A3;

void setup () {
  AudioMemory(160);
  //Serial.begin(115200);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0);

  waveform1.begin(1,880,WAVEFORM_SINE);
}

void loop () {
}
 
Hello again,

I fixed the issue by adding an amp in my audio graph and using the amp gain to achieve the intended function. I'm just going to set sgtl5000_1.volume() once in setup() and then leave it alone. Maybe I was using it in a non intended manner.

Thank you,
Chris

Code:
// Synth Bringup
// Chris, Praj, and Stefan

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

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=333,192
AudioAmplifier           mainOut;           //xy=560,193
AudioOutputI2S           i2s1;           //xy=767,188
AudioConnection          patchCord1(waveform1, mainOut);
AudioConnection          patchCord2(mainOut, 0, i2s1, 0);
AudioConnection          patchCord3(mainOut, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=567,310
// GUItool: end automatically generated code


//Main Output
float volumeFactor = 0.3;
float mainVolume = 1;

//hardware controls
int volumePin = A3;

//forward declarations
void readHardwareControls();

void setup () {
  AudioMemory(160);
  //Serial.begin(115200);
  sgtl5000_1.enable();
  sgtl5000_1.volume(volumeFactor);

  waveform1.begin(1,880,WAVEFORM_SINE);
}

void loop () {
  readHardwareControls();
}

void readHardwareControls() {
  mainVolume = ((float)analogRead(volumePin) * (float)analogRead(volumePin)) / 1046529;
  mainOut.gain(mainVolume);
}
 
Status
Not open for further replies.
Back
Top