Voder-Vocoder

The Log of Hal Canary

Navigation: Home | THE LOG | Log Archives | Resume | Contact Info | Public Key | SSL | Math Applets | Site Map | RSS2 | Atom | Backend

Archive for 2008-12

icecast+liveice

Setting up icecast+liveice so I can stream music from my PC to the internet. A simple

sudo apt-get install -y liveice icecast-server

installs the software. Use

makepasswd --crypt

to make a password and a hash of that password for the icecast server. Edit the /etc/icecast/icecast.conf to put the hashed password in there. Set port, hostname, and server_name. I used my dyndns hostname for my server name and used 8888 for my port. I was sure to open that port on my firewall and forward it on my nat/router. Restart the server with

sudo /etc/init.d/icecast-server start

Check the logs with

tail -f /var/log/icecast/icecast.log

That will let you know if you have password errors connecting to the icecast server.

Now edit the file $HOME/.liveice.cfg by starting with the example found on the internets. Some of the values I put in are:

SERVER localhost
PORT 8888
X_AUDIOCAST_LOGIN
PASSWORD XXXXXXXXXXXX
MOUNTPOINT /x
NO_SOUNDCARD
MIXER
PLAYLIST /home/hal/playlist.pl

Be sure to set all the values, not just the ones I listed.

#!/bin/sh
# $HOME/bin/startliveice.sh
# DTPD
DIR="/d/music/"
find "${DIR}" -name '*.mp3' \
  | ${HOME}/bin/randomize-list.py \
  > ${HOME}/playlist.pl
exec liveice -F ${HOME}/.liveice.cfg \
  2> /dev/null

Now you’re ready to start the liveice program. Read /usr/share/doc/liveice/README.liveice.gz to find out the commands for the curses frontend.

Check that it’s working with

mplayer -quiet -cache 32 http://127.0.0.1:8888/x

If I’m broadcasting, check me at at

http://halcanary.dyndns.org:8888/x

Hal Canary | Computers & Code | 2008-12-22 08:43:49 UTC
Permanent Link |
Comments Off (but feel free to email)

ransdomize

#!/usr/bin/env python
# randomize_list.py
# Written 2008 Hal Canary
# Dedicated to the public domain.
import sys, random
l=[]
for line in sys.stdin:
	l.append(line)
while l:
	e = random.choice(l)
	l.remove(e)
	sys.stdout.write(e)

UPDATE 2009-01-04: Just as I suspected, that code is highly inefficient. Here’s a different algorithm which is much faster for large N.

#!/usr/bin/env python
# randomize_list.py
# Written 2008-2009 Hal Canary
# Dedicated to the public domain.
import sys, random
l=[]
for line in sys.stdin:
	l.append(line)
while l:
	i = random.randint(0,len(l)-1)
	sys.stdout.write(l.pop(i))

Testing with the time command showed a 74% reduction in CPU use with the better algorithm.

Hal Canary | Computers & Code | 2008-12-21 18:50:35 UTC
Permanent Link |
Comments Off (but feel free to email)

/usr/share/dict

grep -i Ubuntu /usr/share/dict/*

In the Ubuntu OS distribution, the standard dictionaries lack the word “Ubuntu.”

Hal Canary | Computers & Code | 2008-12-06 09:51:29 UTC
Permanent Link |
Comments Off (but feel free to email)

Copyright 1997-2011 by Hal Canary.
mailto: h3 at halcanary dot org
http://halcanary.org