Recording audio on Ubuntu while watching TV with my android phone

First a bit of background: I hooked up my TV to a linux-box running Ubuntu. As a mediaplayer i use XBMC which also has a nice Android app for remote control. Something i miss though, is an easy way to record audio while watching. I use a lot of movie-samples (voices, fx, drones) in my music and i’m always looking at easier ways to get a bunch of samples. But here comes Remote Launcher to the rescue!

This app lets you run custom commands and shellscripts with the click of a button on your phone.

Here’s how i did it:

  • Download Remote Launcher server here and install it. Make sure to have java6 installed (apt-get install sun-java6-bin sun-java6-jre)
  • Now we do a testrun: remote-launcher-server -d

    Fill in a password twice. You only have to do this once. If you see a message that it’s running on port 4444. You’re set, and you can just CTRL-C again. The important thing is that you now will have a ~/.remotelauncherserver configuration file.

  • To make sure this server gets started whenever we reboot, we put the startup in /etc/init.d/remotelauncher
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          remotelauncher
    # Required-Start:    $local_fs $all
    # Required-Stop:
    # Default-Start:     2
    # Default-Stop:
    # Short-Description: Start the Android Remote Launcher daemon
    # Description:       See http://owtroid.com/remotelauncher/mediawiki/index.php?title=Remote_Launcher
    ### END INIT INFO
    #
    
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    NAME=remote-launcher-server
    DAEMON=/usr/bin/remote-launcher-server
    
    [ -x "$DAEMON" ] || exit 0
    
    case "$1" in
      start)
            echo "Starting remote-launcher-server"
            start-stop-daemon --start --background --user YOUR_LINUX_USER_NAME --make-pidfile --pidfile /var/run/remote-launcher-server.pid --exec $DAEMON --chuid YOUR_LINUX_USER_NAME -- -d
            ;;
      stop|restart|force-reload)
            echo "Stopping remote-launcher-server"
            start-stop-daemon --stop --pidfile /var/run/remote-launcher-server.pid
            ;;
      *)
            echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
            exit 3
            ;;
    esac
                
  • Make sure it gets linked to the correct rc.d: chmod 755 remotelauncher; update-rc.d remotelauncher defaults 96 02
  • Now we need some scripts to start and stop recording.

    ~/scripts/startrecord.sh

    #!/bin/sh
    
    date=`date +"%Y-%m-%d-%k-%M-%S"`
    filename="/data/Recordings/rec_$date.wav"
    /usr/bin/rec "$filename"
    


    ~/scripts/stoprecord.sh

    #!/bin/sh
    /usr/bin/killall -9 rec
    
  • Make them executable: chmod 755 ~/scripts/startrecord.sh ~/scripts/stoprecord.sh
  • Now we’re ready to configure remotelauncher to use them. Edit ~/.remotelauncherserver and put the following code in there. Make sure to change the paths of the scripts to the correct paths!
    ######## Remote Launcher Server config file ########
    #
    # Add entries in the following format:
    #   Name
    #   Description
    #   Path
    #
    # Example:
    #   Notepad
    #   Launch the Notepad editor
    #   c:\windows\system32\notepad.exe
    #
    # Visit http://sf.net/apps/mediawiki/remotelauncher/
    # for more details and examples.
    #
    # Blank lines or lines beginning with # are ignored.
    
    XBMC
    Start XBMC media center
    /usr/bin/xbmc
    
    Kill XBMC
    Kill XBMC media center
    /usr/bin/killall xbmc
    
    Record
    Start recording
    /home/cjpa/scripts/startrecord.sh
    
    Stop Record
    Stop recording
    /home/cjpa/scripts/stoprecord.sh
    
  • Now we can start and stop XBMC through the Remote Launcher as well as Start and Stop recording. Just run /etc/init.d/remotelauncher start and we’re ready to control our computer from our android device
  • Install the free Android App
  • Once installed you’ll have to add your server and you’re set!
  • The coolest thing about this app is, that you can make a homescreen widget to run 1 of the commands you configured. This makes it super-fast to launch remote scripts from your homescreen!

2 thoughts on “Recording audio on Ubuntu while watching TV with my android phone

  1. Thanks so much for the detailed install guide.. Saved me alot of time.

    One thing.

    I dont have /bin/usr/rec, is there a way to install this app??

Leave a Reply

Your email address will not be published.