Category Archives: Code

Code Music

Old Song, Old Language

Here’s a piece I dug up from last year when I was working quite a bit with RTcmix (Brad Garton’s awesome albeit antiquated musical scripting language). I like the piece’s meditative quality and how varied it sounds for being written with only a few lines of code. It doesn’t follow canonic form at all, but when I hear it I can’t help getting this impression.

[audio:http://amusesmile.com/old/sound/Canon_Mastered.mp3|titles=Canon]
maxamp = 1000
amp = maketable("line", 1000, 0, 0, 50, 1, 51, 1, 100, 0)

wavetable = maketable("wave", 1000, 1, 0.3, 0.2)
pan = 0.5

start = 0.0
start2 = 0.0
freq = 2000.0
freq2 = 0.0

for (i = 0; i < 100; i += 1) {
freq2 = freq/round(irand(1,6))
WAVETABLE(start, 4, 10000*amp, freq2, (.2 + random(0, 0.6)))
freq2 = freq/round(irand(1,12))
WAVETABLE(start, 4, 10000*amp, freq2, (.2 + random(0, 0.6)))

freq2 = freq/round(irand(1,12))
WAVETABLE(start2,  6, 10000*amp, freq2, (.2 + random(0, 0.6)))
start += 2
start2 += 3
MAXMESSAGE(0 \, freq2)
}
Code

OSC Record

I was amazed that no one had already done this, so I built a little program to record and re-send OSC (Open Sound Control) messages. You can download it here. Before making it run you’ll need to install the LIBLO library on your machine.

Code

Seattle Public Library Visualization

This is a visualization of transactions from the Seattle Public Library, taken from a dataset of over 66 million entries collected since 2005. Through this database, I was able to experiment with various methods to filter huge collections of information, attempting to extract meaningful patterns and depict them visually. Many thanks to Professor George Legrady for gaining access to this data.

In this version, I created a 3D map of the 11 most frequently referenced countries and the words most often associated with each for all of 2010. I did this by collecting the first three subject headings for every item circulated with a title referencing a country in either noun or adjective form (for example, “china” or “chinese”). This created a large text file which I simply parsed in terms of word frequency.

The result reveals interesting trends: “war” was the word most often associated with Germany, “cooking” and “food” were important categories for every country except England and Ireland (proving the fact that no one likes British food), and “women” was one of the most words most associated with France, etc. To add another layer of information, I’ve included scrolling “trackers” at the bottom that display actual titles of items containing these subject/keyword pairs (Italian + food, etc.).

The countries are listed in order of popularity- China being first- and the 3D blocks can be read as literal representations of the volume of items checked out in each category.

Technically speaking, data manipulation and filtering was done through MySQL in conjunction with some fancy BASH scripts, and all of the visualization was done in Processing. If you’re curious, please feel free to download the source code and try it for yourself.

Code DSP

Spatial Upmixer

I sort of got obsessed with the idea of being able to take a recording of a soloist and make it sound like an ensemble. As I found out, it’s not an easy thing to do, but adding on to spatialization software written by Ryan McGee, I was able to make something that sounds pretty decent (imho).

Technically speaking, this process is called “decorrellated upmixing” and it’s much harder than just adding a bunch of small delays to a signal. In real life, no two instruments are ever playing perfectly in phase with one another, but when we try to multiply a single signal that’s basically what’s happening, so as a result we often end up with a really strange “alien” phase-cancellation effect which sounds completely unnatural. My software gets around this by all sorts of filters and randomization techniques. Still there’s much work to be done, but I was able to create some realistic ensembles as well as some interesting effects on a variety of files. If anything it might be a quick way to sneak around copyright if you want to use someone’s recording…
[audio:http://amusesmile.com/old/projects/240B/violin.mp3|titles=Bach Chaconne Solo]
[audio:http://amusesmile.com/old/projects/240B/violin_multi.mp3|titles=Bach Chaconne Ensemble]
More Examples in the full project page.