TDM Output

Tengrii

Member
Hey.

I am trying the read TDM output from my Teensy 4.1. But it doesnt look like its working as it suppose.
i have taken a picture from my oscilloscope. I know the signal is a "bit" noisy :D
I was expecting to see something in the middle between the periods, because i did connect my "playsdWav" too 8 and 9, as it can be seen on my code.
My oscilloscope is on Pin 7 and Pin 20.

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


// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=301,501
AudioOutputTDM           tdm1;           //xy=511,580
AudioConnection          patchCord1(playSdWav1, 0, tdm1, 8);
AudioConnection          patchCord2(playSdWav1, 1, tdm1, 9);
// GUItool: end automatically generated code/
int ledPin= 13;



void setup() {
  
  pinMode(LED_BUILTIN, OUTPUT); //Quality of life to see when setup begins and ends
  pinMode(ledPin,OUTPUT);
  
  digitalWrite(LED_BUILTIN, HIGH);



  Serial.print("Programmet er nu startet");
 
  Serial.begin(9600);//Sætter intern baudrate mellem SD kort og SPI
  
  digitalWrite(LED_BUILTIN, LOW);
}



void loop()
{
  if (playSdWav1.isPlaying() == false) {

    playSdWav1.play("YEARS.wav");
    Serial.println("Playing track.");

    delay(10); // wait for library to parse WAV info
     }
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(ledPin,LOW);
      delay(1000);
  }
 

Attachments

  • Osc.jpg
    Osc.jpg
    74 KB · Views: 56
You're missing AudioMemory().

The audio library can't actually do anything unless you give it memory to use. Open any of the examples under File > Examples > Audio to see the syntax.

Here are the sort of waveforms you should see when it works.

cs42448_waveforms.png
 
Hey Paul.
I did put the AudioMemory function and i did put AudioMemoryUsageMax/AudioMemoryUsage and did print it on the monitor it just said 0.
I have uploaded my scope measurements. Maybe its in my software the problem is?
I am quite new to all this, so i hope its okay that i ask some newbie questions. Thank you very much.
 

Attachments

  • Oscny.jpg
    Oscny.jpg
    99.2 KB · Views: 50
  • 23.jpg
    23.jpg
    106.3 KB · Views: 56
  • 21.jpg
    21.jpg
    103.6 KB · Views: 75
Here is a much simpler test program which doesn't depend on the SD card working and having a readable file.

Code:
#include <Audio.h>

AudioSynthWaveformSine   sine1;          //xy=181,170
AudioSynthWaveformSine   sine2;          //xy=182,239
AudioSynthWaveformSine   sine3;          //xy=185,303
AudioOutputTDM           tdm1;           //xy=389,259
AudioConnection          patchCord1(sine1, 0, tdm1, 0);
AudioConnection          patchCord2(sine2, 0, tdm1, 4);
AudioConnection          patchCord3(sine3, 0, tdm1, 6);

void setup() {
  AudioMemory(40);
  sine1.amplitude(0.95);
  sine2.amplitude(0.95);
  sine3.amplitude(0.95);
  sine1.frequency(220);   // A3
  sine2.frequency(587.3); // D5
  sine3.frequency(0.25);  // very slow
}

void loop() {
}

I'm running it here on a Teensy 4.1. These are the waveforms on pins 20, 7, 21:

file.png

Hopefully this known good, zero dependency test program and this capture of its actual waveforms can help you get past this first difficult part where nothing seems to work?
 
Here is a much simpler test program which doesn't depend on the SD card working and having a readable file.

Code:
#include <Audio.h>

AudioSynthWaveformSine   sine1;          //xy=181,170
AudioSynthWaveformSine   sine2;          //xy=182,239
AudioSynthWaveformSine   sine3;          //xy=185,303
AudioOutputTDM           tdm1;           //xy=389,259
AudioConnection          patchCord1(sine1, 0, tdm1, 0);
AudioConnection          patchCord2(sine2, 0, tdm1, 4);
AudioConnection          patchCord3(sine3, 0, tdm1, 6);

void setup() {
  AudioMemory(40);
  sine1.amplitude(0.95);
  sine2.amplitude(0.95);
  sine3.amplitude(0.95);
  sine1.frequency(220);   // A3
  sine2.frequency(587.3); // D5
  sine3.frequency(0.25);  // very slow
}

void loop() {
}

I'm running it here on a Teensy 4.1. These are the waveforms on pins 20, 7, 21:

View attachment 21686

Hopefully this known good, zero dependency test program and this capture of its actual waveforms can help you get past this first difficult part where nothing seems to work?

Thank you very much Paul!

It did work with your test code, now i atleast know where to start with fixing my own test setup!!! Thanks again!!! :D
 
Back
Top