How to get audio output from dac pins on T3.5/3.6?

Status
Not open for further replies.

kobe12345

Member
I've read some discussions but still can't figure out how to get audio(SD card wav file) output from dac pins on T3.5/3.6.
I tested on T3.2 with audio shield it works fine. The file is ok, the speaker is ok, the sensor is ok.

Is there any example sketch that use dac output on T3.5/3.6?

Please help me out!
Thanks

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

// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=107,61
AudioPlaySdWav           playSdWav2;     //xy=108,126
AudioMixer4              mixer1;         //xy=429,117
AudioOutputAnalog        dac1;           //xy=766,61
AudioConnection          patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection          patchCord2(playSdWav1, 1, mixer1, 1);
AudioConnection          patchCord3(playSdWav2, 0, mixer1, 2);
AudioConnection          patchCord4(playSdWav2, 1, mixer1, 3);
AudioConnection          patchCord5(mixer1, dac1);
// GUItool: end automatically generated code


int last = 0;



const int chipSelect = BUILTIN_SDCARD;    

void setup() {
  Serial.begin(9600);

  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(8);

 pinMode(13, OUTPUT); // LED on pin 13
  mixer1.gain(0, 1);
  mixer1.gain(1, 1);
  mixer1.gain(2, 1);
  mixer1.gain(3, 1);
  delay(1000);
}

void loop() {
 int current = analogRead(A2);
  if (current > 70 && abs(current - last) > 7) {

    // decreasing
    if (current < last && playSdWav2.isPlaying() == false) {    
      Serial.println("Start playing 2");
      playSdWav1.stop();
      playSdWav2.play("out-16.wav");
      delay(200); // wait for library to parse WAV info
    }
    // increasing
    else if (current > last && playSdWav1.isPlaying() == false){
      Serial.println("Start playing 1, last = ");
      playSdWav2.stop();
      playSdWav1.play("in-16.wav");
      delay(200); // wait for library to parse WAV info
    }
 }

 last = current;
 Serial.println(current);
 delay(10);
}
 
Last edited:
The AudioMemory is very low (might be a part of the problem)

EDIT: Did you download the newest core, the SD.h and audio-lib from github ?
 
The AudioMemory is very low (might be a part of the problem)

EDIT: Did you download the newest core, the SD.h and audio-lib from github ?

Its from the example, so i didnt change it. It works good on T3.2, so i dont think thats the problem.
 
I tried adding stereo ADC support yesterday, and I ran into strange problems. Might be issues with the new stereo DAC code. Has anyone else tried it yet? Maybe I really need to push out another beta quickly, and we'll have a 4th beta to freeze features?
 
Might be good idea.

What were the issues, you ran into? I know with my first attempt of two separate Analog drivers I was running into issues with the same source trying to drive both... Tomorrow I hope to solder my V.1 version of board similar to Frank's flex board, which should hook up DAC0. At that point, I can probably use my partially assembled board that I was doing the 1 DAC testing yesterday or was it Saturday.
 
Hello,i want to play in a teensy 3.6 audio example "quitar".
What speakers can connect the dac0 pin??
Here it is directly connected to the sound system??
 
The DAC pin is not able to directly drive any speaker. An amplifier is required.

PAM8302 looks like it will work, but it has too much gain for direct connection. This Adafruit board has a pot to attenuate the signal, so it should work. If you build your own, be sure to include something like the pot Adafruit used.
 
Will use the pam8302,the A- connected at gnd and A+ connected at DAC0 pin the teensy,correctly??
Generally the audio library uses DAC0 and DAC1 pins or DAC0 pin??
Τhe examples who has the audio library what DAC pin use??
 
Last edited:
That depends on the output you use... :)
"DAC" uses the the "DAC" Pin on T3.1 / 3.2, "DAC0" on 3.5/3.6
"DACS" both of course, "DAC0" and "DAC1"
 
The truth is that i'm confused,i just want playing wav files from sd card.
In the terminal A+ to pam8302 you need to connect DAC0 pin or another??
like here(6:40 time),from the DAC0 port you can play wav files??
Can someone explain me??
 
Last edited:
For what it is worth on a couple of my boards, I use a LM4862M amplifier that I connect up to a small speaker on my board. It hooks up to DAC0

T3.6-Dac0.jpg

I have not played too much yet with stuff from Audio library, but have used for example the speak text code to be able to output to it...
 
Thanos, just try the waveplayer example, with a 44.1KHz, stereo wavefile.

I don't watch "tutorial videos", I prefer text to read.

A Question, do you have the hardware ? Just try it, it might be easier than you're thinking...

Edit:
For a beginner, it might be easier to just buy the Audio Shield.
Solder pinheaders of our choice, plug in your headphones. Done.
 
Last edited:
Firstly thank you for your answers,frank no i do not have something to try for this asks.
Design a my own board and i want to be sure about the connections but now i understood.
Thanks.
 
Pardon my ignorance, but how exactly would one connect the DAC output of a Teensy 3.2 to a small mono amplifier like this one I bought from Sparkfun?

https://www.sparkfun.com/tutorials/392

I see the A14/DAC pin on the Teensy 3.2 diagram. Does that connect to the + Line In on the amp? Does the - Line In come from the ground?

I DO have the Teensy audio shield, but space is limited within my handheld prop, so omitting that from the prop would greatly simplify things. My hope would be to convert two short (5-8 sec) sound effects snippets using WAV2Sketch, trigger those from memory using touch switches (sound effect loops while button is touched), output to the DAC, amplify that and output to a small speaker.

I spent over three hours last night watching and experimenting with the Audio tutorial. I understand some of it. I think I have to completely rework the approach I described in this thread over a year ago.

https://forum.pjrc.com/threads/3122...udio-clips-with-pushbuttons?p=86825#post86825

I work slowly.

Thank you.

Shawn Marshall
 
Status
Not open for further replies.
Back
Top