Moving forward with 4.1 For USB audio

donperryjm

Well-known member
So I've enjoyed using the ADC of the 3.x, process some sounds and then route that to USB audio.
In the 4.1 this isn't possible (or at least isn't working)

What can we use for ADC and then USB output in the 4.1?

for the ADC i'm looking on PCM1860DBT
 
Last edited:
Just a few days ago I improved the ADC support for Teensy 4.0 & 4.1 in the audio library. The new code is currently only on github, so if you want to try it before a 1.57-beta1 installer, you'll need to install a copy of the library downloaded from github.

The on-chip ADC is tends to pick up noise from the digital circuitry on the chip. This same problem exists on Teensy 3.2, 3.5, 3.6, 4.0, 4.1. To overcome this noise, a low impedance (strong) drive onto the ADC pin is needed.

PCM1860 looks like a very good part. It will give much better quality audio than using the ADC pin. I glanced at the datasheet briefly. Looks like it should "just work" if you use the hardware pin config for I2S.
 
Just a few days ago I improved the ADC support for Teensy 4.0 & 4.1 in the audio library. The new code is currently only on github, so if you want to try it before a 1.57-beta1 installer, you'll need to install a copy of the library downloaded from github.

Can you direct me to this url please? I'm only finding older stuff.
 
thanks mark

Is there a mislabelling here? On the I2s input help guide it states pin 8 as input, but on the T4.1 card it states pin 7
Untitled.png
 
OK. I tested your latest adc input cpp.

Still no audio through the USB. Tested 4.1 and 4.0. Tested diff input pins.

I have a 3.5 that I test also, and it works with that, just not the 4.x.
 
Starting to wonder if my problem is in the input part of the library and not the output as others on here has been using the usb output just fine.

Edit:

I made a tone generation test file, and still no USB. I'm using the teensy version 1.55

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <avr/wdt.h>
elapsedMillis thresholdTime;
#include "settings.h"

 
 
 

// GUItool: begin automatically generated code
AudioSynthToneSweep      tonesweep1;     //xy=307,175
AudioOutputUSB           usb2;           //xy=747,349
AudioConnection          patchCord1(tonesweep1, 0, usb2, 0);
AudioConnection          patchCord2(tonesweep1, 0, usb2, 1);
// GUItool: end automatically generated code



void setup()
{
	analogReadResolution(13);
	AudioMemory(6);
	tonesweep1.play(10, 400, 5000, 100);

	 
}
void loop()
{
}
 
Last edited:
You need at least 1 other hardware input or output which causes the entire audio library to update.

Tonesweep also requires input range from 0 to 1.0 for level. Try running this on your Teensy 4.1.

Code:
#include <Audio.h>

AudioSynthToneSweep      tonesweep1;     //xy=307,175
AudioOutputUSB           usb2;           //xy=747,349
AudioConnection          patchCord1(tonesweep1, 0, usb2, 0);
AudioConnection          patchCord2(tonesweep1, 0, usb2, 1);

AudioOutputI2S           unused_but_needed_output;

void setup() {
  AudioMemory(16);
}

void loop() {
  tonesweep1.play(0.95, 60, 5000, 2);
  while (tonesweep1.isPlaying()) {
    // wait while the tone plays
  }
  delay(500); // half second of silence before restarting
}
 
Paul, I now have audio coming out of the T4 USB!

that one line did the trick
Code:
AudioOutputI2S           unused_but_needed_output;

This wasn't needed in my 3.5 project, but surely does work in the 4.x

I await the new pcb and I2S device to test the audio input >process> usb output.

Thanks!
 
pcm1860DBT (Custom).JPG
pinout pcm1860.jpg

How does this pinout wire up look according to the excerpt from the PCM1860 datasheet? I used the same name label names of the 4.1 teensy pins (where applicable.)

What would code for passthrough to USB look like?
 
Not sure what Im doing wrong, here is my schematic.

s1.jpg
and this is the audio routing/ design
Code:
// GUItool: begin automatically generated code
AudioInputI2S2           i2s2_1;         //xy=430,369
AudioFilterBiquad        biquad1L;       //xy=629,355
AudioFilterBiquad        biquad1R;        //xy=643,461
AudioAmplifier           amp1R;           //xy=786,461
AudioAmplifier           amp1L;          //xy=802,365
AudioAnalyzePeak         peakL;          //xy=992,357
AudioOutputUSB           usb2;           //xy=1002,552
AudioAnalyzePeak         peakR;          //xy=1047,669
AudioConnection          patchCord1(i2s2_1, 0, biquad1L, 0);
AudioConnection          patchCord2(i2s2_1, 1, biquad1R, 0);
AudioConnection          patchCord3(biquad1L, amp1L);
AudioConnection          patchCord4(biquad1R, amp1R);
AudioConnection          patchCord5(amp1R, 0, usb2, 1);
AudioConnection          patchCord6(amp1R, peakR);
AudioConnection          patchCord7(amp1L, peakL);
AudioConnection          patchCord8(amp1L, 0, usb2, 0);
// GUItool: end automatically generated code

not getting anything out of it.

I had replaced analog input with the i2S input source that is there now.
 
here is my schematic.
....
and this is the audio routing/ design

This isn't enough to be able see or even make a reasonable guess about what's wrong.

Normally a schematic would clearly show which pins of the ADC chip connect to which pins on Teensy. But Teensy isn't even shown. The net names attached to each pin have no indication about which pin on the unseen Teensy they might connect.

Likewise, the audio design alone isn't enough. How your program initializes the biquad filter and amp matter. Simple mistakes like forgetting AudioMemory() can also cause an otherwise good design to give no sound.

I want to help you, but I can't with so little info. I have very limited time on this forum recently. Supply chain issues are taking almost all of my attention. But still, I spent time to write this message, which could have been time actually trying to solve your problem, but instead that time went into writing this message to help you understand how to better ask for help.
 
s1.jpgteensy1.jpg3.jpg

I basically ported the code from the old project where i used analog input instead of this i2s chip.


/**********************************SINGLE CHANNEL*******************************/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
elapsedMillis thresholdTime;



// GUItool: begin automatically generated code
AudioInputI2S2 i2s1; //xy=430,369
AudioFilterBiquad biquadL; //xy=629,355
AudioFilterBiquad biquadR; //xy=643,461
AudioAmplifier ampR; //xy=786,461
AudioAmplifier ampL; //xy=802,365
AudioAnalyzePeak peakL; //xy=992,357
AudioOutputUSB usb2; //xy=1002,552
AudioAnalyzePeak peakR; //xy=1047,669
AudioConnection patchCord1(i2s1, 0, biquadL, 0);
AudioConnection patchCord2(i2s1, 1, biquadR, 0);
AudioConnection patchCord3(biquadL, ampL);
AudioConnection patchCord4(biquadR, ampR);
AudioConnection patchCord5(ampR, 0, usb2, 1);
AudioConnection patchCord6(ampR, peakR);
AudioConnection patchCord7(ampL, peakL);
AudioConnection patchCord8(ampL, 0, usb2, 0);
// GUItool: end automatically generated code


AudioOutputI2S unused_but_needed_output;



void setup()
{
analogReadAveraging(1);

pinMode(35, INPUT);

analogReadResolution(12);
AudioMemory(6);

LoadSettings();
}

//this section worked flawlessly in the previous design, using pure ADC instead of i2s
void LoadSettings()
{


ampL.gain(2);
ampR.gain(2);


biquadL.setHighpass(0, 200, 1.5); //1.5 was 2.0
biquadR.setHighpass(0, 200, 1.5); //1.5 was 2.0
biquadL.setLowpass(1, 6000, 1.5); //1.5 was 2.0
biquadR.setLowpass(1, 6000, 1.5); //1.5 was 2.0


}

