Re: read/write SD files with WaveHC + SdFat
OK, I've got it working now a couple of different ways with the SD/SdFat lib in Arduino 22 on an Uno. Here's what I did in case other people find this information useful.
Option 1: Tweaked the WaveHC lib just enough so it could co-exist with SD lib. Used the SdFat version of FatStructs.h, fixed the DIR_IS_* macros/funcs, and removed duplicate defs of FreeRam and other funcs in WaveUtil.h. My sketch uses the normal SdReader classes for reading/playing WAV files, and the SD "File" class for writing log files.
Option 2: Made a new lib called "WaveSD" based on WaveHC. Ripped out FatStructs.h, WaveUtil.*, and the SdReader/FatReader/FatVolume classes, leaving only WaveSD.* files, *Pin*.h, and mpcdac.h. Changed all the WAV-playing code to use the equivalent classes in SdFat. My sketch uses SdFile both for reading/playing WAV files and writing log files.
To gauge the impact of each option, I made two versions of the "daphc" example sketch, and measured the compiled size and initial FreeRam() readings. To maximize RAM, I changed the WAV PLAYBUFFLEN to 256 bytes rather than 512, and I changed the RX_BUFFER_SIZE in HardwareSerial.cpp to 16 instead of 128.
Option 1: daphc sketch, size=14686, freeram=527
Option 2: daphc sketch, size=15274, freeram=674
For comparison, the original daphc sketch with the original WaveHC lib: size=9554, freeram=1314.
Since I care most about free RAM, I'm going with option 2.
Last edited by botbilder
on Sun Jan 09, 2011 11:26 pm, edited 1 time in total.