Jump to content


Photo

Porting Timidity ++


  • Please log in to reply
17 replies to this topic

#1 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 17 March 2011 - 10:47 AM

I'm working on a full port of Timidity++ (not to be confused with sebt3's installer which enables music in certain games). The main motivation for this port is to use Timidity as an ALSA device, to handle MIDI output from something like Seq24.

I have a PND already, which is behaving strangely, but was never expected to 'just run' anyway. Its behaviour is a bit of a tangent at this point so I'll throw it into a spoiler.

Spoiler


To give it a test I threw the binary itself onto SD and attempted to play a midi file:
# ./timidity song.mid

It asked for /mnt/utmp/timidity/share/timidity/timidity.cfg. Naturally without a PND mounted this wasn't there, but after mounting the PND (which I presumed would make the cfg accessible via that path) and running the standalone binary again it gave the same error.

Obviously the PND needs to be an installer but I'm not sure where to go from here.

#2 skeezix

skeezix

    Mega GP Mania

  • GP Guru
  • 5088 posts
  • Gender:Male
  • Interests:Blog: http://www.rjmitchell.ca/~jeff/blog2009/

Posted 17 March 2011 - 03:09 PM

One pnd, shows up twice?

Is it in /pandora/apps, or /pandora/desktop?

Got the PXML to show us?

jeff

#3 Farox

Farox

    GP Mania

  • GP Guru
  • 491 posts
  • Gender:Male
  • Location:Italy
  • Interests:Pandora
    GP2X
    Caanoo

Posted 17 March 2011 - 04:36 PM

I think i could help for the 2 icon displayed on desktop.
I think is a bug of genpxml script, for some strange motive it generate a series of scripts under the dir /mnt/utmp/name_of_app/scripts and also append it to pxml.xml file.
For example:

sudo /usr/pandora/scripts/pnd_run.sh -m -p /media/GP2X8GB/pandora/desktop//timidity.pnd -e scripts/icon.png.sh -b timidity

So delete the others *.sh exept your timidity.sh under the scripts dir.
Next edit your PXML.xml file so to eliminate all the parts relative to the others scripts.
Next rebuild the PND.

Forgot to mention that is apply to sebt3 Yactfeau toolchain (IIRC Gruso seems to compile with this ).

Edited by Farox, 17 March 2011 - 04:50 PM.


#4 sebt3

sebt3

    homebrew player (P. & C.)

  • GP32 Hardcore
  • PipPipPipPipPipPip
  • 1897 posts
  • Gender:Male
  • Location:QC

Posted 17 March 2011 - 04:55 PM

It is showing up twice on the desktop. Running each one produces different output:

sudo /usr/pandora/scripts/pnd_run.sh -m -p /media/GP2X8GB/pandora/desktop//timidity.pnd -e scripts/icon.png.sh -b timidity


When genpxml cant find any .desktop file to generate the content of the PXML file, it create launchers scripts and an application entry for any executable files found in the PND directory.
I'm guessing that your icon have the execution bit set thuss had its PXML entry generated.
I think this could/should be dropped ;)


It asked for /mnt/utmp/timidity/share/timidity/timidity.cfg

imho your binary should use /etc/timidity/timidity.cfg instead (so it will use that data my installer deploy, but that will requiere you to rebuild timidity with an other pndconfigure option).

Else, you could copy /etc/timidity/timidity.cfg to /mnt/utmp/timidity/share/timidity/timidity.cfg using a scripts/pre_script.sh ;)

#5 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 18 March 2011 - 10:51 AM

Dual icon problem solved and PXML cleaned up. chmod -x icon.png, heh :)

On to /scripts/pre_script.sh, naturally I just grabbed timidity.sh to scoop out the bulk of it and drop my own line in. This is what it looks like:

#!/bin/sh
export PATH="/mnt/utmp/timidity/bin:${PATH:-"/usr/bin:/bin:/usr/local/bin"}"
export LD_LIBRARY_PATH=":${LD_LIBRARY_PATH:-"/usr/lib:/lib"}"
export HOME="/mnt/utmp/timidity" XDG_CONFIG_HOME="/mnt/utmp/timidity"

cp /etc/timidity/timidity.cfg /mnt/utmp/timidity/share/timidity/

Error in timidity.out:

Cannot create regular file '/mnt/utmp/timidity/share/timidity/timidity.cfg': Operation not permitted

I've tried a few different approaches to this but I'm not getting it right.

#6 sebt3

sebt3

    homebrew player (P. & C.)

  • GP32 Hardcore
  • PipPipPipPipPipPip
  • 1897 posts
  • Gender:Male
  • Location:QC

Posted 18 March 2011 - 01:10 PM

