<?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>Trnsfrmr &#187; Code</title>
	<atom:link href="http://trnsfrmr.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://trnsfrmr.com</link>
	<description>only fools &#38; horses work.</description>
	<lastBuildDate>Mon, 21 Feb 2011 15:28:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>macruby 0.6 is kinda slow :-(</title>
		<link>http://trnsfrmr.com/2010/08/23/macruby-0-6-is-kinda-slow/</link>
		<comments>http://trnsfrmr.com/2010/08/23/macruby-0-6-is-kinda-slow/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 22:18:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[macruby]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=190</guid>
		<description><![CDATA[So I have this ruby script that reads in a bunch of csv files and creates objects of different classs using configuration info extracted from the first couple of lines in each csv file. My results showed ruby 1.9.1 to be 2.425 times faster than macruby. When I used Cocoa classes such as NSDate in [...]]]></description>
			<content:encoded><![CDATA[<p>So I have this ruby script that reads in a bunch of csv files and creates objects of different classs using configuration info extracted from the first couple of lines in each csv file.</p>
<p>My results showed ruby 1.9.1 to be 2.425 times faster than macruby. When I used Cocoa classes such as NSDate in place of ruby&#8217;s Parsedate, macruby improved a bit and I ended up with a ratio of 2.212. I was pleasantly surprised by the performance of jruby though. Spinning up the JVM didn&#8217;t seem to have much of a negative impact.</p>
<p>I&#8217;ll have to profile the script to determine where macruby is choking.</p>
<ol>
<li>ruby19 => <strong>47</strong> secs</li>
<li>jruby => <strong>50</strong> secs</li>
<li>ruby18 => <strong>80</strong> secs</li>
<li>macruby 0.6 w/ NS classes => <strong>104</strong> secs</li>
<li>macruby 0.6 => <strong>114</strong> secs</li>
</ol>
<div id="attachment_192" class="wp-caption aligncenter" style="width: 620px"><a href="http://trnsfrmr.com/wp-content/uploads/2010/08/rubyshootout.png"><img src="http://trnsfrmr.com/wp-content/uploads/2010/08/rubyshootout.png" alt="" title="Ruby Platform Shootout" width="610" height="489" class="size-full wp-image-192" /></a><p class="wp-caption-text">Shorter is better.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/08/23/macruby-0-6-is-kinda-slow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby everywhere.</title>
		<link>http://trnsfrmr.com/2010/08/23/ruby-everywhere/</link>
		<comments>http://trnsfrmr.com/2010/08/23/ruby-everywhere/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 20:05:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[automator]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=183</guid>
		<description><![CDATA[I love Ruby so I want to use it everywhere! That means in my browser, mail, yojimbo, word and any application that will take text. So I built a very simple automator service that evaluates selected text as ruby and replaces the selection with the output from the ruby interpreter. Essentially, this service turns any [...]]]></description>
			<content:encoded><![CDATA[<p>I love Ruby so I want to use it everywhere! That means in my browser, mail, yojimbo, word and any application that will take text. So I built a very simple automator service that evaluates selected text as ruby and replaces the selection with the output from the ruby interpreter.</p>
<p>Essentially, this service turns any text entry field into Irb and to make it fit into my workflow unobtrusively, I invoke it using the keyboard shortcut <strong>control-option-command R</strong>. Of course you may still perform the substitution using either the contextual or services menus.</p>
<p>I can now enter a timestamp in a document simply by typing <strong>Time.now.to_s</strong>, selecting it and hitting <strong>⌃⌥⌘R</strong> to get <strong>Mon Aug 23 15:52:46 -0400 2010</strong>.<br />
<i>&#8220;A96tATYEsqJ-9Ag5VZTdqkejjsqwAm3w8gEh-fGHGtXuYhsbgerENqIG&#8221;.upcase</i> will yield <i>&#8220;A96TATYESQJ-9AG5VZTDQKEJJSQWAM3W8GEH-FGHGTXUYHSBGERENQIG&#8221;</i>.</p>
<p> I did this for bash as well. The plan now, is to build a library of methods and scripts that I can use for frequent substitutions.</p>
<p><a href="http://trnsfrmr.com/wp-content/uploads/2010/08/rubybashservices.png"><img src="http://trnsfrmr.com/wp-content/uploads/2010/08/rubybashservices.png" alt="" title="Ruby &amp; Bash Substitution Service" width="601" height="815" class="aligncenter size-full wp-image-188" /></a></p>
<p><a href="http://trnsfrmr.com/wp-content/uploads/2010/08/keyboardshortcuts.png"><img src="http://trnsfrmr.com/wp-content/uploads/2010/08/keyboardshortcuts-300x271.png" alt="" title="Keyboard Shortcuts" width="300" height="271" class="aligncenter size-medium wp-image-185" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/08/23/ruby-everywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automate db:pull from heroku</title>
		<link>http://trnsfrmr.com/2010/08/23/automate-dbpull-from-heroku/</link>
		<comments>http://trnsfrmr.com/2010/08/23/automate-dbpull-from-heroku/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 19:01:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[heroku]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=181</guid>
		<description><![CDATA[You need to use expect since &#8220;heroku db:pull&#8221; is interactive and requires user input. Alternatively, you can use expectj which as you may have already guessed, is the java implementation of expect. One advantage of using expectj is that your IDE will autocomplete the expect commands for you. #!/bin/sh expect -c " #Your timeout should [...]]]></description>
			<content:encoded><![CDATA[<p>You need to use expect since &#8220;heroku db:pull&#8221; is interactive and requires user input.<br />
Alternatively, you can use expectj which as you may have already guessed, is the java implementation of expect.<br />
One advantage of using expectj is that your IDE will autocomplete the expect commands for you.<br />
<code><br />
#!/bin/sh<br />
expect -c "<br />
#Your timeout should correspond to the number of seconds you expect pull to take.<br />
set timeout 600<br />
spawn heroku db:pull sqlite:///home/www/sites/xxx/db/xxxbackup.sqlite3 --app xxx<br />
expect \"Are you sure you wish to continue? (y/n)? \"<br />
send \"y\r\"<br />
set results $expect_out(buffer)<br />
expect eof"<br />
date >> /home/www/sites/xxx/db/backuplog.log<br />
echo "db pull done"<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/08/23/automate-dbpull-from-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails decimal columns in Mysql</title>
		<link>http://trnsfrmr.com/2010/08/23/rails-decimal-columns-in-mysql/</link>
		<comments>http://trnsfrmr.com/2010/08/23/rails-decimal-columns-in-mysql/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 18:50:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=180</guid>
		<description><![CDATA[To avoid getting weird decimal conversion issues when using Mysql, make sure you specify scale and precision options in your migrations. t.decimal :amount, :precision => 9, :scale => 2]]></description>
			<content:encoded><![CDATA[<p>To avoid getting weird decimal conversion issues when using Mysql, make sure you specify scale and precision options in your migrations.<br />
<code>t.decimal :amount, :precision => 9, :scale => 2</code></p>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/08/23/rails-decimal-columns-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Flash vs Apple</title>
		<link>http://trnsfrmr.com/2010/04/10/adobe-flash-vs-apple/</link>
		<comments>http://trnsfrmr.com/2010/04/10/adobe-flash-vs-apple/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 17:32:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=177</guid>
		<description><![CDATA[In response to Apple&#8217;s decision to limit iPhone OS app development to C, C++, objective-c and JavaScript. The Flash Blog I think that by restricting Developers to a specific set of languages, Apple can somewhat ensure that developers target their platform specifically rather than have developers submit apps that are built for the lowest common [...]]]></description>
			<content:encoded><![CDATA[<p>In response to Apple&#8217;s decision to limit iPhone OS app development to C, C++, objective-c and JavaScript. <a href="http://theflashblog.com/?p=1888">The Flash Blog</a><br/></p>
<p>I think that by restricting Developers to a specific set of languages, Apple can somewhat ensure that developers target their platform specifically rather than have developers submit apps that are built for the lowest common denominator of mobile devices. I guess they don’t want to foster an environment that mirrors what’s on the web today. Most websites leave out a ton of features just because IE6 cannot support those features. I do believe that developers produce their best work when they target a specific platform and take advantage of the unique features that platform has to offer.</p>
<p>It is also good business for Apple to maintain a base of developers that are “married” to their platform. Imagine an environment where most iPhone developers migrate to Flash CS5. In such an environment, if Apple releases enhancements to their frameworks, developers would have to wait for Adobe to integrate those changes into Flash before the developers could take advantage of Apple’s improvements.</p>
<p>What if Google buys Adobe and decides CS6 will only come out on google chrome and Flash will only support Android? Apple and all developers that target iPhone OS get left in the dust!</p>
<p>Let’s face it, we always have a choice of mobile phones but when it comes to graphics applications, Adobe is a very strong monopoly. I’d be cautious siding with them on an issue such as this. It may not end well. How much is the web premium suite again? Do you think we would have to pay that much if Adobe and Macromedia never merged?</p>
<p>Adobe is a behemoth. IPhone devs may not be able to use Flash but I’ll bet my last dollar that 99.9999999876% of all graphic content you’ll see on Apple, Sony, Microsoft, Palm &#038; Android devices as well as the web will be created using Adobe’s tools. Isn’t that enough?</p>
<p>I don&#8217;t necessarily have an issue with Adobe&#8217;s goal of making flash an indispensable tool but I do think that a lot of comments in the blogosphere wrongly suggest that Adobe may have altruistic motives. Adobe&#8217;s goal isn&#8217;t to give developers choice; it is to maintain and extend the dominance Flash currently enjoys. Apple&#8217;s goal isn&#8217;t to limit developers choice but rather to ensure that their platform doesn&#8217;t become just another deployment target for Flash.</p>
<p>Consider the following: <br />
If a developer uses Flash, who becomes responsible for performance tuning? The developer or Flash? <br />
My guess is Flash.</p>
<p>If Flash achieves 65% penetration into the iPhone development market? Who becomes responsible for how efficient Flash generated byte code runs on iPhone?<br />
My guess is Apple because end users will not attribute sucky performance to Adobe but to Apple. </p>
<p>Both companies are right so there really is no need for Adobe evangelists to pretend this is a fight about open vs closed.</p>
<p>I bet the blogs on here will have a totally different tone if MS/Google/Apple release free tools that allow developers to deploy their apps as Flash files. We will not hear all the clamoring for choice on the developers behalf.</p>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/04/10/adobe-flash-vs-apple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bytes, Nibbles &amp; Bits for CoreMidi</title>
		<link>http://trnsfrmr.com/2010/03/12/bytes-nibbles-bits-for-coremidi/</link>
		<comments>http://trnsfrmr.com/2010/03/12/bytes-nibbles-bits-for-coremidi/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 19:37:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Synth]]></category>
		<category><![CDATA[CoreMidi]]></category>
		<category><![CDATA[MIDI]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/?p=174</guid>
		<description><![CDATA[So I&#8217;m working on YAMP (yet another midi project and it took me a while to recollect all the binary arithmetic required to parse MIDI packets. Take a midi packet with 3 bytes in hexadecimal notation such as 99 3C 64. This stream encapsulates the following instructions: Play middle C on channel 10 at velocity [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m working on YAMP (yet another midi project <img src='http://trnsfrmr.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  and it took me a while to recollect all the binary arithmetic required to parse MIDI packets.</p>
<p>Take a midi packet with 3 bytes in hexadecimal notation such as <strong>99 3C 64</strong>. This stream encapsulates the following instructions:</p>
<p>Play middle C on channel 10 at velocity 100. Now lets strip it down to nibbles &amp; bits.</p>
<p>9 -&gt; Note on message. (Examples of other status messages are: 0xB for controller change, 0x C for program change &amp; 0xE for pitch-bend)</p>
<p>9 -&gt; Middle channel 10. (Range 0 -15)</p>
<p>3C -&gt;Middle C -&gt; Note 60</p>
<p>64 -&gt; 100 in decimal</p>
<p><strong>Determining if a stream begins with a status byte.</strong></p>
<p>A set high-bit on the first byte identifies the byte as a status message. This can be accomplished visually by converting <strong>99</strong> from hex to binary <strong>10011001</strong>,  and seeing if the first bit is 1. This can be tested mathematically with the following condtion:</p>
<p><strong>0&#215;99 &gt; 0x7F</strong></p>
<p>Once you have determined that the byte actually sets a status, you need to identify the actual status that is set. Some examples of status messages are: <strong>0xB</strong> for controller change, <strong>0xC</strong> for program change &amp; <strong>0xE</strong> for pitch-bend. To get the value of the left nibble, you can use the following expression.</p>
<p><strong>0&#215;99 &gt;&gt; 4</strong> (Shift the 4 places) or <strong>0&#215;99 / 0&#215;10</strong></p>
<p><strong>Determining the midi transmission channel.</strong></p>
<p>The second nibble (9<strong>9</strong>) of the first byte in the stream, represents the midi transmission channel. Channels are 0 indexed so they range from 0-F in hex or 0-15 in decimal. So we can tell quite easily that the transmission channel in our stream is 10 just by adding 1 to the second nibble. We can extract the 2nd nibble using the following expression:</p>
<p><strong>0&#215;99 % 0&#215;10</strong> (% = modulo)</p>
<p>and get the midi channel by adding 1 to the result</p>
<p><strong>(0&#215;99 % 0&#215;10) + 1</strong></p>
<p><strong><br />
</strong></p>
<p><strong>Determining the note number and velocity. </strong></p>
<p><strong><span style="font-weight: normal;">These are pretty simple. Just convert the Hex values to a decimal values</span></strong></p>
<p><strong><span style="font-weight: normal;">0x3c = 60</span></strong></p>
<p><strong><span style="font-weight: normal;">0&#215;64 = 100</span></strong></p>
<p>I&#8217;ll post my parser here when I&#8217;m done with it this weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2010/03/12/bytes-nibbles-bits-for-coremidi/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Getting started with CoreMidi</title>
		<link>http://trnsfrmr.com/2009/01/12/getting-started-with-coremidi/</link>
		<comments>http://trnsfrmr.com/2009/01/12/getting-started-with-coremidi/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 04:35:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[CoreFoundation]]></category>
		<category><![CDATA[CoreMidi]]></category>
		<category><![CDATA[MIDI]]></category>

		<guid isPermaLink="false">http://trnsfrmr.com/blog/?p=113</guid>
		<description><![CDATA[So I finally started on Octopussy. I&#8217;ve always found CoreMidi and procedural APIs in general a bit puzzling so I thought I would start with the simplest of tasks to help me demystify it all. My goal was simply to send a MIDI note on message from the Mac to the blofeld. After perusing MIDIService.h, [...]]]></description>
			<content:encoded><![CDATA[<p>So I finally started on <a href="/blog/octopussy">Octopussy</a>. I&#8217;ve always found CoreMidi and procedural APIs in general a bit puzzling so I thought I would start with the simplest of tasks to help me demystify it all. My goal was simply to send a MIDI note on message from the Mac to the blofeld.</p>
<p>After perusing MIDIService.h, I gathered that I had to ultimately use the MIDISend().</p>
<pre><span class="keyword">extern</span> <a class="type" href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/ErrorHandler/Reference/reference.html#//apple_ref/c/tdef/OSStatus" target="_top"><span class="type">OSStatus</span></a> <a class="function" href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/MusicAudio/Reference/CACoreMIDIRef/MIDIServices/CompositePage.html#//apple_ref/c/func/MIDISend"><span class="function">MIDISend</span></a>(
    <a class="type" href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/MusicAudio/Reference/CACoreMIDIRef/MIDIServices/CompositePage.html#//apple_ref/c/tdef/MIDIPortRef"><span class="type">MIDIPortRef</span></a> <span class="param">port</span>,
    <a class="type" href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/MusicAudio/Reference/CACoreMIDIRef/MIDIServices/CompositePage.html#//apple_ref/c/tdef/MIDIEndpointRef"><span class="type">MIDIEndpointRef</span></a> <span class="param">dest</span>,
    <span class="keyword">const</span> <a class="type" href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/MusicAudio/Reference/CACoreMIDIRef/MIDIServices/CompositePage.html#//apple_ref/c/tag/MIDIPacketList"><span class="type">MIDIPacketList</span></a> *<span class="param">pktlist</span>);</pre>
<p>When it was time to create a MIDIEndpointRef, I was presented with numerous paths. My initial instinct was to traverse some hierachy to get to the Blofeld MIDI Out but it turns out that each MIDIEntity can be reference using a unique id. I was hoping that this info would be available in the Audio MIDI Setup utility but it turns out you can only get at it via code. So I created a foundation tool with the following code.</p>
<pre><span>#import </span>&lt;Foundation/Foundation.h&gt;

<span>#import </span>&lt;CoreMIDI/CoreMIDI.h&gt;

<span>int</span> main (<span>int</span> argc, <span>const</span> <span>char</span> * argv[]) {

<span>    </span>NSAutoreleasePool<span> * pool = [[</span>NSAutoreleasePool<span> </span><span>alloc</span><span>] </span><span>init</span><span>];</span>

<span>	</span><span>MIDIDeviceRef</span> midiDevice;

<span><span>	</span></span><span>int</span><span> numOfDevices = </span>MIDIGetNumberOfDevices<span>();</span>

<span>	</span><span>int</span> numOfBlofeldEntities;

<span>	</span><span>for</span>(<span>int</span> i=<span>0</span>; i&lt; numOfDevices; i++ ){

<span>		</span>midiDevice = <span>MIDIGetDevice</span>(i);

<span>		</span><span>NSDictionary</span> *midiDeviceProperties;

<span>		</span><span>MIDIObjectGetProperties</span>(midiDevice, (<span>CFPropertyListRef</span> *)&amp;midiDeviceProperties, <span>YES</span>);

<span><span>		</span></span>NSLog(@"midiDeviceProperties:%@", midiDeviceProperties);

<span>	</span>}

    [pool <span>drain</span>];

    <span>return</span> <span>0</span>;

}</pre>
<p>After running the tool, I get the ff output. I need to run this on multiple Macs to verify that the uniqueID is actually the same regardless of which machine I run it on.</p>
<pre><strong>2009-01-11 23:24:31.273 MidiProperties[4198:10b] midiDeviceProperties-5:{</strong>

<strong>    SerialNumber = "8290071532-023547011532";</strong>

<strong>    USBLocationID = -46923776;</strong>

<strong>    USBVendorProduct = 317063187;</strong>

<strong>    "apple.midi.audiomidisetup.widget.xPosition" = 385;</strong>

<strong>    "apple.midi.audiomidisetup.widget.yPosition" = 203;</strong>

<strong>    driver = "com.apple.AppleMIDIUSBDriver";</strong>

<strong>    entities =     (</strong>

<strong>                {</strong>

<strong>            destinations =             (</strong>

<strong>                                {</strong>

<strong>                    name = "Blofeld MIDI out";</strong>

<strong>                    uniqueID = -934632258;</strong>

<strong>                }</strong>

<strong>            );</strong>

<strong>            embedded = 0;</strong>

<strong>            maxSysExSpeed = 3125;</strong>

<strong>            name = "Waldorf Blofeld";</strong>

<strong>            sources =             (</strong>

<strong>                                {</strong>

<strong>                    name = "Blofeld MIDI in";</strong>

<strong>                    uniqueID = 1439776402;</strong>

<strong>                }</strong>

<strong>            );</strong>

<strong>            uniqueID = -1524681845;</strong>

<strong>        }</strong>

<strong>    );</strong>

<strong>    image = "/Library/Audio/MIDI Devices/Access Music/Images/Virus TI Snow.tiff";</strong>

<strong>    manufacturer = "Waldorf Music GmbH";</strong>

<strong>    model = "Waldorf Blofeld";</strong>

<strong>    name = Blofeld;</strong>

<strong>    offline = 0;</strong>

<strong>    "receives MTC" = 0;</strong>

<strong>    "receives clock" = 0;</strong>

<strong>    "supports General MIDI" = 0;</strong>

<strong>    "supports MMC" = 0;</strong>

<strong>    "transmits MTC" = 0;</strong>

<strong>    "transmits clock" = 0;</strong>

<strong>    uniqueID = 1111148707;</strong>

<strong>}</strong></pre>
<p>Finally armed with the blofeld&#8217;s MIDI Out uniqueID, the rest was cake. Here is the code I used to send the note on message.</p>
<pre><span>#import </span>&lt;Foundation/Foundation.h&gt;

<span>#import </span>&lt;CoreMIDI/CoreMIDI.h&gt;

MIDIEndpointRef getEndpointWithUniqueID(<span>MIDIUniqueID</span> <span>id</span>){

<span><span>	</span></span>MIDIObjectRef<span> endPoint;</span>

<span><span>	</span></span>MIDIObjectType<span> foundObj;</span>

<span>	</span><span>MIDIObjectFindByUniqueID</span>(<span>id</span>, &amp;endPoint, &amp;foundObj);

<span><span>	</span></span><span>return</span><span> (</span>MIDIEndpointRef<span>) endPoint;</span>

}

MIDIClientRef getMidiClient(){

<span>	</span><span>MIDIClientRef</span> midiClient;

<span>	</span><span>NSString</span> *outPortName =<span>@"blofeldOut"</span>;

<span>	</span><span>MIDIClientCreate</span>((<span>CFStringRef</span>)outPortName, <span>NULL</span>, <span>NULL</span>, &amp;midiClient);

<span>	</span><span>return</span> midiClient;

}

MIDIPortRef getOutPutPort(){

<span><span>	</span></span>MIDIPortRef<span> outPort;</span>

<span>	</span><span>NSString</span> *outPortName =<span>@"blofeldOut"</span>;

<span>	</span><span>MIDIOutputPortCreate</span>(<span>getMidiClient</span>(), (<span>CFStringRef</span>)outPortName, &amp;outPort);

<span>	</span><span>return</span> outPort;

}

MIDIPacketList getMidiPacketList(){

<span><span>	</span></span>MIDIPacketList<span> packetList;</span>

<span>	</span>packetList.<span>numPackets</span> = <span>1</span>;

<span>	</span><span>MIDIPacket</span>* firstPacket = &amp;packetList.<span>packet</span>[<span>0</span>];

<span>	</span>firstPacket-&gt;<span>timeStamp</span> = <span>0</span>;<span>	</span><span>// send immediately</span>

<span>	</span>firstPacket-&gt;<span>length</span> = <span>3</span>;

<span>	</span>firstPacket-&gt;<span>data</span>[<span>0</span>] = <span>0x90</span>;

<span>	</span>firstPacket-&gt;<span>data</span>[<span>1</span>] = <span>60</span>;

<span>	</span>firstPacket-&gt;<span>data</span>[<span>2</span>] = <span>64</span>;

<span><span>	</span></span>// TODO: add end note sequence

<span>	</span><span>return</span> packetList;

}

<span>void</span> play_note(<span>void</span>) {

<span><span>	</span></span>NSAutoreleasePool<span> * pool = [[</span>NSAutoreleasePool<span> </span><span>alloc</span><span>] </span><span>init</span><span>]; </span>

<span><span>	</span></span><span>MIDIPacketList</span><span> packetList=</span>getMidiPacketList<span>();</span>

<span>	</span><span>MIDIUniqueID</span> blofeldEndpointID = -<span>934632258</span>;

<span>	</span><span>MIDIEndpointRef</span> blofeldEndpoint = <span>getEndpointWithUniqueID</span>(blofeldEndpointID);

<span>	</span><span>MIDISend</span>(<span>getOutPutPort</span>(), blofeldEndpoint, &amp;packetList);

<span>	</span><span>MIDIEndpointDispose</span>(blofeldEndpoint);

<span>	</span>[pool <span>drain</span>];

}

<span>int</span> main (<span>int</span> argc, <span>const</span> <span>char</span> * argv[]) {

<span>    </span>play_note<span>();</span>

    <span>return</span> <span>0</span>;

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://trnsfrmr.com/2009/01/12/getting-started-with-coremidi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

