-
Notifications
You must be signed in to change notification settings - Fork 139
Using the Audio Expander Capelet
#Using the Audio Expander Capelet
The Audio Expander Capelet is a hardware accessory for the Bela cape which converts the 16-bit analog inputs and outputs to extra audio channels. It provides lowpass filtering to reduce noise and aliasing, and DC blocking and level-shifting to allow audio signals to be sent and received from the analog I/Os.
Please read the entirety of this guide before using the Audio Expander in your project so you understand its capabilities and how to enable it on particular channels.
##Hardware Setup
###Installation
To install the audio expander, place it on top of the Bela cape. Ensure that all the pins fit into the sockets in the cape, especially the analog input and output sockets.
Make sure the audio expander is pushed down as far as it will go, so it makes a secure connection with the sockets underneath.
###Audio Expander Outputs
The 3-pin connectors labelled OUT on the edge of the audio expander give you the extra audio outputs. These connectors contain low-pass filtered, level-shifted versions of the signals on each of the 8 analog output pins.
The 3-pin connectors use the same pinout as the audio input and output connectors on the Bela cape, so the same type of adapter cable can be used.
Unlike the Bela cape, the audio expander outputs are not designed to directly drive headphones. These should be considered line outputs only, and an external amp should be used for driving speakers and headphones.
###Audio Expander Inputs
The 3-pin connectors labelled IN on the edge of the audio expander give you the extra audio inputs. Audio signals coming into these connectors will be low-pass filtered and level-shifted for use with the Bela analog inputs.
Important: to use the audio expander inputs, you must install wire jumpers between connectors J10 and J11 for the channels you want to use. The jumpers connect the output of the audio expander circuits to the Bela analog inputs. With the jumper installed, the audio expander is enabled, overriding the analog input; with the jumper removed, the analog input works normally and you can connect an analog signal directly to J10.
The audio expander inputs have a selectable gain: installing wire jumpers on J12 (labelled IN-GAIN) will increase the gain of selected channels by a factor of 20dB (x10).
##Software
Special software is not required to use the Audio Expander Capelet. Two command-line options are provided for working with the audio expander and are also accessible through the IDE settings tab:
-Y
or --audio-expander-inputs
selects analog input channels to rescale and filter for use with the audio expander. Provide a list of channels (0 through 7) separated by commas. Example: -Y 0,1,2,3
would rescale analog inputs 0-3 for use with the audio expander. In this case, the analog input range is -1 to 1 rather than 0 to 1, and a highpass filter is added to remove the DC offset from the audio expander circuit.
-Z
or --audio-expander-outputs
selects analog output channels to rescale for use with the audio expander. Provide a list of channels (0 through 7) separated by commas. Example: -Z 4,5
would rescale analog outputs 4 and 5 for use with the audio expander. In this case, the analog output range is -1 to 1 rather than 0 to 1, and this will be rescaled internally to a single-ended signal suitable for the analog output.
###Working with raw signals: C++
You can access the audio expander the same way you normally access the analog inputs and outputs on Bela. The analogRead()
and analogWrite()
functions work as they normally do, and these pins can now connect to the audio expander. The main differences to consider have to do with scaling and level shifting:
Using analogWrite()
, the signal should be scaled between 0 and 1, not between -1 and 1 as with audioWrite()
. To rescale an audio signal to this range, add 1 and multiply by 0.5. That said, the very top of the analog output range is sometimes clipped if the USB port powering the board has a voltage of less than 5V, so it is recommended to scale it down so the output never goes above 0.92.
If n
is the frame number, ch
is the channel, and signal
ranges from -1 to 1:
analogWrite(context, n, ch, (signal + 1.0) * 0.46);
Using analogRead()
will likewise return a signal between 0 and 1, with an offset of about 0.4 from the audio expander filters. This needs to be high-pass filtered to eliminate the DC offset. A first-order filter will be sufficient for this task.
###Working with raw signals: Pd
In Pd, the analog inputs and outputs are on ADC and DAC channels 3 through 10. These are also scaled between 0 and 1, and will need to be rescaled in the same way as above.
##Tech Specs
Audio input channels:
- 2nd-order lowpass filters, f3 = 17.6kHz
- Gain: 1.6 (default, no jumper set) or 16 (jumper set)
- DC offset at Bela analog in: 1.8V
- Max input range: +/- 1.12V (jumper not set) or +/- 112mV (jumper set)
Audio output channels:
- 2nd-order lowpass filters, f3 = 17.8kHz
- Gain: 1.0
- Max output range: +/- 2.3V (assuming
analogWrite()
range 0 to 0.92)
The filters are implemented with OPA4348 opamps.
##Comparison to Bela audio input and output
The Audio Expander Capelet uses the Bela cape's DC-coupled ADC and DAC. These parts are of a different type to the sigma-delta codec used for the main Bela audio I/O. See here for a discussion of the different types of converter and their performance for audio.
Also, there are some nonlinear effects on the DAC related to limited slew rate and differing settling time for different DAC codes, which add a bit of nonlinear distortion to the DAC outputs. (These issues do not affect the ADC.) We are currently working on software compensation for these effects, which will be added to the dev-capelet
branch when ready.