On to /scripts/pre_script.sh, naturally I just grabbed timidity.sh to scoop out the bulk of it and drop my own line in. This is what it looks like:

Imho, it should look like :
#!/bin/sh

APP=timidity
if [ -z "$APPDATADIR" ];then
        printf "WARNING Guessing APPDATADIR="
        PND=$(sudo losetup -a |grep $APP|sed 's/.*(//;s/)//')
        if [[ "x$PND" = "x" ]];then
                {
                        mount|awk '/mmc/{print $3;exit}';
                        echo /
                }|while read dir;do
                        if [ -d $dir/pandora/appdata/$APP ];then
                                APPDATADIR=$dir/pandora/appdata/$APP
                        fi
                done
                echo "$APPDATADIR (wild guess)"
        else
                APPDATADIR=$(echo $PND|sed 's/pandora.*/pandora\/appdata\/'"$APP/")
        fi

fi
if [ -d "$APPDATADIR" ];then
        mkdir -p $APPDATADIR/share/timidity
        cp /etc/timidity/timidity.cfg $APPDATADIR/share/timidity
else
        echo "ERROR: APPDATADIR not found !"
fi


#7 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 18 March 2011 - 02:08 PM

Why didn't I think of that.

You have sorted me out once again, thank you. :) I am currently listening to a very cheesy rendition of Walk The Line by Johnny Cash. Job's not finished yet - all I've done here is mount the PND, then run the executable from elsewhere. Now I've got a few avenues to look at (ALSA device, usable MIDI file player, etc etc), will report back.

[edit] Trying to load it as an ALSA device, ugh. Command should be:

./timidity -iA -Os
Output is:
Interface `A' is not compiled in.
Recompile with:
pndconfigure --enable-alsa --enable-sound=alsa
No luck yet. 2.40am is bedtime.

#8 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 19 March 2011 - 01:25 AM

Lots of false starts in spoiler, optional reading for fans of schadenfreude.

Spoiler

Edited by Gruso, 19 March 2011 - 06:46 AM.


#9 mash-system

mash-system

    Member

  • Members
  • PipPip
  • 9 posts

Posted 19 March 2011 - 04:32 AM

but now I'm back to "Interface `A' is not compiled in." Argh.

I'm not that deep into timidity++, but what does it say if you just call "timidity -h"?
Can you see the ALSA-Interface listed?

This is from my Debian Squeeze desktop-machine:

Available interfaces (-i, --interface option):
  -in          ncurses interface
  -ie          Emacs interface (invoked from `M-x timidity')
  -ia          XAW interface
  -id          dumb interface
  -ir          remote interface
  -iA          ALSA sequencer interface
Supported dynamic load interfaces (/usr/lib/timidity):

Interface options (append to -i? option):
  `v'          more verbose (cumulative)
  `q'          quieter (cumulative)
  `t'          trace playing
  `l'          loop playing (some interface ignore this option)
  `r'          randomize file list arguments before playing
  `s'          sorting file list arguments before playing
  `D'          daemonize TiMidity++ in background (for alsaseq only)


#10 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 19 March 2011 - 05:10 AM

Available interfaces (-i, --interface option):
  -id          dumb interface
It looks like I feel. I didn't even think to look there, thanks for that. Shines a bit of light on what's happening (or, what is not).

[edit] Ok, couple of beers and an hour watching TV and then everything started to work. Correct build options:
# pndconfigure --enable-audio=alsa --enable-interface=alsaseq
Successfully ran
./timidity -iA -Os
...on the Pandora, and it's showing up as a MIDI device in Seq24. Shyeah! (It did ask for snd_seq initially, which I was able to load with Seq24. Will have to include it with Timidity too). Time to pack some of this joy into a working PND.

Question:-

Getting back to my crossroads from the first post, there are numerous ways to use Timidity and I don't think one PND will cover them all unless it is turned into a full installer. (I'll tell you now I'm not going near such scripts, I was mindblown enough by the chasm between what I thought was a sufficient pre_script.sh and what sebt3 posted.)

I'm planning to release the first beta as an ALSA daemon loader only. If there's interest in using this as a MIDI file player, perhaps a separate PND with GUI.

Thoughts?

------------------------

TiMidity Daemon Loader

It will prompt for password if snd-seq is not loaded (per session). Run PND, enter password, fire up Seq24 and make some noise. It is quite stuttery with moderate MIDI traffic.

Edited by Gruso, 19 March 2011 - 07:38 AM.


#11 mash-system

mash-system

    Member

  • Members
  • PipPip
  • 9 posts

Posted 19 March 2011 - 07:30 PM

...on the Pandora, and it's showing up as a MIDI device in Seq24. Shyeah! (It did ask for snd_seq initially, which I was able to load with Seq24. Will have to include it with Timidity too). Time to pack some of this joy into a working PND.

Great stuff! Will definately try that out soon!

I'm planning to release the first beta as an ALSA daemon loader only. If there's interest in using this as a MIDI file player, perhaps a separate PND with GUI.
Thoughts?

Maybe it could be handy for that to use the "multiple-application-feature" of the PXML/PNDs?

So there could be only one PND, but different ways to invoke timidity. I'm using this eg. in my Links2-PND.

#12 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 20 March 2011 - 12:15 AM

Oh yes, good idea.

[edit] Can anyone provide some insight on peelie's issue here?

hi was trying to use my own sequence. also when firing up daemon got a strange message about malicious program and mouse? not been able to repeat it.
-------

rm: cannot remove `/tmp/cpuspeed': No such file or directory
not mounted on loop yet, doing so
LoopMountedon:
/dev/loop3
Filetype is Squashfs
sudo mount -t squashfs /dev/loop3
mounting union!
Filesystem is vfat
[------------------------------]{ App start }[---------------------------------]
WARNING Guessing APPDATADIR=
(gksudo:5396): Gdk-CRITICAL **: gdk_draw_pixbuf: assertion `GDK_IS_DRAWABLE (drawable)' failed
Requested buffer size 32768, fragment size 8192
ALSA pcm 'default' set buffer size 32768, period size 8192 bytes
TiMidity starting in ALSA server mode
Opening sequencer port: 128:0 128:1 128:2 128:3
Requested buffer size 32768, fragment size 8192
ALSA pcm 'default' set buffer size 32768, period size 8192 bytes


I thought it might be a HF4 issue, but he tried it on a fresh HF5 SD install and reports the same error.

Edited by Gruso, 20 March 2011 - 01:40 AM.


#13 peelie

peelie

    GP Mania

  • GP32 Hardcore
  • PipPipPipPipPip
  • 381 posts

Posted 21 March 2011 - 12:46 AM

Oh yes, good idea.

[edit] Can anyone provide some insight on peelie's issue here?

<snip>



got it sorted - did not realise you had to higlight sequence to get it to output sound!
hope next version of seq24 will iron out stutter issues - then all i need is to mod my korg monotron to have midi input and away we go :)