void loop()
{



}
 

Attachments

  • teensy1.jpg
    teensy1.jpg
    70.1 KB · Views: 43
If you're struggling to get this chip to just work at all, going from simple hardware config to complicated software config is probably not a path to success.

You can configure all the essential settings by simply connecting these pins high or low.

screenshot.png

You can always try the more complicated approach later, but first just get the chip working with basic functionality. Then when you're experimenting with I2C config, you can know at least everything else is wired and working correctly.
 
Before I spend more time on this, can I see a photo of the actual hardware you've built?

Please also show me the complete test program you're running? I understand you are developing a proprietary application and you do not wish to show much of your work or give anything in public which might help competitors. But this thread is simply about using a particular codec chip, and my motivation to put time into help you is also to have this public conversation serve as info for anyone else who might wish to connect this particular chip.

But before I pour more time into trying to help you get your commercial project working, I really want to see new up-to-date code and schematic and hardware photo, not just the stuff you posted 8 months ago (especially the code, which should have been edited based on msg #16-17). I'm sure you can do at least this without disclosing anything too sensitive or proprietary.
 
1.jpg

5e.jpg

4.jpg
20221229_182101.jpg 20221229_182046 (1).jpg



I've attached:
Schematic of audio input circuit (resistor values slightly different for attenuating the input, works in version without audio chip)
audio chip and it's connection to the T4
T4 and connection to Audio chip.

Code:
/**********************************SINGLE CHANNEL*******************************/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
elapsedMillis thresholdTime;



// GUItool: begin automatically generated code
AudioInputI2S2 i2s1; //xy=430,369
AudioFilterBiquad biquadL; //xy=629,355
AudioFilterBiquad biquadR; //xy=643,461
AudioAmplifier ampR; //xy=786,461
AudioAmplifier ampL; //xy=802,365
AudioAnalyzePeak peakL; //xy=992,357
AudioOutputUSB usb2; //xy=1002,552
AudioAnalyzePeak peakR; //xy=1047,669
AudioConnection patchCord1(i2s1, 0, biquadL, 0);
AudioConnection patchCord2(i2s1, 1, biquadR, 0);
AudioConnection patchCord3(biquadL, ampL);
AudioConnection patchCord4(biquadR, ampR);
AudioConnection patchCord5(ampR, 0, usb2, 1);
AudioConnection patchCord6(ampR, peakR);
AudioConnection patchCord7(ampL, peakL);
AudioConnection patchCord8(ampL, 0, usb2, 0);
// GUItool: end automatically generated code


AudioOutputI2S unused_but_needed_output;



void setup()
{
analogReadAveraging(1);

pinMode(35, INPUT);

analogReadResolution(12);
AudioMemory(6);

LoadSettings();
}

//this section worked flawlessly in the previous design, using pure ADC instead of i2s
void LoadSettings()
{


ampL.gain(2);
ampR.gain(2);


biquadL.setHighpass(0, 200, 1.5); //1.5 was 2.0
biquadR.setHighpass(0, 200, 1.5); //1.5 was 2.0
biquadL.setLowpass(1, 6000, 1.5); //1.5 was 2.0
biquadR.setLowpass(1, 6000, 1.5); //1.5 was 2.0


}

void loop()
{



}
 

Attachments

  • 2.jpg
    2.jpg
    24.6 KB · Views: 22
  • 4.png
    4.png
    15.5 KB · Views: 33
  • 5e.jpg
    5e.jpg
    43.4 KB · Views: 25
Last edited:
Please show the test program you're running on Teensy 4.1. Maybe it will be very similar to msg #15, but should have the issue addressed from msg #16 & 17. Small details matter, so the actual code used the test the hardware is essential.
 
Fixed the info above with code and readable schematic.
I should have the breakout board for this chip here next weekend or so. I could mail you one, Paul.
 
Last edited:
Back
Top