Generate pink noise under ubuntu

Thu, 2008-08-28

Pink noise is useful to drown out distracting noises that surround you. In that way it can help your concentration.

A simple program that ships with Ubuntu that generates pink noise is speaker-test. It comes with the package alsa-utils.

Difference between apt-get upgrade and apt-get dist-upgrade

Sun, 2008-08-24

Imagine you have installed packages A-1.deb and B-1.deb
A-1.deb depends on packages Adep1-1.deb and Adep2-1.deb while B-1.deb depends on package Bdep1-1.deb:

`—– Adep1-1.deb
`—– Adep2-1.deb

`—— Bdep1-1.deb

Now, there is a new package available for program A, namely A-2.deb. A-2.deb still depends on Adep1-1.deb but now it also depends on a new version of Adep2, namely Adep2-2.deb:

`—– Adep1-1.deb
`—– Adep2-2.deb

There is also a new package for program B, namely B-2.deb, and there is also a new version of B-2’s dependency, namely Bdep1-2.deb. But contrary to the already installed version of B, B-1.deb, B-2.deb also depends on a new package: Bdep-new-1.deb

`—— Bdep1-2.deb
`—— Bdep-new-1.deb

If you now execute an apt-get upgrade you would see something like this:

     # apt-get upgrade
     Reading Package Lists... Done
     Building Dependency Tree... Done
     The following packages have been kept back
     The following packages will be upgraded
       A Adep1 Adep2
     3 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
     Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
     Do you want to continue? [Y/n]

As you can see the package B is kept back. The reason is that in order to install the new version of B, B-2.deb, a new package must be installed, Bdep-new-1.deb, but apt-get upgrade doesn’t install new packages, it only upgrades already installed packages.

On the other hand, apt-get dist-upgrade will also install new packages in order to resolve dependencies. So with a dist-upgrade you would get something like this:

     # apt-get dist-upgrade
     Reading Package Lists... Done
     Building Dependency Tree... Done
     Calculating Upgrade... Done
    The following NEW packages will be installed:
     The following packages will be upgraded
       A Adep1 Adep2 B Bdep1
     5 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
     Need to get 7055B/7055kB of archives. After unpacking 1161kB will be used.
     Do you want to continue? [Y/n]

In general, if you do an apt-get upgrade and a package is kept back:
“This means that there are new versions of these packages which will not be installed for some reason. Possible reasons are broken dependencies (a package on which it depends doesn’t have a version available for download) or [like in my example] new dependencies (the package has come to depend on new packages since the last version). ” [APT HOWTO
Chapter 3 – Managing packages, section 3.4 Upgrading packages

Bridged networking with virtualbox, ubuntu and static ips

Thu, 2008-08-07

This is a little howto where I explain how I configured bridged networking for virtualbox with static ips on an Ubuntu host in order to make the virtual machine accessible from outside the host system.

sudo aptitude install bridge-utils uml-utilities

sudo adduser $USER uml-net

Login again so the change takes effect.

Modify /etc/network/interfaces so it has the following content:

auto lo
iface lo inet loopback

iface eth0 inet static

auto eth0

auto tap0
iface tap0 inet manual
up ifconfig $IFACE up
down ifconfig $IFACE down
tunctl_user david

auto br0
iface br0 inet static
bridge_ports eth0 tap0

Restart networking:

sudo /etc/init.d/networking restart

Open virtualbox. Click on settings and choose network. Where it says “Attached to” select Host Interface. In the text field labeled “Interface Name” insert tap0.

Boot your guest OS and configure networking under your guest OS the same way you would configure any other machine on your local LAN.

Chapter 6, Virtual Networking, from the Virtualbox User Manual

Spanish mental addition mp3

Fri, 2008-08-01

In another post I wrote how to create with festival, lame and sox an mp3 to practice mental addition. That mp3 used festival’s default english voice. What I did to have a spanish version is the following:

Copy the text2wave script to ~/bin/
mkdir ~/bin
cp $(which text2wave) ~/bin/text2wavees

Add the following after line 46 of ~/bin/text2wavees:

Use the following script to generate the mp3:

#!/bin/bash -e

# output file

if [ -z "$output" ]; then 
        echo "usage: $0 OUTFILE"


TMP=`mktemp -d /tmp/speed_addition.XXXX`
pushd $TMP

# pause length in seconds

for i in `seq 32`; do
        x=$(($RANDOM % 999))
        while [ $x -lt 11 ]; do
                x=$(($RANDOM % 999))
        y=$(($RANDOM % 999))
        while [ $y -lt 11 ]; do
                y=$(($RANDOM % 999))
        echo "$x + $y" | $TEXT2WAVE -o add$i.wav
        echo "$(($x+$y))" | $TEXT2WAVE -o result$i.wav
        sox add$i.wav add_with_pause$i.wav pad 3 $pause
        sox add_with_pause$i.wav result$i.wav out$i.wav

sox out*wav out.wav
lame --ta speed-math --tl speed-math-es --tt $output --silent out.wav $CWD/$output


rm -r $TMP