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

Thread: Audioshield playing sound from SD and microphone

  1. #1
    Junior Member
    Join Date
    Jun 2019

    Audioshield playing sound from SD and microphone


    First of all thank you for this amazing project!

    My goal is mixing the sound of a headset microphone with sound playing from a SD card and playing it back on the headphone (high impedance headphone 150 ohm).

    I got most examples working but I'm having a few issues.

    1. Clicking sound in headset when using microphone and playing sound from SD card
    2. can't play sound from internal SD card (teensy 3.6)

    First issue:
    When playing sound from the sdcard (audio shield) and connecting both microphone and headphone from the same headset I get a clicking sound mixed in the music.
    The clicking sound stops if I remove the microphone wire or use a separate headphone (mic and headphones separated).
    If I play the sound stored in the teensy memory there is no clicking sound.
    If I use an external microphone amplifier they clicking noise stays, but when I connect the amplifier to a separate power supply the noise is not noticeable.
    When i connect the ground wires of the separate PSU's the noise is back.

    I suspect that there is some kind of noise introduced by reading the SD card on the power supply and it transfers though the wire of the headphone to the mic.

    I made some measurements of the 3.3V when playing sound from the SD card and when I stop playing from SD card.

    Image one is 3.3V rail no sound playing from SD card (CH1 is 3.3V from teensy, CH2 is 3.3V from separate PSU)
    Click image for larger version. 

Name:	DS1Z_QuickPrint3.png 
Views:	10 
Size:	56.2 KB 
ID:	16803

    Next Image is when the SD card is playing
    Click image for larger version. 

Name:	DS1Z_QuickPrint2.png 
Views:	13 
Size:	63.4 KB 
ID:	16804

    I tried adding 0.1F cap and 47F. The signal gets smaller but clicking sound stays the same.

    Any idea's to resolve this problem without the need of a separate PSU?

    Second issue:

    I tried fixing the SD card issue by using the internal SD card from the teensy 3.6.
    I changed the ports in the software but no sound is playing from the internal SD card. (If i do not insert SD card on the teensy i get an 'Unable to access the SD card', so its detecting the SD card)
    I tried the example listing all files on the internal SD-card and that is working fine.
    So no sound from internal SD card.

    Any idea's how I can get the internal SD card to work?

    • Arduino 1.8.9
    • Teensyduino 1.46
    • Teensy 3.6

    // Advanced Microcontroller-based Audio Workshop
    // Part 2-4: Using The Microphone
    // copy the Design Tool code here
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    #include <Bounce.h>
    // GUItool: begin automatically generated code
    AudioPlaySdWav           playSdWav1;     //xy=257,314
    AudioInputI2S            i2s2;           //xy=263,223
    AudioMixer4              mixer1;         //xy=517,198
    AudioMixer4              mixer2;         //xy=518,294
    AudioOutputI2S           i2s1;           //xy=712,253
    AudioConnection          patchCord1(playSdWav1, 0, mixer1, 1);
    AudioConnection          patchCord2(playSdWav1, 1, mixer2, 1);
    AudioConnection          patchCord3(i2s2, 0, mixer1, 0);
    AudioConnection          patchCord4(i2s2, 0, mixer2, 0);
    AudioConnection          patchCord5(mixer1, 0, i2s1, 0);
    AudioConnection          patchCord6(mixer2, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=394,448
    // GUItool: end automatically generated code
    Bounce button0 = Bounce(0, 15);
    Bounce button2 = Bounce(2, 15);  // 15 = 15 ms debounce time
    // Use these with the Teensy Audio Shield
    // Works
    /*#define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    // Use these with the Teensy 3.5 & 3.6 SD card
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    void setup() {
      mixer1.gain(0, 0.8);
      mixer1.gain(1, 0.2);
      mixer2.gain(0, 0.8);
      mixer2.gain(1, 0.2);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
          Serial.println("Unable to access the SD card");
      pinMode(0, INPUT_PULLUP);
      pinMode(2, INPUT_PULLUP);
    void loop() {
      if (playSdWav1.isPlaying() == false) {
        //Serial.println("Start playing");"SDTEST1.WAV");
        delay(10); // wait for library to parse WAV info
      // do nothing while playing...
     /* // read pushbuttons
      if (button0.fallingEdge()) {
      if (button2.fallingEdge()) {
    Thx for the feedback!

  2. #2
    Junior Member
    Join Date
    Jun 2019

    Found the SD-card problem on the forum. Issue in Teesyduino 1.46

    In hardware\teensy\avr\libraries\Audio\play_sd_wav.h 
    //uint8_t buffer[512];		// buffer one block of data
    uint8_t buffer[512] __attribute__ ((aligned (4)));
    And in play_sd_wav.cpp
    commented out: __disable_irq();
    	wavfile =;
    	if (!wavfile) {

Posting Permissions

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