Category: Linux

Un-ubuntuing Ubuntu… one of several million, no doubt. Ubuntu is pretty good, but persists in making what I’d regard as irritating desktop usability blunders. One of them is the use of “overlay scrollbars” which are scrollbars that are mostly hidden until you mouse over them. I found this annoying, but whatever, I can deal. It even more or less works, most of the time.

However, it breaks Inkscape. Inkscape’s color picker is a long strip of color patches, which you can click to select stroke and fill colors for drawings. The color picker has a scrollbar. If overlay scrollbars are on, then the entire area of the color picker ends up being the mouse-over area for the overlay scrollbar, so you can’t pick colors.

The fix is to issue the command “gsettings set com.canonical.desktop.interface scrollbar-mode normal” from the command line.

Useful mencoder invocation

mencoder -nosound mf://*.jpg -mf w=1280:h=800:type=jpg:fps=30 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2400:mbd=2:keyint=132:v4mv:vqmin=3:lumi_mask=0.07:dark_mask=0.2:mpeg_quant:scplx_mask=0.1:tcplx_mask=0.1:naq -o output_filename.avi

Turns all the JPEG files in the directory you are currently in into a nice quality MPEG-4/AVI file. The width and height in the options after -mf should be changed to match the images. This command line also works for PNG files if you replace both instances of “jpg” with “png”.

Command Line Audio Editing With Sox

For my ritual spoken word software piece, I recruited a bunch of my friends to say the text of the ritual. Each “stanza” of the ritual has a call and a response, so I broke each recording up into individual clips for each call and response. That gave me about 28 files per person, and over 100 clips total.

The different participants all recorded on different hardware, and at different volume levels. I also wasn’t super-precise about trimming the clips, so each file had silence at the beginning.

This left me with two problems: some participants were much softer than others, and some of the clips lagged each other, which made for bad chorus effects.

To trim the clips, I used sox, a Linux tool for manipulating sounds, with the command:

for file in *.wav; do sox $file $file.wav silence 1 0.1 2%

This results in a file named foo.wav.wav for each foo.wav file in the directory, so I cleaned up with:

rename -f “s/.wav././g” *

Note that this scribbles over the originals, so keep backups. I’m glad I did, because 2% turned out to be a little aggressive, and trimmed off the beginning of clips starting with an “ma-” sound, such as “make us a…”. This is likely because the sound faded in slowly, and so got counted as part of the noise rather than the beginning of a sound.

There is useful documentation for the sox silence filter here.

Turning the volume up on the files was done with:

for file in *.wav; do sox $file $file.wav gain -l 8; done

and another pass of rename, as above. Adjust the “8” up or down to suit your needs. Positive numbers make it louder, negative make it quieter.

If you want to preview a sox effect, just replace “sox” in the command with “play”, and leave off the output file. For example,

play myfile.wav gain -l 8

will play myfile.wav with increased gain, but won’t change the file.

We Make Ritual Noise

For a festival that I attend, I’m writing a soundscape in boodler to provide the vocal component for a ritual. Here, I’m going to annotate what I need to do to run Boodler on my laptop, which I’ll have at the festival.

The main thing is that Boodler seems to default to OSS, and I use PulseAudio, so to invoke the ritual, you need to run:

boodler -o pulse –external disturbingrelics com.gizmosmith.disturbingrelics/Example

The -o option tells it to use PulseAudio, –external makes it load from a directory instead of a .boop package for testing purposes, and the rest is the agent to run.

To organize all the sound clips I’m using, I have a boodler package for each person’s reading of the ritual script. The script is in a call and response format, with 14 calls and responses, so each package has 28 audio clips, one each for the call and response. I named all the clips “call_N_…” and “response_N_…” (for N in 1..14) so that the program can figure out the call/response pairs by name.

Each package starts out as a directory with the 28 files and a metadata file in them. For the directory “sage”, I create the package with:

boodle-mgr –import create sage

and then install it with:

boodle-mgr install ./com.gizmosmith.sage.1.0.boop

Converting .MPG to .AVI with Linux programs

I am trying to convert .mpg files from a sony camera into other, smaller versions for distribution. The files are in the mpeg2video codec, with a resolution of 720×480 at 29.97 fps. Normally, I’d use ffmpeg for this, but apparently “This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.” Thanks Ubuntu, I’m sure that won’t screw up a few thousand people’s video conversion scripts.

Anyway, let’s see what man avconv has to say. I want no sound, and I want to start 55 seconds into the film, to cut off most of a boring first minute. Seeking into the video is -ss 00:00:55. The option -an drops the audio. So, avconv -i blue_ball.mpg -an -ss 00:00:55 blue_ball.avi should do it. And, in fact, it does.

Cross-system chat log sync

I created a directory called “pidgin_logs” in my Dropbox folder, backed up my logs, removed the old log directory, and then created a link from where the log directory should have been to the Dropbox directory. Pidgin still starts up fine, and after I do this on all of my systems, they will all log chats to my Dropbox account.

