Tsunami is a new Robertsonics / SparkFun product, available now. Think WAV Trigger on steroids.
You can read the details on the new product page. I thought I’d use this post to discuss the design philosophy, how Tsunami differs from the WAV Trigger and what that means for you.
The WAV Trigger has been an ongoing exercise in optimization; trying to eke out the maximum performance in terms of number of voices without sacrificing quality and stability. I don’t ever want to hear a glitch, and nor should you!
While the WAV Trigger’s STM32F405 processor speed is certainly a factor, the limiting resource is actually the amount of on-board SRAM, used to buffer each wav file being played by a voice. The absolute maximum number of voices the WAV Trigger can support with 44.1kHz, 16-bit, stereo wav files is 14. Even then, I don’t have enough memory to support true seamless looping (which requires more buffering per voice.) With the latest WAV Trigger firmware release, I feel as though I’ve reached the performance limit for this platform.
Tsunami began when I read about the new Atmel S70 ARM Cortex-m7 processor and realized that it runs almost twice as fast and has twice the amount of on-board SRAM. If I was going to design yet another audio player, this seemed like a good place to start.
Another motivating factor for a new product was the fact that customers were writing to tell me that they really wanted more than a single stereo output. Indeed, some people were using multiple WAV Triggers not to get more voices, but to get more audio output channels. In addition, people are always asking about audio input, which the WAV Trigger doesn’t support since it only has a stereo DAC.
I started with the following goals based on customer feedback from the WAV Trigger:
- More voices
- Seamless looping
- 8 line-level audio outputs (4 stereo)
- 2 line-level audio inputs (1 stereo)
- Reset button for changing microSD card without a power cycle
- Ability to update the firmware directly from the SD card
- Dedicated MIDI port so you can use MIDI without additional circuitry
I also thought long and hard about connectors. Everyone seems to want something different – 3.5mm, 1/4″, RCA, direct solder terminals… I ultimately decided to keep it simple and just provide dedicated 0.1″ header for everything. You can either wire directly to another unit or make your own connector/cable assembly. This also keeps both the size and cost down. Same with MIDI – No sense in burdening the board with a 5-pin DIN since not everyone will use MIDI. If you do, you can just cut the end off a MIDI cable, connect two wires to the header and you’re in business.
After selecting a multi-channel audio codec and designing a prototype board, I started porting the WAV Trigger code to get a feeling for the performance capabilities of the new processor.
Mono vs Stereo
Another consideration was that many customers have expressed a desire for support for mono wav files. Stereo is not necessary, or even desirable, for every application. And moving to a mono format increases the output routing flexibility, not to mention the fact that memory-wise I can support almost twice as many voices in mono as stereo. In considering this for the WAV Trigger, I came to the conclusion that supporting mono was too costly from a DSP standpoint. The WAV Trigger’s stereo DAC is actually better served by stereo data – it’s much more efficient because the wav files contain the same interleaved format that the DAC wants. Supporting mono playback in the WAV trigger would very likely have reduced the performance.
Tsunami’s TDM codec, however, wants the channels split to begin with, so the penalty for mono is nowhere as severe. Since Tsunami’s firmware can be updated easily from the SD card, without additional hardware, I decided to provide both mono and stereo firmware versions. (Supporting both at the same time is a bit more complicated, and I’ve provided a way to play stereo content in the mono version.) The stereo version is similar to the WAV Trigger, with 18 stereo voices to any of 4 stereo output pairs. The mono version provides a whopping 32 mono voices to any of 8 mono outputs. A new “Synced Pair” trigger function in the mono version plays 2 specified tracks out adjacent outputs for stereo content. (Yes, they are sample-synced.)
MIDI was an afterthought with the WAV Trigger. By that I mean that when I initially designed the WAV Trigger, I had no inkling that the performance would allow for real-time playability. It wasn’t until I got the latency down to around 8ms and the voice count up to 12 (now 14) that serious MIDI control seemed sensible. While it works great, I had to share the serial port and customers have to construct their own MIDI input circuit (to convert MIDI’s 20mA current loop to logic level serial.) This is a royal pain.
So Tsunami has a dedicated MIDI IN (and OUT, not implemented in firmware yet) with an integrated opto-isolator. It’s a separate UART from the serial control port so you can use both at the same time. The firmware now supports proper use of MIDI Channel, including Omni mode. Even more exciting is a new file-naming convention that lets MIDI users specify the output and looping on a per MIDI note basis. Yes, you can map each key to any of 8 mono (or 4 stereo) outputs.
I know, but unfortunately the Atmel SAM S70 is a 3.3V device without 5V tolerant inputs. This means that your first choice in mating it with another microcontroller should be a 3.3V Arduino. Tsunami, like the WAV Trigger, has a pin-compatible header for the FTDI-Basic USB-to-Serial adaptor, but make sure you’re using the 3.3V version! For you modular synth folks, you have to voltage-limit the gate signals anyway, so this shouldn’t be any more of a burden than for the WAV Trigger.
Please use this post to ask questions and provide comments, feedback… whatever.
Update: First panel off the press:
I’ve just finished adding a bunch of new features (and one bug fix) to the WAV Trigger firmware. Version 1.30 includes the following changes and enhancements:
- Increases total supported track count to 4096 – double the previous 2048 tracks.
- Increases total MIDI Banks to 32.
- Trigger Banks – map triggers to different banks of 16 tracks.
- Voice Lock – when starting a track using a trigger or serial command, you can specify the track to not be used by the voice stealing algorithm. This lets you, for example, start a backing track and then play MIDI without risk of cutting off the backing track.
- New serial reporting mode – The WAV Trigger can now be set to send track status messages whenever a track starts or stops.
- True MIDI Channel/Omni – The WAV Trigger can now be set to respond to only a specific MIDI channel, or to Omni mode (all channels.)
- Improved performance and timing of volume faders.
- Fixed bug that allowed re-triggering when both Re-Trigger and Polyphonic trigger options were de-selected.
- Fixed sample-rate offset algorithm to allow full 2X up.
I’ve also update the WAV Trigger InitMaker app to v1.20 support the new options. The screenshot below highlights some of the new features, and the app now (finally) sports it’s own application icon.
If you’d like to help me test all this, the links below will get you preliminary releases of both the new WAV Trigger firmware and InitMaker app. Please let me know here if you discover any issues with either.
Finally, I’ve also revamped the Arduino Serial Control Library to take advantage of the enhanced features. A new advanced example sketch demonstrates how to put the WAV Trigger in reporting mode and use the library to find out when specific tracks have completed or stopped. Get the updated library here.
Just posted v1.28 of the WAV Trigger firmware that dramatically improves the quality of the built-in track fades, and MIDI attack and release volume fades. Previously, volume was adjusted on a per audio buffer basis, resulting in small steps in volume that produced slight, but sometimes noticeable, distortion during fades. The new version now adjusts volume on a per sample basis, producing much smoother dynamic volume adjustments.
I also nailed a couple of subtle issues with interrupt priorities that caused random audio glitches when maxing out 14 voices repeatedly, such as rapidly playing lots of MIDI notes/chords with long release times.
Finally, this new version implements the MIDI Sustain Pedal controller, to make the WAV Trigger even more of a musical instrument.
As I mentioned previously, I’m currently working on support for seamless looping, eventually to include adjustable loop length and starting positions. Loops take more memory than voices, so adding loops will reduce the number of traditional voices. The first implementation will likely be a separate firmware release that supports say 4 independent loops and 8 traditional voices. Exact allocation TBD.
Haven’t posted in a while, so I thought I’d give a brief update. After seeing the appreciated, but rudimentary demo video for the WAV Trigger posted by SparkFun on the product page, which doesn’t even mention polyphony – the very same demo could have been done with the MP3 Trigger – I decided that I needed to put some effort into a killer demo of my own.
I won’t spoil the surprise, but suffice to say that my application requires seamless looping, so I’m currently working on providing this capability in the WAV Trigger firmware. I mention this here because a number of people have asked for it. I used to think it was too hard, given the architecture, but it turns out that some changes I made for sample rate conversion / pitch bending have quite possibly made it more achievable.
A number of people have made some perfectly valid requests for other new features. I’m not ignoring you, I just want to try this first.
A few recent WAV Trigger related projects worth mentioning.
Next up, my favorite WAV Trigger project so far. I want one.
Here’s another interesting interactive audio toy idea implemented with just a WAV Trigger.
There’s been some confusion about whether or not you need to modify your WAV Trigger to use the on-board amplifier. The first hardware version of the board was shipped from SparkFun with a capacitor missing from the input of the on-board audio amp that resulted in a DC offset on the speaker output. This post details how to add the cap.
The board design was amended and a new hardware version of the WAV Trigger made its way into the SparkFun manufacturing pipeline about 8 months ago. The new version requires no modification to use the amp.
Since then, SparkFun has not shipped any of the older version. However, it’s certainly possible that some distributors still have the older version in stock.
Unfortunately, while the SKU number changed, there’s no clear indication on the board itself of the version. Here’s how you can tell:
Again, if you have the newer hardware version of the WAV Trigger, you do not need to make any modification in order to use the on-board amplifier.
I’ve had a number of requests recently for help with using the WAV Trigger Serial Control Library for Arduino, so here’s a basic “how-to” using the example Uno sketch that’s now included in the library. For those of you unfamiliar with GitHub, fear not; Just use the “Download Zip” button on the library’s GitHub repo page (above link.)
Step 1: Install some Arduino libraries.
At a minimum, you’ll need to know how to install third party libraries into your Arduino development environment. There are plenty of tutorials available on that subject, so check ’em out and come back here when you’re up to speed. The example sketch requires 3 libraries be installed into your Arduino “libraries” folder.
Some Arduinos, such as the Uno, only have a single hardware serial port. I find it cumbersome to have to share with the USB connection when you need a serial port for your sketch. The AltSoftSerial library effectively creates another serial port out of normal digital pins. The specific pins it uses for RX and TX vary with the Arduino board type, and you can find out which ones by looking in the “known_boards.h” file in that library. All we need to know for now is that for the Uno, it makes Pin 9 be the TX pin.
Update: If you’d rather use a hardware serial port (UART) instead, the library now also supports Serial, Serial1, Serial2 or Serial3. The caveat is that you have to make one small edit in the wavTrigger.h file. See the library readme file for the details of how to do this.
Metro is a great interval timer class when you need to schedule events that you can’t use delay() for, such as blinking lights. The nice thing is that it doesn’t use any hardware timer resources. I use it a lot, and you should too.
Step 2: Prep your WAV Trigger.
I strongly advise that you install post headers or receptacles in any WAV Trigger connector that you’re planning to use. PCB connector pads are not meant for direct soldering and I’ve seen too many pads ripped off boards because people solder directly to them and don’t provide strain relief.
The example Arduino sketch is written to use a specific set of audio tracks. Download these tracks, unzip and copy them to the WAV Trigger’s microSD card. They already have the correct track names. You do not need an init file for this example unless you’re using the on-board amplifier and a speaker instead of the line out audio jack.
Step 3: Connect the WAV Trigger to the Uno.
The library currently only implements commands to the WAV Trigger, so you only need to connect 2 wires: GND, and the Uno TX pin to the WAV Trigger RX pin.
Step 4: Power up and run the sketch.
Apply power to both boards and connect your USB cable to the Uno. If the libraries have been installed properly, you should be able to open the WTriggerUno sketch: File->Sketchbook->libraries->WavTrigger->wTriggerUno.
This example sketch demonstrates many of the library’s functions for starting, looping, fading, cross-fading, stopping tracks and groups of tracks and sample-rate (playback speed) control. It makes use of the sample tracks from Step 2 above, and probably won’t make much sense if you try to use your own sounds as is. You can of course, modify the example sketch to work with any sounds you wish.
The example sketch also assumes you have recent firmware in your WAV Trigger. Some of the features demonstrated by the sketch, such as pitch bending, have been added since the last SparkFun release firmware, so in order to get the full effect, you may need to update your WAV Trigger with the latest version from the download page.
Extra Credit: Powering the WAV Trigger from the Uno.
It’s possible to power the WAV Trigger from the Arduino 5V, although you probably should not do this if you’re planning to drive a speaker continuously at high-levels using the on-board amplifier, due to potentially high 5V current draw (even though I do.)
First you’ll need close the solder jumper on the WAV Trigger that connects the on-board 5V to the serial connector. The WAV Trigger doesn’t ship from SparkFun this way, because people might connect an FTDI Basic at the same time that they’re powering the WAV Trigger from the barrel connector. I always close this jumper because it allows me to power the WAV Trigger from the FTDI basic.
Now just connect a 3rd wire from the Uno 5V pin to the WAV Trigger pin labeled “5Vin” next to the serial RX pin. Make sure not to power the WAV Trigger from the barrel connector at the same time!
WAV Trigger firmware version 1.06 adds variable sample rate conversion on the main output. This comes in the form of MIDI Pitch Bend support and a new serial control protocol message.
By default, in MIDI mode, MIDI Pitch Bend (any channel) raises and lowers the pitch of the WAV Trigger’s main output mix by plus and minus 2 semitones. The latest version of the InitMaker app allows for changing the pitch bend range to from 1 to 5 semitones using a new #BEND command in the init file.
There’s also a new samplerateOffset serial command that allows for adjusting the output sample rate between 1/2x to 2x with 16-bit resolution – while audio is playing. Documentation for this message has been added to the Online User Manual and the latest version of the Remote Control demonstration app adds a sample rate control knob to demonstrate this. I’ll add support for this feature to the Arduino Serial Control Library shortly.
The new firmware and update related apps are all on the download page.