#14 Gruso

Gruso

    thunderbox

  • X-treme Team
  • 5538 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 21 March 2011 - 03:30 AM

I'm wondering if buffer settings will improve performance. I'll experiment with some of these:

-k  msec
              Specify audio queue time limit to reduce voices.  If the remain-
              ing  audio buffer is less than msec milliseconds, TiMidity tries
              to kill some voices.  This feature makes  it  possible  to  play
              complicated MIDI files on slow CPUs.  Setting msec to zero tells
              TiMidity to never remove any voices.

 -B fragments[,buffer-bits]
              For the Linux/FreeBSD/OSS/ALSA/Windows sound driver, selects the
              number of buffer fragments in interactive mode.  Increasing  the
              number  of  fragments  may reduce choppiness when many processes
              are running.  It will make TiMidity seem to  respond  sluggishly
              to  fast forward, rewind, and volume controls, and it will throw
              the status display off sync.  Specify a fragments number of 0 to
              use the maximum number of fragments available.

-q m/n Specify audio buffer in seconds.  m: maximum size of buffer,  n:
              percentage  filled  at the beginning (default is 5.0/100%) (size
              of 100% equals the whole device buffer size)

On the GUI front, I've tried compiling in some options (listed below) but nothing seems to work. Even doing a native build on my desktop (xubuntu 10.04) I only got xaw to work, and it was crashy.

--enable-interface[=interface_list]
	ncurses: Ncurses interface. timidity's -in option will invoke this interface.
	slang: slang interface. timidity's -is option will invoke this interface.
	motif: Motif interface. timidity's -im option will invoke this interface.
	tcltk: Tcl/Tk interface. timidity's -ik option will invoke this interface.
	emacs: Emacs front-end. Type M-x timidity to invoke.
	vt100: The full-screen interface using VT100 terminal control codes. timidity's -iT option will invoke this interface.
	xaw: X Athena Widgets interface. timidity's -ia option will invoke this interface.
	xskin: X skin interface. timidity's -ii option will invoke this interface.
	gtk: GTK+ interface. timidity's -ig option will invoke this interface.
	w32gui: Build as Windows GUI binary.


#15 M-HT

M-HT

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 157 posts
  • Location:Bratislava

Posted 21 March 2011 - 08:02 AM

Which version of Timidity++ are you using ?
From the first post it looks like version 2.13.0.
The latest released version is 2.13.2 from October 2004.
But there's also the CVS version from September 2010, which contains a lot of fixes since 2004.