<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visualmotive Blog &#187; echo nest</title>
	<atom:link href="http://blog.visualmotive.com/tags/echo-nest/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.visualmotive.com</link>
	<description>Thoughts on maps and visualization</description>
	<lastBuildDate>Sat, 12 Jun 2010 18:24:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Song Visualizations with Echo Nest</title>
		<link>http://blog.visualmotive.com/2009/song-visualizations-echo-nest/</link>
		<comments>http://blog.visualmotive.com/2009/song-visualizations-echo-nest/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 12:00:34 +0000</pubDate>
		<dc:creator>Chris Mueller</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[echo nest]]></category>

		<guid isPermaLink="false">http://blog.visualmotive.com/?p=78</guid>
		<description><![CDATA[<a href="http://blog.visualmotive.com/2009/song-visualizations-echo-nest/"><img align="left" hspace="5" width="150" height="150" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/glass2-150x150.png" class="alignleft wp-post-image tfe" alt="Philip Glass String Quartet #5, 2nd Movement" title="philip_glass_string_quartet_viz" /></a>We recently came across Anita Lillie&#8217;s beautiful music visualization and MusicBox projects. The music visualization project was especially intriguing to us, since it was the only music visualization project we&#8217;d seen that did not require video playback—the visualizations were strictly in 2D. Unfortunately, the source code for Lillie&#8217;s visualizations was not available, so we decided [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_79" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-79" title="philip_glass_string_quartet_viz" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/glass2.png" alt="Philip Glass String Quartet #5, 2nd Movement" width="640" height="216" /><p class="wp-caption-text">Philip Glass String Quartet #5, 2nd Movement</p></div>
<p>We recently came across Anita Lillie&#8217;s beautiful <a href="http://www.flyingpudding.com/projects/viz_music/">music visualization</a> and <a href="http://thesis.flyingpudding.com/">MusicBox</a> projects. The music visualization project was especially intriguing to us, since it was the only music visualization project we&#8217;d seen that did not require video playback—the visualizations were strictly in 2D. Unfortunately, the source code for Lillie&#8217;s visualizations was not available, so we decided to build our own.</p>
<p>Our goal was to build a 2D visualization that could be approached like one of Edward Tufte&#8217;s sparklines: a quick, snapshot overview with high information density. In addition, having an image snapshot of a song could be useful for visually-minded people who often find themselves thinking of music as in spatial or pictorial terms. In the same way that Cicero used different rooms in his home to memorize different sections of his oratories, a 2D song-picture could provide a memorable structure for interpreting and contextualizing moments in a piece of music.</p>
<p>Here is the fruit of our labors. The top segment represents volume across the duration of the song. The bottom segments represent the 12 pitches of the song&#8217;s primary key, and the weight of each block corresponds to that pitch&#8217;s volume at that point in the song. Details, including Echo Nest integration and source code, are below.</p>
<div id="attachment_84" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-84" title="darkside" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/darkside.png" alt="Pink Floyd, Dark Side of the Moon, &quot;Speak to Me/Breathe in the Air&quot;" width="640" height="216" /><p class="wp-caption-text">Pink Floyd, Dark Side of the Moon, &quot;Speak to Me/Breathe in the Air&quot;. The opening crescendos of this album are clearly visible. </p></div>
<div id="attachment_87" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-87" title="highroller" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/highroller.png" alt="Crystal Method, Vegas, &quot;High Roller&quot;" width="640" height="216" /><p class="wp-caption-text">Crystal Method, Vegas, &quot;High Roller&quot;. We like the seeing that perfect volume curve at the beginning of this song. There&#39;s a pronounced industrial feeling here.</p></div>
<div id="attachment_100" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-100" title="imperial1" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/imperial1.png" alt="John Williams, Star Wars: A New Hope, &quot;Imperial Attack&quot;" width="640" height="216" /><p class="wp-caption-text">John Williams, Star Wars: A New Hope, &quot;Imperial Attack&quot;. This visualization should probably be in black.</p></div>
<div id="attachment_86" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-86" title="goldfrapp_whitehorse" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/goldfrapp_whitehorse.png" alt="Goldfrapp, Supernature, &quot;Ride a White Horse&quot;" width="640" height="216" /><p class="wp-caption-text">Goldfrapp, Supernature, &quot;Ride a White Horse&quot;. Volume leveling clearly visible. Pop at its finest.</p></div>
<div id="attachment_92" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-92" title="kyrie" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/kyrie.png" alt="Mozart, Requiem, &quot;Kyrie&quot;" width="640" height="216" /><p class="wp-caption-text">Mozart, Requiem, &quot;Kyrie&quot;</p></div>
<div id="attachment_90" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-90" title="permutations" src="http://blog.visualmotive.com/wp-content/uploads/2009/03/permutations.png" alt="George Maasry, &quot;Permutations&quot; " width="640" height="216" /><p class="wp-caption-text">George Maasry, &quot;Permutations&quot;. Mathematical permutations on a theme.</p></div>
<p><span id="more-78"></span></p>
<h3>Making Of</h3>
<p>The <a href="http://the.echonest.com/">Echo Nest</a> has developed a brilliant piece of software called Analyze. It &#8220;listens&#8221; to music as if it were human, and extracts information about rhythm, tone, pitch, etc. The amount and quality of information available is stunning. A simple web service API provides anyone with access to its vast power.</p>
<p>Adam Lindsay has written a <a href="http://lindsay.at/work/remix/overview.html">fantastic overview</a> of the API service.</p>
<p>Our code, below, requires the <a href="http://www.pythonware.com/products/pil/">Python Imaging Library</a>, <a href="http://effbot.org/zone/pythondoc-aggdraw.htm">aggdraw</a>, and <a href="http://code.google.com/p/echo-nest-remix/">Echo Nest Remix</a> with a valid <a href="http://developer.echonest.com/pages/overview">API key</a>. This is a rough sketch of what is possible, and there are probably bugs, so don&#8217;t be surprised if something breaks.</p>
<p>Please feel free to use and modify this code as you see fit, we&#8217;d just ask that you provide a link back to this site if you happen to use our code in any of your projects.</p>
<pre>import echonest.audio as audio
import Image
import aggdraw
import math

def main( input_filename, output_filename, width=None, height=None ):
    """
    Simple song visualization using Echo Nest
    published by Chris Mueller, http://visualmotive.com
    """
    audio_file = audio.LocalAnalysis( input_filename )
    segments = audio_file.analysis.segments

    if width is None:
        width = int( math.ceil( audio_file.analysis.duration ) ) * 2
    width_scale = float( width ) / audio_file.analysis.duration
    if height is None:
        height = 216
    height_part = height/3

    img = Image.new( "RGBA", ( width, height ), "#ffffff" )
    draw = aggdraw.Draw( img )
    draw.setantialias( False )
    brush = aggdraw.Brush( "#0088aa", 255 )
    pen = aggdraw.Pen( "#ffffff", 1, 0 )

    for segment in segments:
        left = width_scale * segment.start
        right = width_scale * ( segment.start + segment.duration )
        rect = ( left,
                 height_part,
                 right,
                 segment.loudness_max * -1 )
        draw.rectangle( rect, pen, brush )
        for i in xrange( len( segment.pitches ) ): # assumes a constant key
            pitch_loudness = segment.pitches[ i ]
            pitch_brush = aggdraw.Brush( "#0088aa", int( 255 * pitch_loudness ) )
            pitch_height = 2 * height_part * ( 1.0 / 12.0 )
            top = height_part + i * pitch_height
            rect = ( left,
                     top,
                     right,
                     top + pitch_height )
            draw.rectangle( rect, pen, pitch_brush )

    draw.flush()
    del draw
    img.save( output_filename, "PNG")</pre>
<p>This is only scratching the surface of possible 2D music visualizations. We look forward to exploring this concept more in the future. Many thanks to Echo Nest for their great service.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visualmotive.com/2009/song-visualizations-echo-nest/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
