Share this on: 


Bpod now has a scalable solution for precision psychoacoustics.

Delivering precise audio stimuli with Bpod has been a frustrating experience for many in our user community. Our existing solutions had either lacked industry standard audio quality, or relied on non-realtime software triggering of PC sound cards. The latter solution was dependent on intermittent availability of specific sound cards. More concerning were updates to software dependencies and the non-realtime OS that occasionally affected timing properties of sound playback. The ideal solution would not have components that need to be updated constantly for security and compatibility.

The new HiFi Module HD was designed to fulfill this need. It uses PJRC's lightning-fast Teensy 4.1 microcontroller platform to directly control DAC2 HD, a new high resolution sound card developed by HiFiBerry for Raspberry Pi. Interfacing these two incredible pieces of hardware took some serious reverse engineering - but we think it was well worth the trouble.
Here are 8 reasons why:

1. Its timing precision is unmatched. When a sound is triggered by the Bpod finite state machine, 192kHz stereo playback begins after only [0.22 ± 0.01ms] - less than the width of an action potential. Importantly, the same latency and jitter also apply to triggered playback stop. The following plot shows sound onset latency on 10,000 trials with respect to a TTL output set high on state entry:

2. It does not require down-time. In experiments with multiple trials, the next trial's sound set can be loaded to the device without interrupting playback or affecting the current sound set. This enables experiments with continuous behavioral data acquisition if used with our TrialManager class or Brody Lab's BControl.

3. An isolated TTL output provides audio sync to other instruments. The HiFi module's Arduino-language firmware has access to the audio DAC's DMA channel interrupt service routine, called just prior to each sample during playback. In addition to filling the buffer with the next sample of audio data, the firmware drives logic pins high and low to indicate sound onset and offset. An advanced isolator IC (Analog Devices ADUM6200) exposes this sync signal to other instruments without the risk of creating a ground loop.

4. It can transform and synthesize sound. Our current firmware provides a configurable 2,000-sample amplitude envelope that is applied at sound onset, and in reverse at sound offset (even when sounds are stopped during playback). This can mitigate speaker pop, or create "fade-in" and "fade-out" effects. The firmware also has some rudimentary synthesis functions. It can generate white noise or pure tones with configurable frequency and amplitude. Synth playback can span the intervals between sounds (e.g. to mask ambient sounds with white noise) or it can act as the entire stimulus set.

5. With Full Speed USB2.0, audio data transfers rapidly. At 480Mbit/s, Teensy 4.1 has a faster USB data connection than any previous Arduino-compatible microcontroller. In practice, data transfer time includes MATLAB or Python overhead, and generally averages ~40-50Mbit/s for sounds of 1s or more.

6. Its ultrasonic range is usable. At its maximum sampling rate of 192kHz, HiFi Module HD can render pure tones at frequencies across the rodent hearing range. For a 60kHz pure tone sampled at 192kHz, the following plot compares the input data vs. the output signal. The output shown was captured from the HiFi Module's output channels with an oscilloscope:

7. The SD model includes a headphone amplifier output. The HiFi module hardware supports two HiFiBerry sound cards - DAC2 HD and DAC2 Pro. This article focused on the 'HD' version of the HiFi module. For applications that can tolerate audio playback with a higher noise floor and distortion in the ultrasonic range (comparable to most high-end portable music players), we also developed the 'SD' version of the HiFi module, outfitted with DAC2 Pro. This version has an audio DAC with lower SNR and higher THD, and lacks the HD model's custom analog output stage. At the expense of these, it adds a headphone amplifier with software-adjustable gain. Together with low-cost headphone drivers (e.g. this), the SD model provides a complete audio system for applications where the purpose of sound is to provide feedback cues that are distinct and easily differentiable.

8. It is low-cost and 100% open source!. As with all instruments developed at Sanworks, we made the Bpod HiFi module's software, firmware and CAD files open. This provides a DIY option for labs with funding constraints, and keeps the instrument supremely flexible for the end users when needs arrive that we hadn't anticipated.





Comments ()