在純字符界面下聽歌
利用 play 命令能夠在命令行中播放音頻文件,在純字符界面下也沒問題!
------------------------------------------------------------------------------------------- 咱們能夠用 man 命令先查看一下 play 的手冊頁:「play 和 rec 命令分別用於播放和錄製音頻文件」
好,先來聽一聽 *.wav 格式的音頻文件:
# play /usr/share/sounds/KDE_Startup.wav 或者 # play /usr/share/sounds/KDE_Startup_new.wav
這兩個好像是KDE的登陸音樂
------------------------------------------------------------------------------------------- 可是如今播放 mp3 文件仍是有問題,咱們須要下載相關的編、解碼器:
libmp3lame 和 libmp3lame-devel (這兩個是編碼器)
mad (這是解碼器)
咱們能夠從 rpmfind.net 網站上搜索並下載這三個包;
我搜索並安裝的是:(注:個人系統爲 redhat AS4 ) libmp3lame-3.95.1-1.i386.rpm libmp3lame-devel-3.95.1-1.i386.rpm mad-0.14.2b-1.i386.rpm
安裝以後就能夠 play 命令播放 mp3 文件了!
可是用此命令播放的音樂效果比較差,只能湊合着聽 :(
------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- 一個簡單的 play 命令爲何就能播放音頻文件呢?
咱們能夠看一下此命令的源代碼:# vi /usr/bin/play
會發現它其實調用的是 sox 命令!
(看 man 手冊頁也會發現 play 和 rec 是 sox 命令的前端程序)
sox 是什麼呢?它是一個功能強大的音頻處理程序,能夠用於播放、錄製音頻文件、轉換音頻格式、添加特殊音效;
------------------------------------------------------------------------------------------- sox 全稱爲:Sound eXchange
是一個命令行下的音頻處理程序,能夠用來將音頻文件在各類不一樣的格式間相互轉換,例如 mp3 轉 wav,
或者 wav 轉 mp3 等等;能夠對音頻文件長短進行裁剪;還能夠爲音頻文件添加各類特殊音效。
sox 支持的音頻格式有:
RAW sound data in various data styles RAW textual sound data Amiga 8svx files Apple/SGI AIFF files SUN .au files PCM, U-law, A-law, G7xx ADPCM files mutant DEC .au files NeXT .snd files AVR files CD-R data (music CD format) CVS and VMS files (continous variable slope) GSM raw data (with optional library) Macintosh HCOM files Amiga MAUD files MP3 files (with optional external library) Psion Record.app files IRCAM SoundFile files NIST SPHERE files Turtle beach SampleVision files Soundtool (DOS) files Yamaha TX-16W sampler files Sound Blaster .VOC files Dialogic/OKI ADPCM .VOX files Ogg Vorbis files Microsoft .WAV files PCM, U-law, A-law, MS ADPCM, IMA ADPCM, GSM (optional), RIFX (big endian) Psion (palmtop) A-law .WVE files Record and Play from OSS or ALSA /dev/dsp and Sun /dev/audio. nul file type that reads and writes from/to nothing.
對音頻文件可設置的音效有:
Channel averaging, duplication, and removal Band-pass filter Band-reject filter Compress and Expand (compand) the dynamic range of samples Chorus effect DCShift audio Deemphases filter Move soundstage to front of listener. Add an echo or sequence of echos Fade in or out Apply a flanger effect Apply a high-pass filter Apply a low-pass filter Display a list of loops in a file Add masking noise to a signal Multi-band Compander Pan sound between channels Apply a phaser effect Change the pitch of a sound file without affecting its speed. Change sampling rates using several different algorithms. Repeat audio data Apply a reverb effect Reverse sound samples (to search for Satanic messages Detect periods of silence and start and stop processing based on it Change the speed of samples being played (without affecting pitch) Display general stats on sound samples Stretch/shorten the duration of a sound file. Swap stereo channels Create sounds with a simple synthesizer Trim audio data from beginning and end of file. Add the world-famous Fender Vibro-Champ effect Adjust volume of samples.
在咱們的 Linux 發行版中通常會默認安裝了 sox 程序包,能夠用 rpm -qa sox 查看;
若是沒有安裝,那麼能夠從 http://sox.sourceforge.net/ 網站下載最新的源碼包:
sox-12.18.2.tar.gz
解壓後編譯安裝便可;
------------------------------------------------------------------------------------------- 下面咱們舉幾個簡單的例子,來看一下如何使用 sox 來處理音頻文件:
(1) 轉換音頻格式:
# sox file.mp3 new.wav
(2) 查看音頻文件的信息:
# sox file.mp3 -e stat
(3) 裁剪音頻文件:
# sox file.mp3 new.mp3 trim 5 40 (注:選項 trim 用於裁剪文件)
執行此命令後生成的 new.mp3 文件是 file.mp3 文件的 5 秒至 40 秒之間的數據;
(4) 設置「淡入淡出」效果:
# sox file.mp3 faded.mp3 fade 5 240 5 (注:選項 fade 用於設置淡入淡出)
生成的 faded.mp3 的前 5 秒和最後 5 秒爲漸強和減弱音;(240 是整個音頻文件的播放時間)
(5) 設置「顫音」效果:
格式:sox file.mp3 new.mp3 vibro [speed] [depth] (注:speed 值應小於 30,depth 值應在 0.5 到 1 之間)
# sox file.mp3 new.mp3 vibro 10 0.5
本身聽聽效果吧
(6) 設置快速播放效果:
# sox file.mp3 new.mp3 speed 2 (注:選項 speed 用於設置加速效果)
生成的 new.mp3 的播放速度是原文件的 2 倍。
------------------------------------------------------------------------------------------- 其餘功能還有不少,我就不一一列舉了。
詳細內容能夠參照 man 手冊頁:# man sox
雖然 play 命令能夠在純字符界面下播放音樂,但音效比較差,因此仍是建議你們用 xmms 在圖形界面下聽吧 |
|