<?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>frey - art with machines &#187; code</title>
	<atom:link href="http://frey.co.nz/old/categories/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://frey.co.nz/old</link>
	<description>art with machines</description>
	<lastBuildDate>Sat, 24 Oct 2009 17:34:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Drawing into a CGContextRef created using CGBitmapContextCreate</title>
		<link>http://frey.co.nz/old/2008/11/cgbitmapcontextcreat/</link>
		<comments>http://frey.co.nz/old/2008/11/cgbitmapcontextcreat/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 19:23:14 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/?p=351</guid>
		<description><![CDATA[So, if you happen to be doing what the subject line says &#8211; drawing anything into a CGContextRef that was created using CGBitmapContextCreate &#8211; and you&#8217;re seeing nothing but black, the trick is the following: you have to memset the the pixel data to all 0xFF&#8217;s before you draw.
For example, to draw a PDF document [...]]]></description>
			<content:encoded><![CDATA[<p>So, if you happen to be doing what the subject line says &#8211; drawing anything into a CGContextRef that was created using CGBitmapContextCreate &#8211; and you&#8217;re seeing nothing but black, the trick is the following: you have to memset the the pixel data to all 0xFF&#8217;s before you draw.</p>
<p>For example, to draw a PDF document reference by &#8216;document&#8217;:</p>
<p>// allocate pixels<br />
unsigned char* pixels = new unsigned char[thumb_height*thumb_width*4];</p>
<p>// create context<br />
CGContextRef context = CGBitmapContextCreate(pixels, thumb_width, thumb_height, 8, 4*thumb_width, CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ), kCGImageAlphaNoneSkipLast );</p>
<p>// clear<br />
memset( pixels, 255, thumb_width*thumb_height*4 );</p>
<p>// render page 1 into the pixels array<br />
CGPDFPageRef page = CGPDFDocumentGetPage( document, 1 );<br />
CGContextDrawPDFPage( context, page );</p>
<p>(For some reason I just wasn&#8217;t able to create any kind of RGBA context with CGBitmapContextCreate() &#8211; I always had to use the skip-alpha enum. Weird.)</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/11/cgbitmapcontextcreat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gnuplot from stdin</title>
		<link>http://frey.co.nz/old/2008/08/clever/</link>
		<comments>http://frey.co.nz/old/2008/08/clever/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 21:56:30 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/08/09/clever/</guid>
		<description><![CDATA[Since I couldn&#8217;t find this in an easy-to-use format anywhere else, here&#8217;s how you use gnuplot to plot a list of numbers sent in with stdin:
(echo plot \"-\" with lines; cat numbers.txt) &#124; gnuplot
numbers.txt is a list of numbers, with or without terminating semicolons. Scientific notation is ok.
(30 minutes later) &#8230; and, here&#8217;s how to [...]]]></description>
			<content:encoded><![CDATA[<p>Since I couldn&#8217;t find this in an easy-to-use format anywhere else, here&#8217;s how you use gnuplot to plot a list of numbers sent in with stdin:</p>
<p><code>(echo plot \"-\" with lines; cat numbers.txt) | gnuplot</code></p>
<p>numbers.txt is a list of numbers, with or without terminating semicolons. Scientific notation is ok.</p>
<p>(30 minutes later) &#8230; and, here&#8217;s how to write a pdf graph of each text file in the current directory:</p>
<p><code>ls *.txt | perl -e 'while(&lt;stdin&gt;) { chomp; system "(echo set term pdf; echo set yrange [-1:1]; echo plot \\\"-\\\" with lines; cat $_ ) | gnuplot > $_.pdf"; }</code></p>
<p>(and so I don&#8217;t lose it, here&#8217;s how to generate a whole bunch of testunits:</p>
<p><code>perl -e 'for ( $i=1; $i&lt;60; $i+=5 ) { for ( $j=$i+1; $j&lt;150; $j*=1.5 ) { print "#X obj ".($i*40)." ".(int($j))." testunit $i-".(int($j))." $i ".(int($j))." senergy;\n"; } } ' > 1.actions/testunits.pd.txt</code></p>
<p>)</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/08/clever/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ofxOsc</title>
		<link>http://frey.co.nz/old/2008/08/ofxosc/</link>
		<comments>http://frey.co.nz/old/2008/08/ofxosc/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 14:14:32 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/08/07/ofxosc/</guid>
		<description><![CDATA[I&#8217;ve updated ofxOsc to v0.2 &#8211; now with OSC Bundle support. Check it out here.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated ofxOsc to v0.2 &#8211; now with OSC Bundle support. Check it out <a href='/projects/ofxosc/'>here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/08/ofxosc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save file dialog code &#8211; OSX/Carbon</title>
		<link>http://frey.co.nz/old/2008/05/save-file-dialog-code-osxcarbon/</link>
		<comments>http://frey.co.nz/old/2008/05/save-file-dialog-code-osxcarbon/#comments</comments>
		<pubDate>Fri, 02 May 2008 22:25:53 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/05/02/save-file-dialog-code-osxcarbon/</guid>
		<description><![CDATA[Why is this so hard?

	short fRefNumOut;
	FSRef output_file;

	NavDialogCreationOptions options;
	NavGetDefaultDialogCreationOptions( &#038;options );
	options.modality = kWindowModalityAppModal;

	NavDialogRef dialog;
	err = NavCreatePutFileDialog ( &#038;options, "Midi", 'MIDI', NULL, NULL, &#038;dialog);
	printf("NavCreatePutFileDialog returned %i\n", err );

	err = NavDialogRun( dialog );
	printf("NavDialogRun returned %i\n", err );

	NavUserAction action;
	action = NavDialogGetUserAction( dialog );
	printf("got action %i\n");
	if (action == kNavUserActionNone &#124;&#124; action == kNavUserActionCancel) {
		return 2;
	}

	// get dialog reply
	NavReplyRecord reply;
	err = [...]]]></description>
			<content:encoded><![CDATA[<p>Why is this so hard?</p>
<pre>
	short fRefNumOut;
	FSRef output_file;

	NavDialogCreationOptions options;
	NavGetDefaultDialogCreationOptions( &#038;options );
	options.modality = kWindowModalityAppModal;

	NavDialogRef dialog;
	err = NavCreatePutFileDialog ( &#038;options, "Midi", 'MIDI', NULL, NULL, &#038;dialog);
	printf("NavCreatePutFileDialog returned %i\n", err );

	err = NavDialogRun( dialog );
	printf("NavDialogRun returned %i\n", err );

	NavUserAction action;
	action = NavDialogGetUserAction( dialog );
	printf("got action %i\n");
	if (action == kNavUserActionNone || action == kNavUserActionCancel) {
		return 2;
	}

	// get dialog reply
	NavReplyRecord reply;
	err = NavDialogGetReply(dialog, &#038;reply);
	if ( err != noErr )
		return 2;

	if ( reply.replacing )
	{
		printf("need to replace\n");
	}

	AEKeyword keyword;
	DescType actual_type;
	Size actual_size;
	FSRef output_dir;
	err = AEGetNthPtr(&#038;(reply.selection), 1, typeFSRef, &#038;keyword, &#038;actual_type,
						  &#038;output_dir, sizeof(output_file), &#038;actual_size);

	printf("AEGetNthPtr returned %i\n", err );

	UInt8 output_dir_name[1024];
	FSRefMakePath(&#038;output_dir, output_dir_name, 1024 );
	printf("got %s\n", output_dir_name );

	// now get filename
	CFIndex len = CFStringGetLength(reply.saveFileName);
	if (len > 255)
		len = 255;
	UniChar output_filename[255];
	CFStringGetCharacters(reply.saveFileName, CFRangeMake(0, len), output_filename);

	// need to unlink the old file
	if ( reply.replacing )
	{
		FSRef oldfile;

		err = FSMakeFSRefUnicode(&#038;output_dir, len, output_filename,
								kTextEncodingUnicodeDefault,
								&#038;oldfile);
		if (err == noErr)
			err = FSDeleteObject(&#038;oldfile);
		if (err != noErr)
		{
			printf( "error %d erasing old file\n", err );
			return 2;
		}
	}

	err = FSCreateFileUnicode( &#038;output_dir, len, output_filename, kFSCatInfoNone,
							   NULL, &#038;output_file, NULL );

	if ( err != noErr )
	{
		fprintf( stderr, "error %i creating file\n", err );
		return 2;
	}

	// cleanup dialog
	NavDialogDispose(dialog);

	HFSUniStr255 data_fork;
	FSGetDataForkName( &#038;data_fork );
	err = FSOpenFork(&#038;output_file,data_fork.length, data_fork.unicode,fsWrPerm,&#038;fRefNumOut);
	if ( err != noErr )
	{
		fprintf( stderr, "error %i opening data fork for writing\n", err );
		return 2;
	}

	char* buf = "hello";
	long bytes_written;
	FSWriteFork( &#038;fRefNumOut, fsAtMark, 0, strlen(buf), buf, &#038;bytes_written );

	FSCloseFork( &#038;fRefNumOut );
</pre>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/05/save-file-dialog-code-osxcarbon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some more history</title>
		<link>http://frey.co.nz/old/2008/03/some-more-history/</link>
		<comments>http://frey.co.nz/old/2008/03/some-more-history/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 00:39:08 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[research]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/03/26/some-more-history/</guid>
		<description><![CDATA[

]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/_itMu1ZbY6c&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/_itMu1ZbY6c&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/VjgMoezkXUU&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/VjgMoezkXUU&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/03/some-more-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some history</title>
		<link>http://frey.co.nz/old/2008/03/some-history/</link>
		<comments>http://frey.co.nz/old/2008/03/some-history/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 16:05:17 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[research]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/03/21/some-history/</guid>
		<description><![CDATA[These things have all influenced me deeply on some level. Whether or not I&#8217;m willing to call them &#8216;art&#8217; is a different question. 

(higher quality video here)



]]></description>
			<content:encoded><![CDATA[<p>These things have all influenced me deeply on some level. Whether or not I&#8217;m willing to call them &#8216;art&#8217; is a different question. </p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/IyHt0BbI1a0&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/IyHt0BbI1a0&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object><br />
(higher quality video <a href='http://www.demoscene.tv/page.php?id=172&#038;lang=uk&#038;vsmaction=view_prod&#038;id_prod=12612'>here</a>)</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ZVB_S3ouIkE&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ZVB_S3ouIkE&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/PgGs-NTp0Uk&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/PgGs-NTp0Uk&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/7kLNXg4BmM8&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/7kLNXg4BmM8&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/03/some-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transistors: BC vs 2N</title>
		<link>http://frey.co.nz/old/2008/03/transistors-bc-vs-2n/</link>
		<comments>http://frey.co.nz/old/2008/03/transistors-bc-vs-2n/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 19:27:27 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/03/11/transistors-bc-vs-2n/</guid>
		<description><![CDATA[PNP
BC556, BC557, BC558
2N3906
NPN
BC546, BC547, BC 548
2N3904, 2N2222
just because i couldn&#8217;t find it anywhere else
]]></description>
			<content:encoded><![CDATA[<p><b>PNP</b><br />
BC556, BC557, BC558<br />
2N3906</p>
<p><b>NPN</b><br />
BC546, BC547, BC 548<br />
2N3904, 2N2222</p>
<p>just because i couldn&#8217;t find it anywhere else</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/03/transistors-bc-vs-2n/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun Run Sun has its own project page</title>
		<link>http://frey.co.nz/old/2008/02/sun-run-sun-has-its-own-project-page/</link>
		<comments>http://frey.co.nz/old/2008/02/sun-run-sun-has-its-own-project-page/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 18:38:02 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[participate]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/02/04/sun-run-sun-has-its-own-project-page/</guid>
		<description><![CDATA[at http://www.frey.co.nz/projects/sunrunsun/
enjoy.
]]></description>
			<content:encoded><![CDATA[<p>at <a href='http://www.frey.co.nz/projects/sunrunsun/'>http://www.frey.co.nz/projects/sunrunsun/</a></p>
<p>enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/02/sun-run-sun-has-its-own-project-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun Run Sun</title>
		<link>http://frey.co.nz/old/2008/01/sun-run-sun/</link>
		<comments>http://frey.co.nz/old/2008/01/sun-run-sun/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 00:50:14 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[participate]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2008/01/23/sun-run-sun/</guid>
		<description><![CDATA[I&#8217;m in Amsterdam, NL working at NIMK/Montevideo with Yolande Harris, who is currently Montevideo&#8217;s Artist In Residence. She has a project called Sun Run Sun which is about sonifying navigation data, in particular GPS data.
I have been called in to help write some Pure Data patches for this project. The patches need to run with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in Amsterdam, NL working at <a href='http://www.nimk.nl/en/'>NIMK/Montevideo</a> with <a href='http://yolande.janvaneyck.nl/'>Yolande Harris</a>, who is currently Montevideo&#8217;s Artist In Residence. She has a project called <a href='http://sunrunsun.nimk.nl/'>Sun Run Sun</a> which is about sonifying navigation data, in particular GPS data.</p>
<p>I have been called in to help write some <a href='http://puredata.info/'>Pure Data</a> patches for this project. The patches need to run with <a href='http://gige.xdv.org/pda/'>PDa</a> on a <a href='http://gumstix.com/'>Gumstix</a> computer.</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2008/01/sun-run-sun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dorkbot Valencia presentation / S5</title>
		<link>http://frey.co.nz/old/2007/12/dorkbot-valencia-presentation/</link>
		<comments>http://frey.co.nz/old/2007/12/dorkbot-valencia-presentation/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 20:12:44 +0000</pubDate>
		<dc:creator>frey</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.frey.co.nz/blog/2007/12/01/dorkbot-valencia-presentation/</guid>
		<description><![CDATA[I gave a presentation last night at Dorkbot Valencia. The presentation was called &#8220;Performing Music with PureData,&#8221; and it included some discussion of my ideas about performance with laptops and why it so often is uninspiring, as well as a little demonstration of my PureData patches, and last a little demonstration of some computer vision [...]]]></description>
			<content:encoded><![CDATA[<p>I gave a presentation last night at <a href='http://www.dorkbot.org/dorkbotvalencia'>Dorkbot Valencia</a>. The presentation was called &#8220;Performing Music with PureData,&#8221; and it included some discussion of my ideas about performance with laptops and why it so often is uninspiring, as well as a little demonstration of my PureData patches, and last a little demonstration of some computer vision tracking used as music control.</p>
<p>The presentation was built using something I found called <a href='http://meyerweb.com/eric/tools/s5/'>S5</a> which calls itself <em>A Simple Standards-Based Slide Show System</em>. It&#8217;s basically the entire functionality of PowerPoint in a single HTML file, with CSS to control the look and JavaScript to handle the navigation. Very, very nice. Have a look at <a href='/content/presentations/dorkbotvalencia/dorkbotvalencia.html'>my Dorkbot Valencia</a> presentation for a demo&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://frey.co.nz/old/2007/12/dorkbot-valencia-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
