<?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>zachberry/blog</title>
	<atom:link href="http://zachberry.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://zachberry.com/blog</link>
	<description>Posts from a Web, Flash and Flex Developer</description>
	<lastBuildDate>Sun, 23 Oct 2011 23:48:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Incorporating an iPad into a DAW controlled studio (or, how to build a ghetto Alesis IO Dock for slightly less)</title>
		<link>http://zachberry.com/blog/?p=113</link>
		<comments>http://zachberry.com/blog/?p=113#comments</comments>
		<pubDate>Sat, 22 Oct 2011 03:18:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[music]]></category>
		<category><![CDATA[Alesis]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[Beringer]]></category>
		<category><![CDATA[dac]]></category>
		<category><![CDATA[daw]]></category>
		<category><![CDATA[io Dock]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[ipad 2]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[midi]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=113</guid>
		<description><![CDATA[<p>I&#8217;ve been experimenting with various methods to control the iPad via MIDI as well as getting pro-audio out of it, and now I&#8217;d like to share my results.</p> <p>First &#8211; this video by <a title="tekserv" href="http://www.youtube.com/user/tekserve" target="_blank">tekserv</a> is a good introduction on some of the possibilities to get MIDI working as well as how to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with various methods to control the iPad via MIDI as well as getting pro-audio out of it, and now I&#8217;d like to share my results.</p>
<p>First &#8211; this video by <a title="tekserv" href="http://www.youtube.com/user/tekserve" target="_blank">tekserv</a> is a good introduction on some of the possibilities to get MIDI working as well as how to get clean audio out, and is worth viewing:</p>
<p><iframe src="http://www.youtube.com/embed/8bz_YiMUY5E?rel=0" frameborder="0" width="640" height="360"></iframe></p>
<p><strong>But,</strong> what if you wanted to do both MIDI in/out and <strong>pro-audio</strong> out at the same time?  You can &#8211; read on as I run through a few options you have, starting simple and going into full DAW integration:</p>
<h2>Options with MIDI, Audio and the iPad:</h2>
<p>First, for any of this stuff to work you&#8217;ll need to go out and buy a <a href="http://store.apple.com/us/product/MC531ZM/A">Camera Connection Kit</a> (<em>$29</em>), which confusingly can do much more than connect to cameras &#8211; in fact it can get USB digital audio out as well as MIDI in and out.  With that out of the way:</p>
<ul>
<li><strong>How to control the iPad with a USB MIDI Keyboard:</strong></li>
</ul>
<p style="text-align: center;"><strong><a href="http://zachberry.com/blog/wp-content/uploads/2011/10/ipad-controller-keyboard-2.png" rel="fancybox-113"><img class="aligncenter size-medium wp-image-130" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad-controller-keyboard-2" src="http://zachberry.com/blog/wp-content/uploads/2011/10/ipad-controller-keyboard-2-300x109.png" alt="" width="300" height="109" /></a></strong></p>
<p>This setup will allow you to control an iPad soft synth, like Animoog, with a physical MIDI controller keyboard.  If your lucky you should be able to plug up your USB MIDI Keyboard into the CCK directly and it should “just work.”  It will &#8220;just work&#8221; based on two factors: first, your keyboard should be <strong>CoreMIDI</strong> compliant <em>(in other words, it follows the MIDI specification and doesn’t do anything “weird” or proprietary. Lucky for you you can visit <a title="iosmidi.com" href="http://iosmidi.com/devices/">iosmidi.com</a> for more information on supported keyboards). </em>Second, your device can&#8217;t draw too much power as the iPad is stingy with how much power it&#8217;ll give connected devices.  The good news is that if your keyboard is power hungry you can plug it up to a powered USB hub and connect the powered USB hub to the CCK, as shown above.</p>
<ul>
<li><strong>How to control the iPad with an <em>old-school</em> MIDI Keyboard:</strong></li>
</ul>
<p style="text-align: center;"><a href="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-midi-controller-keyboard.png" rel="fancybox-113"><img class="aligncenter size-medium wp-image-123" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad-midi-controller-keyboard" src="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-midi-controller-keyboard-285x300.png" alt="" width="285" height="300" /></a></p>
<p>You can also control the iPad with MIDI via a USB/MIDI interface.  Again you’ll need to make sure it’s CoreMIDI comptable and you may need to plug it in via a powered USB hub if it draws too much power.  I’ve used E-MU interfaces, which I like (and work happily with CoreMIDI).  In the diagram above I show a 1&#215;1 interface, but really any CoreMIDI-supported MIDI interface will work.</p>
<ul>
<li><strong>How to capture digital audio from the iPad:</strong></li>
</ul>
<p style="text-align: center;"><a href="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-audio-to-computer.png" rel="fancybox-113"><img class="aligncenter size-medium wp-image-120" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad-audio-to-computer" src="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-audio-to-computer-300x186.png" alt="" width="300" height="186" /></a></p>
<p>By using a USB Audio interface/DAC plugged into the CCK you can capture pure digital audio out <strong>directly from an iPad app</strong> which you can then plug into a mixer (as in this diagram), or to a four track, cassette player, or whatever analog input you want.  Since I record everything on my laptop I&#8217;m showing off my setup, which is iPad audio to a Firewire mixer, than back into my computer.</p>
<ul>
<li><strong>How to capture digital audio <em>while</em> controlling the iPad with a MIDI Keyboard:</strong></li>
</ul>
<p style="text-align: center;"><span class="Apple-style-span" style="color: #0000ee;"><img class="aligncenter size-medium wp-image-119" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad-audio-out-with-keyboard" src="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-audio-out-with-keyboard-300x193.png" alt="" width="300" height="193" /></span></p>
<p>This is where the real fun begins.  The CCK will send out both USB MIDI and USB Audio just fine, and your hub will do all the work!</p>
<ul>
<li><strong>Incorporating an iPad into a DAW controlled studio as another instrument (aka building a ghetto Alesis IO Dock):</strong></li>
</ul>
<p><a href="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-full-studio.png" rel="fancybox-113"><img class="aligncenter size-medium wp-image-122" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad-full-studio" src="http://zachberry.com/blog/wp-content/uploads/2011/08/ipad-full-studio-300x267.png" alt="" width="300" height="267" /></a></p>
<p>Now we&#8217;re talking.  With this setup you can add in the iPad as another instrument in your studio.  The idea is to send/recieve MIDI data to/from the iPad via a DAW (I’m using <em>Logic Studio</em>) as well as capturing pro-audio out via the DAC at the same time.  To do this, you’ll need the following:</p>
<ul>
<li>A <strong>powered</strong> USB Hub &#8211; I&#8217;m using one I got from Staples.  You might want to avoid any dirt cheap $5 questionable Chinese hubs. (~$30)</li>
<li>The Apple Camera Connection Kit ($30)</li>
<li>A 1&#215;1 USB/MIDI Interface (Male USB to Male MIDI) (~$20)</li>
<li><em>Another</em> USB/MIDI Interface (Female MIDI to Male USB) &#8211; See note below (~$30)</li>
<li>A USB Audio Interface &#8211; I&#8217;m using the <a href="http://www.amazon.com/Behringer-UCA202-Audio-Interface/dp/B000KW2YEI/ref=sr_1_2?ie=UTF8&amp;qid=1319165104&amp;sr=8-2">Beringer UCA202</a> - See end of this post for more info (~$30)</li>
<li>RCA cables and a project box (~$10)</li>
<li>Total cost: ~$120 assuming you already have a USB/MIDI interface, ~$150 otherwise.</li>
</ul>
<p>By cramming all of this in a project box, you get this (mine complete with crude Sharpie graphics):</p>
<p><a href="http://zachberry.com/blog/wp-content/uploads/2011/10/ipad.png" rel="fancybox-113"><img class="aligncenter size-medium wp-image-135" style="border-width: 1px; border-color: rgba(0,0,0,.3); border-style: solid;" title="ipad" src="http://zachberry.com/blog/wp-content/uploads/2011/10/ipad-300x112.png" alt="" width="300" height="112" /></a></p>
<p><strong>A few notes:</strong></p>
<ul>
<li>Since I have a bedroom studio thing going on I had some of this stuff lying around already (making it a fun experiment to try).  If you don’t have any of this stuff need to buy everything on this list you should consider an <a href="http://www.alesis.com/iodock">Alesis iO Dock</a> which basically is this plus some more output options and around $40 more.  If there is a benefit to its ghetto clone, though, it’s that you don’t need to keep the iPad sloped downwards locked into position and you can use it in portrait mode.</li>
<li>If you notice in the diagram I have a MIDI/USB interface going into a MIDI/USB interface which seems redundant.  Unfortunately &#8211; working with off-the-shelf parts like this &#8211; I wasn’t able to plug a USB cable from the CCK or from the USB hub to my laptop and have OS X recognize that I plugged up a MIDI capable device.  There may be an app to workaround this (or this may work on a Windows machine) so if you find it out let me know!</li>
</ul>
<h2>Gotchas:</h2>
<ul>
<li>There are a few cases where USB MIDI or USB Audio will stop working suddenly.  The fact is it is still somewhat temperamental (I suspect a combination of the closed nature of the iPad and the lack of CoreMIDI documentation).</li>
<li>I noticed that whenever I changed the MIDI setup of my studio Sunrizer started to silently fail and stopped receiving MIDI data.  Force quitting the faulty app fixes this (To force quit: Exit to the home screen, then double tap the home button to bring up the multitask tray, hold down on the problematic app, then click its “X” button).  This is always a good thing to try in general if things aren’t working.</li>
<li>Plugging up the USB hub via the CCK and then plugging in the AC adapter caused the iPad to declare that the device was using too much power.  However, plugging up the AC adapter, then plugging the USB hub in to the CCK was fine.  My guess is that doing this in the wrong order sends a voltage spike that causes the iPad to reject whatever is plugged into it.</li>
<li>Attempting to use the full setup just flat-out stopped working for me when the iPad got to around 20-15% battery life (In my case the light on the hub was no longer illuminating, meaning the USB hub wasn’t actually on).  Trying again with more battery life fixed this.</li>
</ul>
<h2>Why USB Audio? Why not just use the headphone port?</h2>
<p>USB Audio is going to be your cleanest audio source from the iPad, since you&#8217;ll be getting digital audio direct from the iPad app to your own DAC.  I’m using a <a href="http://www.amazon.com/Behringer-UCA202-Audio-Interface/dp/B000KW2YEI/ref=sr_1_2?ie=UTF8&amp;qid=1319165104&amp;sr=8-2">Beringer UCA202</a> which is cheap and works great.  <a href="http://nwavguy.blogspot.com/2011/02/behringer-uca202-review.html">NwAvGuy has an amazingly thorough anlaysis on the Beringer</a> - tl;dr version: It’s a damn good DAC considering the price.</p>
<p>Your next best option for pro-audio is to get line audio out from the iPad pin connector, but this means two things. First, your audio will be colored by the iPad&#8217;s DAC.  I admit that I don’t know the quality of the built in iPad DAC, and it’s highly possible that the difference between the iPad’s DAC and an external DAC is reasonably negligible.  Still &#8211; by using an external DAC you are giving yourself the option to upgrade the DAC if you wanted.  Second, you&#8217;d need to solder up a connector for this to work that would essentially be a hybrid of the CCK (for MIDI) and the line audio out.</p>
<p>For pro-audio you absolutely don&#8217;t want the headphone port since that is colored by both the iPad&#8217;s DAC <em>and</em> its headphone amp circuitry.  The headphone audio out is made to be good enough for you to listen to but not something you&#8217;d want to commit to a recording.</p>
<h2>What about the Line 6 MIDI Mobilizer?</h2>
<p>Well, I don&#8217;t own one, so I can&#8217;t speak to how well it works, but I think the CCK is definitely the way to go here.  Any app that supports CoreMIDI (from iOS 4.x and up) <em>should </em>work with the CCK, whereas apps have to add in support for the MIDI Mobilizer which is non-standard.  Plus, the CCK is cheaper!</p>
<h2>What about the iRig MIDI?</h2>
<p>Thanks to Will in the comments who pointed me towards the iRig MIDI.  I also don&#8217;t own an iRig, but from what I can read online the iRig will remove the need for you to buy a MIDI interface <em>and</em> a Camera Connection Kit, instead you can just get the iRig and get MIDI in and out.  What I don&#8217;t know is if  you can connect the iRig&#8217;s USB cable into an external DAC like the Beringer and get USB Audio out or if your confined to the noisy headphone port.  If any iRig MIDI owners want to experiment with this please reply back and let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=113</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Amazon Cloud Player, now with Keyboard Shortcuts &amp; Growl Notifications!</title>
		<link>http://zachberry.com/blog/?p=108</link>
		<comments>http://zachberry.com/blog/?p=108#comments</comments>
		<pubDate>Sat, 02 Apr 2011 05:38:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=108</guid>
		<description><![CDATA[<p>&#8230;Sorta. :) <a href="https://github.com/zachberry/amazon-cloud-player-growl">Code is at GitHub!</a> Explanation below:</p> <p>Andy Lemay made a very useful post on <a href="http://www.andylemay.com/blog/2011/03/29/how-to-use-fluid-to-run-amazon-cloudplayer-as-its-own-app/">how to use fluid to run Amazon CloudPlayer as its own app</a>. In a nutshell: You can download an excellent application called <a href="http://fluidapp.com/">Fluid</a> to create a desktop version of a webpage &#8211; in this case, the [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;Sorta. :)  <a href="https://github.com/zachberry/amazon-cloud-player-growl">Code is at GitHub!</a>  Explanation below:</p>
<p>Andy Lemay made a very useful post on <a href="http://www.andylemay.com/blog/2011/03/29/how-to-use-fluid-to-run-amazon-cloudplayer-as-its-own-app/">how to use fluid to run Amazon CloudPlayer as its own app</a>.  In a nutshell: You can download an excellent application called <a href="http://fluidapp.com/">Fluid</a> to create a desktop version of a webpage &#8211; in this case, the newly released Amazon Cloud Player.  This worked great, however I was hoping to get keyboard shortcuts and Growl notifications working.  Luckily, <a href="http://fluidapp.com/developer/">Fluid has a UserScript API</a> to allow you to write UserScripts (essentially just js files) which can be loaded into the web application.</p>
<p>Now to poke around!  Digging into the page and js files in Amazon CloudPlayer revealed a nice API that I figured I could hack into. TextMate&#8217;s &#8216;Reformat Document&#8217; was a huge help here to turn the minimized js files into something human readable. </p>
<p>The resulting UserScript I wrote polls amznMusic.widgets.player.getCurrent (which returns a lot of metadata on the current song playing) to display growl notifications when the metadata that it returns changes.  The script also adds dock menu items to play/pause, play the previous song and play the next song.  After some searching, I found that it&#8217;s <em>possible</em> to get keyboard shortcuts working with this, but it&#8217;s quite a hack.  Keyboard triggers can be defined in Quicksilver to run AppleScripts, which in turn do some UI Scripting to &#8220;click&#8221; the dock menu items.  There are a number of problems with this &#8211; it can be quite slow initially (taking up to a few seconds), you&#8217;ll see the dock menu flash on screen for a brief period, and you can&#8217;t use the media keys.  It may be possible to overcome this by building a Cocoa plugin for Fluid, however I don&#8217;t have the Cocoa chops for that.</p>
<p><a href="https://github.com/zachberry/amazon-cloud-player-growl">Get the code on the GitHubs</a>.  The README has a full rundown of all the steps you&#8217;ll need.</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=108</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Trace Flex &amp; Flash content (minus Flex/FlashBuilder junk)</title>
		<link>http://zachberry.com/blog/?p=3</link>
		<comments>http://zachberry.com/blog/?p=3#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:33:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[flex]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flashbuilder]]></category>
		<category><![CDATA[flashtracer]]></category>
		<category><![CDATA[flexbuilder]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=3</guid>
		<description><![CDATA[<p>I use <a href="http://www.visible-form.com/blog/view-trace-statements-in-the-terminal-on-os-x/">a tail command alias</a> (from FlashApe) to constantly output the contents of my flashlog file to the terminal which makes reading output very useful. However, if you use FlexBuilder/FlashBuilder at all, you&#8217;ll notice it will dump millions of useless comments such as</p> <p>-> Begin call to AS: getSelectedItems()<br /> Begin AS external [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://www.visible-form.com/blog/view-trace-statements-in-the-terminal-on-os-x/">a tail command alias</a> (from FlashApe) to constantly output the contents of my flashlog file to the terminal which makes reading output very useful.  However, if you use FlexBuilder/FlashBuilder at all, you&#8217;ll notice it will dump millions of useless comments such as</p>
<p><code>-> Begin call to AS: getSelectedItems()<br />
<- End call to AS: getSelectedItems, Result = Text23<br />
==> Begin AS external call: designViewComplete()<br />
<== End AS external call: designViewComplete, Result =</code></p>
<p>Just resizing the design view is enough to dump tons of these statements into your trace output, which gets very annoying.  While working on a project, a <a href="http://rev-in.com/">friend</a> of mine had the idea of somehow removing these statements, which got me thinking.  The dirty solution I came up with is to <b>grep -v</b> the flashlog before you send it to the tail command using a regex that will match any line starting with one of the four arrow characters (->, <-, ==>, <==).  As a consequence, you will also remove any traces that begin with these characters, so be mindful of how you write your trace statements.  I'm sure there's a way to modify this to search for 'Begin call to AS' and so on.</p>
<p>Anyway, the command is a bash alias called <b>trace</b>.  How-to:</p>
<p>1. First, you'll need the Flash debug player if you don't already have it.  Go to <a href="http://playerversion.com/">playerversion.com</a> - if you don't see <b>(Debug Player)</b> by the version number, go <a href="http://www.adobe.com/support/flashplayer/downloads.html">here</a>, and download the appropriate debug players for your browser/OS.</p>
<p>2. Next, go to the terminal and open your ~/.bash_profile</p>
<p><code>nano ~/.bash_profile</code></p>
<p>3. Then, add the following line somewhere within the file:</p>
<p><code>alias trace='tail -f /Users/YOUR-USER/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt | grep -v "^\->\|^<\-\|^\=\=>\|^<\=\="'</code></p>
<p>4. Be sure to replace YOUR-USER with your username, or, if your flashlog.txt file is in a different location (I'm using OS X, linux will be different) change the command to point wherever your flashlog.txt file is located.  If you don't have a flashlog.txt file, you can create one.</p>
<p>5. If you don't have it, create a file in your home directory called 'mm.cfg'.  Add the following:</p>
<p><code>TraceOutPutFileName=/Users/YOUR-USER/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt<br />
ErrorReportingEnable=1<br />
TraceOutputFileEnable=1<br />
MaxWarnings=9999<br />
</code></p>
<p>6. Make sure <strong>TraceOutPutFileName</strong> is the same as the directory you put in your .bash_profile.</p>
<p>Now you should be able to type <b>trace</b> in the terminal to see the trace output, minus the pesky FlashBuilder comments!  Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=3</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically Ripping FLAC Files to mp3s Via Shell Script &#8211; Update!</title>
		<link>http://zachberry.com/blog/?p=96</link>
		<comments>http://zachberry.com/blog/?p=96#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:27:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[music]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[easytag]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[flac]]></category>
		<category><![CDATA[genre]]></category>
		<category><![CDATA[genres]]></category>
		<category><![CDATA[id3]]></category>
		<category><![CDATA[lame]]></category>
		<category><![CDATA[lossless]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macintosh]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[metaflac]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[ripping]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=96</guid>
		<description><![CDATA[<p>I have made a slight update to the earlier post at <a href="http://zachberry.com/blog/?p=53">Automatically Ripping FLAC Files to mp3s Via Shell Script</a>. I have updated the script so that it will automatically make the database directory the first time you run it. Without that change, the script wouldn&#8217;t work as expected unless you manually created the [...]]]></description>
			<content:encoded><![CDATA[<p>I have made a slight update to the earlier post at <a href="http://zachberry.com/blog/?p=53">Automatically Ripping FLAC Files to mp3s Via Shell Script</a>.  I have updated the script so that it will automatically make the database directory the first time you run it.  Without that change, the script wouldn&#8217;t work as expected unless you manually created the directory.</p>
<p>In addition, I attempted to get the script working on my OS X machine with much success.  Installing the Apple Developer Tools (available on your OS X install disc) will provide you with the &#8216;make&#8217; command line utility.  This will allow you to compile <a href="http://home.wanadoo.nl/squell/id3.html">id3 mass tagger</a>.  MacPorts and/or Fink will provide you with the other tools you&#8217;ll need &#8211; lame, flac, and metaflac.  I was able to compile and install id3 mass tagger without any problems (much to my surprise).</p>
<p>Once you have these tools, the script should work as expected.  Let me know if you have any problems and I may be able to help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=96</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking Cog to have an iTunes style library</title>
		<link>http://zachberry.com/blog/?p=14</link>
		<comments>http://zachberry.com/blog/?p=14#comments</comments>
		<pubDate>Sat, 22 Aug 2009 19:35:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[music]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cog]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[m3u]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macintosh]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[player]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=14</guid>
		<description><![CDATA[<p>I use <a href="http://cogx.org/">Cog</a> on OS X as my primary music application which I&#8217;m pretty happy with &#8211; It&#8217;s very lightweight and plays FLAC files. Still, I prefer how Rhythmbox and iTunes manages your music in one large library. Cog, on the other hand, gives you a directory listing and requires you to drag and [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://cogx.org/">Cog</a> on OS X as my primary music application which I&#8217;m pretty happy with &#8211; It&#8217;s very lightweight and plays FLAC files. Still, I prefer how Rhythmbox and iTunes manages your music in one large library. Cog, on the other hand, gives you a directory listing and requires you to drag and drop files into a library to listen to them.</p>
<p>This post describes a way to make Cog work more like iTunes. The library for Cog is simply a m3u playlist file on the filesystem. I wrote a script that would overwrite the m3u file with list of files in my music directory whenever you run Cog. To do this:</p>
<p>1. Rename the actual Cog application (within the /Applications/Cog.app folder). In the terminal,</p>
<p><code>mv /Applications/Cog.app/Contents/MacOS/Cog /Applications/Cog.app/Contents/MacOS/Cog-Application</code></p>
<p>2. Create a shell script to masquerade as Cog. This will first update the Cog m3u file, then run Cog. Copy the script below in a file called &#8216;Cog&#8217; and place it at /Applications/Cog.app/Contents/MacOS/</p>
<pre>
#!/bin/sh

######################
#Update Library File:#
######################
LIBRARY_FILE=~/Library/Application\ Support/Cog/Default.m3u #Location of Cog playlist file (Shouldn't need to change this)
LIBRARY_FOLDER=/Volumes/Music/collection/tagged/ #The folder that keeps all of the music you want to listen to

echo ' ' &gt; $LIBRARY_FILE #Clear out library
find $LIBRARY_FOLDER -type f -name "*.flac" &gt; $LIBRARY_FILE #Add flac files
find $LIBRARY_FOLDER -type f -name "*.mp3" &gt;&gt; $LIBRARY_FILE #Add mp3 files
### Add other file types here
#find $LIBRARY_FOLDER -type f -name "*.ogg" &gt;&gt; $LIBRARY_FILE #Add ogg files
#find $LIBRARY_FOLDER -type f -name "*.wav" &gt;&gt; $LIBRARY_FILE #Add wav files

#########
#Run Cog#
#########

/Applications/Cog.app/Contents/MacOS/Cog-Application
</pre>
<p>You will want to modify the script. Change the LIBRARY_FOLDER to point to a directory where all of your music files are located. You&#8217;ll also want to add or remove the find statements to find the type of music files you are looking for (flac, mp3, ogg, etc).</p>
<p>3. Set the permissions on the script to make it executable</p>
<p><code>chmod 755 /Applications/Cog.app/Contents/MacOS/Cog</code></p>
<p>Now whenever you run Cog, the library will be updated with your music files. If you add music files to your music directory, you will need to restart Cog.</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=14</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically Rescaling Flex Applications</title>
		<link>http://zachberry.com/blog/?p=66</link>
		<comments>http://zachberry.com/blog/?p=66#comments</comments>
		<pubDate>Thu, 06 Aug 2009 02:00:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[flex]]></category>
		<category><![CDATA[accessibility]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[modal]]></category>
		<category><![CDATA[popupmanager]]></category>
		<category><![CDATA[rescale]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[systemmanager]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=66</guid>
		<description><![CDATA[<p>For a project, we&#8217;ve been meaning to implement some accessibility features such as providing the ability to resize all of the text in the application. The problem with this is that it requires a lot of overhead to build your application so that it can handle dynamic text sizes. I wanted instead to try some [...]]]></description>
			<content:encoded><![CDATA[<p>For a project, we&#8217;ve been meaning to implement some accessibility features such as providing the ability to resize all of the text in the application.  The problem with this is that it requires a lot of overhead to build your application so that it can handle dynamic text sizes.  I wanted instead to try some scaleX and scaleY action on the entire Flex application, emulating the way Firefox (and other similar browsers) now handle page resizing.</p>
<p>For the most part, this worked really well.  You need some UI to set the scale value (for example, a slider component).  Then, in your application you can just set the scaleX and scaleY values to the value of that component.</p>
<p>Things get slightly more tricky when you include the PopUpManager.  When you rescale the Application, any pop-ups (which are placed a layer above the Application clip) remain unscaled.  Attempting to cast systemManager to a DisplayObject, and rescaling that ended up breaking the application since the content would no longer fill the entire stage.</p>
<p>A less elegant solution was to simply rescale the pop-ups as they are added via PopUpManager.  While working it out, a friend suggested to add an event listener for when popups are added, and to rescale the pop-ups then (so there&#8217;s no need to manually rescale the pop-ups).  That&#8217;s what I came up with.  The important caveat here is that you need to add/create your pop-ups in the PopUpManagerChildList.POPUP child list.  I was having fun so I added keyboard commands just because I&#8217;m that kind of guy.  A&#8230; keyboard command adding&#8230; guy.</p>
<p><strong>Instructions:</strong> Click somewhere on the flash movie to give it focus.  Move the slider (or press <strong>Ctrl &#038; -</strong> or <strong>Ctrl &#038; =</strong> ) (or Command for OS X) to rescale the content.  The flex movie has view source enabled, so right click and select &#8216;View Source&#8217; to peer into the un-ending black darkness.</p>
<p>
<object width="600" height="500">
<param name="movie" value="http://zachberry.com/blog/wp-content/uploads/2009/08/ScaleTest.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="600" height="500" src="http://zachberry.com/blog/wp-content/uploads/2009/08/ScaleTest.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Or, <a href="http://zachberry.com/blog/wp-content/uploads/2009/08/ScaleTest.swf">view in a new window.</a> (View Source won&#8217;t work in the new window, click on the embedded movie instead to view source).</p>
<p>A few flaws with this method:</p>
<ul>
<li>Images will look trashy when scaled.  The only thing you can do about this is stick with vector graphics.  Unless having the image in perfect clarity is critical to your application, I think it&#8217;s fine to let the user gain the functionality to rescale the application at the sacrifice of image clarity.</li>
<li>The text in buttons (that don&#8217;t explicitly define a size) will sometimes get truncated (ie, &#8220;Cancel&#8221; becomes &#8220;Can&#8230;&#8221;).  If the buttons are allowed to auto size, I don&#8217;t see why the text would truncate.  Annoying.  I still want to play with this and see if I can figure it out.</li>
<li>If you are focused in a TextField, pressing Ctrl &#038; &#8211; or Ctrl &#038; = will input &#8211; and = characters into the TextField!  <a href="http://bugs.adobe.com/jira/browse/FP-368%3Bjsessionid=F1004A97545046B4F0F3942A5F0AF65E?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel">You can&#8217;t prevent this</a>, unfortunately, but you could provide a work around if you really wanted to.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=66</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically Ripping FLAC Files to mp3s Via Shell Script</title>
		<link>http://zachberry.com/blog/?p=53</link>
		<comments>http://zachberry.com/blog/?p=53#comments</comments>
		<pubDate>Tue, 04 Aug 2009 04:06:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[music]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[easytag]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[flac]]></category>
		<category><![CDATA[genre]]></category>
		<category><![CDATA[genres]]></category>
		<category><![CDATA[id3]]></category>
		<category><![CDATA[lame]]></category>
		<category><![CDATA[lossless]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[metaflac]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[ripping]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=53</guid>
		<description><![CDATA[<p>Disclaimer: These instructions are for Ubuntu (or other Linux distro) &#8211; I will be doing an updated post later on to cover OS X.</p> <p>Being somewhat of an audiophile, I&#8217;ve been encoding my music in lossless FLAC format for a while now &#8211; which is great, except when you want to put them on an [...]]]></description>
			<content:encoded><![CDATA[<p>Disclaimer: These instructions are for Ubuntu (or other Linux distro) &#8211; I will be doing an updated post later on to cover OS X.</p>
<p>Being somewhat of an audiophile, I&#8217;ve been encoding my music in lossless FLAC format for a while now &#8211; which is great, except when you want to put them on an iPod (which of course, won&#8217;t play FLAC files).  One option would be to convert these files to Apple Lossless, however, I don&#8217;t mind sacrificing some quality to be able to put more music on my iPod.  Plus, I probably couldn&#8217;t tell the difference while I&#8217;m listening to the iPod anyway.</p>
<p>Therefore, I wanted a shell script that I could run that would find out which files I had recently added to my collection and convert them to mp3s (preserving metadata).  Then, I could grab those mp3s and put them into gtkpod or iTunes.</p>
<p>I created the shell script below borrowing liberally from other similar scripts I found online.  The key thing about this script is that it keeps a simple flat text file database so that it can remember which files it has already converted.</p>
<p>The biggest problem I stumbled on was handling genres.  For whatever reason, many command line and GUI tools refuse to let you write in your own genres &#8211; you pick from a pre-defined list.  This boggles my mind &#8211; it seems presumptuous to me that some group would be tasked with coming up with all of the possible labels to all music.  I listen to a lot of Electronic music, which alone covers &#8216;Drum and Bass&#8217;, &#8216;House&#8217;, &#8216;Techno&#8217;, &#8216;Electro&#8217;, &#8216;Progressive Trance&#8217;, &#8216;Microhouse&#8217; and a trillion other tiny genres.  In addition to sub-genres, you also have the problem of your cousins band which plays an Acoustic Goth-Country &#8220;experience&#8221; that defies categorization, and cannot simply be lumped into &#8216;Alternative&#8217;.</p>
<p>I found two solutions to this problem.  For ripping from CDs to FLAC, I use EasyTag which will let you enter in genres by hand.  EasyTag&#8217;s not my favorite program in the world, but it gets the job done and you can get it from your package manager.  For decoding the FLAC files and encoding them to mp3s, I found <a href="http://home.wanadoo.nl/squell/id3.html">id3 mass tagger</a> by squell.  My script below uses this program (simply called <strong>id3</strong>), so you&#8217;ll need to install that first.</p>
<p>In addition to the id3 mass tagger, you&#8217;ll need to have <strong>lame</strong> (for encoding mp3s), <strong>flac</strong> (for decoding flacs) and <strong>metaflac</strong> (for handling the flac metadata).  On linux, all of these should be obtainable through your package manager.</p>
<p>Next, grab this script and save it somewhere that is in your path (for example, /usr/bin).  Personally, I like making a bin folder in my home directory to keep all of my scripts.  You do whatever tickles your fancy.  Make sure to give the script executable permissions:</p>
<p><code>chmod 755 name-of-the-script</code></p>
<p><strong>The script:</strong></p>
<pre>
#!/bin/bash

#flac-to-mp3 will search FLAC_SOURCE_DIR for all flac files added since last time you've run flac-to-mp3.  These files will be converted to mp3s and placed in MP3_OUTPUT_DIR.  This script can be useful when maintaining a flac music collection along with a mp3 player like the iPod.

#Dependencies: lame, flac, metaflac, ID3 mass tagger (id3)

#Directory settings:
FLAC_SOURCE_DIR=/path/to/your/flac/files
MP3_OUTPUT_DIR=/path/to/where/you/want/to/output/the/mp3s
DB_DIR=/home/YOUR-USER-NAME/.flac-to-mp3

#You probably don't need to set these.  These specify the files that keep track of changes:
CURRENT="$DB_DIR"/current
INDEXED="$DB_DIR"/indexed
DIFF=/tmp/flac-to-mp3-dif
TMP_FILE="$DB_DIR"/tmp.tmp

IFS=" ";

if [ ! -d "$DB_DIR" ]; then
	mkdir "$DB_DIR"
fi

if [ ! -f "$CURRENT" ]; then
	touch "$CURRENT"
fi

if [ ! -f "$INDEXED" ]; then
	touch "$INDEXED"
fi

#Update index of flac files
find "$FLAC_SOURCE_DIR" -type f -name "*flac" > "$CURRENT"

#Get a list of files that have been newly added
if [ -f "$DIFF" ]; then
	rm "$DIFF"
fi

#Sort the database files so the diff won't have problems with files being in a different order:
sort "$INDEXED" > "$TMP_FILE"
cat "$TMP_FILE" > "$INDEXED"
sort "$CURRENT" > "$TMP_FILE"
cat "$TMP_FILE" > "$CURRENT"

touch "$DIFF"
diff "$INDEXED" "$CURRENT" | grep ">" | cut -c 3- > "$DIFF"

#Reset IFS so that our for loop won't die on spaces
IFS="
";

#Encode the flac files that are new into mp3s into the MP3_OUTPUT_DIR directory.
for FLAC in `cat "$DIFF"`
do
	#We first have to detect for duplicates.  If an mp3 file of the same name exists in the MP3_OUTPUT_DIR then we should append (2), (3), and so on to the filename.  Otherwise mp3 files would be overwritten.  This situation arises when there are two or more flac files with the same name.
	echo "${FLAC%.flac}" | sed 's/.*\///' > "$TMP_FILE"
	TMP=`cat "$TMP_FILE"`
	NUM_FILES=`ls "$MP3_OUTPUT_DIR" | sed 's/.mp3//' | grep "$TMP" | wc -l`

	if [ "$NUM_FILES" -gt 0 ]; then
		V=`expr $NUM_FILES + 1`
		MP3_PATH="${FLAC%.flac} ($V).mp3"
	else
		MP3_PATH="${FLAC%.flac}.mp3"
	fi

	#Encode flac file to mp3 file.
	echo "$MP3_PATH" | sed s/^.*\\///g > "$TMP_FILE"
	MP3=`cat "$TMP_FILE"`

	[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&#038;1 ; exit 1 ; } ;
	metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' >"$TMP_FILE"
	cat "$TMP_FILE" > /dev/null 2>&#038;1
	. "$TMP_FILE"
	flac -dc "$FLAC" | lame --preset standard --tt "$TITLE" \
	--tn "$TRACKNUMBER" \
	--ty "$DATE" \
	--tc "$COMMENT" \
	--ta "$ARTIST" \
	--tl "$ALBUM" \
	--add-id3v2 \
	- "$MP3_OUTPUT_DIR"/"$MP3"

	#We use ID3 mass tagger to write the genre tag - this will allow us to write non-standard genres.  ID3 can be found at http://home.wanadoo.nl/squell/id3.html
	id3 -2 -g "$GENRE" "$MP3_OUTPUT_DIR"/"$MP3"

	#Update the database:
	echo "$FLAC" >> "$INDEXED"
done

#Cleanup
rm "$DIFF"
rm "$TMP_FILE"

IFS=" "
MP3_PATH=
MP3=
FLAC=
FLAC_SOURCE_DIR=
MP3_OUTPUT_DIR=
CURRENT=
INDEXED=
DIFF=
DB_DIR=
NUM_FILES=
TMP=
V=
TMP_FILE=
</pre>
<p>Note that you&#8217;ll need to edit a few things, namely, the first three lines.  FLAC_SOURCE_DIR should point to where you store your flac files.  MP3_OUTPUT_DIR should point to a folder where you want the encoded mp3 files will end up.  DB_DIR will be the folder that will hold the flat file databases.  My script has a folder (.flac-to-mp3) in my home directory.</p>
<p>You may also want to modify the encoding options.  Line 72 uses the <strong>&#8211;preset standard</strong> option &#8211; you might want to change this.</p>
<p>Outside of that, you probably don&#8217;t need to modify the script much.  Read on if you want to know more about the inner workings of the script.</p>
<p>The script keeps two flat text database files &#8211; <strong>indexed</strong> and <strong>current</strong>.  <strong>indexed</strong> lists all of the files that you have already encoded.  When you run the script, <strong>current</strong> is rebuilt which is simply a list of all of the flac files in your FLAC_SOURCE_DIR.  These two files are sorted, then a diff is performed to see which files exist in current that are missing from indexed.  These are the files that (assumed) you have added since you last ran the script.  </p>
<p>Next, a check is performed to make sure that a file of the same name doesn&#8217;t already exist in the MP3_OUTPUT_DIR.  If it does, then a (2), (3) and so on are appended to the file name.  After that, the script exports the flac metadata into a temporary file.  Then, it decodes the flac file (line 72: <strong>flac -dc</strong>) and pipes that into lame.  Next, id3 (the id3 mass tagger application) writes the id3 tag information into the newly created mp3.  If all of these steps work, then the <strong>indexed</strong> file is appended with the name of the file (since it has already been encoded).</p>
<p>One final mega disclaimer: You&#8217;re at your own risk.  I wrote this for my personal use and I haven&#8217;t tested it thoroughly, so backup your files or run the script on a small sample to make sure it works first!</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=53</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Required First Post</title>
		<link>http://zachberry.com/blog/?p=51</link>
		<comments>http://zachberry.com/blog/?p=51#comments</comments>
		<pubDate>Mon, 03 Aug 2009 04:00:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[intro]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[introductions]]></category>

		<guid isPermaLink="false">http://zachberry.com/blog/?p=51</guid>
		<description><![CDATA[<p>Jello!</p> <p>Since I&#8217;m starting a blog, I have to get the introductions out of the way. I&#8217;m Zachary Berry, a web developer with a leaning towards Flex and Flash work. Since the end of 2004 I&#8217;ve been working as a Web Application Designer &#038; Developer at the University of Central Florida under the New Media [...]]]></description>
			<content:encoded><![CDATA[<p>Jello!</p>
<p>Since I&#8217;m starting a blog, I have to get the introductions out of the way.  I&#8217;m Zachary Berry, a web developer with a leaning towards Flex and Flash work.  Since the end of 2004 I&#8217;ve been working as a Web Application Designer &#038; Developer at the University of Central Florida under the New Media team.  Before that, all of my web development work was simply various experiments, home-pages, angelfire sites, and the like.</p>
<p>I also enjoy synthesizers, music and long walks on the beach.  Two of those passions will also drive some of the content for the blog.</p>
<p>There, now that that&#8217;s out of the way, we can get to the rest of the blog! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zachberry.com/blog/?feed=rss2&#038;p=51</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

