Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: TDM Output

  1. #1
    Junior Member
    Join Date
    Aug 2020
    Posts
    13

    TDM Output

    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
    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);
      }
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Osc.jpg 
Views:	9 
Size:	74.0 KB 
ID:	21666  

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    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.


  3. #3
    Junior Member
    Join Date
    Aug 2020
    Posts
    13
    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.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Oscny.jpg 
Views:	7 
Size:	99.2 KB 
ID:	21683   Click image for larger version. 

Name:	23.jpg 
Views:	5 
Size:	106.3 KB 
ID:	21684  

    Click image for larger version. 

Name:	21.jpg 
Views:	6 
Size:	103.6 KB 
ID:	21685  

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    Another quick look... SD.begin() is also missing, so it can't actually access the SD card.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    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:

    Click image for larger version. 

Name:	file.png 
Views:	8 
Size:	63.4 KB 
ID:	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?

  6. #6
    Junior Member
    Join Date
    Aug 2020
    Posts
    13
    Quote Originally Posted by PaulStoffregen View Post
    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:

    Click image for larger version. 

Name:	file.png 
Views:	8 
Size:	63.4 KB 
ID:	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!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •