audio-dac

CLI reference

glasgow run audio-dac

Play sound using a 1-bit sigma-delta DAC, i.e. pulse density modulation.

Currently, the supported sample formats are:
  • 1..16 channel signed/unsigned 8-bit,

  • 1..16 channel signed/unsigned 16-bit little endian.

Other formats may be converted to it using:

$ sox <input> -c <channels> -r <rate> <output>.<u8|u16>

For example, to play an ogg file:

$ sox samples.ogg -c 2 -r 48000 samples.u16
$ glasgow run audio-dac -V 3.3 --o A0,A1 -r 48000 -w 2 -u play samples.u16

To use the DAC as a PulseAudio sink, add the following line to default.pa:

load-module module-simple-protocol-tcp source=0 record=true rate=48000 channels=2 format=s16le port=12345

Then run:

$ glasgow run audio-dac -V 3.3 --o A0,A1 -r 48000 -w 2 -s connect tcp::12345
usage: glasgow run audio-dac [-h] [-V SPEC] [--o PINS] [-w WIDTH] (-s | -u)
                             [-f FREQ] [-r RATE]
                             OPERATION ...
-h, --help

show this help message and exit

-V <spec>, --voltage <spec>

configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)

--o <pins>

bind the applet I/O lines ‘o’ to PINS (default: ‘A0’, optional)

-w {1,2}, --width {1,2}

set sample width to WIDTH bytes (default: 1)

-s, --signed

interpret samples as signed

-u, --unsigned

interpret samples as unsigned

-f <freq>, --frequency <freq>

set modulation frequency to FREQ MHz (default: maximum)

-r <rate>, --sample-rate <rate>

set sample rate to RATE Hz (default: 8000)

glasgow run audio-dac connect

usage: glasgow run audio-dac connect [-h] PCM-ENDPOINT
pcm-endpoint

listen at PCM-ENDPOINT, either unix:PATH or tcp:HOST:PORT

-h, --help

show this help message and exit

glasgow run audio-dac play

usage: glasgow run audio-dac play [-h] [-l] FILE
file

read PCM data from FILE

-h, --help

show this help message and exit

-l, --loop

loop the input samples