I’m not sure I’m comfortable with the level of trust that this places in Dropbox, but it will be very convenient.

The commands to do it are:

cd ~/Dropbox/
mkdir pidgin_logs
cd ~/.purple/
mv logs logs_backup
mkdir logs
ln -sfn ~/Dropbox/pidgin_logs ~/.purple/logs
mv logs_backup/aim logs/
mv logs_backup/jabber logs/

Chatbot is done

I finished writing the chatbot that I was working on. It consists of a set of scripts to prepare the data, and another script that listens for incoming messages and responds. You can get the code and an overview of how it works here.

Obviously, I’m not publishing my chat logs. Use your own. It is designed to work with Pidgin’s HTML-like format for chat logs, but it could be modified to work on almost any corpus. I really should clean up things like the string cleaning routines, but it worked for class, and that’s what actually matters.

Python Pidgin Dbus Monitor

This is a script that registers a callback with Pidgin’s Dbus interface, and then sends a message in response whenever anyone sends an IM. I’m using it for a chatbot, but it could easily be extended to do things like switch X10 light controllers on and off, get the state of hardware connected to the target computer, and so forth. Pidgin has to be running and configured to use Dbus, but it does that by default.

Created on Nov 18, 2011
Watches pidgin over Dbus and responds to incoming messages.

import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gobject

class StupidResponder():
    def getResponse(self, message):
        #This is where you would do something clever to come up with a response
        return "Insect! I cannot bear your words! They are TOO TINY!"

def got_msg_cb(account, sender, message, conversation, flags):
    purple.PurpleConvImSend(purple.PurpleConvIm(conversation), responder.getResponse(message))

if __name__ == '__main__':

    #load a response generator
    responder = StupidResponder()

    #Connect to pidgin on Dbus
    main_loop = DBusGMainLoop()
    session_bus = dbus.SessionBus(mainloop = main_loop)
    obj = session_bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
    purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")

    #Add the callback
    session_bus.add_signal_receiver(got_msg_cb, dbus_interface="im.pidgin.purple.PurpleInterface", signal_name="ReceivedImMsg")

    loop = gobject.MainLoop()

Unresolved imports in Eclipse/Pydev

The Pydev plugin for Eclipse (at least on my system, Ubuntu Linux on a PC) has a hard time with imports, reporting them as unresolved when Python can actually find them.  I find this particularly bothersome when I do projects with OpenCV and Beautiful Soup, as it can’t find either of them and so can’t do code completion.

This thread has the answer. In case that goes away, what you need to do is this:

Go to Project Properties -> Interpreter -> the “Configure an Interpreter not listed” hyperlink

Uncheck and recheck the box next to the interpreter you are already using (probably the default one), or make some other change that doesn’t really change things.

Hit “Apply” and go for a soda while PyDev reindexes things.

Open some file with the bogus unresolved import and make an edit, then save it. Pydev will recheck the imports and stop whinging about the unresolved ones.

As they say on the Heart of Gold, anything you cannot deal with now is your own problem.

Mixing software for Linux

As part of my portable sound system, I need something to play. I’m not a DJ, so I’m not going to make mixes on the fly, because I’ll just trainwreck and embarrass myself. Instead, I’m going to carefully tweak and fiddle with mixes at home. That does mean I won’t be able to do the proper DJ thing and have a gradual build, respond to the crowd, etc. Admittedly, some DJs don’t do that either, but I digress…

I also don’t own any records, and only a few CDs. All of my music is MP3s, so I’m going to be making the mix out of MP3s. I’m a Linux user. I have been for 8 years or so. My laptop runs Linux, everything in my house runs Linux, so I’m going to do my mixing on Linux.

Audacity is actively developed, already installed on my machine, and certainly capable of mixing multiple tracks and recording to disk. I know this because I’ve used it before to make a mix of bird sounds, vocals, and machines for a prop that some friends wanted. It supports shifting tempo and pitch, editing MP3s, and adding all sorts of filters and effects.

Mixx also appears to be actively developed, but also looks like it is for live performance. I’m not playing live, so it may be a case of having a great tool for a job that I’m not doing. TerminatorX is also explicitly realtime, and so is not really the tool I’m looking for.

BPMDJ has a lot of sophisticated analysis options (because most club DJs care deeply about Harr wavelet analysis), automixing. On top of that, it appears to be under active development, which is more than I can say about a bunch of Linux mixing tools.

DJPlay looks to be about 4 years old, but may be useful. If nothing else, I can use the BPM counter to figure out the BPM of some of my music and use that as a rough guide for what might mix well. The interface looks like it was designed for live performance, but interacting with controls that mimic physical controls by using a mouse is kind of a recipe for UI disaster.

GDAM is even older, having no new news for the last 8 years. It does, however, support recording mixes to disk. It is intended for live performance, which is not what I’m doing.

Once I’ve installed and played with a few of these mixers, I’ll update this entry with my impressions.