Forum Rule: Always post complete source code & details to reproduce any issue!
Page 7 of 8 FirstFirst ... 5 6 7 8 LastLast
Results 151 to 175 of 177

Thread: WAV playback sounds distorted

  1. #151
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Pensive,

    Thanks for the ideas!

    How do I go about placing 80ms delays between them then without using delay?

  2. #152
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Metro, flexitimer, mstimer or interval timer?

    Metro is your best bet, but why do you need that delay to solve your SDCard problem?

    If you want to break it, call audionointerrupts a, then start all 3, then rein it audio interrupts. This is the peak load on the SDcard, which is what we are trying to determine and improve, unless I missed something earlier...

  3. #153
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    The delays were for testing purposes only. To mimic someone hitting a triggering device multiple times in a row.

    The actual code would not have delays in it.

    And what is "Metro"?

  4. #154
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Quote Originally Posted by dsparks View Post
    The delays were for testing purposes only. To mimic someone hitting a triggering device multiple times in a row.

    The actual code would not have delays in it.

    And what is "Metro"?
    Metro is a loop based timer library which doesnt use interrupts to achieve "mostly accurate" timer functions, without using delay(). delay() tells the teensy to STOP EVERYTHING.
    I'm using to update my lcd display while the audio library does its thing.

    here's my code for looping a wav file. put it in the loop(), duplicate for 3 or 4 wavs to see how things go.
    Code:
    if (! (playWav1.isPlaying())){
        playWav1.play("1644100M.WAV");
        }
    at least you'll eliminate another variable if it has no effect.

  5. #155
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Ill give metro a try.

    Thanks!!!

  6. #156
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    I am having terrible luck getting metro to play even 2 samples alternating.

  7. #157
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,128
    Here's what I see with a Sandisk Ultra card:

    Code:
    SD Card Test
    ------------
    SD card is connected :-)
    Card type is SDHC
    File system space is 15923.15 Mbytes.
    SD library is able to access the filesystem
    
    Reading SDTEST1.WAV:
      Overall speed = 1.27 Mbyte/sec
      Worst block time = 1.73 ms
        59.66% of audio frame time
    
    Reading SDTEST1.WAV & SDTEST2.WAV:
      Overall speed = 1.26 Mbyte/sec
      Worst block time = 1.58 ms
        54.46% of audio frame time
    
    Reading SDTEST1.WAV & SDTEST2.WAV staggered:
      Overall speed = 1.26 Mbyte/sec
      Worst block time = 1.21 ms
        41.60% of audio frame time
    
    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
      Overall speed = 1.26 Mbyte/sec
      Worst block time = 2.37 ms
        81.58% of audio frame time
    
    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
      Overall speed = 1.27 Mbyte/sec
      Worst block time = 1.62 ms
        56.01% of audio frame time
    
    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
      Overall speed = 1.27 Mbyte/sec
      Worst block time = 3.15 ms
        108.74% of audio frame time
    
    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
      Overall speed = 1.27 Mbyte/sec
      Worst block time = 2.04 ms
        70.28% of audio frame time

  8. #158
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    This is a simple loop bit that will play the file for 4 beats quick then with a pause.....instead of using delays


    void loop() {

    int playtime = millis();

    AudioNoInterrupts();
    wav1.play("40BP.wav");
    AudioInterrupts();
    while (millis() < (playtime + 100));

    playtime = millis();

    AudioNoInterrupts();
    wav1.play("40BP.wav");
    AudioInterrupts();
    while (millis() < (playtime + 100));

    playtime = millis();

    AudioNoInterrupts();
    wav1.play("40BP.wav");
    AudioInterrupts();
    while (millis() < (playtime + 100));

    playtime = millis();

    AudioNoInterrupts();
    wav1.play("40BP.wav");
    AudioInterrupts();
    while (millis() < (playtime + 500));

    }

  9. #159
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Paul,

    Thank you for sharing your results!

    BTW, my Teensy is running at 96Mhz.

  10. #160
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Thanks Teenfor3!

    After trying your code Im convinced its my SD cards now!

    Still not able to play 4 RAW mono samples from the SD card.

    And Im noticing glitches at playing 3 of the same file in quick succession as was my original post issue.

    I sure hope using a Sansdisk SD will fix this!

  11. #161
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Im also curious, would a slower card, as appears in my case, also produce higher CPU usage rates?

    Mine are considerably higher than on your SD test Paul.

    Thank you!

  12. #162
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    This is the test for my Sandisk Ultra 16 GB with about 30 files on it each about 5 to 10 seconds each
    I assume the size of the disk maybe means slower..????? and more files means slower...????
    No files currently on this SD have been edited since last formatted. Only some of the files were originally added, then the rest added as and when....no files have been deleted from it.

    SD Card Test
    ------------
    SD card is connected :-)
    Card type is SDHC
    File system space is 15923.15 Mbytes.
    SD library is able to access the filesystem

    Reading SDTEST1.WAV:
    Overall speed = 0.80 Mbyte/sec
    Worst block time = 1.10 ms
    38.09% of audio frame time

    Reading SDTEST1.WAV & SDTEST2.WAV:
    Overall speed = 0.80 Mbyte/sec
    Worst block time = 2.24 ms
    77.27% of audio frame time

    Reading SDTEST1.WAV & SDTEST2.WAV staggered:
    Overall speed = 0.80 Mbyte/sec
    Worst block time = 1.78 ms
    61.25% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
    Overall speed = 0.80 Mbyte/sec
    Worst block time = 3.36 ms
    115.91% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
    Overall speed = 0.80 Mbyte/sec
    Worst block time = 2.43 ms
    83.89% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
    Overall speed = 0.82 Mbyte/sec
    Worst block time = 4.88 ms
    168.34% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
    Overall speed = 0.81 Mbyte/sec
    Worst block time = 3.46 ms
    119.22% of audio frame time

  13. #163
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Thats interesting!

    Same card type and yet your results are pretty much like mine!

    We are all using the same code and hardware. Or are we?

    My Teensy is hooked up to the Audio adapter board. Running at 96mhz. Im using a Kingston Class SD card. Also did the SD card test.

    Similar results as your test Teenfor3

  14. #164
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    When you saturate the SDcard bandwidth/cputime you will get some funny issues. PS/2Keyboard library was reporting funny characters because it's interrupt was missing bits for example, vanished once i used flashrom.

  15. #165
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    What is "FLASHROM"???

  16. #166
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Quote Originally Posted by dsparks View Post
    Thats interesting!
    We are all using the same code and hardware. Or are we?
    i'm now running 120mhz, but got 5 x WAV polyphony @ 96mhz from sdcard

    I have a Transcend 4gb class 4 sdhc.

    I'm using the github Audio library, not release version.

  17. #167
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Quote Originally Posted by dsparks View Post
    What is "FLASHROM"???
    the additional 16Mb FlashRom chip you can solder onto the audio board.

  18. #168
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    Ok.

    1. How do I run my Teensy at 120mhz?

    2. Should I run it that fast?

    3. Is there a forum link to using the FLASHROM playing samples from it?

    4. And what is the model# / type of flashrom chip to get?


    Thank you!

  19. #169
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    This is my other Sandisk Ultra...this time it is 8 GB with approx 30 files similar to other one.

    This is the one that last night was giving me more problems with small gaps between some files. And the one I thought I sorted by formatting and coping files on several times before it fixed it. Both appear to work OK. Ist only when testing and I look for glitches and gaps that I find them most files play OK and the glitches if any are small.....But it means if playing "smooth" sounds sinewaves etc and continuous sounds continuing form one sound to the next that you can hear it. That is why I record to Audacity and Zoom so as to see it even though I can hardly hear it. If there are glitches then its not right even though the general quality is very good.....Teensy needs to be able to re-produce the waveform as in the original wav file.

    SD Card Test
    ------------
    SD card is connected :-)
    Card type is SDHC
    File system space is 7939.82 Mbytes.
    SD library is able to access the filesystem

    Reading SDTEST1.WAV:
    Overall speed = 1.28 Mbyte/sec
    Worst block time = 0.80 ms
    27.61% of audio frame time

    Reading SDTEST1.WAV & SDTEST2.WAV:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 1.61 ms
    55.60% of audio frame time

    Reading SDTEST1.WAV & SDTEST2.WAV staggered:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 1.23 ms
    42.43% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 2.41 ms
    83.24% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 1.65 ms
    56.90% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 3.22 ms
    110.91% of audio frame time

    Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
    Overall speed = 1.26 Mbyte/sec
    Worst block time = 2.07 ms
    71.24% of audio frame time

  20. #170
    Senior Member
    Join Date
    Jul 2014
    Posts
    210
    WOW! Way better results Teen! Thats what Im looking for!

  21. #171
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,128
    If you're going to write code like this, which measures elapsed time...

    Code:
      while (millis() < (playtime + 100));
    I highly recommend using elapsedMillis.

    http://www.pjrc.com/teensy/td_timing_elaspedMillis.html

    It's simpler, which makes your job easier.

    It also properly handles the case where the millis() count rolls over from 4294967295 back to zero. Admittedly, that only occurs every 49.7 days. But still, if your Teensy has been running that long and you code hits the rollover case, you can always depend on elapsedMillis to work correctly. It always gives you the actual elapsed number of milliseconds, even if millis() rolls back to zero during the elapsed time.

    The code above will fail badly, essentially crash forever, if "playtime" happens to be 4294967195. Use elapsedMillis and you'll never need to worry about such problems.
    Last edited by PaulStoffregen; 01-24-2015 at 12:14 AM.

  22. #172
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    Well, probably seems that a smaller SDcard is probably faster. Though this was the problem SD last night and one format and copy files did not fix it. So why is it so "fiddly" to format, and both SD are the same. I could understand it if I had copied and deleted and edited files directly on the SD, but that wasn't done. And I could understand OK if problem then format once and copy files back on, but that is not the case.

    I would like Pauls comments on this please and has Paul or anyone else these problems. The problem is not does it work, because yes it does work as though you would think it is working properly. But it is only when you do speed tests or look for glitches that you realise it is not working properly.

  23. #173
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    Thanks Paul for the guide on the elapsed time....will do in future.............Have you any comments on my last post please

  24. #174
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,128
    Quote Originally Posted by Teenfor3 View Post
    The problem is not does it work, because yes it does work as though you would think it is working properly. But it is only when you do speed tests or look for glitches that you realise it is not working properly.
    Yes, this is true for a lot of software in general, but particularly so for audio where typical human listening tests are fairly forgiving of minor errors.

    Lots of other software development has very similar challenges. Back-end server stuff for websites, for example, is another application where thing can seem to be working great in casual, light-weight testing, but fail rather spectacularly when used under heavier load.

  25. #175
    Senior Member
    Join Date
    Apr 2014
    Posts
    319
    Yes, but my query is....Are you having these problem with your system.?. Because i want to be able to give my "gadget" to someone who will not be programming it but may want to change the sounds or if some of the "smoother" sounds starts to develop glitches due to copying on new files etc to the SD by the user. How do I tell him to fix it. It doesnt seem to be a matter of just formatting and copying tine files on again. I seem to have to do it several times. Would there be any timing variables etc in the libraries that maybe if increased slightly may allow for slower cards etc. Or is there any definite procedure I can follow to format and copy files that works every time.

Posting Permissions

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