June 12th, 2013
Sonic Prints
Using openFrameworks and ofxFFT to generate 3D Meshes of sound data for use in 3D printing. This is very much a work in progress, but just wanted to share some initial results while I work on the final visual output.
Part of a side project at work: www.fakelove.tv
April 14th, 2013
Memory Leak Murderer
A theoretically useful, but dangerous shell script for use on OS X…proceed with caution.
Now of course you always do a solid job on your programming, but maybe you didn’t have enough time to find all the memory leak bugs that start to appear a few days into your installation. Something that only appears up after your software loops through 100 times is a much harder thing to deal with than something that shows up every single time. Sometimes you need a hot fix if you’re not able to find the true cause on short notice.
The following is a script that you’ll need to modify for your own uses, but this is essentially what it does: When set to run automatically (cron job or lingon), it checks your computer’s processes every so often to check their memory usage. If an application suddenly shoots over the memory usage threshold, this script quits the leaky app, and then re-opens it…hopefully freeing up leaked memory and allowing the computer to run for a longer period.
Sometimes apps that have leaked too much can grind your computer to a halt and even your other automatic scripts can have a hard time running, so this can work as an early warning system. This could even be modified to email you if your app goes over a specified memory amount.
Thanks to Patricio Gonzalez Vivo for the help with the regular expressions and logic/formatting syntax in the shell scripting
Again, test ahead of time if possible:
#!/bin/sh
#Script to reboot application after crossing memory usage threshold
#Can be used in conjunction with Lingon or a Cron to run on a periodic basis, e.g. every 2 minutes.
#Version 1.0 written by Daniel Mare from http://hintsforums.macworld.com/showthread.php?p=592991
#Date: 02/08/2010
#Modified by Blair Neal 11_27_2012 http://www.blairneal.com
#Helpful shell scripting additions from Patricio Gonzalez Vivo http://www.patriciogonzalezvivo.com/
MEM_THRESHOLD=6 #INTEGERS ONLY If any process uses more MEM (in percentage of total MEM) than this threshold, the application will be rebooted
#Say you have 8gb of RAM, then a process that is using 2gb or more would be using 25%
#test is MEM usage is excessive
MEM_LINE=$(ps wwaxm -o %mem,command | head -2 | tail -1) #Output from ps showing the TOP app that is using the most memory
MEM_USAGE=`echo $MEM_LINE | sed 's/\ .*//'` #Strip off the numbers from above output
MEM_USAGE=${MEM_USAGE/\.*} #Truncate decimals - bash only compares integers TODO: incorporate this line into one above
if [ $MEM_USAGE -gt $MEM_THRESHOLD ] ; then
#echo "Original line: " $MEM_LINE | sed -e 's/.*\///'
MEM_PROCESS=`echo $MEM_LINE | sed -e 's/.*\///'` #this is the process name, used to kill the app later
MEM_FORMATTED=`echo $MEM_LINE | sed -e 's/.*\///' | sed 's/ -psn_[0-9]_[0-9]*/.app/' | sed 's/ //g'` #Get the name of process that triggered this alert, strip off the -psn and ID numbers and delete all spaces so it can be compared with your app name. Could be more elegant, but gets the job done!
echo "Memory leak threshold exceeded by this process: " $MEM_FORMATTED
echo $MEM_FORMATTED "It was using this percentage of memory: " $MEM_USAGE
if [ $MEM_FORMATTED == "Twitter.app" ]; then #make sure you're killing your own app, not something else important like a system process
echo "Closing Leaky App " $MEM_PROCESS
killall $MEM_PROCESS
else
echo "This is not the leaky process you're looking for!" #Your app wasn't the culprit
fi
else
echo "All is well! Your app is not using too much memory."
fi
sleep 15 #Wait 15seconds (arbitrary) for everything to close out before restarting
#Now check and see if your app is closed out, and if it isn't then re-open it
if [ $(ps ax | grep -v grep | grep "Twitter.app" | wc -l) -eq 0 ] ; #Replace Twitter.app with your own app's name
then
echo "YourAppName not running. Opening..."
open /Applications/Twitter.app
else
echo "YourAppName running"
fi
You could also set it to open an Automator Script or an Applescript to do whatever it is you need run instead of having it just close and open your app.
P.S. I’ve found Firefox is a really good tester if you need something that gobbles up memory quickly
February 25th, 2013
Doggifer
Doggifer is an application that saves or tweets animated gifs of your pet’s movement’s throughout the day. It can also just be a general use toy for collecting automatically triggered animated gifs. You will need to set up a twitter account to use the twitter portion of the app. Instructions for setting that up are included in the readme file accompanying the app.
Download Here: Doggifer v4 (74) (Only tested on OSX 10.6.8 but will run all day on a 5yr old laptop)
You can see my dog Margot when we set up the cam at home @doggifer on twitter.
Doggifer is made with openFrameworks and uses ofxUI from Reza Ali and ofxGifEncoder from Jesus Gollonet and Nick Hardeman.
You can grab the source of Doggifer on my github and change stuff up as much as you’d like. Originally made with OF0073. Let me know if you have suggestions and I’ll do my best to add them. Let me know if you catch any good shots!
If you do use Doggifer, I’m not personally asking for any compensation, but I (and many animals!) would really appreciate it if you donated to a local animal shelter instead. There is a very deserving no-kill shelter ( Sean Casey Animal Rescue ) in NYC that I’m a fan of and they would certainly appreciate your donations!

