Sunday, March 12, 2006

MIDI on Nokia770 with Timidity


While recent Nokia phones handle Midi-Files quite well, so far the support on N770 was missing.
Here is how to get them played.

Requirements
  • get my binaries for Timidity timidity-2.10.4_N770bin.tar.gz [This is an older version of timidity, but runs much faster than 2.13.0, see here:
    timidity++2.13.0_N770bin.tar.gz ]

  • you need some Instruments to play your MIDIs, definitely NOT a huge footprint, so I recommend 2MBGMGS.SF2 (usually shipped with some soundcards) or take some small .pat files for single instruments (see timidity.cfg)
  • and of course: some midi-Files of your choice.
  • xterm ... as there is no GUI so far (besides "ncurses")

Installing
Unpack the binary (tar -zxvf timidity++2.13.0_N770bin.tar.gz) to for example /user/home. This will create a subfolder timidity.
Place 2MBGMGS.SF2 and you MIDI-Files in the same folder for the moment.
As timidity will look for its config in /etc/timitidy.cfg , place there
a link: ln -s /home/user/timidity/timidity.cfg /etc/timidity.cfg
For convenience, you may also want to place a link to timidity somewhere to your path.

Using
In the timidity-folder enter ./timidity -in *.mid
After a few seconds, it will start playing. Otherwise, check the path in timitity.cfg.

With the ncurses interface (-in) you can use the hardkey arrows for midi volume, etc.
Use 'q' to quit, 'n' for the next song. Sufficient interfacing and nostalgic as using timidity first time back in the 90th.

Why MIDI?
Well, there is already a text editor and python on the N770... So, if you want to create ringtones on the road, have a look at MMA (Musical MIDI Accompaniment). You can basically script some tunes, it has more than 50 presets for auto accompaniment.
Well, rather "Band in the Pocket" than "Band in a Box" ;-)
In brief: Download and extract (tar -zxvf mma-bin-0.20.tar.gz) , no need to install it, simply
cd mma-bin-0.20 and run /var/lib/install/usr/bin/python2.4/python mma -g
This takes a while as it updates the MMA library. Now you can "re-compile" any of the demo songs in order to verify it works: python mma ./egs/lyrics/twinkle.mma




UPDATE...
After just finishing with the first version of this post (2.13.0 of Timidity++), I decided to give an older version a try (2.10.4). This was a complete success. Some options had a different format, so the timidity.cfg also incorporates some slight changes. Additionally, I changed timidity.h in order to use some slow CPU defaults and removed some Tracker-Formats. The binary is now way smaller. The part below the line is for later reference - maybe the newer Timidity will improve.




Performance issue...
Latest versions of Timidity seem to be a bit slow due to higher standards in playback quality. However, I remembered that I was using it back in the old times on a 100MHz system.
It is crucial for playback on the N770 to disable many of the new features, see timidity.cfg for this:



opt EFresamp=d #disable resampling
opt EFvlpf=d #disable VLPF
opt EFreverb=d #disable reverb
opt EFchorus=d #disable chorus
opt EFdelay=d #disable delay
#opt no-anti-alias #disable sample anti-aliasing
opt EWPVSETOZ #disable all Midi Controls
opt p16a #default to 32 voices with auto reduction
opt s32kHz #default sample frequency to 32kHz
opt fast-decay #fast decay notes
opt output-mono # MM: Speaker of N770...



Please add Comments to this Post if you found out additional options.
Also see http://timidity.sourceforge.net/ for more infos on Timidity.
The ncurses-Interface can in principle be used (add -in to the command line options), but this slows down and your MIDI-files might sound choppy.
The slow startup is probably due to the unpacking of the Soundfonts (.sf2). If you know a 1MB GeneralMIDI set (either .pat-Files or a .sf2), please post here a link. Also, an older and simpler version of timidity might perform better.

Some comments on compiling
The 770 uses the ALSA sound system
Nokia770-51:/home/user/timidity# cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.9rc2 (Thu Mar 24 10:33:39 2005 UTC).

However, it returned me finally some errors on the device, probably some version conflict with libasound. The Enlightened sound daemon seems to be available as well, so use the esd-option:

./configure --enable-interface=ncurses --enable-audio=esd

Afterwards, compiling in the scratchbox (ARM/QEMU target) was straightforward.

8 Comments:

Anonymous Anonymous said...

If you have more (swap)space available, you can also try 8MBGMSFX.SF2 from your creative driver cd.
Additonally, change the following parameters in the .cfg:
"opt p24a" and "opt s44kHz"

March 12, 2006 3:48 PM  
Anonymous Anonymous said...

Nice to see this working on 770!

I notice this version does not play .mod
files as my desktop version does.

It is 2.11c on Fedora.

Keep up the work

Everett Holland

everett@infionline.net

March 29, 2006 9:19 PM  
Blogger Michael said...

Right, I removed the mod-libraries to keep the binary smaller and as I had some trouble compiling.
Maybe I'll add it in the future, but I do not even have .mod files to test.

March 29, 2006 10:03 PM  
Anonymous Anonymous said...

Do not see your email address.

Send me an email and I will reply with
a few .mod files.

Everett Holland

March 31, 2006 9:15 PM  
Blogger Unknown said...

Could you package the smallest, simplest, fastest version of timidity as a deb (for 770 and 800?) I compiled a working version here (yours wouldn't run for me) but building the deb is still not working.

Cheers,

April 19, 2007 2:46 AM  
Blogger Unknown said...

Looking more at midi/cpu performance, timidity can be absolutely terrible with some midis, making it a bad choice for game music.

I was looking at it for Exult ultima7 remake (dl at http://pupnik.de) but midi was too slow, so I converted everything to mp3 for dsp-accelerated playback.
I'm also looking at midi-to-mod conversion programs for alternatives.

Anyway, for standalone playing i suppose it's not a real problem. A little midi playing app or plugin for gstreamer might be a nice project.

May 11, 2007 4:14 PM  
Anonymous Anonymous said...

It doesn't work on my Nokia 770. I followed the instructions but got ./startTimidity.sh: 3: ./timidity: not found. What might be the problem?

September 13, 2007 4:20 PM  
Anonymous Anonymous said...

It doesn't work on my Nokia 770. I followed the instructions but got ./startTimidity.sh: 3: ./timidity: not found. What might be the problem?
-------------------------------
i have same problem with 770(2008he)

February 27, 2009 4:55 PM  

Post a Comment

<< Home