Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad LineOut audio when muteHeadPhone() is called #467

Open
nodemand opened this issue Oct 4, 2023 · 0 comments
Open

Bad LineOut audio when muteHeadPhone() is called #467

nodemand opened this issue Oct 4, 2023 · 0 comments

Comments

@nodemand
Copy link

nodemand commented Oct 4, 2023

Description

When I call the AudioControlSGTL5000::volume() function with a value of 0.00 which in effect calls the muteHeadPhone() function, the LineOut audio goes bad.

Steps To Reproduce Problem

A call to AudioControlSGTL5000::volume(0.00) will make the LineOut audio go bad. When I remove the call to muteHeadPhone() from AudioControlSGTL5000::volumeInteger(), the problem is gone and the LineOut audio is ok again.

Hardware & Software

Board: Teensy 4.0
Shields / modules used: Teensy Audio Shield Rev. D2
Arduino IDE version: 2.2.1
Teensyduino version: 1.58.1
Operating system & version: macOS Ventura 13.6

Arduino Sketch

#include <Audio.h>
#include <utility/imxrt_hw.h>

AudioInputI2S            in;           //xy=184,239
AudioOutputI2S           out;           //xy=556,246
AudioConnection          patchCord1(in, 0, out, 0);
AudioConnection          patchCord2(in, 1, out, 1);
AudioControlSGTL5000     codec;     //xy=416,138

void setup() {
  AudioMemory(1024);
  setI2SFreq(192000);
  codec.muteLineout();
  codec.enable();
  codec.inputSelect(AUDIO_INPUT_LINEIN);
  codec.volume(0.8);
  codec.unmuteLineout();
}

void loop() {
  codec.volume(0.00); // THIS IS WHERE IT GOES SOUTH!
}

void setI2SFreq(int freq) {  //Teensy 4
  // PLL between 27*24 = 648MHz und 54*24=1296MHz
  int n1 = 4;  //SAI prescaler 4 => (n1*n2) = multiple of 4
  int n2 = 1 + (24000000 * 27) / (freq * 256 * n1);
  double C = ((double)freq * 256 * n1 * n2) / 24000000;
  int c0 = C;
  int c2 = 10000;
  int c1 = C * c2 - (c0 * c2);
  set_audioClock(c0, c1, c2, true);
  CCM_CS1CDR = (CCM_CS1CDR & ~(CCM_CS1CDR_SAI1_CLK_PRED_MASK | CCM_CS1CDR_SAI1_CLK_PODF_MASK))
               | CCM_CS1CDR_SAI1_CLK_PRED(n1 - 1)   // &0x07
               | CCM_CS1CDR_SAI1_CLK_PODF(n2 - 1);  // &0x3f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant