In the next article we are going to take a look at Sox. This is a well-known application with which users who spend a lot of time using the terminal for almost everything, we can listen to our mp3 collection or other formats.
In the following lines we are going to see how users can install and use the play option of this famous utility for the command line in a basic way. Everything here we are going to see, I have tested on an Ubuntu 18.04 LTS system.
This utility reads and writes audio files in the most popular formats. Optionally it can also allow us to apply effects to them. It can combine multiple input sources, synthesize the audio, and in many systems act as a general-purpose audio player or multitrack audio recorder. It also has a limited ability to split the input into multiple output files.
We will find all the functionality available using only the Sox command. To simplify audio playback and recording, if Sox is called as a playback, the output file is automatically set as the default sound device, and if it is invoked as a recording, the default sound device is used as the input source. .
Install Sox on Ubuntu 18.04
We will be able to find the Sox application available in the official Ubuntu repository. This makes installing it on our computer as simple as opening a terminal (Ctrl + Alt + T) and writing the following script in it:
sudo apt update && sudo apt install sox
It should be mentioned that during the previous installation, the terminal will suggest that we install the package libsox-fmt-all manually after installing Sox. This library package will allow us to play all song formats in Sox. To install the package we are talking about, in the same terminal we will only have to write the following command:
sudo apt-get install libsox-fmt-all
After accepting the installation, the package will be installed and configured with Sox.
After all the installation, we will be able to verify the version number of the application. In addition to getting the version number, the following command will also serve as verification that the application has been installed correctly. The command to use will be the following:
sox --version
Play mp3 files using Sox
The operation of this application for play mp3 files via Sox it's simple. To play a single mp3 from the terminal, you will not have to use the following syntax:
play ~/ruta/al/archivo.mp3
While the song is playing, we will be able to exit the player and close the current playback using the key combination Ctrl + C.
If we don't want to have to indicate the entire path to the file we want to play, we can also play songs located in a specific folder by moving to it and then using the command to play the file as follows:
play archivo.mp3
Play all mp3 files in a folder
Sox will also allow us to play all mp3 files located in a single folder. To do this we will only have to use the following syntax:
play ~/ruta/a/los/archivos/mp3/*.mp3
A practical example of this command, with which you can play all .mp3 content in the Music folder would be the following:
play ~/Música/*.mp3
To jump to the next track you can use the key combination Ctrl + C. To exit the player and abort playback, just use Ctrl + C + C.
Uninstall Sox
In case this music player for the command line does not finish convincing you and you want to remove it from your system, just open a terminal (Ctrl + Alt + T) and execute the following commands:
sudo apt-get remove sox
sudo apt-get remove libsox-fmt-all && sudo apt-get autoremove
With everything indicated here you can make a basic use of Sox. For get help About the use of this application, you just have to use the corresponding command by typing in the terminal:
sox --help
In addition, you can also get more information about her in the official documentation which can be found on the project website.