Thursday, December 19, 2013

Chicago Boss: an Erlang Web Framework

This looks really exciting. The goal of the project is to cut operations cost of web apps by 90% through better processor and memory utilization.

Monday, November 25, 2013

"Decoherence" Music Video


Decoherence from backtrace music on Vimeo.

I've started making some music videos to go with the tracks from Pythagorean Clouds and a few other pieces.  I got a new computer last week with a GPU card which, combined with the new OpenCL rendering in the new version of Mandelbulber (1.19) lets me render certain kinds of animations very quickly.

The animation in this video is a transformation of a Mandelbox, which took about half a day to render at 1280x720px.  The current OpenCL implementation only allows for a few basic fractal formulas to be rendered, and it's a little crashy on Windows. But it's super fast - cranking out almost 100 frames per minute sometimes, compared to maybe getting 1 frame per minute if I was lucky with my previous setup.  I can't do anything with volumetric shaders right now, but I'm kind of getting into this aesthetic.  Flat surfaces, "perfect" lighting with no depth of field.  (I feel like if there's too many shading effects, you fall into the uncanny valley of being super conscious that you're watching a computer-generated video, and not really being able to experience the visuals for what they are)  Because the algorithm gets glitchy when you zoom too close, I've been trying out different effects where the camera stays still and the fractal morphs around it. Overall though I like working within the constraints of a medium, especially when it's kind of minimal and lo-fi, so this works for me.

Tuesday, October 29, 2013

Circles and Euclidian Rhythms

Circles and Euclidean Rhythms: Off the Grid, a Few Music Makers That Go Round and Round

Imagine an alternate universe in which Raymond Scott’s circle machine – a great, mechanical disc capable of sequencing sounds – became the dominant paradigm. We might have circles everywhere, in place of left-to-right timelines now common in media software. Regardless, it’s very likely Scott’s invention inspired Bob Moog’s own modular sequencers; it was almost certainly the young Moog’s exposure to the inventions in Scott’s basement that prompted that inventor to go into the electronic music business, thus setting the course for music technology as we know it.
This blog entry includes some nice software examples.

Wednesday, October 23, 2013

"Horizontal Movements"


I composed these 2 pieces almost 2 years ago, but even though they are very autobiographical, I never really talked about the inspiration for them. So I've added a description on SoundCloud.
Like a lot of my music, these 2 pieces are autobiographical, at least in the sense that they were composed during and immediately in response to some significant events in my life - in this case my involvement in the Occupy Wall Street protests. They were composed in late December 2011 through early January 2012, while I was taking some time off from activism to recuperate after police chaos and setbacks of late November and December. The "Frozen Zone" of the titles refers to both the blockade that the NYPD set up in the Financial District in the middle of the night as they evicted protesters from Liberty Square, and more metaphorically to all systemic injustice.

Although the music doesn't convey any overt political messages, the act of writing it was kind of a meditation on the idea of leaderless organizing (the anarchist political philosophy of "Horizontalidad / Horizontalism"). I think of the sounds as being "horizontal" in the sense that there's no hierarchy working to organize them. The musical parts aren't divided into "instruments or "voices" - there's just a single algorithm generating clusters of sine waves. Those individual sine waves, which only differ in pitch and amplitude, converge temporarily to create harmonies, and then dissipate.

Sunday, October 13, 2013

MIDI in the web browser, 2013 style

My first homepage (on AOL) included a lengthly MIDI composition that auto-played upon loading the page.  Browsers don't support MIDI natively anymore but there are JS libraries that will load sound fonts and let you create midi compositions in JS.

midi.js is a good starting point.
Jasmid for reading MIDI files with JS.

Grimes "Genesis" extended remix



I haven't done one of these in a few years but I've been really into the song Genesis by Grimes lately so I decided to do an extended granular remix of it, similar to what I'd done with Aisler's Set and Joanna Newsom a few years ago.

This song works well for looping - the melodies are all in the high register, with lots of reverb so they won't sound choppy when overlapped, and there's not a lot of bass so it doesn't sound muddy.  The drum track is clean, with the one strong kick drum that adds just the right amount of bass when it's looped.

