<?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>Talk Unafraid &#187; Processing</title>
	<atom:link href="http://www.talkunafraid.co.uk/category/code-snippets-and-examples/processing-code-snippets-and-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.talkunafraid.co.uk</link>
	<description>The (occasionally coherent) ramblings of a geek</description>
	<lastBuildDate>Sat, 07 Jan 2012 22:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ProscDMX &#8211; A DMX Multiplexing OpenSoundControl Server</title>
		<link>http://www.talkunafraid.co.uk/2009/01/proscdmx-a-dmx-multiplexing-opensoundcontrol-server/</link>
		<comments>http://www.talkunafraid.co.uk/2009/01/proscdmx-a-dmx-multiplexing-opensoundcontrol-server/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 22:39:29 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Awesome Stuff]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[dmx]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osc]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[theatre]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=190</guid>
		<description><![CDATA[It&#8217;s a little bit of a mouthful, isn&#8217;t it? I&#8217;ve been working on this for the last few days. It basically takes Open Sound Control (OSC) packets- from any number of clients- which specify a DMX address, value and fadetime. The server is written in Processing, and uses the oscP5 library. Right now it uses [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a little bit of a mouthful, isn&#8217;t it?</p>
<p>I&#8217;ve been working on this for the last few days. It basically takes <a href="http://opensoundcontrol.org/">Open Sound Control</a> (OSC) packets- from any number of clients- which specify a DMX address, value and fadetime. The server is written in Processing, and uses the <a href="http://www.sojamo.de/libraries/oscP5/">oscP5</a> library. Right now it uses the <a href="http://www.enttec.com/index.php?main_menu=Products&amp;prod=70304&amp;show=description">ENTTEC USB DMX Pro</a> adapter to talk to DMX via serial comms, plus an excellent DMX class published on the Processing forums.</p>
<p>Why would you want this? Well, it means you can use anything that supports OSC to control your lighting and theatrical effects. Beat-syncing music is a piece of cake, controlling from an iPhone/iPod Touch likewise (Just write a little webapp and you&#8217;re good- or use a tool like TouchOSC). It&#8217;s stable (I threw strobe commands at all 512 channels for 12 hours and it was still running just fine afterwards), works a treat, and is perfect if you&#8217;re writing an OSC app and want a quick and easy way to hook into DMX controls.</p>
<p>The only documentation is this: It expects a message to /set with typetag iif, in the format address (1-&lt;unisize&gt;, default 128), value (0-255), and fadetime (0.0-n, where n is a large float). Other than that, run and enjoy. I&#8217;ll be throwing the odd update to this up but I expect the API to remain the same. I&#8217;m using this for a project where we want to do some interesting things with a large number of LED parcans very quickly, so performance is fairly vital- it&#8217;s designed to be quick, but I&#8217;m not Java genius, so suggestions are welcome.</p>
<p>Using the <a href="http://github.com/fugalh/rosc/">Ruby OSC library</a>, you can whip up a simple client in seconds:</p>
<div class="geshi no ruby">
<div class="head">require &#39;osc&#39;</div>
<ol>
<li class="li1">
<div class="de1">c = <span class="re2">OSC::UDPSocket</span>.<span class="me1">new</span></div>
</li>
<li class="li1">
<div class="de1">m = <span class="re2">OSC::Message</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">&#39;/set&#39;</span>, <span class="st0">&#39;iif&#39;</span>, <span class="nu0">1</span>,<span class="nu0">255</span>,<span class="nu0">0.0</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">c.<span class="me1">send</span> m, <span class="nu0">0</span>, <span class="st0">&#39;localhost&#39;</span>, <span class="nu0">9000</span></div>
</li>
</ol>
</div>
<p>This sets channel 1 to snap on. Easy, eh? I&#8217;ve not tested this with bundles but it should work fine.</p>
<p>You can grab the source (Processing required to run) <a href="http://github.com/JamesHarrison/proscdmxserver/tree/master">over here on Github</a>.</p>
<p>I&#8217;m under a bit of time pressure at the moment but might end up writing this again in openFrameworks. It&#8217;s C++, so much faster, and should be more flexible in terms of sheer speed. Sub-second strobes and so on should be attainable. My next hardware project? Bodged strobe controller for Arduino&#8230;. <img src='http://www.talkunafraid.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2009/01/proscdmx-a-dmx-multiplexing-opensoundcontrol-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Processing, Mediawiki, and force-directed layouts</title>
		<link>http://www.talkunafraid.co.uk/2008/12/processing-mediawiki-and-force-directed-layouts/</link>
		<comments>http://www.talkunafraid.co.uk/2008/12/processing-mediawiki-and-force-directed-layouts/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 13:36:47 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Awesome Stuff]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[EVE]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[work in progress]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=116</guid>
		<description><![CDATA[Happily, the EVE Online official wiki- the Evelopedia- has now gone into public beta. You can imagine, then, that there&#8217;s a lot of activity on it. I&#8217;m something of a Mediawiki fan; I&#8217;m currently using a very hacked-upon version on my laptop for notetaking and information storage, and used to contribute quite a bit to [...]]]></description>
			<content:encoded><![CDATA[<p>Happily, the EVE Online official wiki- the <a href="http://wiki.eve-online.com/">Evelopedia</a>- has now gone into public beta. You can imagine, then, that there&#8217;s a lot of activity on it. I&#8217;m something of a Mediawiki fan; I&#8217;m currently using a very hacked-upon version on my laptop for notetaking and information storage, and used to contribute quite a bit to Wikinews/Wikipedia. So when the Evelopedia went live I was at it like a shot.</p>
<p>The recent changes pages of Mediawiki list the most recent changes to the wiki, providing information on the page edited, the edit made, the date of the edit, and the user making the edits. It&#8217;s simple enough to read through, but behind the monotonous list there&#8217;s a much more interesting picture to be found.</p>
<div id="attachment_117" class="wp-caption aligncenter" style="width: 610px"><a href="http://assets.talkunafraid.co.uk/2008/12/evelopedia_for_blog.png" rel="lightbox[116]"><img class="size-full wp-image-117" title="Evelopedia Recent Changes" src="http://assets.talkunafraid.co.uk/2008/12/evelopedia_for_blog.png" alt="The final(ish) recent changes app, having been running for a night." width="600" height="375" /></a><p class="wp-caption-text">The final(ish) recent changes app, having been running for a night. </p></div>
<p>This is my first real finished product done with <a href="http://www.processing.org/">Processing</a>. It grabs the RSS feed of changes, imports each change by adding a change node, an author node, and a page node. If the author or page already exists, it links them again via the newly added change and adds weight to the author and page nodes. It then queries the RSS feed every minute to grab fresh data, and imports any new changes.<br />
<a href="http://assets.talkunafraid.co.uk/2008/12/rightnow1.png" rel="lightbox[116]"><img class="alignleft size-thumbnail wp-image-128" title="What was going on last night? This!" src="http://assets.talkunafraid.co.uk/2008/12/rightnow1-150x150.png" alt="What was going on last night? This!" width="150" height="150" /></a><br />
The layout of the graphs is performed automatically using a force-directed layout. I used a simple physics library for Processing (<a href="http://www.cs.princeton.edu/~traer/physics/">traer.physics</a>), and added the physics framework to my existing Node framework originally designed for the EVE Tactical Map. Every particle has repulsion to every other particle, except for particles they are linked to- they have an attraction and a spring whose length is defined by the number of links of the parent particle.</p>
<p><a href="http://assets.talkunafraid.co.uk/2008/12/elp_rc_win.png" rel="lightbox[116]"><img class="alignright size-thumbnail wp-image-114" title="Evelopedia Recent Changes - Early Version" src="http://assets.talkunafraid.co.uk/2008/12/elp_rc_win-150x150.png" alt="Evelopedia Recent Changes - Early Version" width="150" height="150" /></a><br />
Depending on what the simulation damping setting is, it can take from 10 seconds to 5 minutes for the simulation to become stable and settle down- it&#8217;s all done in realtime, with new changes randomly appearing and being pulled towards their appropriate author/page articles.</p>
<p><object width="600" height="450" data="http://vimeo.com/moogaloop.swf?clip_id=2525125&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2525125&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /></object><br />
<a href="http://vimeo.com/2525125">Evelopedia Recent Change Monitor &#8211; Trailer</a> from <a href="http://vimeo.com/user549470">James Harrison</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Once I get the source in shape (It&#8217;s a single 310-line .pde file right now with few comments and no error handling) I&#8217;ll probably open this up for all who want to have a play with it. I&#8217;d be interested to see what a force-directed layout method would make of the EVE map, so I might end up backporting my code to the Tactical Map to see what happens.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2008/12/processing-mediawiki-and-force-directed-layouts/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Draggable Objects in Processing</title>
		<link>http://www.talkunafraid.co.uk/2008/11/draggable-objects-in-processing/</link>
		<comments>http://www.talkunafraid.co.uk/2008/11/draggable-objects-in-processing/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 21:58:22 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Code Snippets and Examples]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=72</guid>
		<description><![CDATA[I&#8217;ve been playing around in Processing to create a synth which is controlled by linking nodes together. These nodes are basically circles, with information displayed within them. One thing I ran into right away which, in my opinion, should be a Processing core class is a lack of a Draggable class. With the help of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around in Processing to create a synth which is controlled by linking nodes together. These nodes are basically circles, with information displayed within them.</p>
<p>One thing I ran into right away which, in my opinion, should be a Processing core class is a lack of a Draggable class. With the help of some googling, I eventually cooked up my own, which performs quickly no matter the framerate.</p>
<p><span id="more-72"></span></p>
<p>This code makes use of Vectors, so it should be a very quick bit of code. I&#8217;ve had no problems using it.</p>
<div class="geshi no java">
<div class="head">Vector nodes;</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw4">boolean</span> drag_locked<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; size<span class="br0">&#40;</span><span class="nu0">700</span>, <span class="nu0">500</span>, P2D<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; smooth<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; nodes = <span class="kw2">new</span> <span class="kw3">Vector</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; drag_locked = <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; nodes.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw2">new</span> Node<span class="br0">&#40;</span><span class="nu0">20</span>, <span class="nu0">20</span>,<span class="nu0">20</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; nodes.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw2">new</span> Node<span class="br0">&#40;</span><span class="nu0">50</span>, <span class="nu0">50</span>,<span class="nu0">20</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; frameRate<span class="br0">&#40;</span><span class="nu0">30</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">void</span> draw<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; smooth<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; background<span class="br0">&#40;</span><span class="nu0">20</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> i=<span class="nu0">0</span><span class="sy0">;</span>i<span class="sy0">&lt;</span>nodes .<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>i++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Node temp = <span class="br0">&#40;</span>Node<span class="br0">&#41;</span>nodes.<span class="me1">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; temp.<span class="me1">draw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Node</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw4">float</span> x,y,mo_x,mo_y<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw4">int</span> radius<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw4">boolean</span> locked<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Node<span class="br0">&#40;</span><span class="kw4">float</span> x, <span class="kw4">float</span> y, <span class="kw4">int</span> radius<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">x</span> = x<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">y</span> = y<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">radius</span> = radius<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw4">void</span> draw<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; fill<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">255</span>,<span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; ellipse<span class="br0">&#40;</span>x, y, radius<span class="sy0">*</span><span class="nu0">2</span>, radius<span class="sy0">*</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>over<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> keyPressed<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; nodes.<span class="me1">remove</span><span class="br0">&#40;</span>nodes.<span class="me1">indexOf</span><span class="br0">&#40;</span><span class="kw2">this</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>mousePressed <span class="sy0">&amp;&amp;</span> over<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span>drag_locked<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; mo_x = x-mouseX<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; mo_y = y-mouseY<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; locked = <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; drag_locked = <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>mousePressed<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; locked = <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; drag_locked = <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>locked<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; x = mouseX+mo_x<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; y = mouseY+mo_y<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw4">boolean</span> over<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>dist<span class="br0">&#40;</span>x, y, mouseX, mouseY<span class="br0">&#41;</span> <span class="sy0">&lt;</span> radius<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">return</span> <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">return</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>This will set up two nodes on your screen which are draggable, complete with offsetting and so on to make them behave perfectly. Hope this helps!</nodes></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2008/11/draggable-objects-in-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

