sox adalah pisau manipulasi audio Tentara Swiss, yang disimpan dalam paket dengan nama yang sama. Setelah terinstal, kita dapat melihat halaman manualnya, di mana dijelaskan bahwa ia tidak hanya dapat memutar file audio, tetapi juga dapat memanipulasinya! Berikut baris kodenya:
SoX reads and writes audio files in most popular formats and can optionally apply effects to them. It can combine multiple input sources, synthesise audio, and, on many systems, act as a general purpose audio player or a multi-track audio recorder. It also has limited ability to split the input into multiple output files. All SoX functionality is available using just the sox command. To simplify playing and recording audio, if SoX is invoked as play, the output file is automatically set to be the default sound device, and if invoked as rec, the default sound device is used as an input source. Additionally, the soxi(1) command provides a convenient way to just query audio file header information. The heart of SoX is a library called libSoX. Those interested in extending SoX or using it in other programs should refer to the libSoX manual page: libsox(3). SoX is a command-line audio processing tool, particularly suited to making quick, simple edits and to batch processing. If you need an interactive, graphical audio editor, use audacity(1).
Seperti yang dapat kita lihat di deskripsi sebelumnya, sox dan soxi dapat digunakan untuk banyak penggunaan yang berbeda dalam memanipulasi file audio.
kita dapat memutar format file audio yang didukung hanya dengan menggunakan baris perintah ini:
# sox tone-sine-1000hz.wav -t alsa hw:2 tone-sine-1000hz.wav: File Size: 1.76M Bit Rate: 1.41M Encoding: Signed PCM Channels: 2 @ 16-bit Samplerate: 44100Hz Replaygain: off Duration: 00:00:10.00 In:78.9% 00:00:07.89 [00:00:02.11] Out:348k [====|====] Hd:2.4 Clip:0
Jika file yang terlibat tidak memiliki ekstensi sama sekali, kita dapat memaksa file audio menggunakan argumen opsi -t sebagai berikut:
# sox tone-sine-1000hz.wav -t au tone-sine -1000hz # file tone-sine-1000hz tone-sine-1000hz: Sun/NeXT audio data: 16-bit linear PCM, stereo, 44100 Hz
Jika Anda menemukan kesalahan di bawah ini saat menjalankan perintah soxi:
soxi: command not found
Anda dapat mencoba menginstal paket di bawah ini sesuai dengan pilihan distribusi Anda.
Distribusi | Perintah |
---|---|
OS X | brew install sox |
Debian | apt-get install sox |
Ubuntu | apt-get install sox |
Alpin | apk tambahkan sox |
Linux Arch | pacman -S sox |
Kali Linux | apt-get install sox |
CentOS | yum install sox |
Fedora | dnf install sox |
Raspbian | apt-get install sox |
Contoh Perintah sox
1. Gabungkan dua file audio menjadi satu:
$ sox -m input_audiofile1 input_audiofile2 output_audiofile
2. Pangkas file audio ke waktu yang ditentukan:
$ sox input_audiofile output_audiofile trim start end
3. Normalisasi file audio (sesuaikan volume ke tingkat puncak maksimum, tanpa kliping):
$ sox --norm input_audiofile output_audiofile
4. Membalikkan dan menyimpan file audio:
$ sox input_audiofile output_audiofile reverse
5. Cetak data statistik file audio:
$ sox input_audiofile -n stat
6. Tingkatkan volume file audio sebanyak 2x:
$ sox -v 2.0 input_audiofile output_audiofilesoxi:perintah tidak ditemukan