命令行听歌http://www.linuxsir.org/bbs/thread280142.html?pageon=1#1584689

 

在纯字符界面下听歌 


利用 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 在图形界面下听吧心情好
 
 
作一只一往无前的小企鹅~~
相关文章
相关标签/搜索