Doggifer by Blair Neal is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
February 21st, 2013
Guide to Camera Types for Interactive Installations
I just published an epic article over on Creative Applications detailing the use of different kinds of cameras in interactive installations. Check it out, and add any additional tips in the comments there!:
http://www.creativeapplications.net/tutorials/guide-to-camera-types-for-interactive-installations/
December 17th, 2012
The Ethereal Geometric Volume in music videos
I wanted to write something about a very specific genre of music videos that seems to pop up every few years and has only continued to increase in popularity as special effects costs get lower and the techniques get more accessible. This music video type can be found in genres ranging from electronica to rock and beyond. The trope common to all the music videos I’m discussing is the use of the ethereal geometric volume
An ethereal geometric volume is a plot device similar to something like Hitchcock’s MacGuffin where it can simply exist as a polygonal device to move the plot along without it really being explained what this volume really is.
These devices can be the main characters, a representation of an omnipotent force, a terror, an alien invasion. They can be Cubes, Pyramids, and Spheres or broken polygonal shapes. They can be shattered to bits and oh..good lord, they float and hover like nobody’s business.
Let’s start at n=4..the PYRAMID
Pyramid Example #1: M83 – “Wait” – 2012
Pyramid as Spaceship
M83 ‘Wait’ Official video from The Creators Project on Vimeo.
Pyramid Example #2: Frank Ocean – “Pyramids” – 2012
Pyramid as Structure and 2d John Mayer guitar solo background
frank ocean [pyramids] from christopher francis ocean on Vimeo.
Now let’s step forward into n=6…the CUBE
Cube example #1: Phantogram – Don’t Move – 2012
Cube as ethereal looming terror (with shatter!)
Phantogram ‘Don’t Move’ from 10lb Pictures on Vimeo.
Cube example #2: Battles – Atlas – 2007
Cube as floating spaceship stage (low-rez…anyone have an HD link for this vid?)
Cube example #3: Mew – Introducing Palace Players – 2009
Cubes as alien lifeforms
Cube Example #4: M83 – We Own the Sky – 2009
Cubes as alien life forms (with shatter!)
Cube Example #5: Kid606 – Sometimes – 2006
Cubes as alien life forms (also with shatter…)
And then finally n= infinity…the SPHERE
Sphere example #1: The Antlers – Bear – 2010
Sphere as relationship burden/unborn child
(Hemi)Sphere Example #2: Denali – Hold your breath – 2003
Sphere as strange alien invasion of a river jam session
December 16th, 2012
Top Albums/songs/etc. of 2012
I’ve been doing a top 10 albums list since at least 2004 (see below for previous years lists). This year was another weird one for me in terms of discovering new music. The desire to purchase physical CD’s is at an all time low, so it was a big digital year for me. I started using Spotify a lot more than MP3s and my iTunes library even. That caused me to listen a little less on the go since I didn’t always have the mp3′s with me in subways and things like that…I think certain albums didn’t quite get the full time they deserved, but it was still an amazing year. Let me know if you have any suggestions for stuff to check out in the comments.
This year wasn’t as exciting for me for music videos but I’m sure I’m forgetting a few gems…I will post a follow up eventually.
Many of these albums are on a spotify playlist where I’m keeping albums I’m interested in. If you’d like to check them out in an easy to digest format, please check out or subscribe to my Ambient Signal~ spotify playlist: AmbientSignal~
Here is my list of favorites and notables in a slightly particular order at the top and less particular towards the bottom.
Top Albums (Bottom ones don’t mean they are bad albums, just that I liked them a little less in relativity to the others):
~~~~~Dirty Projectors – Swing Lo Magellan
Favorite tracks: Just from Chevron, Socialites, Swing Lo Magellan
I have not been a huge fan of Dirty Projectors in the past, but I think this album toned them down enough to make them within reach for me. Shows some fantastic, varied musicianship the whole way through without feeling like it is all over the place.
~~~~~Freelance Whales – Diluvia
Favorite tracks: Dig into Waves, Red Star, Follow Through
The content of the album is a little hard to grasp or relate to because it’s mostly about space travel and ethereal BIG universal things, but the music has a lot of really fun things to let your musical mind play with and I found myself returning very often. Their album in 2010 was my top album that year so it was great to see them return so strongly in their sophomore effort.
~~~~~Why? – Mumps, etc.
Favorite tracks: Sod in the Seed, White English, Strawberries
This album actually manages to beat out Alopecia for my favorite Why? album so far which is a rare feat…especially when I originally considered Alopecia to be such a fantastic piece.
~~~~~Helio Sequence – Negotiations
Favorite tracks: October, One More Time, The Measure
Hadn’t heard from these guys in years but was very pleased to get this amazing follow up from their 2008 Keep Your Eyes Ahead
~~~~Alt-J( ∆ ) – An Awesome Wave
Favorite tracks: Tesselate, Matilda, Breezeblocks
This was one of those random finds that came out of a tumble through random music blogs and I was very intrigued right off the bat. His unusual voice isn’t for everyone, but there are some really interesting musical moments hidden in there. The most interesting thing about this album for me: drums are prominently featured but there is very little use of cymbals and no use of crash at all.
~~~Sun Airway – Soft Fall
Favorite tracks: Black Noise, Close
Had the pleasure of listening to this one early on and pitching a music video for Close. The album has a nice flow all the way through and some great repeating motifs that only come through on multiple listens.
~~~Beach House – Bloom
Favorite tracks: Myths, Lazuli
~~Lymbyc Systym – Symbolyst
Favorite tracks: Prairie School, Nightfall, Falling Together
~~Purity Ring – Shrines
Favorite track: Fine Shrines
~~Grizzly Bear – Shields
Favorite tracks: Yet Again, Simple Answer
Notable as well:
~Hammock – Departure Songs
~Album Leaf – Forward/Return
~Sigur Ros – Valtari
~Balmorhea – Strangers
~Cat Power – Sun
~Menomena – Moms
~Dntel – Aimlessness
~Ramona Falls – Prophet
Most anticipated albums of 2013: The Velvet Teen (recorded), Son Lux (not sure), Hooray For Earth (recording), Braids (recording I think), Blue Hawaii (releases in january), Annuals (touring..that’s something), Phantogram (recording/recorded I think)
Previous lists:
December 10th, 2012
Painterly Jitter
(Click for versions in their full 640 x 480 glory)Playing around with old code, feedback loops and Andrew Benson’s always fun optical flow shaders. Sometimes stills of unusual systems are nicer than the thing in motion…
November 22nd, 2012
Structured light scanning the dog
or she’s just looking through window blinds…there is no way she’d stay still long enough. Would love to see some Kinect point cloud pet portraits though…
November 22nd, 2012
How to make an installation stay up 4evr (Mac OS X version)
UPDATED: Added launchd boot option and some other system preference tips
(if you’re looking for help with this task with Windows, check out this awesome script StayUp from Stephen Schieberl. And check out this great step by step from EVSC: http://www.evsc.net/home/prep-windows-machine-for-fulltime-exhibition-setup ).
At work I recently had to set up a four installations of different configurations that would need to run all day, every day, 24 hours a day for a couple months with as few crashes or glitches as possible and without anyone going to check on them. This is something that a lot of media artists need to do all the time, and there are a bunch of different tricks and tips to keeping things up for an extended period, I figured I’d share my findings. There are alternate ways to do many of these tasks and this is only one road so please share some tips you’ve picked up out in the field down in the comments box below.
I had to do several searches in a couple different places to find all the information I needed to keep everything consistently up and bug free. Luckily most of the installations I was dealing with this time were fairly light in terms of resources and complications, but it’s always best practices to have a safety net.
I usually run these off brand new, unboxed computers so this is sort of starting from scratch. Most of the things I point out are set to the opposite by default.
Tip: if you’re doing multiple computers, do these prep steps on one of them and just boot the others into target disk mode and use something like Carbon Copy Cloner to mirror the first one on the next so everything is as consistent as possible.
Step 1: Prep your software and the computer
When building your software or whatever it might be, always keep the long running installation in mind. Plan which things will need to be adjusted by whoever is watching over the installation from the beginning (or at least don’t save it for the end). In my experience, keep it as simple as possible, so that it’s easy for the caretaker to get in there to fix or adjust what they need without opening Xcode and compiling or even exiting out of your app. Time you spend now to make things simple will save you hours of remote debugging when something breaks.
You’ll need to go through and turn off or disable several different automatic settings to keep things from popping up over top of your application. This can differ depending on whether you’re running 10.6, 10.7, 10.8 etc etc.
In System Preferences:
•••Desktop and Screensaver: Disable Screensaver. Set it’s time to “Never”
•••Energy Saver: Turn Display Sleep and Computer Sleep to Never. Enable “Start up automatically after power failure” and “Restart automatically if the computer freezes” (these are only available in 10.7 and later…not exactly sure how reliable they are, have not used them myself yet)
•••Accounts: ->Login Options: Enable Automatic Login
•••Software update: Disable automatic updates.
•••Sharing: (optional if you’re concerned about security). If you are running these without a monitor or in an inaccessible area, don’t forget to turn on file sharing and screen sharing so that you can just plug an Ethernet cable into the install computer and your laptop and be able to use screen sharing to control the computer without a mouse and keyboard but with low latency.
•••Network: If you don’t need remote access or don’t need Internet access for the installation, it’s not a bad idea to disable the wifi so the “please select a wireless network” window doesn’t pop up when you least expect it.
•••Bluetooth :If running without a mouse or keyboard plugged in, sometimes you can get the annoying ”Bluetooth keyboard/mouse setup” pop up over your application. You can temporality disable these by going to the advanced settings within the Bluetooth Preferences. See below for it’s location in 10.6.
•••Security: If you’re really paranoid, you can even disable things like the IR remote receiver that still exists on some macs and definitely on Macbooks. This would keep pranksters with Apple TV remotes from “Front Rowing” your installation. To disable, go to your Security->General tab (Security->General->Advanced (at the bottom) on 10.8) and “Disable remote control IR receiver”.
(Click the image for the full size version)


Step 2: Boot into your software
Things get unplugged, power goes out, not everyone has budget or space for a battery backup etc etc. Above, I covered how to have everything reboot automatically after power failures or freezes, but you’ll also need your app to be ready to go from the start and not leave the desktop open to prying eyes. In the System Preferences “Accounts” panel, select “Login Items” and drag your application into there to have it open automatically on launch and strip out whatever you don’t need.
(Click the image for the full size version)
Step 3: Keep it up (champ!)
There are several ways to make sure your application goes up and stays up
•••Launchd
Alternate method that is a little simpler using a Launch Agent plist to have things be launched automatically on boot and continuously if they go down. Launchd plists are very useful alternatives to cron jobs and can be used to run things on a periodic basis or on calendar days. You could achieve similar results with a combination of automator and iCal, but it depends on what you’re comfortable with.
Here is an Apple Doc on using Launch Agents and Launch Daemons in various ways.
The difference between a Launch Daemon and a Launch Agent (Basically whether you need it to run when a user is logged in or not…for most simple options like launching a regular app, you’ll just want a Launch Agent)
A launchd example from admsyn: https://gist.github.com/4140204
(Tip from James George below in comments): Of course you could make the launchd plist yourself for free from a template like above. One quick method to setting up Launchd is to use Lingon ($4.99 in the App Store)
In Lingon, hit the + to create a new launchd plist. Just make it a standard launch agent. Now Set up your plist like so:
One additional/optional thing you can add to this is to put an additional key in the plist for a “Successful Exit”. By adding this, your app won’t re-open when it has detected that it closed normally (ie You just hit escape intentionally, it didn’t crash). Can be useful if you’re trying to check something and OS X won’t stop re-opening the app on you. To easily add this to the key, just hit “expert mode” on the bottom of the Lingon window after selecting your newly made script on the left. Then modify the relevant bits highlighted in the screenshot:
•••Shell script+Cron Job method
(I got the following super helpful tip from Kyle McDonald)
In this step, shell scripting is your best friend. With the help of the script below and an application called CronniX , you will be able to use a cronjob to check the system’s list of currently running processes. If your app does not appear on the list, then the script will open it again, otherwise it won’t do anything. Either download the script or type the following into a text editor, replacing Twitter.app with your app’s name and filepath. Don’t forget the “.app” extension in the if statement!:
#!/bin/sh
if [ $(ps ax | grep -v grep | grep "Twitter.app" | wc -l) -eq 0 ]
then
echo "Twitter not running. opening..."
open /Applications/Twitter.app
else
echo "Twitter running"
fi
Save that file as something like “KeepOpen.sh” and keep it next to your application or somewhere convenient. Download the script here: Keep Open Script (112)
After creating that file, you’ll need to make it executable. To do this, open the Terminal and in a new window type “chmod +x ” and then enter the path to the shell script you just created (you can either drag the shell script into the terminal window or manually type it). It would look something like this:
Laser-MacBook-Pro:~ laser$ chmod +x /Users/laser/Desktop/KeepOpen.sh
After you have made it executable, you’re now ready to set it up as a cronjob. Tip: to test the script, you can change the extension at the end to KeepOpen.command as an alternative to opening it with Terminal, but the same thing gets done.
Cronjobs are just low level system tasks that are set to run on a timer. The syntax for cronjobs is outside of the scope of this walkthrough, but there are many sites available for that. Instead, the application CronniX can do a lot of the heavy lifting for you.
After downloading CronniX, open it up and create a new cronjob. In the window that opens, in the command window, point it to your KeepOpen.sh file and check all of the boxes in the simple tab for minute, hour, month, etc. This tells the job to run every minute, every hour, every day, every month. If you want it to run less frequently or at a different frequency, play around with the sliders.
Now just hit “New” and then make sure to hit “Save” to save it into the system’s crontab. Now if you just wait a minute then it should open your app every minute on the minute. Maybe save this one for the very end if you have more to do
This is a great tool if there is an unintended crash because the app will never be down longer than a minute.
•••Non Cronjob Shell method
From comment below by Kris Meeusen:
#!/bin/bash while true do #using open to get focus echo "Trying to open empty example" open -a emptyExample sleep 10 done
Just type this into a plaintext document and save it as something like ”KeepMyAppAlivePlz.command” and then use chmod as above to make the file executable and then drop this in your login items as above. This one will just continuously try and open your app every 10ms, but if it is already open, the OS knows to not try opening it a second, third, fourth time.
•••Launchd
Alternate method that is a little simpler using a Launch Agent plist to have things be launched automatically on boot and continuously if they go down. Launchd plists are very useful alternatives to cron jobs and can be used to run things on a periodic basis or on calendar days. You could achieve similar results with a combination of automator and iCal, but it depends on what you’re comfortable with.
Here is an Apple Doc on using Launch Agents and Launch Daemons in various ways.
The difference between a Launch Daemon and a Launch Agent (Basically whether you need it to run when a user is logged in or not…for most simple options like launching a regular app, you’ll just want a Launch Agent)
A launchd example from admsyn: https://gist.github.com/4140204
(Tip from James George below in comments): Of course you could make the launchd plist yourself for free from a template like above. One quick method to setting up Launchd is to use Lingon ($4.99 in the App Store)
In Lingon, hit the + to create a new launchd plist. Just make it a standard launch agent. Now Set up your plist like so:
One additional/optional thing you can add to this is to put an additional key in the plist for a “Successful Exit”. By adding this, your app won’t re-open when it has detected that it closed normally (ie You just hit escape intentionally, it didn’t crash). Can be useful if you’re trying to check something and OS X won’t stop re-opening the app on you. To easily add this to the key, just hit “expert mode” on the bottom of the Lingon window after selecting your newly made script on the left. Then modify the relevant bits highlighted in the screenshot:
Make sure to check the Console.app for any errors that may have come through when no one caught them, whenever you check the installation in person or remotely. This is not a fix-all for buggy programming, just a helper to keep things running smooth. The more things you can do to leave yourself notes about why the crash happened, the faster you can address the core issue.
Step 4: Reboot periodically
This one is a little more preventative, or maybe superstitious so hopefully someone can point out a concrete reason why this is a good idea. Depending on your app and the amount of stuff it reaches into, there could be some memory leaks or other OS bugs that you haven’t accounted for. Rebooting every day or week is a good idea to keep everything tidy, system wise.
The simplest option by far would be to go to System Preferences->Energy Saver and then click “Schedule…” and enter in some values if you need to turn the computer off to rest for a longer period of time to save it some stress when it might not be used at night time or something. Heat can do funny things sometimes, so if you have a chance to get your computer to rest and the time to test it, definitely give this a shot…saves some energy too which is nice.
You could also set up another shell script with a crontab as above with CronniX that reboots the system with as often as you specify.
Another option (if you don’t want to deal with the terminal and shell scripting) is to use iCal to call an Automator iCal event. This method is perhaps a little easier to schedule and visualize when you will reboot. Within Automator, create a new file with the iCal event template to do something like this:
(Click the image for the full size version)
Run it to see if it does what you expect and then save it out. When you save,it will open in iCal as an action that gets opened. Just set it to repeat as often as you’d like.
If you’d like to just close your programs and re-open them and there is a background and foreground do something like this (pauses are so the quitting and re-opening stuff has time to actually execute):
(Click the image for the full size version)
Step 5: Check in on it from afar.
There are a bunch of options here from various paid web services (like Logmein or Teamviewer), to VNC (many options for this RealVNC tends to come up a bunch) to SSHing. The choice here depends on your comfort level and how much you need to do to perform maintenance from far away.
Leaving a Dropbox connected to the computer and your own is super useful for file swaps between the two computers. Although most remote screensharing services have file sharing built in, Dropbox is just a nice, fairly transparent option.
Step 6: Test, test, test.
You’ve already tested and perfected your software for the installation, so make sure to test all of the above methods and automatic scripts in as realistic manner as you can before you leave it alone for the first day at school.
You can’t account for everything, so don’t beat yourself up if something does eventually happen, but this list will hopefully alleviate a little bit of frustration. Good luck!
Other resources people have sent me:
http://vormplus.be/blog/article/configuring-mac-os-x-for-interactive-installations
http://www.evsc.net/home/prep-windows-machine-for-fulltime-exhibition-setup
November 11th, 2012
GL Rotate and translate example (OpenFrameworks)
I consistently seem to get myself confused by the order of operations when working with ofTranslate and ofRotate in openFrameworks and it feels like I have to re-teach myself each time I have to do something with those transforms.
I made this simple bare bones cheatsheet program for myself to help show the differences between different rotate and translate orders, and I hope it helps others…hopefully will get time to post more low level tutorials like this in the near future with some of the more complicated matrix transforms/homography for projection mapping.
Made with xCode and OF0072 but you should be able to just drop the “src” file into a Visual Studio Empty Example if you need to…enjoy!
OF_translate_rotate_cheatsheet (157)
















































































No Comments »