The basic spec for this project was as follows:
- 44.1 Khz 16 bit stereo
- Allow up to three (maybe four) stereo audio tracks at a time.
- Each track triggered via a button (or some other control)
- USB or battery operation
- Easy to update audio
My search for a good board for this project brought me to the Teensy Audio Board.
This project started with near disaster, but brought a great deal of satisfaction afterward. The disaster started when the Sparkfun package came earlier than expected (normally that is a GOOD thing!). I enthusiastically jumped into the project on a weeknight after being fried from work. Never a good idea. I was also working from a relocated laptop area that was less comfortable and poorly lit. Yeah, my own fault.
So the focus that I’d normally bring to something like this just wasn’t there, and probably accounts for some of the early struggles.
The Teensy Audio Board video and PDF tutorial that the makers of Teensy provide is great. Mostly. There are a few details they leave out about SD card formatting and the camera angles in the video make it difficult to see the wiring of their test device.
Sparkfun sells a header kit for Teensy, but right away I didn’t like how it was going to go together. The Teensy has 14 pins on the long side, but the long headers in the kit only cover 13 of those… leaving the end pins (12,13) open. There’s a 7-pin header that is intended to handle this… but it is not a great fit.
Having already soldered the 13-pin headers into place, and not having much to work with, I came up with a silly workaround…
I purposely didn’t solder this connection and just left it wired together with friction. This worked for a while, but when I got deep into the code I had to eliminate some of the variables that might have been causing some strange behaviors (like this crappy connection).
So I eventually broke down and filed the headers so that they fit together, with the 7-pin header boxing everything in.
The 5 pins in the center (VBat, 3.3V, GND, Program, A14/DAC) are either redundant or not needed for my planned project, so I could have cut those pins off. Note how they do not cooperate with the breadboard. Instead of cutting them, I just bent them out for potential use later.
It was only after all this drama that I learned that there are some specialized headers out there from the Teensy folks. Sparkfun also carries better Female Headers (PRT-00115) and Break Away Headers – Long (PRT-10158). There’s also some nice tricks in a 4-channel audio project buried on Sparkfun’s site. Had I seen all of this beforehand, I would have approached things much differently!
I’ll take responsibility for not researching my options further on this one, and just jumping in with what was in front of me. But it still seemed odd to me that Sparkfun would sell something with such obvious flaws. So I contacted them and they quickly responded. After sending them pictures and describing the issue they gave me a credit for the Teensy board and the header kit (more than I expected). Pretty cool. I’ve already placed an order for more boards (AND BETTER HEADERS) so I can redo the hardware part of this project. I’ll keep the first one as the prototype… which is the point after all.
As you’ll see, I’ll have mostly good things to say about Teensy and their audio board, but there is one last pet peeve…
As I learned later, in the workshop materials, they wired up their breadboards first and then plopped the controller down into place. This is completely backwards from how I work on projects.
I like to see the pins I am accessing. The wings of the Teensy Audio board are problematic for easy access to the pins. At one point this contributed (with poor light and fatigue) to some funky wiring on my part which made me think I had routed voltage to an input. The board seems to work though, so I may be OK.
Libraries – Bounce and SD
The projects that I was working on just before this one used the web IDE for Particle Photon. I really like the Particle IDE, and got kind of spoiled by how easily they handle libraries. When I came back to Arduino, I had to reacquaint myself with how libraries are stored and updated, and how to handle conflicts.
I had the most trouble out of Bounce and SD libraries, either because they were old or conflicting with Teensy’s better libraries. When this happens, you get some freaky errors…
Arduino: 1.8.5 (Windows 8.1), TD: 1.41, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English" C:UsersJeremy dePriscoDocumentsArduinolibrariesBounce._Bounce.cpp:1:1: warning: null character(s) ignored Mac OS X 2 ° â ATTR;šÉÿ â ¼ Y ¼ J com.apple.quarantine com.apple.TextEncoding -40000;50e83707;Safari;A8E94CDC-818F-4261-9260-ADAEECB12457|com.apple.Safariutf-8;134217984
These were easy enough to work through, and a couple reboots were needed to really clear things out.
SD Card Madness
Over the years as I’ve tried other boards, SD card and file format issues were the norm. So I wasn’t surprised to run into some things here. As of this writing, the Teensy folks leave out some specifics on the requirements. On both generic and SanDisk SD cards, a default Windows FAT32 with default block size didn’t work. NTFS and exFAT also didn’t work (didn’t think they would – only tried for the heck of it).
It was only after I reformatted using 16kb block size that I had success. Some tutorials will tell you to use FAT16, but there is no option to format FAT16 in Win 8.1 (not without special software). Even the Sandisk SD card formatting program only did FAT32.
Teensy recommends that you use a Sandisk Ultra card for SD card Ultra best for multi-file playback, which I proved out: my generic card glitched out and sent me down a rabbit hole looking for coding solutions that were not necessary.
From there, the file naming convention is 8.3, which is typical of these projects. It was so nice to be free to use more than 8 or 16 MB of audio! With 16 GB, there’s not really much I can’t do with this.
The Good News
After moving my work area back to a much more comfortable spot, and after getting some sleep, I tackled this project for about 8 hrs. The time flew by. The Teensy Audio Board kicks ass.
I was able to duplicate most of the behaviors of the pre-programmed Adafruit FX Board by creating my own code pieced together from a variety of example files. But it wasn’t all copy/paste. I had to solve a number of issues, all of which took some careful thought.
The online audio system design tool gives a great visual representation of how signals are routed. While I’ve been exposed to MAX in Ableton, this was my first outing with this sort of platform, and it was easy to use. Creating my own routing for my project – which differed significantly from the workshop setup – was easy to do.
Where’s the code? I’m going to post that eventually, but right now this write-up is more about the hardware – and the benefit of setting aside dedicated time to immerse yourself into a subject.
February 10, 2018 Update
After considering a few different options for mounting and headers, I gave it another go with fresh boards.
Yet a third iteration is on the way using the Teensy Breakout sold on Tindie. Sparkfun also carries a Teensy Shield that allows interfacing with the Arduino Uno shield footprint, but it is of course a bit larger and more than I need for this project.