Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Random SMS starcraft style

    Reply
    Dotblank | # 1 | 2010-04-08, 16:19 | Report

    This will be my first technical post as well as my first N900 hack! I am not a programmer or a developer I just have too much time.

    One day I had an idea to set my phone's SMS alert to a random Starcraft unit selection sound. After much tweaking and trial and error I am now very pleased with my hack.

    What I did was download the SC1 sound pack from teamliquid onto my device.

    After much trial and error I found the location of the cached SMS alert wave files. I then created a placeholder wav file called randomsc.wav somewhere in the MyDocs directory using an existing wav file.

    I then created a named pipe at /home/user/.local/share/sounds/randomsc.wav.wav (The phone encodes whatever file you select and appends a .wav to it when selecting an alert)

    Code:
    mkfifo /home/user/.local/share/sounds/randomsc.wav.wav
    I then set the alert to my placeholder wav file (the phone sees that it is already cached and does not attempt to re-cache it)

    All I had to do now was pipe random wav files into the named pipe. I created an index of the files to be randomized with

    Code:
    find /home/user/MyDocs/SC1S/Sounds/ | grep wav > /home/user/list.txt
    /home/user/MyDocs/SC1S/Sounds/ is the location of the soundpack of the wav files to be randomized

    With the index created I now just have to pipe random entries into the named pipe with:

    Code:
    while true; do /usr/bin/gnu/shuf /home/user/list.txt | head -n 1 | xargs cat 1>/home/user/.local/share/sounds/randomsc.wav.wav; done
    What this did was loop cat random files into the named pipe randomsc.wav.wav. this also requires the coreutils-gnu package to be installed in order to use the "shuf" command. The above code will loop infinitely until the task is terminated. While that code was running any SMS I received was a random Starcraft Unit selection sound.

    There are many problems with this set-up and it is not ideal. It could be improved several ways.

    1. If the device were to be plugged into a computer in mass storage mode and you were to receive an SMS it would cause lots of problems (this could be avoided if you put the sound files into the rootfs)
    2. The loop command has to be run in order for any of this to work and this needs to be daemonized.
    3. Deleting sound files might cause an SMS alert to be missed

    This named pipe feature seems very extensible to me. So i tried piping espeak into the fifo and viola dynamic tts SMS alert.
    Code:
    while true; do date | espeak -w /home/user/.local/share/sounds/randomsc.wav.wav; done
    I also believe this concept to be extended to Per-Contact Ringtones as the regular ringtones use the same method. You could make a simple python script catch a dbus message and look up the number and pipe the relevant ringtone.

    I think this is very cool method to generating dynamic ringtones and I can't wait to try out per contact ringtones. I'm also not a developer but I'm sure some of you out there can take my concept and make it user friendly and refined.

    I am not familiar with upstart so I have no idea how to make the loop run at startup

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Dotblank; 2010-04-08 at 17:22.
    The Following 9 Users Say Thank You to Dotblank For This Useful Post:
    baksiidaa, clasificado, F2thaK, jarmo2, Manul, mmurfin87, Netweaver, Patola, v13

     
    fcrochik | # 2 | 2010-06-21, 00:32 | Report

    Just to finish the "circle", and in case you missed, there is a thread about how to assign ring tones to groups using python here

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by fcrochik; 2010-06-21 at 00:35.
    The Following User Says Thank You to fcrochik For This Useful Post:
    clasificado

     
    mmurfin87 | # 3 | 2010-06-21, 03:36 | Report

    Cool stuff! How about a video of this in action?

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout