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

Thread: Playing multiple WAV files at the same time - SD settings

  1. #1

    Playing multiple WAV files at the same time - SD settings

    Hello all!

    On T4 I am looking for a way to play multiple wav or stereo raw files at the same time. The T4 using SDIO can happily play (8!!!) stereo wav files at the same time but if you launch them all at the same time you get drop out on the first one (the wave form has gaps in it when recorded and reviewed) this only happens for the first fractions of a second then it all works perfectly again.

    This is using the wav player example with the wav player duplicated. The RAW player is mono only which isn't ideal as all my files are stereo.

    In the note on the audio config tool it says to un-comment the SD optimisation when playing multiple files, if I do this on T4 then it wont compile. are these optimisations still relevant to T4 and SDIO as I know SDIO is much faster anyway.

    I have tried staggering the loading of each wav slightly using a counter but for some reason this actually causes more drop outs and clicks when loading every file rather than just the first one...

    Code:
      int currentWAVloadMS = millis();
      int prevWAVloadMS = millis();
      int durWAVload = 10;
      int LOADtime = 1;
      int index = 1;
    
      while (LOADtime == 1) {
    
        currentWAVloadMS = millis();
        
      if (currentWAVloadMS - prevWAVloadMS >= durWAVload) {
    
      // Start playing the files
      if (index == 1) { playSdWav1.play(filename1); Serial.println("Debug"); }
      if (index == 2) { playSdWav2.play(filename2); Serial.println("Debug"); }
      if (index == 3) { playSdWav3.play(filename3); Serial.println("Debug"); }
      if (index == 4) { playSdWav4.play(filename4); Serial.println("Debug"); }
      if (index == 5) { playSdWav5.play(filename5); Serial.println("Debug"); }
      if (index == 6) { playSdWav6.play(filename6); Serial.println("Debug"); }
      if (index == 7) { playSdWav7.play(filename7); Serial.println("Debug"); }
      if (index == 8) { playSdWav8.play(filename8); Serial.println("Debug"); }
      if (index == 9) { LOADtime = 0; }
    
       prevWAVloadMS = currentWAVloadMS;
       index++;
    
      }
      }
    I know I am asking a lot from the T4 but the fact that it plays all the audio fine once the files are loaded makes me think there must be a way to load them In a way which doesn't cause dropouts.

    Is there a way to increase the buffer used when loading to give the system a bit more headroom?

    Thanks all, -A

  2. #2
    I still get some pops and clicks just loading 4 stereo wav files at the same time, which you would of thought would be okay. there must be an optimisation I can do? the issue is present using SPI and SDIO although you can play 8 stereo wavs with SDIO and a max of 6 with SPI.

    edit: its only the initial loading of the wavs where you get clicks. once they are playing it all works perfectly.

    cranking AudioMemory up doesn't make any difference, I am 90% sure its to do with reading off the SD card.

    A
    Last edited by alrj; 05-20-2020 at 09:10 AM.

  3. #3
    In the image top is the file playing as the other 2 or 3 wav files load, below is what it looks like while playing if a load is not happening

    Click image for larger version. 

Name:	Screen Shot 2020-05-20 at 10.40.12.jpg 
Views:	2 
Size:	75.0 KB 
ID:	20203

    edit: this is loading 4 wavs at the same time after stopping the previous 4, with SDIO using SD.h on T4.0

  4. #4
    If I have two playing and trigger another 4 in a cycle I also get a click...

    Click image for larger version. 

Name:	Screen Shot 2020-05-20 at 11.52.46.png 
Views:	0 
Size:	142.9 KB 
ID:	20204

    but they all play together fine once they are up and running. : / I tried with RAW files but got the same issue, plus the RAW are mono so it ruins the stereo field when they are not triggered exactly together.

  5. #5
    It really sounds like #define USE_TEENSY3_OPTIMIZED_CODE would fix my issue but even just on the wavplayer example on T4 it wont compile...

    Code:
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:31:29: error: conflicting declaration 'volatile uint8_t* SDClass::csreg'
     volatile uint8_t * SDClass::csreg;
                                 ^
    In file included from /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:28:0:
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/SD_t3.h:85:32: note: previous declaration as 'volatile unsigned int* SDClass::csreg'
      static volatile IO_REG_TYPE * csreg;
                                    ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:31:29: warning: declaration of 'volatile unsigned int* SDClass::csreg' outside of class is not definition [-fpermissive]
     volatile uint8_t * SDClass::csreg;
                                 ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:32:18: error: conflicting declaration 'uint8_t SDClass::csmask'
     uint8_t SDClass::csmask;
                      ^
    In file included from /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:28:0:
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/SD_t3.h:86:21: note: previous declaration as 'unsigned int SDClass::csmask'
      static IO_REG_TYPE csmask;
                         ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:32:18: warning: declaration of 'unsigned int SDClass::csmask' outside of class is not definition [-fpermissive]
     uint8_t SDClass::csmask;
                      ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp: In static member function 'static bool SDClass::sd_read(uint32_t, void*)':
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:113:2: error: 'SPI0_PUSHR' was not declared in this scope
      SPI0_PUSHR = 0xFFFF | SPI_PUSHR_CTAS(1);
      ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:113:40: error: 'SPI_PUSHR_CTAS' was not declared in this scope
      SPI0_PUSHR = 0xFFFF | SPI_PUSHR_CTAS(1);
                                            ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:116:12: error: 'SPI0_SR' was not declared in this scope
       while (!(SPI0_SR & 0xF0)) ;
                ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:118:17: error: 'SPI0_POPR' was not declared in this scope
       uint32_t in = SPI0_POPR;
                     ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:122:11: error: 'SPI0_SR' was not declared in this scope
      while (!(SPI0_SR & 0xF0)) ;
               ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:123:16: error: 'SPI0_POPR' was not declared in this scope
      uint32_t in = SPI0_POPR;
                    ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/card_t3.cpp:126:11: error: 'SPI0_SR' was not declared in this scope
      while (!(SPI0_SR & 0xF0)) ;
               ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/init_t3.cpp: In function 'uint32_t unaligned_read32_align16(const void*)':
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/init_t3.cpp:44:55: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
      return *(const uint16_t *)p | (*(const uint16_t *)(p+1) << 16);
                                                           ^
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/init_t3.cpp: In function 'uint32_t unaligned_read16_align8(const void*)':
    /Applications/Ard Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD/init_t3.cpp:53:53: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
      return *(const uint8_t *)p | (*(const uint8_t *)(p+1) << 8);

Posting Permissions

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