Recording Sound from the gdam-server

Server support is in place for recording sound output by the gdam server to a given device. The sound can be written directly to disk, or sent to another process (i.e. an mp3 encoding process on some machine).

Starting and Stopping Recording with gdamcli

The long way to do this is to use the gdamcli program to start and stop the recording. You do this:

       % ./gdamcli [--device /dev/dsp?]

                  #  Print out the mixer's information.  The `parent'
                  #     is always the recording filter.
        gdam-cli> ls -a $mixer
        source 1.
          arg 0: mixed => []
          arg 1: parent => 2
          arg 2: terminates => 0
          arg 3: paused => 0
          arg 4: mode => eternal
          arg 5: parent_device => 0
          arg 6: position => 182272L
          arg 7: subsources => []

                # The number after `call' should be the parent number.
        gdam-cli> call 2 add_output connect your_host:your_port_number

          arg 0: output_id => 1
                # So now it'll be connecting/recording on your host.

And to stop it:

       gdam-cli> call 2 remove_output output_id 1

                # will stop it (use the output_id it gives you)

                # You can record to multiple computers this way.

                # Finally, instead of `connect' you can say `file'
                # which will make the server write the raw sound data
                # to a local file.
So if you set up something to record at that port, you're ready to go.

Starting and Stopping Recording with record-mp3 and record-stop

The cli/record-mp3 script attempts to automate this, as its first argument it takes the host and port to tells the gdam server to connect to host:port as specified as the argument to the script. The cli/record-stop scripts removes the output which record-mp3 adds.

Recording from within the GUI

The gdam-launcher pops up single turntables with an entry at the bottom for a recording location. Format is 'host:port'. Pressing the Record button will cause the entire mix being sent to the first sound device (the value of the first --device flag, or the GDAM_DEVICE environment variable, or /dev/dsp by default) to be mirrored to the given host. While it is recording, the button will remain depressed. Press it again to stop the recording.

Setting Up Something to Record

We have used gogo to encode mp3 data, and with some success, but it seemed a bit unstable. lame isn't quite as fast, but it hasn't crashed yet. Try the following line in your inetd.conf:

       6060 stream tcp nowait /usr/sbin/tcpd /usr/local/sbin/run-lame
And the following 3-line shell script as /usr/local/sbin/run-lame:
       #! /bin/sh
        DATE=`date +%d-%b-%Y-%H:%M:%S`
        /usr/local/bin/lame -r -x -m s - /mnt/18/lame/l-$DATE.mp3 > /tmp/lame.log.$DATE 2>&1
Alternately, use /usr/local/sbin/run-gogo:
       #! /bin/sh
        DATE=`date +%d-%b-%Y-%H:%M:%S`
        /usr/bin/gogo stdin /mnt/18/gogo/$DATE.mp3 -offset 0 > /tmp/gogo.log.$DATE 2>&1
And you have to accept that this is probably a security hole if you are outside a firewall :) See the appendix for more security info.

Icecast / Shoutcast

If you want to talk to a Shoutcast server, here is an untested alternate script that can be run from inet.d by Scott Manley (aka Szyzyg) .

       #! /bin/sh
        DATE=`date +%d-%b-%Y-%H:%M:%S`
        mkfifo /tmp/mp3pipe
        echo "password" > /tmp/shoutheaders
        echo "icy-name: Test" >> /tmp/shoutheaders
        echo "icy-genre: Mixed" >> /tmp/shoutheaders
        echo "" >> /tmp/shoutheaders
        /usr/bin/lame - - > /tmp/mp3pipe &
        cat /tmp/shoutheaders /tmp/mp3pipe | nc localhost 8000 
Should suffice to have it bounce off to an mp3 encoding server... As a note, icecast has broken support for piping in raw audio data which could be used live. Alternately, I hacked the shout utility to support streaming a file which was growing in size. This was sufficient to manage a live broadcast.

Further icecast utilities to come...

Related Links