forcing the correct SD.h to be used? better wav playing capability?

Status
Not open for further replies.

dentaku

Member
I was going through the audio tutorials following the .PDF from Supercon 2015.
When I got to the one that tries to play two .WAV files at once (Part 2-2: Mixers & Playing Multiple Sounds) I ran into a problem with horrible sound and knobs that don't respond.

I've ran some of speed testing sketches with different SD cards and they don't seem to perform great.
My 32GB Sandisk Ultra card is barely any faster than a random Sony SDHC card I found.

QUESTION: I see that for some reason when compiling it decides to NOT use the SD library from the \hardware\teensy\avr\libraries\ folder.
How can I force the teensy folder's specific library to get used instead? Would this even make a difference?

Multiple libraries were found for "SD.h"
Used: C:\Users\dentaku\Documents\Arduino\libraries\SD
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Using library SD at version 1.2.2 in folder: C:\Users\dentaku\Documents\Arduino\libraries\SD
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
Sketch uses 20140 bytes (7%) of program storage space. Maximum is 262144 bytes.
Global variables use 5344 bytes (8%) of dynamic memory, leaving 60192 bytes for local variables. Maximum is 65536 bytes.


I ran SD Card Test on my Sandisk and this is what I get.

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

Reading SDTEST1.WAV:
Overall speed = 0.37 Mbyte/sec
Worst block time = 3.02 ms
103.92% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV:
Overall speed = 0.34 Mbyte/sec
Worst block time = 6.00 ms
206.70% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV staggered:
Overall speed = 0.34 Mbyte/sec
Worst block time = 4.52 ms
155.86% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
Overall speed = 0.34 Mbyte/sec
Worst block time = 8.93 ms
307.69% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
Overall speed = 0.34 Mbyte/sec
Worst block time = 5.99 ms
206.46% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
Overall speed = 0.34 Mbyte/sec
Worst block time = 11.85 ms
408.54% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
Overall speed = 0.34 Mbyte/sec
Worst block time = 7.45 ms
256.61% of audio frame time
 
QUESTION: I see that for some reason when compiling it decides to NOT use the SD library from the \hardware\teensy\avr\libraries\ folder.
How can I force the teensy folder's specific library to get used instead? Would this even make a difference?

Multiple libraries were found for "SD.h"
Used: C:\Users\dentaku\Documents\Arduino\libraries\SD
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
by removing the SD library in your local \Arduino\libraries folder.
Local library folder takes precedence in linking over core library \teensy\avr\libraries

Edit: or by using ViualTeensy from luni (https://github.com/luni64/VisualTeensy, also this forum) where you can control better the libraries to be used
 
OK. I removed the library from C:\Users\dentaku\Documents\Arduino\libraries\SD
and it finally chose the correct one.
I tried removing the one in C:\Program Files (x86)\Arduino\libraries\SD first but that didn't help. I'm assuming if I use SD.h in a sketch for one of my UNOs or Leonardos they will use that one instead of the Teensy one?


Multiple libraries were found for "SD.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Using library SD at version 1.2.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI



AND... the performance is MUCH better :)
I think I'll format the card with SD Card Formatter 5.0.0 then run the test again to see if it makes even more difference.

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

Reading SDTEST1.WAV:
Overall speed = 1.16 Mbyte/sec
Worst block time = 1.13 ms
38.78% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV:
Overall speed = 0.90 Mbyte/sec
Worst block time = 2.19 ms
75.59% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV staggered:
Overall speed = 0.90 Mbyte/sec
Worst block time = 1.68 ms
57.87% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
Overall speed = 0.93 Mbyte/sec
Worst block time = 3.23 ms
111.26% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
Overall speed = 0.93 Mbyte/sec
Worst block time = 2.19 ms
75.65% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
Overall speed = 0.94 Mbyte/sec
Worst block time = 4.26 ms
146.76% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
Overall speed = 0.94 Mbyte/sec
Worst block time = 2.71 ms
93.47% of audio frame time
 
It's WAY better now that I'm using the correct SD library.
I just tried Part 2-2: Mixers & Playing Multiple Sounds and it works as it supposed to, playing two songs smoothly and letting me cross-fade between them using knob 3.
 
Formatting made no difference to me but at least now that I'm using the correct SD library it works fine anyway.
 
Status
Not open for further replies.
Back
Top