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

Thread: 8.3 FORMAT - STILL NO SOUND (even though I can get SDTEST1.WAV to play fine)

  1. #1
    Junior Member
    Join Date
    Mar 2020
    Posts
    14

    8.3 FORMAT - STILL NO SOUND (even though I can get SDTEST1.WAV to play fine)

    Hello everyone! I've got a Teensy 4.0 with an Audio Shield REV D all soldered together and working PERFECTLY for everything else - just can't play my tracks off the sd card Click image for larger version. 

Name:	Capture.PNG 
Views:	1 
Size:	55.4 KB 
ID:	19432

    So everything was going great, I was thoroughly enjoying baby stepping along with Alex Glow as my tour guide, and i've been able to get pretty much everything to work functionally. I've got all the connections to produce the desired effect with all the PROVIDED audio files you guys made available (which are amazing by the way and kudos to the chef if one of them happens to be on 'the team').

    However, I have as yet been unable to get any audio files I've put on the sd card to play in any kind of way. Sure the device is happy to tell me its playing them, I was able to get this far by changing the title of the files to an 8.3 format. I've tried everything i can think of, even converting to RAW headerless file types and attempting to play from MEM (all my files are tiny little samples I'll eventually want to simply loop, driven by hopefully one of the clocks on teensy so it would be amazing if i could play them like that though i don't expect to really was just trying it to see if i could get something to play).

    Here is source code for playing one of the files (I think the sketch is the first music playing one in the tutorial) and the serial monitor just outputs 'Start Playing' over and over again to the delay that is set. No sound though, and if i play any of my files in the 'wavplayer' it'll actually say that it's 'playing DRUM120.WAV' or whichever just no sound until it plays one of YOUR files like SDTEST3.WAV and then it plays all the way through, then going to KEYS150.WAV, GUIT85.WAV, and so on and so forth with no sound whatsoever.

    I assuming it's the format of the files but they are all 32-bit 44100Hz which is the same as the SDTEST.WAV files i've noticed so not sure why that wouldn't work. Ok i've included the source code and a pic. hope ya'll can help!




    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    AudioPlaySdWav           playSdWav1;
    AudioOutputI2S           i2s1;
    AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
    AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;
    
    // Use these with the Teensy Audio Shield
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  11
    #define SDCARD_SCK_PIN   13
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(8);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      delay(1000);
    }
    
    void loop() {
      if (playSdWav1.isPlaying() == false) {
        Serial.println("Start playing");
        playSdWav1.play("DRUM80.WAV");
        delay(10); 
      }
     
    }
    Last edited by defragster; 03-21-2020 at 05:16 AM. Reason: add # CODE tag

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,984
    Indeed that works here on a Beta T_4 with Audio card.

    Using PJRC published file "SDTEST1.WAV" in place of the posted file name.

    Something not converted properly - or perhaps the file is corrupt.

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,984
    Note: it does take some delay(); after the .play() command to have the sound start (open file and begin transfer and output) or the next test will still see .isPlaying == false

    On my machine I'm seeing start time take ~1.5 to almost 3 ms at times with this code ending setup() and starting loop() using PJRC supplied samples.
    Without that delay() { the while() } in setup - it leaves setup() and enters loop() and TEST2 plays instead of TEST3
    Code:
    	Serial.println("Start playing ... 0");
    	playSdWav1.play("SDTEST3.WAV");
    	uint32_t ww = micros();
    	while (playSdWav1.isPlaying() == false && ww + 10000 > micros()) ;
    	Serial.println(micros() - ww);
    	if (playSdWav1.isPlaying() == false)
    		Serial.println("FAILED Start playing");
    }
    
    void loop() {
    	if (playSdWav1.isPlaying() == false) {
    		Serial.println("Start playing");
    		playSdWav1.play("SDTEST2.WAV");
    		delay(10);
    	}

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,398
    Quote Originally Posted by NewtonBIV View Post

    I assuming it's the format of the files but they are all 32-bit 44100Hz which is the same as the SDTEST.WAV files i've noticed so not sure why that wouldn't work. Ok i've included the source code and a pic. hope ya'll can help!
    not 32-bit
    SDTEST3.WAV: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

  5. #5
    Junior Member
    Join Date
    Mar 2020
    Posts
    14
    Quote Originally Posted by manitou View Post
    not 32-bit
    SDTEST3.WAV: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz
    Wow really? Thank you! I opened the file on one of my audio editors and guess i mistook the default encoding for the file's original specs. I'll change one of the files then woohoo!

    As always thank you everyone!

Posting Permissions

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