This is the first time I've really done anything with Garage Band.  The granular looping was done in Granulab as usual.  With both of these programs I feel like I've pushed them as far as I want to go - it's too bad that in going for simplicity of the user interface you loose a lot of precision in the settings.  In Garage Band I really wanted these loops to hit exactly on the beat, but you can only get resolution on the low end of around 0.1 BPM which makes for some noticeable grinding or stuttering.  Similar in Garage Band, the resolution when automating parameters is kind of a joke - it's a linear division of the frequency spectrum in Hz, so while I can get like 100 divisions of the octave between 10khz and 20khz, on the low end, settings jump right from 20hz to like 700 hz, with nothing in between.  Good luck getting a band pass filter to zero in on one sound.

This went through a bunch of phases where there were a lot more ideas at first - there was a timestretched track with doomy  overdrive + reverb, and other rhythmic layers, all fading in and out, but I ditched all of that for a simple one track of the song looped with a little bit of pitch shifting going on.

I'm looking forward to emulating enough of Granulab in SuperCollider that I can do mixes like these with the kind of precision you need eliminate artifacts (or make the artifacts musically significant by harmonizing them with the rest of the song).  I've been getting into using the TGrains ugen alot in the Backtrace Livestream project, so this should be a pretty straightforward thing to adapt.

Saturday, October 5, 2013

Saturday, June 29, 2013

Upgrading from Snow Leopard to Mountain Lion: Not Bad

