Linux CLI Audio Cheatsheet
Related Posts
Manage Volume
Increase Volume
amixer -D pulse sset Master 2%+
Decrease Volume
amixer -D pulse sset Master 2%-
Set Specific Volume
Set volume to a specific amount:
amixer -D pulse sset Master 50%
Manage Microphone
Listen To Microphone
If you want to hear what your microphone sounds like, then do the following:
arecord -f cd - | aplay -
Record To File
arecord -f cd -t wav recording.wav
Listen To Microphone And Record
If you wish to record the microphone whilst listening to it, do the following:
arecord -f cd - | tee output.wav | aplay -
List Microphones
arecord -l
List Audio Sources
pactl list sources
Create Virtual Microphone
SOURCE_NAME="virtmic"
FILE_PATH="$HOME/virtmic"
pactl load-module module-pipe-source \
source_name=$SOURCE_NAME \
file=$FILE_PATH \
format=s16le \
rate=16000 \
channels=1
Set Default Microphone
pactl set-default-source $SOURCE_NAME
Play Sound Down Virtual Microphone
SOUND_FILEPATH="/path/to/example.mp3"
VIRTUAL_MIC_FILEPATH="$HOME/virtualmic"
ffmpeg -re \
-i $SOUND_FILEPATH \
-f s16le \
-ar 16000 \
-ac 1 - \
> $VIRTUAL_MIC_FILEPATH
References
- Ask Ubuntu - Terminal command to set audio volume?
- Ask Ubuntu - How to hear my voice in speakers with a mic?
- Stack Overflow - Linux pipe audio file to microphone input
- Unix And Linux - How to merge two microphone inputs into a single virtual microphone in realtime?
- arecord: Linux Command to List all Soundcards and Digital Audio Devices
Last updated: 28th January 2024
First published: 21st February 2022
First published: 21st February 2022