Rants of a madman » 2008 » March

Archive for March, 2008

Mar
22

Ive been coding some perl for my Nokia 770 that needed to play sounds and i found that play-sound should do the trick. However the volume is very low and a lot of googling turned up nothing but other people with the same problem.

After analysing ‘play-sound’, i found out 2 things.

  1. It does use “esd” to play waves, which is good since its “non-blocking”.
  2. It’s made for playing “system-alert” sounds

So looking in the sound configuration, you can choose the volume level of system-alert sounds. The options are “none”,”level 1″ and “level 2″ and after raising my sound to level-2, it still wasnt loud enough. Also, i really dont want all other alert sounds at that volume.

So based on my (simple) analysis, the play-sound program reads a config option called “system_alert_volume”. So i thought there might also be a “master_volume” defined as well and did a small patch. And i was right.

So my solution is this (and requires perl on the tablet or an “offline” hex-edit):

Make a copy of play-sound:
$ cp /usr/bin/play-sound /usr/bin/play-sound2

Patch /usr/bin/play-sound2 to use “master_volume” instead. With perl, do this:
$ perl -pi -e 's/system_alert_volume/master_volume\x00...../' /usr/bin/play-sound2

Problem solved ;). Now you can use the command:
$ play-sound2 test.wav

to play sounds at the set master volume.

To do the same patch in a hex-editor, locate “system_alert_volume” and overwrite the string with “master_volume”, plus a “null” char (\x00) to terminate the string. If you forget to null-terminate, play-sound2 will segfault.

I like this solution, since “play-sound” is only 10k large and no extra dependencies needs to be filled.. And the “copy & patch” could be done from an install script.



  - Dan