<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>JOCABOLA ARCHIVES</title>
	
	<link>http://www.jocabola.com/archives</link>
	<description>Archives of Jocabola.com – Eduard Prats Molner</description>
	<lastBuildDate>Fri, 14 Jan 2011 10:45:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/jocabola" /><feedburner:info uri="jocabola" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/jocabola" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fjocabola" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>The Wilderness Downtown – Behind The Scenes</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/zsSoF3qx184/</link>
		<comments>http://www.jocabola.com/archives/work/the-wilderness-downtown/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 13:21:12 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sequencer]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=967</guid>
		<description><![CDATA[Background: coincidences and a bit of luck A few years ago I was attracted by the great interface of “The Turn” website. Digging into the credits, I found out that Guille Lopez was responsible for the development. Funny enough, Guille was from Barcelona and he studied exactly the same and in the same place as [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/wutw.jpg" alt="" title="wutw" width="600" height="382" class="alignnone size-full wp-image-1070" /></p>
<h2>Background: coincidences and a bit of luck</h2>
<p>A few years ago I was attracted by the great interface of <a href="http://theturn.tv/">“The Turn”</a> website. Digging into the credits, I found out that <a href="http://www.ductil.org/">Guille Lopez</a> was responsible for the development. Funny enough, Guille was from Barcelona and he studied exactly the same and in the same place as I did.</p>
<p>Encouraged by the parallelism, I decided to write him and send my congratulations for the great work. By that time, I was still based in Berlin and Guille told me that he just moved to London where he started working at <a href="http://www.b-reel.com">B-Reel</a>.</p>
<p>About a year ago, it was me who moved to London and I had the chance to personally meet Guille right before he moved from London to B-Reel&#8217;s New York office.</p>
<p>Ten months later, Guille contacted me again and asked me if I was interested in taking part of a very exciting HTML5 music video project in collaboration with Google and B-Reel.</p>
<p>As soon as I got the briefing and we started talking about it, I got very excited. The video was going to be directed by <a href="http://www.chrismilk.com">Chris Milk</a>, <a href="http://www.aaronkoblin.com">Aaron Koblin</a> was behind it and <a href="http://www.mrdoob.com">Mr.Doob</a> himself (who I casually met just a few days before all this happened) was going to be actively involved.</p>
<p>We were really lucky to have someone like <a href="http://twitter.com/thespite">Jaime Sánchez</a> joining the dev team, which was completed by <a href="http://www.georgemichaelbrower.com/">George Michael Bower</a> and <a href="http://www.ghost-hack.com/">Michael Chang</a> from the Google Creative Lab, and Eric Haeton who was in charge of the backend.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/wutw-02.jpg" alt="" title="wutw-02" width="600" height="342" class="alignnone size-full wp-image-1072" /></p>
<h2>My role in the project</h2>
<p>As you may already know, <a href="http://www.thewildernessdowntown.com/">The Wilderness Downtown</a> is composed by several pop up windows showcasing different contents during the interactive video-clip experience. Each content pops in and out at a certain time during track&#8217;s playback.</p>
<p>We had an amazing team of developers taking care of the production of all window&#8217;s contents: bird flocks, canvas 360° street-view, tree explosions, 3D optimisation, Google maps integration and routes calculation, <a href="http://mrdoob.com/projects/harmony/">Harmony</a> drawing tool&#8217;s adaptation and so on&#8230;</p>
<p>B-Reel wanted me to create the mainframe of the application while making sure that everything came nicely together. There were a bunch of feature requests in order to make the concept work: content pre-loading, sharing information in-between windows, sound spectrum support, liquid pop-up window layout, a main controller, tracking …</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/wutw-03.jpg" alt="" title="wutw-03" width="600" height="340" class="alignnone size-full wp-image-1076" /></p>
<h2>The sequencer – aka the engine –</h2>
<p>Luckily enough, Mr.Doob created this magic little <a href="https://github.com/mrdoob/xplsv_orsotheysay/blob/master/js/Sequencer.js">Sequencer JS object</a> that provides sequencing control of what we call <i>Effects</i>. Effects can be added to the sequence as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
seqeuncer.add ( effect, start_time, duration );
</pre>
<p>Effects are objects with show / hide functions which are used to update sequencer&#8217;s state at a given time.</p>
<p>So the Sequencer object provides the core functionality of the engine but this needed to be extended to fully support the content / pop up window system we were aiming for.</p>
<p>One of the biggest constraints was obviously the fact of using pop-up windows since these need to be launched by a user click in order to avoid the default popup-blocker behaviour. This actually means that we need such a work-flow:</p>
<p>1) Create all content objects and start loading them<br />
2) When loaded, tell the user to proceed by clicking a launch button<br />
3) Create <u>all popup windows at once</u> and &#8220;hide&#8221; non-used windows<br />
4) Define content targets (tell every content on which window should go)<br />
5) Start audio+sequencer playback<br />
6) Append contents to target windows as soon as they need to be in the sequence</p>
<p>So we needed to create two different kinds of Effects for the sequencer: <i>Popup Window Effects</i> and <i>Content Effects</i>.<br />
Popup Window Effects can be understood as cue-points that define the size and position of a popup window at a given time.<br />
Content Effects are mostly <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html">Canvas</a> experiments that are appended into a popup window&#8217;s body at “show” (start_time) and removed at “hide” (end_time = start_time + duration). Content Effects may need to preload images or video and need to notify when they are successfully preloaded.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/wutw-04.jpg" alt="" title="wutw-04" width="600" height="511" class="alignnone size-full wp-image-1078" /></p>
<h2>The complexity of making adjustments</h2>
<p>We had initially a 8-window setup, and only during the first act of the video, we had already generated about 30 window cue-points. One cue-point looks like something like this:</p>
<pre class="brush: jscript; title: ; notranslate">
sequencer.add(new PopupEffect(popup3, {x: 10, y: 1024, width: 100, height: 60}, false), 132.36700439453125, 24.432998657226562);
</pre>
<p>Notice that the latest two numbers refer to “start_time” and “duration”.<br />
Besides the window cue-points, we need to assign every content to a specific window as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
addContentToSequence(1, popup2, 31.117, 28.383);
</pre>
<p>So, only during the first act of the video, we had already about 50 lines of code with floating point numbers defining times and durations.<br />
The full clip is defined by 4 acts, so we could expect about 200 lines of code like the ones above.</p>
<p>I suddenly realised how painful would it be when Chris and Ben, creative director at B-Reel, would like to make content and time adjustments to the sequence, as well as change content / window assignments, pushing a part of the sequence a few seconds forwards, resizing windows, and so on.<br />
Doing such changes manually could become a mess and would keep me too busy right at the end of the project, which could be quite inconvenient.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-01.jpg" alt="" title="tool-01" width="600" height="366" class="alignnone size-full wp-image-1080" /></p>
<h2>We like tools to automate boring processes</h2>
<p>I thought it would be useful for Ben and Chris to be able to do changes in the sequence by themselves, so I decided to build an interface for generating our sequencer code.</p>
<p>Since the project was about Chrome and HTML5, I thought it would make sense to use the same technologies, so the sequencer tool was created with CSS/HTML + Javascript and a little bit of PHP to dynamically generate JS files on the server. To minimise production time, the tool was uniquely targeting Chrome / Webkit since was for internal use only.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-02.jpg" alt="" title="tool-02" width="600" height="70" class="alignnone size-full wp-image-1081" /></p>
<h2>The soundtrack timeline</h2>
<p>The tool works time-based around a main timeline reproducing the same &#8220;We Used To Wait&#8221; soundtrack as a reference. On besides, the original animatic sketch from Chris Milk is added into it, so we have a constant visual reference of the current act / sequence.</p>
<p>It is possible to navigate through the timeline either by dragging the progress marker or by entering a time code manually. Hitting the spacebar key will toggle play/pause.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-03.jpg" alt="" title="tool-03" width="600" height="373" class="alignnone size-full wp-image-1082" /></p>
<h2>The cue-point editor: controlling windows</h2>
<p>I have created a light JS window manager to control windows. The &#8220;fake&#8221; windows can be resized and moved around which updates / creates automatically a window cue-point.</p>
<p><b>History</b><br />
The cue-points are stored and sorted by time values into a history drop-down which allows to directly jump to the particular cue-point.</p>
<p><b>Tweens</b><br />
We have a tween option that allows the windows to be animated when a cue-point is reached (We didn&#8217;t use this feature at the end although is still implemented and ready to be used).</p>
<p><b>Playback</b><br />
If the sequence is played, it is possible to see on-the-fly the window animatic sequence as it will behave later within the &#8220;real experience&#8221;.</p>
<p><b>Copy &#038; Paste</b><br />
Ben wanted to be able to copy &#038; paste cue-points since the &#8220;hidden&#8221; status of a window happens to be always the same width, height, x and y settings. This saved Ben some time <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-04.jpg" alt="" title="tool-04" width="600" height="360" class="alignnone size-full wp-image-1083" /></p>
<h2>Content cue-points: assigning contents to windows</h2>
<p>We need to distinguish in between two types of content. In one side we have pure video contents, and in the other hand the interactive / JS Canvas experiments.</p>
<p>The tool has a built-in video library that can be browsed and which displays video information such as size in pixels and duration. When assigning a video content into a window, we can automatically let the system calculate the duration of the content based on the original video duration.</p>
<p>If we are assigning other contents rather than video, we&#8217;ll only be accessing the &#8220;standard&#8221; parameters: width, height and duration.</p>
<p>All content objects support dynamic size (width and height). When selecting a target window for a content, the width and height are automatically adjusted to fit window&#8217;s size, so everything makes sense.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-05.jpg" alt="" title="tool-05" width="600" height="340" class="alignnone size-full wp-image-1084" /></p>
<h2>Dynamic canvas</h2>
<p>We had a minimum target resolution of 1024 x 768 but loads of users have big screens with higher resolutions.</p>
<p>The tool displays a cyan 1024 x 768 canvas where to position and resize the windows. Later on, the real browser application is dynamically adjusting the positions of the windows and contents according to user&#8217;s resolution.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/11/tool-06.jpg" alt="" title="tool-06" width="600" height="572" class="alignnone size-full wp-image-1085" /></p>
<h2>I need a break, please save my progress</h2>
<p>There is a save functionality built-in, so the sequence can be finished another time.</p>
<h2>Finally, let me preview it and see how it looks like</h2>
<p>Current settings can be saved as Javascript sequencer code and be previewed in a version of the real application within a click.</p>
<h2>Considerations and what could have been much better</h2>
<p>The sequencer tool was a very useful toy for playing around and generating the final animatic but the interface and UX could have been much better.</p>
<p>You have to take into account that I couldn&#8217;t spend too much time on it since I needed to be working on all the other stuff; but would have been great to have a graphic drag-and-drop timeline interface to visualise and move around the cue-points.</p>
<p>Another cool feature would have been previewing content directly built in the fake windows of the sequencing tool.</p>
<h2>Some problems faced during the progress and things worth sharing</h2>
<p><b>Preloading</b><br />
The contents were generated before being appended to the DOM. Some contents needed to fetch data from Google and preload some images but I faced a problem with the videos since media elements (video and audio) won&#8217;t load if they aren&#8217;t appended to the DOM; so we had to rely on cache for the videos.</p>
<p>It was only possible to preload a video by appending it into a DIV located outside the main window or invisible and remove it again when the video reached the &#8220;ready&#8221; state (no need to actually preload the whole video).</p>
<p><b>Safari is very, very picky</b><br />
Safari is very strict on which audio and video codecs should be in the web. It would be a nice move if Apple would add support for Vorbis/Theora but they clearly want H264 and AAC to be the standard HTML5 codecs.</p>
<p>I recommend to any Safari user in Mac to install this great Quicktime component that will allow your Safari as well as your Quicktime player to support OGG and OGV files: <a href="http://www.xiph.org/quicktime/download.html">http://www.xiph.org/quicktime/download.html</a></p>
<p>We obviously needed to have OGG / OGV with MP3 and MP4 fallbacks, but the most ridiculous episode was when Safari wasn&#8217;t working with MP3 files encoded with <a href="http://lame.sourceforge.net/">LAME</a>. We had issues with different versions of Safari and at the end we had to encode the MP3 file using iTunes. Surprised?</p>
<p><b>A lovely python script to generate sound spectrum values at a perfect framerate</b><br />
We needed some audio spectrum support and you can&#8217;t do this in real-time using Javascript. Well, Firefox is able to do this (at least the 4 beta), but not Safari nor Chrome. Mr.Doob pointed me at a great <a href="http://www.python.org/">python</a> script that lets you generate an array of spectrum values at a perfect framerate, given a WAVE file:</p>
<pre class="brush: python; title: ; notranslate">
import math
import struct
import wave
import sys

w = wave.open(sys.argv[1], 'rb');
# We assume 44.1k @ 16-bit, can test with getframerate() and getsampwidth().
sum = 0;
value = 0;
delta = 0;
amps = [ ];

for i in xrange(0, w.getnframes()):
	# Assume stereo, mix the channels.
	data = struct.unpack('&lt;hh', w.readframes(1))
	sum += (data[0]*data[0] + data[1]*data[1]) / 2
	# 44100 / 60 = 735 (60 fps)
	if (i != 0 and (i % 735) == 0):
		value = int(math.sqrt(sum / 735.0) / 10)
		amps.append(value) # absolute value no delta
		delta = value
		sum = 0

print amps
</pre>
<p>More information in <a href="http://mrdoob.com/blog/post/677">his post here</a>.</p>
<h2>The web trend loop</h2>
<p>When I started working in Barcelona back in 1999 there was a hype thanks to <a href="http://www.doubleyou.com/">DoubleYou</a>. It was the Netscape vs Explorer times and the hype was called DHTML (Dynamic HTML). DHTML isn&#8217;t far of the technology used for “The Wilderness Downtown”: HTML + Javascript.</p>
<p>Flash was by then stuck at version 4 and AS1 and it was becoming popular thanks to people like <a href="http://www.joshuadavis.com/">Joshua Davis</a> and <a href="http://gmunk.com/">Gmunk</a>.</p>
<p>I remember one of my first projects. We created a website for the spanish pavilion of an art fair that I barely remember. We used DHTML and we recreated a Mac OS 9 OS using Javascript and with a JS window manager, quite a coincidence <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I remember one of the &#8220;plus&#8221; features being an animated (DIV tween) desktop background. It was 2000 and it was running in the two major browsers: Netscape and Explorer. The site won&#8217;t work in any of the modern browsers today.</p>
<p>I have been working with AS2 and AS3 for many years now and I really wanted to work in a HTML / Javascript interface again, and this project was as challenging as ironically bringing me in a way back to where I started. Of course many things have changed: AJAX, Canvas, Video, Audio, minimised cross-browser pain and WebGL around the corner; but Javascript feels quite the same as it did back then.</p>
<p>Oh, and don&#8217;t get me wrong. I am not trying to participate in any &#8220;Flash VS HTML5&#8243; bullshit. I just enjoy using different technologies and keep learning things out of challenging projects. In fact, I think I should step out of the web soon and invest a few months in other types and formats of work.</p>
<h2>I would like to know more about the graphics / content part</h2>
<p>If you would like to know more about the 3D / Graphics, optimisation and the Google API, you should read <a href="http://mrdoob.com/blog/post/705">this great post by Mr. Doob</a>.</p>
<p>There is also some more information about the project <a href="http://www.chromeexperiments.com/arcadefire/">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/zsSoF3qx184" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/work/the-wilderness-downtown/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/work/the-wilderness-downtown/</feedburner:origLink></item>
		<item>
		<title>Openframeworks to Flash [MIDI]</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/h6MORPfhX58/</link>
		<comments>http://www.jocabola.com/archives/lab/openframeworks-to-flash-midi/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 19:40:17 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[midi]]></category>
		<category><![CDATA[openframeworks]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=899</guid>
		<description><![CDATA[I have been interested in using MIDI devices for different specific interfaces lately. I have been using mainly Openframeworks to play a little bit around with it and understand the possibilities of such hardware interfaces. If you have followed my previous , you&#8217;ll see how easy is to get your MIDI hardware up and running [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/10/Screen-shot-2010-10-17-at-19.35.20.png" alt="" title="Screen shot 2010-10-17 at 19.35.20" width="600" height="400" class="alignnone size-full wp-image-901" /></p>
<p>I have been interested in using MIDI devices for different specific interfaces lately. I have been using mainly <a href="http://www.openframeworks.cc">Openframeworks</a> to play a little bit around with it and understand the possibilities of such hardware interfaces.</p>
<p>If you have followed my previous <a href="http://www.jocabola.com/archives/lab/oflab-at-the-va-part-i/">MIDI / OF tutorial</a>, you&#8217;ll see how easy is to get your MIDI hardware up and running in OF, but what about using MIDI hardware in Flash? I was really interested on being able to use a MIDI controller within a Flash application, so I researched a little bit and found <a href="http://consultingblogs.emc.com/filthyria/archive/2008/05/27/passing-binary-data-to-flash.aspx">this helpful post</a>.</p>
<p>Apparently, you can send data from OF (C++) to Flash via TCP using binary sockets in as3 and ofxTCPServer in OF.</p>
<p><strong>The approach is simple:</strong></p>
<p>1) Create a C++ TCP Server application using OF to send encapsulated MIDI messages.</p>
<p>2) Create an as3 client application that reads the MIDI messages and do whatever you want to do with them <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/10/Screen-shot-2010-10-17-at-20.46.07.png" alt="" title="Screen shot 2010-10-17 at 20.46.07" width="600" height="440" class="alignnone size-full wp-image-908" /></p>
<h2>TCP Server (OF)</h2>
<p>Let&#8217;s start with the OF server side: you&#8217;ll need to use the ofxMidi and ofxTCPServer addons.</p>
<p>The first thing I did was to create a simple C++ class to encapsulate the necessary information of my MIDI messages to be sent:</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 *  SocketMessage.h
 *  MIDISocket
 *
 *  Created by Eduard Prats Molner on 04/10/2010.
 *  Copyright 2010 Jocabola. All rights reserved.
 *
 */

#ifndef SOCKET_MESSAGE
#define SOCKET_MESSAGE

class SocketMessage{

public:

	SocketMessage();
	~SocketMessage(void);

	int MIDI_val;
	int MIDI_ID;
	int MIDI_port;

};

#endif
</pre>
<p>I used the ofxTCPServer OF sample combined with my MIDI test class. This is how the TestApp header looks like:</p>
<pre class="brush: cpp; title: ; notranslate">
#ifndef _TEST_APP
#define _TEST_APP

#include &quot;ofMain.h&quot;
#include &quot;ofxMidi.h&quot;
#include &quot;ofxNetwork.h&quot;
#include &quot;SocketMessage.h&quot;

class testApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

		void keyPressed  (int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void windowResized(int w, int h);

	void newMessage(ofxMidiEventArgs &amp;args);

	ofxMidiIn midiIn;

	ofxTCPServer TCP;

	ofTrueTypeFont  mono;

	vector &lt;string&gt; storeText;

};

#endif
</pre>
<p>In the setup method we&#8217;ll need to initialise the MIDI and TCP Server as follows (setting up the TCP server at port 11999):</p>
<pre class="brush: cpp; title: ; notranslate">
void testApp::setup(){
	midiIn.openPort();
	ofAddListener(midiIn.newMessageEvent, this, &amp;testApp::newMessage);

	//load our type
	mono.loadFont(&quot;type/mono.ttf&quot;, 8);

	//setup the server to listen on 11999
	TCP.setup(11999);

	ofBackground(0, 0, 0);
}
</pre>
<p>Now, I&#8217;ll update the MIDI &#8220;new message&#8221; listener to be sending the desired MIDI arguments using the TCP server and encapsulating the MIDI port, id (which knob, button, toggle) and value into a SocketMessage class instance:</p>
<pre class="brush: cpp; title: ; notranslate">
void testApp::newMessage(ofxMidiEventArgs &amp;args){
	SocketMessage* sm = new SocketMessage();
	sm-&gt;MIDI_port = args.port;
	sm-&gt;MIDI_ID = args.byteOne;
	sm-&gt;MIDI_val = args.byteTwo;
	TCP.sendRawBytesToAll((char*) sm, sizeof(SocketMessage));
	storeText.push_back(&quot;Sending message: &lt;port: &quot; + ofToString(sm-&gt;MIDI_port) + &quot;; id: &quot; + ofToString(sm-&gt;MIDI_ID) + &quot; value: &quot; + ofToString(sm-&gt;MIDI_val) + &quot;&gt;&quot;);
}
</pre>
<p>Notice that I stored the messages into a storeText vector which I use for printing messages in the little server app. That&#8217;s how my update and draw methods look like:</p>
<pre class="brush: cpp; title: ; notranslate">
void testApp::update(){
	if(storeText.size() &gt; 28){
		storeText.clear();
	}
}

//--------------------------------------------------------------
void testApp::draw(){
	mono.drawString(&quot;TCP SERVER launched on port: &quot; + ofToString(TCP.getPort()), 10, 20);

	for(int i=0;i&lt;storeText.size();i++){
		mono.drawString(storeText[i], 10, 30 + 10*i);
	}
}
</pre>
<h2>Client application (AS3)</h2>
<p>Is time for grabbing the MIDI messages from Flash! <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My Flash application is called MidiSocket and has a Socket class instance that acts as a client application:</p>
<pre class="brush: as3; title: ; notranslate">
//--------------------------------------
//  CONSTANTS &amp; VARIABLES
//--------------------------------------

private var _client:Socket;

public function MidiSocket(){
	_client = new Socket();
	_client.addEventListener(&quot;ioError&quot;, retry);
	_client.addEventListener(&quot;connect&quot;, connectionEstablished);
	_client.addEventListener(&quot;socketData&quot;, socketData);

	_client.connect(&quot;localhost&quot;, 11999);
}
</pre>
<p>Now, before getting into the actual socket data parsing / fetching. Let&#8217;s make some memory about the two variables of the MIDI messages that are really important to us: <i>byteOne</i> and <i>byteTwo</i>.</p>
<p>As their names already tell us, each of these variables is represented by one byte (8 bits). byteOne is an unsigned integer that represents the ID of the MIDI parameter being changed (identifies a particular knob, a fader, a button, …). byteTwo is the actual value of it which is represented by an unsigned integer that goes from 0 to 127 (128 possible values).</p>
<p>When fetching the values in Flash, I faced the problem that the values being read where really long weird nonsense numbers. I suspected that had to do with the bit representation of the integers since Socket.readInt() returns a 32-bit integer, so I had to refresh &#8220;bit shifting&#8221;: <a href="http://www.gamedev.net/reference/articles/article1563.asp">Great explanation here</a>.</p>
<p>Basically, I needed to shift right 24 bits to convert the values back to the original 8 bit representation. In other words, to be able to have nice integers from 0 to 128 (much easier to handle) once again.</p>
<pre class="brush: as3; title: ; notranslate">

private function socketData(evt:ProgressEvent):void{
	var buffer:ByteArray = new ByteArray();
	_client.readBytes(buffer, 0, _client.bytesAvailable);

	var val:uint = buffer.readInt() &gt;&gt; 24;
	var id:uint = buffer.readInt() &gt;&gt;  24;
	var port:uint = buffer.readInt();	

	trace(&quot;MESSAGE: &lt;port: &quot; + port + &quot;, id: &quot; + id + &quot;, value: &quot; + val + &quot;&gt;&quot;);
}
</pre>
<p>There are also two more important things to take into account. Make sure to read the whole buffer; otherwise you&#8217;ll be accumulating some weird data that will end with wrong values being read. So best practice is to always read the whole buffer: _client.readBytes(buffer, 0, _client.bytesAvailable);</p>
<p>Once you grab the bytes, remember to fetch the arguments in the same exact order as they are defined in the C++ SocketMessage class: For instance, first int will be the value, second the id and last one the port.</p>
<p>That&#8217;s pretty much it! <a href='http://www.jocabola.com/archives/wp-content/uploads/2010/10/of-flash.zip'>Get the sources here</a> and feel free to drop any questions as comments.</p>
<p><b>Considerations</b></p>
<p>1) I think it should be better to create a pure C++ command line tool for such a server app.</p>
<p>2) Notice that MIDI was just an example. Using this technique you can send any data from OF to Flash, and works very fast (complete real-time feeling with the MIDI controller).</p>
<p>3) I haven&#8217;t tried the buffer.readObject in depth. Would be great to serialise objects; Something like AFM / JSON and work with objects encapsulating all variables instead.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/h6MORPfhX58" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/lab/openframeworks-to-flash-midi/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/lab/openframeworks-to-flash-midi/</feedburner:origLink></item>
		<item>
		<title>London overground’s emergency alarm…</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/HRWO8AfIZnk/</link>
		<comments>http://www.jocabola.com/archives/blog/london-overgrounds-emergency-alarm/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 14:06:16 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=894</guid>
		<description><![CDATA[&#8230; looks like an ashtray to me]]></description>
			<content:encoded><![CDATA[<p>&#8230; looks like an ashtray to me <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/10/overground.jpg" alt="" title="overground" width="600" height="390" class="alignnone size-full wp-image-895" /></p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/HRWO8AfIZnk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/blog/london-overgrounds-emergency-alarm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/blog/london-overgrounds-emergency-alarm/</feedburner:origLink></item>
		<item>
		<title>Animatrix</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/DmcLimx7XE0/</link>
		<comments>http://www.jocabola.com/archives/lab/animatrix/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 13:58:15 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[frame-offset]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=885</guid>
		<description><![CDATA[A couple of months ago I did a little experiment using Flash. The idea was to record every single frame of a very simple animation into a Bitmap Object and later render them into a tiled matrix across the screen. Basically, once recorded, the main animation is constantly looping with a frame offset of +1 [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago I did a little experiment using Flash. The idea was to record every single frame of a very simple animation into a Bitmap Object and later render them into a tiled matrix across the screen.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/10/animatrix.jpg" alt="" title="animatrix" width="600" height="374" class="alignnone size-full wp-image-886" /></p>
<p>Basically, once recorded, the main animation is constantly looping with a frame offset of +1 in each consecutive tile.</p>
<p>Imagine the recorded animation having 250 frames. We set up a counter that goes from 1 to 250 and then starts over again.<br />
Each tile renders the current counter frame + an offset defined by its position in the matrix as shown below (n represents current frame):</p>
<p>[n] [n+1] [n +2] [n +3] [n + 4] &#8230;</p>
<p>The results of a few test animations turned into this:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="flash"
			class="flashmovie"
			width="600"
			height="400">
	<param name="movie" value="http://playground.jocabola.com/animatrix/Animatrix.swf" />
	<param name="menu" value="false" />
	<param name="quality" value="high" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="allowscriptaccess" value="always" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://playground.jocabola.com/animatrix/Animatrix.swf"
			name="flash"
			width="600"
			height="400">
		<param name="menu" value="false" />
		<param name="quality" value="high" />
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="allowscriptaccess" value="always" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><a href="http://playground.jocabola.com/animatrix/">Visit the full-browser version</a> if you want to see it bigger.</p>
<p>To store the frames I used the BitmapData Object and its draw function which allows to easily capture any DisplayObject as pixels. I created a base Sprite subclass called &#8220;BitmapRenderer&#8221;. The class contains a little &#8220;renderer&#8221; sprite which is masked by a square defined by the bitmap size (tile size) that we want:</p>
<pre class="brush: as3; title: ; notranslate">
//
//  BitmapRenderer
//
//  Created by Eduard Prats Molner on 2010-06-06.
//  Copyright (c) 2010 Jocabola. All rights reserved.
//

package render{

	import flash.display.Sprite;
	import flash.display.BitmapData;
	import render.BitmapRendererEvent;

	/**
 	* Class.
 	*
	* @langversion ActionScript 3.0
 	* @playerversion Flash 9.0
 	*
 	* @author Eduard Prats Molner
 	* @since  2010-06-06
 	*/
	public class BitmapRenderer extends Sprite{

		//--------------------------------------
		//  CONSTANTS &amp; VARIABLES
		//--------------------------------------

		public static const BITMAP_WIDTH:uint = 80;
		public static const BITMAP_HEIGHT:uint = 60;

		protected var __bitmap:Array;

		protected var __renderer:Sprite;
		protected var __rendererMask:Sprite;

		/**
	 	* @constructor
	 	*/
		public function BitmapRenderer(){
			super();
			__bitmap = new Array();

			addChild(__renderer = new Sprite());
			addChild(__rendererMask = new Sprite());

			__renderer.mask = __rendererMask;

			__rendererMask.graphics.beginFill(0x000000, 1);
			__rendererMask.graphics.drawRect(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
		}

		//--------------------------------------
		//  PUBLIC METHODS
		//--------------------------------------

		public function begin():void{// to be extended - here we add the actual animated objects into __renderer}

		//--------------------------------------
		//  PRIVATE &amp; PROTECTED INSTANCE METHODS
		//--------------------------------------

		protected function dispatchBitmapEvent():void{
			dispatchEvent(new BitmapRendererEvent(&quot;renderComplete&quot;, __bitmap));
		}

		protected function addBitmapData():void{
			var bmpd:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT, false, 0x000000);

			bmpd.draw(this);
			__bitmap.push(bmpd);
		}
	}

}
</pre>
<p>Once our animation is ready, we&#8217;ll fire a &#8220;BitmapEvent&#8221; which contains our array of BitmapData objects (the actual frames of the animation):</p>
<pre class="brush: as3; title: ; notranslate">
//
//  BitmapRendererEvent
//
//  Created by Eduard Prats Molner on 2010-06-06.
//  Copyright (c) 2010 Jocabola. All rights reserved.
//

package render{

	import flash.events.Event;

	/**
 	* Class.
 	*
	* @langversion ActionScript 3.0
 	* @playerversion Flash 9.0
 	*
 	* @author Eduard Prats Molner
 	* @since  2010-06-06
 	*/
	public class BitmapRendererEvent extends Event{

		//--------------------------------------
		//  CONSTANTS &amp; VARIABLES
		//--------------------------------------

		private var __data:Array; // BitmapData array

		/**
	 	* @constructor
	 	*/
		public function BitmapRendererEvent($type:String, $data:Array, $bubbles:Boolean = false, $cancelable:Boolean = false){
			super($type, $bubbles, $cancelable);
			__data = $data;
		}

		//--------------------------------------
		//  GETTER/SETTERS
		//--------------------------------------

		public function get data():Array{
			return __data;
		}

	}

}
</pre>
<p>So, each of the 5 simple animations are basically child classes of &#8220;BitmapRenderer&#8221;. Here is one sample:</p>
<pre class="brush: as3; title: ; notranslate">
//
//  CircleScaleRenderer
//
//  Created by Eduard Prats Molner on 2010-06-06.
//  Copyright (c) 2010 Jocabola. All rights reserved.
//

package render{

	import render.BitmapRenderer;
	import flash.display.Sprite;

	import com.greensock.*;
	import com.greensock.easing.*;

	/**
 	* Class.
 	*
	* @langversion ActionScript 3.0
 	* @playerversion Flash 9.0
 	*
 	* @author Eduard Prats Molner
 	* @since  2010-06-06
 	*/
	public class CircleScaleRenderer extends BitmapRenderer{

		//--------------------------------------
		//  CONSTANTS &amp; VARIABLES
		//--------------------------------------

		private var __circle:Sprite;

		/**
	 	* @constructor
	 	*/
		public function CircleScaleRenderer(){
			super();

			__renderer.addChild(__circle = new Sprite());
			__circle.graphics.beginFill(0xFFFFFF);
			__circle.graphics.drawCircle(0, 0, 24);

			__circle.x = BitmapRenderer.BITMAP_WIDTH/2;
			__circle.y = BitmapRenderer.BITMAP_HEIGHT/2;
		}

		//--------------------------------------
		//  PUBLIC METHODS
		//--------------------------------------

		override public function begin():void{
			TweenLite.to(__circle, 1, {scaleX: 0.1, scaleY: 0.1, ease: Strong.easeIn, onUpdate: addBitmapData, onComplete: reverseAnimation});
		}

		///--------------------------------------
		//  PRIVATE &amp; PROTECTED INSTANCE METHODS
		//--------------------------------------

		private function reverseAnimation():void{
			TweenLite.to(__circle, 1, {scaleX: 1, scaleY: 1, ease: Strong.easeOut, onUpdate: addBitmapData, onComplete: dispatchBitmapEvent});
		}

	}

}
</pre>
<p>Notice that in this sample I am using <a href="http://www.greensock.com/tweenlite/">Greensock&#8217;s TweenLite engine</a>. Luckily, and thanks to <a href="http://www.mrdoob.com">Mr.Doob</a>, I have recently switched to <a href="http://code.google.com/p/eaze-tween/">eaze tween engine</a> for my Flash work.</p>
<p>I hope this would be helpful to someone. Feel free to drop a comment if you have any questions.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/DmcLimx7XE0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/lab/animatrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/lab/animatrix/</feedburner:origLink></item>
		<item>
		<title>London Crosswalk Countdowns</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/paBH9FCUWoU/</link>
		<comments>http://www.jocabola.com/archives/blog/london-crosswalk-countdowns/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 17:14:50 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=875</guid>
		<description><![CDATA[I recently realised that some London crosswalk lights were updated with a countdown (or at least never realised before). This is a neat feature, giving visual feedback to the annoying &#8220;long&#8221; waiting period with both, traffic lights and pedestrian lights, in red.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/09/london_crosswalk_countdown.jpg" alt="" title="London Crosswalk Countdown" width="600" height="400" class="alignnone size-full wp-image-879" /></p>
<p>I recently realised that some London crosswalk lights were updated with a countdown (or at least never realised before). This is a neat feature, giving visual feedback to the annoying &#8220;long&#8221; waiting period with both, traffic lights and pedestrian lights, in red.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/paBH9FCUWoU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/blog/london-crosswalk-countdowns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/blog/london-crosswalk-countdowns/</feedburner:origLink></item>
		<item>
		<title>Visual accidents – part II</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/deH_csE_0jg/</link>
		<comments>http://www.jocabola.com/archives/lab/visual-accidents-part-ii/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 09:01:28 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[openframworks]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=861</guid>
		<description><![CDATA[I love when the unexpected happens by the art of coding&#8230; the wrong thing I was playing yesterday with OpenFrameworks trying to propagate certain recorded animation pixels across the screen. Apparently, the pixel data was somehow corrupted which generated beautiful unexpected results. It looks quite similar to a broken graphic card&#8217;s driver or so. The [...]]]></description>
			<content:encoded><![CDATA[<p>I love when the unexpected happens by the art of coding&#8230; the wrong thing <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I was playing yesterday with <a href="http://www.openframeworks.cc">OpenFrameworks</a> trying to propagate certain recorded animation pixels across the screen.</p>

<a href='http://www.jocabola.com/archives/lab/visual-accidents-part-ii/attachment/wrong-pixels-01/' title='wrong-pixels-01'><img width="190" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/06/wrong-pixels-01-190x140.png" class="attachment-thumbnail" alt="wrong-pixels-01" title="wrong-pixels-01" /></a>
<a href='http://www.jocabola.com/archives/lab/visual-accidents-part-ii/attachment/wrong-pixels-02/' title='wrong-pixels-02'><img width="190" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/06/wrong-pixels-02-190x140.png" class="attachment-thumbnail" alt="wrong-pixels-02" title="wrong-pixels-02" /></a>
<a href='http://www.jocabola.com/archives/lab/visual-accidents-part-ii/attachment/wrong-pixels-03/' title='wrong-pixels-03'><img width="190" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/06/wrong-pixels-03-190x140.png" class="attachment-thumbnail" alt="wrong-pixels-03" title="wrong-pixels-03" /></a>

<p>Apparently, the pixel data was somehow corrupted which generated beautiful unexpected results. It looks quite similar to a broken graphic card&#8217;s driver or so. The graphics looked even cooler in motion <img src='http://www.jocabola.com/archives/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><b>Update:</b><br />
These accidents where due to a bug in current OF for iPhone: <a href="http://github.com/openframeworks/openFrameworks/issues/#issue/135">Here is a fix by Theo</a>.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/deH_csE_0jg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/lab/visual-accidents-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/lab/visual-accidents-part-ii/</feedburner:origLink></item>
		<item>
		<title>Cell Flot splash goes 2.0</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/lFIsrO0lKjk/</link>
		<comments>http://www.jocabola.com/archives/work/cell-flot-splash-2-0/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 11:15:05 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[audiovisual]]></category>
		<category><![CDATA[cellflot]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=848</guid>
		<description><![CDATA[The mini splash page of Cell Flot has been updated with a video showcase of current and upcoming work. We&#8217;ll be adding new videos until we launch a portfolio site.]]></description>
			<content:encoded><![CDATA[<p><a href="http://cellflot.com/minisplash-v2/"><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/06/01.jpg" alt="" title="01" width="600" height="451" class="alignnone size-full wp-image-849" /></a></p>
<p>The <a href="http://cellflot.com/minisplash-v2/">mini splash page of Cell Flot has been updated</a> with a video showcase of current and upcoming work. We&#8217;ll be adding new videos until we launch a portfolio site.</p>
<p><a href="http://cellflot.com/minisplash-v2/"><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/06/03.jpg" alt="" title="03" width="600" height="309" class="alignnone size-full wp-image-855" /></a></p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/lFIsrO0lKjk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/work/cell-flot-splash-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/work/cell-flot-splash-2-0/</feedburner:origLink></item>
		<item>
		<title>SKTCH iPhone App</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/Cw7wpQWRJdk/</link>
		<comments>http://www.jocabola.com/archives/lab/sktch-iphone-app/#comments</comments>
		<pubDate>Wed, 05 May 2010 15:29:36 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[of]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=818</guid>
		<description><![CDATA[Filip Visnjic from CAN, asked me if I wanted to create a preset for his SKTCH iPhone app. I happily accepted and wrote two simple drawing presets for the app. The application has a set of variables: colour (r, g, b), size, extent and opacity which can be randomized with a click. My first preset [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fvda.co.uk/">Filip Visnjic</a> from <a href="http://www.creativeapplications.net/">CAN</a>, asked me if I wanted to create a preset for his <a href="http://sktchapp.com/">SKTCH iPhone app</a>. I happily accepted and wrote two simple drawing presets for the app.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/05/sktch-basic.jpg" alt="" title="sktch-basic" width="600" height="445" class="alignnone size-full wp-image-820" /></p>
<p>The application has a set of variables: colour (r, g, b), size, extent and opacity which can be randomized with a click. My first preset is super basic, just using circles and mapping their resolution to one of the parameters, so circles eventually become hexagons, quads, triangles or even lines (2 segments).</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/05/sktch-firfly.jpg" alt="" title="sktch-firfly" width="600" height="445" class="alignnone size-full wp-image-821" /></p>
<p>The second preset is driven by short-living particles which are drawing their growth before dying.</p>
<p>Presets can be combined which, together with randomizing the settings, creates infinite output. The application features other presets by <a href="http://www.nanikawa.com/">Andreas Müller</a>, <a href="http://kimasendorf.com/">Kim Asendorf</a>, <a href="http://www.deffekt.ch/">Martin Fuchs</a>, <a href="http://www.undef.ch/">Philip Whitfield</a> and <a href="http://mike-tucker.com/">Mike Tucker</a>. For more information visit <a href="http://sktchapp.com/">http://sktchapp.com/</a></p>
<p>It was a fun experience and an open door to creative application development for the iPhone using <a href="http://www.openframeworks.cc">OpenFrameworks</a>.</p>
<p>You can <a href="itms://itunes.apple.com/us/app/sktch/id369434236?mt=8">buy the app here</a> and visit its <a href="http://www.flickr.com/groups/sktch/">Flickr group page</a>!</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/Cw7wpQWRJdk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/lab/sktch-iphone-app/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/lab/sktch-iphone-app/</feedburner:origLink></item>
		<item>
		<title>Siemens S7-1200</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/MvbGGXvfyPQ/</link>
		<comments>http://www.jocabola.com/archives/work/siemens-s7-1200/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 18:38:50 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[zinc]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=802</guid>
		<description><![CDATA[Siemens SIMATIC S7-1200 is a desktop application which I have developed in Action Script 3 and Zinc.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/018.jpg" alt="" title="01" width="600" height="366" class="alignnone size-full wp-image-803" /></p>
<p>Siemens SIMATIC S7-1200 is a desktop application which I have developed in Action Script 3 and <a href="http://www.multidmedia.com/">Zinc</a>.</p>
<p><img src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/027.jpg" alt="" title="02" width="600" height="366" class="alignnone size-full wp-image-804" /></p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/MvbGGXvfyPQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/work/siemens-s7-1200/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/work/siemens-s7-1200/</feedburner:origLink></item>
		<item>
		<title>The drawing particle</title>
		<link>http://feedproxy.google.com/~r/jocabola/~3/LBtMW_tFof8/</link>
		<comments>http://www.jocabola.com/archives/lab/the-drawing-particle/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 10:59:23 +0000</pubDate>
		<dc:creator>jocabola</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[experimentation]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://www.jocabola.com/archives/?p=722</guid>
		<description><![CDATA[Back in 2005, I had the chance to assist to a Jared Tarbell conference during OFFF 2005. Jared shared a little source code of a particle which he called the &#8220;firefly&#8221;. The code of a basic particle class in Processing would be basically something like this: I started to experiment a little bit while learning [...]]]></description>
			<content:encoded><![CDATA[<p>Back in 2005, I had the chance to assist to a <a href="http://www.levitated.net">Jared Tarbell</a> conference during <a href="http://www.shift.jp.org/en/archives/2005/06/offf_festival_2005.html">OFFF 2005</a>.</p>
<p>Jared shared a little source code of a particle which he called the &#8220;firefly&#8221;. The code of a basic particle class in <a href="http://www.processing.org">Processing</a> would be basically something like this:</p>
<pre class="brush: java; title: ; notranslate">
// Particle class
class Particle{
  float x;
  float y;
  float vx;
  float vy;

  Particle(float _x, float _y, float _vx, float _vy){
    x = _x;
    y = _y;
    vx = _vx;
    vy = _vy;
  }

  void update(){
    x = x + vx;
    y = y + vy;

    // change direction
    vx += random(-1,1);
    vy += random(-1,1);

    //apply friction
    vx *= 0.9;
    vy *= 0.9;
  }
}
</pre>
<p>I started to experiment a little bit while learning Processing syntax, the main idea was to use the particles to actually draw their routes instead of rendering them as moving objects.</p>

<a href='http://www.jocabola.com/archives/lab/the-drawing-particle/attachment/01-4/' title='01'><img width="140" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/012-140x140.jpg" class="attachment-thumbnail" alt="01" title="01" /></a>
<a href='http://www.jocabola.com/archives/lab/the-drawing-particle/attachment/02-4/' title='02'><img width="140" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/022-140x140.jpg" class="attachment-thumbnail" alt="02" title="02" /></a>
<a href='http://www.jocabola.com/archives/lab/the-drawing-particle/attachment/03-4/' title='03'><img width="140" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/032-140x140.jpg" class="attachment-thumbnail" alt="03" title="03" /></a>
<a href='http://www.jocabola.com/archives/lab/the-drawing-particle/attachment/04-4/' title='04'><img width="140" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/042-140x140.jpg" class="attachment-thumbnail" alt="04" title="04" /></a>
<a href='http://www.jocabola.com/archives/lab/the-drawing-particle/attachment/05-2/' title='05'><img width="140" height="140" src="http://www.jocabola.com/archives/wp-content/uploads/2010/04/051-140x140.jpg" class="attachment-thumbnail" alt="05" title="05" /></a>

<p>The different results where obtained by applying different basic rules in the system.</p>
<img src="http://feeds.feedburner.com/~r/jocabola/~4/LBtMW_tFof8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jocabola.com/archives/lab/the-drawing-particle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.jocabola.com/archives/lab/the-drawing-particle/</feedburner:origLink></item>
	</channel>
</rss>