I upgraded my MacBook from Snow Leopard to Mountain Lion last night. So far there have only been a few minor hangups, which I've mostly been able to get around.
  • Fixing scrolling, hidden scrollbars etc in Mountain Lion
  •  Here's some other useful tips for Mountain Lion
  • X11 isn't supported, so if you run X11 / GTK apps like Mandelbulber use XQuartz
  • Quicksilver stopped working after the upgrade so I switched to Alfred (thanks to Ashe Dryden for the recommendation)
  • I used Spaces heavily on Snow Leopard (6 desktops, with apps assigned to workspaces for music, code, social media, graphics, sysadmin and writing), which became useless with 10.7 (one of the biggest reasons I didn't upgrade when 10.7 came out).  I'm using TotalSpaces to restore classic Spaces functionality.  I'll probably end up paying the $18 for the full version (almost as much as the OS upgrade itself) just because Spaces is so essential to how I work.
  • Getting the battery time remaining to show in the menu bar was a chore.  In Mountain Lion, you can no longer see the battery time next to the battery icon.  There are 2 apps that can fix this for you.  One is a simple one called "Battery Time" the other a more-advanced $1 app called "Battery Time Remaining".
  • Since 3rd-party menubar items cannot be re-arranged (come on already) I couldn't actually see the battery time remaining on my laptop since the icon was pushed all the way off to the side. There are a few apps that you can get to fix this for you.  "Bartender" at a pricey $15 or the more reasonably-priced "Menu Bar Rearranger" at $4.99.  But really, why do I have to pay to do something as basic as change the ordering of some icons on my menu?
So overall, it could have been much worse.  I didn't have to recompile all of my gems or rebuild virtual machines or re-install anything major to be productive again.  A little annoying though that the upgrade cost $20 (which is cheap for an upgrade) but then I had to pay another $20 or so to restore all of the things that Apple "innovated" between versions.

Sunday, June 23, 2013

New Album: Orbital Slingshot

A 70-minute drone piece, composed with SuperCollider. You can stream it here, or purchase a download on Bandcamp. This is part of a series of studies that may someday lead up to a full-length (195 hours) sonification of the Apollo 11 mission.

Thursday, June 20, 2013

How to Block the Sponsored Posts on your Tumblr Dashboard

I was surprised at how intrusive I found the sponsored posts that have started appearing in the stream on my Tumblr dashboard.  Luckily if you run the AdBlockplugin it's super easy to tweak your settings to block the sponsored posts:


First, open your AdBlock menu from the icon.  This should be in the upper-right corner of your browser window (I'm using Chrome on OSX in the example).  Select "Options" and you should see this menu towards the botton of your screen.


You'll want to paste this line of code to the bottom of the "Manually Edit Your Filters" window:
www.tumblr.com##DIV[class="sponsored_post"]
Click the "edit" button, add the line of code, and then click the "paste" button. This will block all sponsored posts that appear on Tumblr.com.

How to Probably get Pandoc Running on a Linux Server

(

Drink-by date: This post was written based based on work I did in June, 2013. The GHC, Haskell, Cabal and pandoc were all current versions installed in Ubuntu 10.04. If you're reading this documentation after June, 2015, consider it out of date.

This blog post was the original inspiration to use Pandoc

)

A few months ago I started putting my resumé on Github. As a freelance software dev it's quicker to send somebody to 1 spot to see both code for projects I work on and descriptive, bulleted-list of accomplishments (without all of the monetization noise of LinkedIn). Recently I spent 5 hours on one of those endlessly-recursive campaigns of compiling things from source code in order to save myself a few minutes of maintaining my online resumé in different formats (pdf and markdown) and since it deals with some bugs in some standard Ubuntu / Debian packages, I'll post instructions here for how I fixed them.

My goal was to be able to update my resumé in markdown, and have run a single deploy script that would commit changes, generate a pdf from the markdown and push the updated markdown and pdf to GitHub. There's a Linux utility called "pandoc" that does this and a whole lot more. It's written in Haskell, a powerful functional programming language that is beloved by academics and high-frequency stock traders and otherwise hasn't broken into mainstream software developement.

My first time around, I did a standard "sudo apt-get install pandoc" on my Ubuntu server and thought I was good to go. The syntax for a basic conversin is simple, and like ffmpeg, the input and output formats are inferred by file extension:

$ pandoc resume.md -o resume.pdf

Except that this yielded the following error:

pandoc: resume.md: hGetContents: invalid argument (Invalid or incomplete
multibyte or wide character)

A character-encoding bug. Removing curly quotes from the markdown file confirmed this since it worked fine if the input document was all ascii. But what's the point of a PDF if you have to limit yourself to ugly straight quotes and spelling "resumé" as "resume"? There was some chatter on google groups that this was an issue with setting the right LANG in your locale, but that in later version of pandoc this bug was fixed. Rather than fiddle with global settings, I opted to upgrade pandoc.

The version of pandoc, as well as Haskell and GHC (the Glasgow Haskell Compiler) are all years out of date in debian / ubuntu. (The computer I was working on was running Lucid 10.04 which is supported through 2015). So geting the latest pandoc woudln't be as simple as an apt-get upgrade, and would require upgrading the GHC, Haskell, the Haskell Package Manager (cabal) and finally pandoc. All of these are source-code installs except for the final upgrade of pandoc.

If you've already tried to install pandoc or Haskell via apt-get you'll need to remove the packages via the following command:

$ sudo apt-get autoremove ghc6

Now we're ready to start the installation process. First, install the dependencies via apt-get:

$ sudo apt-get install libgmp3c2 freeglut3 libedit2 libedit-dev freeglut3-dev libglu1-mesa-dev
pandoc uses LaTeX for formatting, so you'll need to get pdflatex on your system.
$ sudo apt-get install texlive-full

Now you'll want to get the source code to build the GHC and the Haskell Platform. First the GHC. This a standard configure / make install build.

Cabal, the Haskell Package manager, is included in the Haskell Platform

$ wget http://lambda.haskell.org/platform/download/2013.2.0.0/haskell-platform-2013.2.0.0.tar.gz
$ gunzip haskell-platform-2013.2.0.0.tar.gz 
$ tar -xvvf haskell-platform-2013.2.0.0.tar 
$ cd haskell-platform-2013.2.0.0
$ ./configure
$ ./make
$ ./sudo make install

You can also get the source for Cabal from GitHub.

Once you have Cabal up and running, first refresh the packages list:

$ cabal update
Now, you can install pandoc
$ cabal install pandoc
Cabal will install a bunch of dependencies. This will tak a few minutes. Cabal installs executables to ~/.cabal/bin/pandoc - you can symlink this to a directory that's already in your path:
sudo ln -s ~/.cabal/bin/pandoc /usr/local/bin/pandoc

Now you should be ready to go. For some pointers as to how I actually automated the generating of pdf's by committing changes to my resumé, check out this shell script: https://github.com/erstwhile/resume/blob/master/deploy

Friday, June 14, 2013

Constructing "Cloud City" - the Mandelbulber settings

I've gotten into playing with 3D fractal rendering this year, using a program called "Mandelbulber." There's a whole scene that's emerged in the last 4 years around rending animations exploring 3D fractals, since the discovery of the "Mandelbulb" (a 3D mapping of the Mandelbrot Set) in 2009. I was playing around with a hybrid fractal (combining several algorithms into 1 system) a few months ago when I discovered something that reminded me of the "Cloud City" gas-mining station from the final act of "The Empire Strikes Back". The color palette comes from a photo of the hallway runner in my house, hence the name "Rugs in the 4th Dimension" This is a closeup flythrough of one of the many "trees" that appear throughout the system: You can get the Mandelbulber settings for this algorithm and explore it via Github.

Saturday, June 8, 2013

James Tenney - Melody, Ergodicity, Indeterminacy

James Tenney (1934-2006) was probably the first composer to develop an aesthetic for computer music, realizing that electronic music almost forced the composer to accept noise as “music” and to abandon the idea of absolute control over a composition. He came to accept Cage's passion for randomness, but from a different angle: computer music can be “unpredictable” (rather than “random”).

Sunday, April 14, 2013

Going to try using a Git Repo on Dropbox

Making another attempt to get my Supercollider coding practices in line with something sane that resembles how I write code in other languages. When I write code in SC I usually work off of the same set of files on a Dropbox folder so I can sketch something on my laptop, and then have those changes automatically deployed to my "rendering" machine (an 8-core Mac Mini) or my "livestream" machine (an older-generation Mac Mini running Nicecast, Supercollider, and nothing else). While Dropbox provides automatic backups and deployment, it doesn't provide version control, so I end up committing the cardinal sin of using filenames for version control ("20130410-livestream.scd" or the like). So I'm going to try setting up a git repo in the Dropbox with the source code for the Livestream project and see how that works out.

The more difficult issue here is doing version control in a system that's designed to run entirely as a REPL - how does Smalltalk do version control? Periodic snapshots of object instances? In sclang, you can use Object.archive to dump the state of an object to a text file and from there use Git or whatever to save. Which is kind of a kludge - in Smalltalk you're running in a virtual machine that is a Smalltalk object, with no files. So where do you keep the snapshots?

Here's some StackOverflow conversations on using Git with Dropbox:
Using Git and Dropbox together effectively?
Is this plain stupid: GIT Sharing Via DropBox?

And a tutorial:
How to use Dropbox as a git repository.

Monday, February 25, 2013

Fractal Return

Every 12 years or so I get really into fractals and higher dimensional geometry in at least a serious recreational mathematical way. The last 5 years or so I've been doing a lot of music based on distributions of prime numbers (stuff like Continuation and Closure) but at the start of this year, the fractals came back in a big way. I've been playing around with a program called Mandelbulber to explore 3-D renderings of fractal shapes, an d getting back into the math behind generating the Mandelbrot set.

Last time I was this interested in fractals was around 1999 when I was playing with a MIDI-generating program called "Mu Soft Music Generator" (I think) which would create music based on different fractals, L-Systems or periodic oscillators. This was in between the long-term project from 1997-2003, a Q-Basic application that combined twelve-tone and minimalist techniques to play music on the SoundBlaster 16 soundcard - culminating in Writing Software to Play Music to Write Software To. I was trying to wrap my head around Manfred Schroeder's Fractals Chaos and Power Laws. At the time, seeing any kind of rendering of a fractal was a special thing - I feel like it was one of the first things that really caught my interest about the Web (funny how so many pages relating to fractals and fractal art still date from the late 1990's). Something to look forward to in 15 years will be having computers fast enough to explore high-resolution 3-D fractals in realtime.

I just purchased a copy of Experiments in 4 Dimensions which was one of the books that got me started on all of this, back when I was in 4th or 5th grade (circa 1986). I had that book out from the library multiple times, trying to master the code examples given for rendering and rotating a simple wireframe tesseract (on a 4-color, 8mhz, 640k computer). I don't think I ever got one of the programs completed, because having the source code back in 1986 meant that you had a printout of the source code that you could set in your lap while you typed it into your computer (and probably guessed at how to get Apple Basic to run under DOS). I did build some tesseract and hyperpyramid models out of toothpicks.

When I get the book, I'll see if I can translate the code examples from Experiments in 4 Dimensions to Javascript/html5 so people can share it and play with it.

Friday, February 15, 2013

Mandlebrot Sonifications

Here are 2 studies on sonifying iterations of z=z^2+c. I'm using the same instrument from the Carotid Kundalini studies, and mapping the real, imaginary, angle and radius of each iteration to instrument parameters (see the code comments). Each note is actually a chord of iteration values for one point in the set. As the music moves forward in time, parallel rows move along the real axis. What's most interesting to me here is how you can definitely hear cycles, and loops within loops in the pitches, especially in the 2nd study.
//load up all of our servers into an array
~z = Server.all.asArray;

//our instrument - phase multiplication of sine waves, in a cluster of 8 phase / pitch shifted voices
~z.collect({|z|
SynthDef("sine-cluster",{|freq=100, atk=1, rel=1, slope=1, amp=0.005,pan =0,gate=0,m=0,p=0,ph=0,pl=0,pf=1|
 var sin = SinOsc.ar(  [1,1]  * freq *.x (p+[1-p,1,1+p,1+p+p]) ,pl*SinOsc.ar(freq/(pf),ph*(0..3)/3,XLine.ar(freq.sqrt.ceil*pf,pf*slope.abs,pf/(rel*freq.log2.ceil))),(1/(rel+1))+((2-1)/2)*(amp)/(freq+512));
 OffsetOut.ar(0,Mix.ar(Pan2.ar(sin
 ,[-1,1])) * EnvGen.ar(Env.perc(atk,rel, 1,slope),gate, doneAction:2) );}).send(z);
});

//the Mandelbrot function, where z is a complex number and c is a real number
~m = {|z,c|squared(z)+c};

//utility function - returns unique values in an array
~unique = {|a|var t = Array.fill(a.size);
  a.collect({|i,j|(t.includes(i)).if({t.put(j,nil)}, {t.put(j,a[j])})}).reject({|i|i==nil});
  t.reject({|i|i==nil});
};

 

//the pitch set
~p = ~unique.((16..32).reject({|x|x.factors.detect({|n|n>5})!=nil})*.x(2**((-6)..3))).sort;

//some sonification parameters

~globalSustain =2;
~d = 10;
~minIters =5;

//how many iterations to generate the pitches for an orbit
~maxIters = 1024;
~rows =2;
//minibrot on the the real axis
~d = 12;
~minIters =4;
~cx = -1.635;
~ci = -0.0001220703125;
~globalSustain =1.5;
~rows =2;

//on our way out to the western point
~cx = -1.875;
~ci = 0;

~cx = -1.95125;
~ci = -1/(2**30);

~globalSustain =0.5;
~cx = -1.957125;
~ci = 0;
~rows =2;



//5 arm spirals
~globalSustain =2;
~cx = -0.52482350635;
~ci = 0.62534492645;
~rows =3;
~d = 12;
~minIters =6;



(
//start a loop to crawl along the real number axis of the graph
//each cycle zooms in 2x closer to the original point, and crawls 1/2 as quickly
Routine {
(9..9).do({|y|
 var max = (2**(5+y)).asInt;
max.clip(1,2048).do({|x|
 //the player function is defined outside this loop so it can be tweaked in realtime while the loop is playing 
 ~player.(x,y,max);
 })
})
}.play;

/*recursive function to generate a collection of orbit points - bail out if we reach infinity, zero, or a non-number.   Always quit after reaching "safe" number of iterations
this function returns an array of "points" which are the Complex values for a particular iteration
*/
~mr = {|z,c,safe,points|
 ((safe > 0).and(z.real.isNaN.not).and(z.real!=inf).and(z.real !=0)).if({
 ~mr.(squared(z)+c,c,safe-1,points.add(z))
 },points)
};
)
(
~player = {|x,y,max|
 //we sonfiy a line of points on the imaginary axis together, based on the value of ~rows
 ~rows.asInt.do({|ii|
  //slowly crawl along the real axis
  var c= ~cx+(x/(2**(8+y))) - (max/(2**(9+y))) , z = Complex.new(c,~ci+(1/(2**(8+y))*ii)),points;

  //our initial point to iterate on
  z = ~m.(z,c);
 /*
  alternate traversal strategy, move our sonification point in a tightening spiral around the orginal values for real and imaginary.
  var z = Complex(~cx,~ci),points,c=~ci;
  //z is the original center point.  We add the orbit point to this
  z = (z.asPolar+ Polar(1/2**y,0).rotate(((x*pi*2)/128)).scale(1+((1-(x/1024))/(2**(y-ii))))).asComplex;
*/

  //generate an array of orbit points
  points= ~mr.(z,c,~maxIters,[]);
  /* 
  take a slice of the array to sonify it
  the size of this slice can be tweaked by adjusting ~minIters and ~d.
  the lower end of the array tends to be more chaotic and the higher end of the array more constant.
  all of these points sound simultaneously, as a chord
  */
  points.reverse[~minIters.asInt..~d.asInt].collect({|p,i|
   var ss;
   z = p;
   /*
   z is given as a complex number, but we can also treat it as a polar to get its angle (theta) and radius (rho) from the origin (0,0).  it would probably be more interesting to get rho and theta  relative to the original z point.   */
   ((z.real.isNaN)).if({},{
   ss = Synth("sine-cluster",nil,~z.wrapAt(x));
   //frequency of the pitch, based on the distance from the origin
   //fundamental pitch of 66hz multiplied by an overtone in the pitch set ~p
   ss.set(\freq, 66 * ((~p.wrapAt(z.rho*~p.size*~cx))));
   //phase offset of the pitch, also based on radius
   ss.set(\ph,z.rho);
   //add a small pitch bend 
   ss.set(\p,1/512);
   ss.set(\gate,1);
   //this is the amplitude of the 2nd (phase-shifting) oscillator, based on the imaginary value of of z
   ss.set(\pl, z.imag.abs.log2.clip(-1,1));
   //frequency of the 2nd oscillator, based on one of the harmonics in the pitch set ~p.
   ss.set(\pf, 1/(~p.wrapAt(~p.size *z.theta/pi)));
   //length of the note, based on the real value of z
   ss.set(\rel,~globalSustain/((z.real.abs+2).log2).clip(2,32));
   //pannign position
   ss.set(\pan, (z.imag%1) * (z.real%1));
   //note attack value, based on the reciprocal of the imaginary of z (maximum value 1 second)
   ss.set(\atk,1/(1+z.imag.abs));
   //slope of the peak amplitude drop - higher negative value = sharper attack, quieter sustain
   ss.set(\slope,z.real.abs.log * (z.real/z.real.abs));
   //tweak the amplitude a little to offset notes with a longer attack
   ss.set(\amp,2.5  * (2/(1+(z.imag.abs.clip(0,1)))));
   });
  });
 });
 (1/10).wait;
};
)

Visualizing and Sonifying the Iterations of z=z^2+c

This video looks like an interesting point of departure for sonifying the Mandelbrot fractal. I've never been happy with graphical sonifications that map pitch to the y axis of a rendering, and time to the x axis, but mapping these patterns to sound seems like a very promising way to get interesting patterns out of the iterations of the z=^2+c formula. And it would also be something that could render in realtime, instead of rendering millions of points in advance and then putting that data through a sonification function. Here's a blog post on orbit traps. Just started experimenting with Mandelbrot sonifications this week. I'll have some demo's up in another post.

Saturday, January 12, 2013

New Album: A Sine of the Times

Sunday, January 6, 2013

Almost Anything in Ruby can be a Hash Key

This was a definite huh / aha moment - finding the idiomatic Ruby way to solve a typical problem, in this case, taking an array of objects, and grouping them in a hash so that each element in the hash was all of the objects belonging to a particular user. You could parse out some unique value from your user object (which was the brain-damaged PHP way I had been thinking of this problem) and use that has a hash key:
#ugly
slug = (post.user.name +" "+post.user.id.to_s).to_sym
posts_by_user[slug] << post
When it turns out that you can use objects themselves as hash keys in Ruby, and then use the Hash.keys method to grab those objects back when you need them. So if you had a Post, which belonged to User, and you wanted to get them all and group them by user (assuming that your ORM or whatever won't do it for you in this instance):
posts = Post.all
posts_by_user = Hash.new {|h,k| h[k]=[]}
posts.each do |post|
  #if there is no entry for this user, create one with an empty array
  posts_by_user[post.user] ||= []
  #shovel the post on to the group for that user
  posts_by_user[post.user] << post
end
Iterate through them like this -
posts_by_user.keys.each do |user|
  #the user object
  p user.inspect
  #referencing the hash with the user object as key
  posts_by_user[user].each do |post|
    #each post belonging to that user
    p post.inspect
  end
end