<?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>Mental Notes &#187; Programming</title>
	<atom:link href="http://stephan.acidcats.nl/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://stephan.acidcats.nl/blog</link>
	<description>from the trenches of software development</description>
	<lastBuildDate>Sun, 01 Mar 2009 19:44:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Yalog (Actionscript 3 log utility with viewer) open source</title>
		<link>http://stephan.acidcats.nl/blog/2009/02/04/yalog-actionscript-3-log-utility-with-viewer-open-source/</link>
		<comments>http://stephan.acidcats.nl/blog/2009/02/04/yalog-actionscript-3-log-utility-with-viewer-open-source/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 12:05:27 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Yalog]]></category>

		<guid isPermaLink="false">http://stephan.acidcats.nl/blog/?p=27</guid>
		<description><![CDATA[A few years ago I developed a logging class plus viewer application for debugging purposes. Main requirement was lightweightedness: the logging code should put as little pressure on the CPU as possible, and so should the viewer. At LBi Lost Boys, the company I&#8217;m working for, we&#8217;ve been using this utility over the last years, [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago I developed a logging class plus viewer application for debugging purposes. Main requirement was lightweightedness: the logging code should put as little pressure on the CPU as possible, and so should the viewer. At LBi Lost Boys, the company I&#8217;m working for, we&#8217;ve been using this utility over the last years, and it&#8217;s become an indispensible component of our work flow.<br />
Last week I put out the source, both of the log utility and of the viewer, into open source space. Check <a title="Yalog on Google Code" href="http://code.google.com/p/yalog/" target="_self">the main page on Google Code </a>for source code and downloads. </p>
<p> </p>
<div id="attachment_28" class="wp-caption alignleft" style="width: 138px"><img class="size-full wp-image-28" title="Yala - Yalog viewer" src="http://stephan.acidcats.nl/blog/wp-content/yala128.png" alt="Icon of Yala, the Yalog viewer AIR application" width="128" height="128" /><p class="wp-caption-text"> </p></div>
<p> Yalog consists of the logging utility, comprising one main class (Yalog.as) and a few helper classes, and a viewer. This viewer is basically a swf, so can be used in any context where a swf can be used. Currently it&#8217;s <a title="Yalog viewer application installer" href="http://yalog.googlecode.com/files/Yala_installer_301.air" target="_blank">available for download</a> as an AIR-application. If you just want to use this and not be bothered with the source of the viewer, <a title="Yalog sources" href="http://yalog.googlecode.com/files/Yalog_src_301.zip" target="_blank">download</a> the Yalog source classes, and install the AIR application. </p>
<p> </p>
<p>The viewer can be seen in action at <a title="Yala viewer in HTML" href="http://yala.acidcats.nl/" target="_blank">http://yala.acidcats.nl/</a>. If you open a Yalog-enabled site (such as <a title="DE.nl" href="http://www.de.nl" target="_blank">www.de.nl</a>), you will see debug messages appear in the viewer. A nifty feature of Yalog is that it buffers the last 200 messages (number can be changed) until the viewer appears, so you can open the viewer after something has gone wrong, and still view the latest messages.</p>
<p>When I have more time, I&#8217;ll put up a page here with more info and details.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephan.acidcats.nl/blog/2009/02/04/yalog-actionscript-3-log-utility-with-viewer-open-source/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Spectral analysis with Fast Fourier Transform in Actionscript</title>
		<link>http://stephan.acidcats.nl/blog/2008/12/04/spectral-analysis-with-fast-fourier-transform-in-actionscript/</link>
		<comments>http://stephan.acidcats.nl/blog/2008/12/04/spectral-analysis-with-fast-fourier-transform-in-actionscript/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 13:01:34 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[FFT]]></category>
		<category><![CDATA[spectral analysis]]></category>

		<guid isPermaLink="false">http://stephan.acidcats.nl/blog/?p=23</guid>
		<description><![CDATA[The presentation by Adobe&#8217;s Jim Corbett on Alchemy at the Adobe MAX 2008 conference in Milan last Tuesday (2nd of December), got me thinking about something I used to spend quite some time on back in the early 90&#8217;s, when I studied Sonology at the Kon. Conservatorium in Den Haag: spectral analysis &#38; (re)synthesis of sound. [...]]]></description>
			<content:encoded><![CDATA[<p>The presentation by Adobe&#8217;s Jim Corbett on <a title="Alchemy C/C++ to Actionscript" href="http://labs.adobe.com/technologies/alchemy/" target="_blank">Alchemy</a> at the Adobe MAX 2008 conference in Milan last Tuesday (2nd of December), got me thinking about something I used to spend quite some time on back in the early 90&#8217;s, when I studied Sonology at the Kon. Conservatorium in Den Haag: spectral analysis &amp; (re)synthesis of sound. This is usually done by means of the <a title="Fourier Transform on Wikipedia" href="http://en.wikipedia.org/wiki/Fourier_transform" target="_blank">Fourier Transform</a>, which transforms time-based data such as sound to the frequency domain. The most used algorithm for this is the Fast Fourier Transform, or FFT, which requires the number of samples per transformation to be a power of 2. Usually a block of 1024 samples is used, which equals roughly 50ms of sound at 44.1kHz.</p>
<p>Now the FFT algorithm is quite CPU-intensive, and as Alchemy is put forward as useful for large number-crunching operations, I thought this could be a very interesting case. In order to allow for proper comparison, I decided to first port the FFT code from C to Actionscript, and do some testing. It took some refactoring of the C-code in Actionscript to allow for specific bottlenecks popping up, such as multiple lookup of the same value from a Vector, which turns out to be an expensive operation. Also the calculation of sine &amp; cosine was done beforehand, to allow for a lookup table to be used in the actual FFT algorithm. All in all I managed to gain some 50% speed increase by these optimizations.</p>
<p>To my surprise, a single transformation of one block of 1024 samples takes only 5 ms in Actionscript. Even when performing the necessary after-calculations (normalizing &amp; getting the lenght of vectors, which requires Math.sqrt), a back-and-forth transformation shouldn&#8217;t take more than 10 ms, leaving 40ms for doing fun stuff with the data. So even without a C-port it&#8217;s possible to do real time audio transformation in the frequency domain.</p>
<p>The first thing to do is plot the data in an image. Right now I&#8217;m only posting a screenshot, as I&#8217;d like to polish the example a bit more before putting out the actual code, but this is what a frequency plot of a short piece of music looks like:</p>
<p><a href="http://stephan.acidcats.nl/blog/wp-content/picture-1.jpg" rel="lightbox"><img class="alignnone size-medium wp-image-24" title="Spectral analysis" src="http://stephan.acidcats.nl/blog/wp-content/picture-1-300x154.jpg" alt="" width="300" height="154" /></a></p>
<p>More about this (including source code) soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://stephan.acidcats.nl/blog/2008/12/04/spectral-analysis-with-fast-fourier-transform-in-actionscript/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Flocking</title>
		<link>http://stephan.acidcats.nl/blog/2007/12/26/19/</link>
		<comments>http://stephan.acidcats.nl/blog/2007/12/26/19/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 22:28:32 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[experiments]]></category>

		<guid isPermaLink="false">http://stephan.acidcats.nl/blog/2007/12/26/19/</guid>
		<description><![CDATA[I&#8217;m experimenting a bit with flocking. Haven&#8217;t gotten as far a moving stuff in any interesting way yet, but it&#8217;s fun enough to fool around with maths I haven&#8217;t looked at for decades. In the sample below you can see how the vectors of attraction pull the birds (yeah right!) to the common center, while [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m experimenting a bit with <a href="http://en.wikipedia.org/wiki/Flocking_(behavior)" title="Flocking on WikiPedia" target="_blank">flocking</a>. Haven&#8217;t gotten as far a moving stuff in any interesting way yet, but it&#8217;s fun enough to fool around with maths I haven&#8217;t looked at for decades. In the sample below you can see how the vectors of attraction pull the birds (yeah right!) to the common center, while birdies that are close to each other get nasty long green repulsion vectors.</p>
<p>Click to make them start moving to the center, click again to stop the motion. Makes for a nice hedgehog at some point <img src='http://stephan.acidcats.nl/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>The source code is <a href="http://stephan.acidcats.nl/blog/wp-content/flocking_source.zip" title="Source code for flocking experiment">here</a>. No fla file, code only.</p>
<p>And thanks to <a href="http://www.bonth.nl/" target="_blank" title="Arie de Bonth">Arie</a> for his <a href="http://www.bonth.nl/eerste-pagina/" target="_blank" title="Post on Kimili">tip</a> about the <a href="http://kimili.com/plugins/kimili-flash-embed-for-wordpress" title="Kimili Flash plugin for WordPress" target="_blank">Kimili Wordpress Flash plugin</a></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_flocking_1414567554"
			class="flashmovie"
			width="440"
			height="440">
	<param name="movie" value="http://stephan.acidcats.nl/blog/wp-content/flocking.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://stephan.acidcats.nl/blog/wp-content/flocking.swf"
			name="fm_flocking_1414567554"
			width="440"
			height="440">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://stephan.acidcats.nl/blog/2007/12/26/19/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ADDED_TO_STAGE</title>
		<link>http://stephan.acidcats.nl/blog/2007/12/25/added_to_stage/</link>
		<comments>http://stephan.acidcats.nl/blog/2007/12/25/added_to_stage/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 22:42:00 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://stephan.acidcats.nl/blog/2007/12/25/added_to_stage/</guid>
		<description><![CDATA[One of those things&#8230; The event ADDED_TO_STAGE, dispatched by any DisplayObject when it gets added to the stage (duh) as opposed to added to a parent, wasn&#8217;t available in Flash player 9 before 9.0.28. That basically means we can&#8217;t really trust it will be available until statistics prove that any and all minor releases prior [...]]]></description>
			<content:encoded><![CDATA[<p>One of those things&#8230; The event ADDED_TO_STAGE, dispatched by any DisplayObject when it gets added to the stage (duh) as opposed to added to a parent, wasn&#8217;t available in Flash player 9 before 9.0.28. That basically means we can&#8217;t really trust it will be available until statistics prove that any and all minor releases prior to that one have disappeared from the face of the earth. So instead of that, we have to use Moock&#8217;s solution (but that&#8217;s a hell of a lot of work to be notified of just one little event), or check the event&#8217;s phase (also thanks to Moock): 
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">private</span> <span class="kw3">function</span> handleAdded <span class="br0">&#40;</span>e : <a href="http://www.google.com/search?q=Event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:Event.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">Event</span></a><span class="br0">&#41;</span> : <span class="kw1">void</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>e.<span class="kw7">eventPhase</span> != <a href="http://www.google.com/search?q=EventPhase%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:EventPhase.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">EventPhase</span></a>.<span class="kw8">AT_TARGET</span><span class="br0">&#41;</span> <span class="kw1">return</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// do something useful</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://stephan.acidcats.nl/blog/2007/12/25/added_to_stage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FDT &amp; automatic class name generation in Flash CS3</title>
		<link>http://stephan.acidcats.nl/blog/2007/11/25/fdt-automatic-class-name-generation-in-flash-cs3/</link>
		<comments>http://stephan.acidcats.nl/blog/2007/11/25/fdt-automatic-class-name-generation-in-flash-cs3/#comments</comments>
		<pubDate>Sun, 25 Nov 2007 20:48:08 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://stephan.acidcats.nl/blog/2007/11/25/fdt-automatic-class-name-generation-in-flash-cs3/</guid>
		<description><![CDATA[The function flash.utils.getDefinitionByName has been discussed in various other places (amongst others here and of course in the documentation), but it took a bit of a mental jump to use it as the solution for the problem that linked library instances without a class are not known inside FDT.Suppose we have a library item with a [...]]]></description>
			<content:encoded><![CDATA[<p>The function <code>flash.utils.getDefinitionByName</code> has been discussed in various other places (amongst others <a href="http://www.mikechambers.com/blog/2006/06/22/actionscript-3-get-a-class-reference-by-class-name/">here</a> and of course <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName()">in the documentation</a>), but it took a bit of a mental jump to use it as the solution for the problem that linked library instances without a class are not known inside FDT.Suppose we have a library item with a linkage id of &#8220;square&#8221;, and we decide not to attach a class to it. Flash CS3 reminds us that it will create one for us, and if we code inside the Flash IDE, we can happily write: <code>var s:Sprite = new square(); addChild(s);</code>However, FDT will show an error, because it doesn&#8217;t have a clue what you&#8217;re talking about. To solve this, use <code>getDefinitionByName("square")</code>, as shown in the following example:
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">package</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">import</span> <span class="kw6">flash.display</span>.<a href="http://www.google.com/search?q=MovieClip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:MovieClip.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">MovieClip</span></a>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">import</span> <span class="kw6">flash.display</span>.<a href="http://www.google.com/search?q=Sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:Sprite.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">Sprite</span></a>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">import</span> <span class="kw6">flash.utils</span>.<span class="kw7">getDefinitionByName</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">class</span> Application extends <a href="http://www.google.com/search?q=MovieClip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:MovieClip.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">MovieClip</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">private</span> static const LINKAGE_SQUARE:<a href="http://www.google.com/search?q=String%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:String.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">String</span></a> = <span class="st0">&quot;square&quot;</span>; </div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw3">function</span> Application <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; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> s:<a href="http://www.google.com/search?q=Sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:Sprite.html&#038;filter=0&#038;num=100&#038;btnI=lucky"><span class="kw5">Sprite</span></a> = <span class="kw1">new</span> <span class="br0">&#40;</span><span class="kw7">getDefinitionByName</span><span class="br0">&#40;</span>LINKAGE_SQUARE<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw7">addChild</span><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &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">&nbsp;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://stephan.acidcats.nl/blog/2007/11/25/fdt-automatic-class-name-generation-in-flash-cs3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

