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 VOLTS] [--o PINS] [-w WIDTH] (-s | -u)
[-f FREQ] [-r RATE]
OPERATION ...
- -h, --help¶
show this help message and exit
- -V <volts>, --voltage <volts>¶
output power (voltage reference of the outputs) (range: 1.8..5 V, or ‘S<port>’ to follow the voltage sensed on a port; default: unchanged)
- --o <pins>¶
bind modulated output; the number of pins sets the oversampling resolution to PINS (default: ‘A0’, required)
- -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
API reference¶
- class glasgow.applet.audio.dac.AudioDACPorts(*, supply: glasgow.abstract.GlasgowSupply, o: amaranth.lib.io.PortLike)¶
- supply: GlasgowSupply¶
output power (voltage reference of the outputs)
- o: PortLike¶
modulated output; the number of pins sets the oversampling resolution
- class glasgow.applet.audio.dac.AudioDACInterface(logger: Logger, assembly: AbstractAssembly, ports: AudioDACPorts, *, width: Literal[1, 2], signed: bool)¶
- property sample_clock: ClockDivisor¶
Sampling clock divisor.
- property modulation_clock: ClockDivisor¶
Modulation clock divisor.
- async flush()¶
Ensure any past writes have reached the device FIFO.