让LinuxMobile 支持MIDI
转载时请注明出处和作者联系方式:http://blog.csdn.net/absurd
作者联系方式:李先静 <xianjimli at hotmail dot com>
更新时间:2007-6-5
MIDI的好处在于它占空间小,一般只有几十K甚至几K大小,手机的空间有限,用MIDI作铃音是一种好的选择。其实说白了MIDI就是一种查表算法,它本身并不包含声音数据,而是通过波表去查找实际的声音数据。一般的声卡都固化了波表,可以直接播放MIDI。不过手机上的声卡和PC上的声卡可不一样的,比如我们使用的wm9713芯片,它兼容AC97标准,但并不支持硬件MIDI,所以在手机上播放MIDI,我们要用软件来实现。今天我先在PC上做了实验,在手机的实现也差不多,这里做个笔记。
1. 下载并编译TiMidity
wget http://nchc.dl.sourceforge.net/sourceforge/timidity/TiMidity++-2.13.2.tar.bz2
tar jxvf TiMidity++-2.13.2.tar.bz2
cd TiMidity++-2.13.2
./configure ;make;make install
2. 下载sound font
到http://www.sf2midi.com网站上下载sound font。
mkdir /usr/local/share/sondfont
mv BearVincePizzicati.sf2 /usr/local/share/sondfont
3. 编辑配置文件/usr/local/share/timidity/timidity.cfg
dir /usr/local/share/sondfont
soundfont BearVincePizzicati.sf2
4. 找个midi播放试试
timidity greatewall.mid
Playing greatewall.mid
MIDI file: greatewall.mid
Format: 1 Tracks: 23 Divisions: 240
Track name: Solo Vox
Track name: Synth String2
Track name: Space Voice
Track name: Space Voice
Track name: Clean Guitar
Track name: Clean Guitar
Track name: Fender Bass
Track name: Acou Piano
Track name: Acou Piano
Track name: Distortion Gtr
Track name: Distortion Gtr
Track name: Overdrive Gtr
Track name: Overdrive Gtr
Track name: AcouPiano
Track name: Bass Drum
Track name: Rim shot
Track name: Snare
Track name: Hi-hat
Track name: Open Hi-hat
Track name: Acou Tom
Track name: Clash
Track name: Conga
No instrument mapped to tone bank 0, program 1 - this instrument will not be heard
No instrument mapped to drum set 0, program 35 - this instrument will not be heard
No instrument mapped to drum set 0, program 37 - this instrument will not be heard
No instrument mapped to drum set 0, program 38 - this instrument will not be heard
No instrument mapped to drum set 0, program 41 - this instrument will not be heard
No instrument mapped to drum set 0, program 42 - this instrument will not be heard
因为下载的是一个精简的sondfont,所以会出现No instrument mapped to drum set 0之类的错误,不过除了效果差一点外,没有太大关系。
~~end~~