Score:8

Linux CLI tool for testing audio

cn flag

What are some CLI tools that I can use to output a constant sound from all my speakers?

I'm trying to test my speakers (headphones) to make sure they're functional. It seems that if the wire is kinked in just the wrong way, it stops playing. But I'm not sure. It's really annoying to test this with a random media file because the I'm never sure if the silence is caused by the file having audio output gaps or the speaker failing.

I just need a simple command that will output a constant stream of sound. Bonus points if I can choose the channel.

What command line utilities can I use in Ubuntu to output a constant sound from the speakers for testing audio?

Michael Altfield avatar
cn flag
an acceptable answer would be a tool to generate a track of pink noise and another tool to play it on loop.
qwr avatar
kr flag
qwr
You can use audacity to create a 1 hour constant sine wave or noise.
Score:8
vn flag

The package alsa-utils includes a command called speaker-test.

Install

You can install with

sudo apt install alsa-utils

Run

You can now run this to produce a constant sound

speaker-test -t sine -p 1

Note You'll want to add -p 1 else you'll be blasted with a very loud & very annoying sound that you cannot stop with ctrl+c. We also change the test from the default "pink noise" to "sine" as it's not such a jarring sound.

Michael Altfield avatar
cn flag
`speaker-test` oh my god why does ctrl+c not exit this
Raffa avatar
jp flag
@MichaelAltfield LOL Ctrl+c will exit it when it's like this `speaker-test -t sine -f 100 -c 2 -p 1` for example.
Michael Altfield avatar
cn flag
good lord thank you. Looks like it's the `-p` that's needed. I can't really hear anything on my speakers with `-f 100`, but this worked great for me `speaker-test -t sine -p 1`
Score:2
ma flag

SoX (The Sound eXchange) can do this.

Install:

sudo apt install sox

At its simplest, to just play a continuous 440Hz sine tone, you can do

play -n synth sine 440

play expects an input file, -n is just used to indicate that there is none.

The synth command is quite flexible and can generate wide variety of sounds, including different wave shapes, noise colours, chords and sweeps.

For example, to play a 10 second sine sweep from 20Hz to 20kHz and repeat it five times:

play -n synth 10 sine 20-20000 repeat 5
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.