Tuesday, June 17, 2008

Midi to MP3 and abit of editing

My offspring loves watching Pocoyo, and I kinda like it too. Cute, mildly twisted humour and very entertaining. I learnt today that there is an Official Pocoyo Blog. Its very interesting, as it has news and information on the production of the series.

There is a blog entry entitled "Pocoyo Opening MIDI" - sure enough, they posted the midi file for the opening credits where Pocoyo introduces the characters with a few variations of the catchy theme.

I downloaded the midi, and wondered how I could make this a ringtone, for phones which dont support midi. Timidity was the solution.
# sudo apt-get install timidity
[Downloads about 29MB worth of stuff]
# timidity opening_pocoyo.mid -Ow -o poco.wav
It then displays a mapping of midi instruments, and warns if there are no appropriate instruments. For this case, I got 3 missing ones:

No instrument mapped to tone bank 0, program 11 - this instrument will not be heard
No instrument mapped to tone bank 0, program 108 - this instrument will not be heard
No instrument mapped to drum set 0, program 85 - this instrument will not be heard

you can then play the wav, but we are only halfway there. We still need to convert it to mp3.
# lame poco.wav poco.mp3
LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE, SSE2
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding poco.wav to poco.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA
1555/1555 (100%)| 0:04/ 0:04| 0:09/ 0:09| 9.2741x| 0:00
kbps LR MS % long switch short %
128.0 25.0 75.0 81.9 11.3 6.8
Writing LAME Tag...done

To test, mplayer can be used:
# mplayer poco.mp3
I then sent this file over to my phone, and its my new ringtone!

Instead of having the entire song, I used Audacity and extracted only the final part of the tune. I also used the "Fade In" effect to make it sound better. Audacity has an "Export" to mp3, which makes the lame part redundant.