<?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>One hand clapping &#187; compilation</title>
	<atom:link href="http://warped.org/blog/tag/compilation/feed/" rel="self" type="application/rss+xml" />
	<link>http://warped.org/blog</link>
	<description>Max Baker -- A Man with a Hand</description>
	<lastBuildDate>Mon, 10 May 2010 03:26:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iTunes &#8211; Setting the Compilation Flag on MP3&#8217;s using Perl</title>
		<link>http://warped.org/blog/2009/05/02/itunes-setting-the-compilation-flag-on-mp3s-using-perl/</link>
		<comments>http://warped.org/blog/2009/05/02/itunes-setting-the-compilation-flag-on-mp3s-using-perl/#comments</comments>
		<pubDate>Sun, 03 May 2009 00:10:13 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[Coverflow]]></category>
		<category><![CDATA[id3]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://warped.org/blog/?p=50</guid>
		<description><![CDATA[Update
I&#8217;ve consolidated this script into a new one. GO HERE : http://warped.org/blog/2009/05/03/itunes-fixing-id3-tags-in-mp3s-take-two/
Overview
If you have an album that&#8217;s a compilation or DJ mix, then Cover Flow gets confused and does not group all the tracks together into an album because there is a different &#8220;Artist&#8221; for each track.
iTunes gets around this by setting it&#8217;s own custom [...]]]></description>
			<content:encoded><![CDATA[<h1>Update</h1>
<p>I&#8217;ve consolidated this script into a new one. GO HERE : <a href="http://warped.org/blog/2009/05/03/itunes-fixing-id3-tags-in-mp3s-take-two/">http://warped.org/blog/2009/05/03/itunes-fixing-id3-tags-in-mp3s-take-two/</a></p>
<h1>Overview</h1>
<p>If you have an album that&#8217;s a compilation or DJ mix, then Cover Flow gets confused and does not group all the tracks together into an album because there is a different &#8220;Artist&#8221; for each track.</p>
<p>iTunes gets around this by setting it&#8217;s own custom flag in the ID3 tag : the TCMP frame in ID3v2 to be specific.</p>
<h1>The Script</h1>
<p>The following script uses <a href="http://search.cpan.org/~ilyaz/MP3-Tag-1.00/">MP3::Tag</a> to set the TCMP flag on all the MP3&#8217;s in the current directory, or the files specified on the command line.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;"># mp3_make_comp</span>
<span style="color: #666666; font-style: italic;"># Max Baker</span>
<span style="color: #666666; font-style: italic;"># 4/29/09</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This script will set the I-Tunes Compilation Tag (TCMP)</span>
<span style="color: #666666; font-style: italic;"># on Files passed to it.   If no files are passed, it works on *.mp3 in the current directory.</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> MP3<span style="color: #339933;">::</span><span style="color: #006600;">Tag</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span> <span style="color: #0000ff;">@ARGV</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #0000ff;">@ARGV</span> <span style="color: #339933;">=</span> <span style="color: #000066;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;*.mp3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$f</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@ARGV</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">next</span> <span style="color: #b1b100;">unless</span> <span style="color: #339933;">-</span>r <span style="color: #0000ff;">$f</span><span style="color: #339933;">;</span>
    add_comp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> add_comp <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mp3</span> <span style="color: #339933;">=</span> MP3<span style="color: #339933;">::</span><span style="color: #006600;">Tag</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>config<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'write_v24'</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># scan file for existing tags</span>
    <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>get_tags<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">exists</span> <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>ID3v2<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new_tag<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ID3v2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># check for existing tag</span>
    <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$info</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@rest</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>ID3v2<span style="color: #009900;">&#125;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>get_frame<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;TCMP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$file : TCMP=$info already set.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$file : Setting TCMP=1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>ID3v2<span style="color: #009900;">&#125;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>add_frame<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;TCMP&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$file : Adding TCMP frame failed.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>ID3v2<span style="color: #009900;">&#125;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>write_tag<span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$mp3</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h1>Prerequisites</h1>
<p>I managed to find a bug in MP3::Tag, so you may have to do the patch found <a href="http://rt.cpan.org/Public/Bug/Display.html?id=45647">here</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;N&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> compress <span style="color: #0000ff;">$data</span>
<span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$frame</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>flags<span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>unchanged<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;N&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> compress <span style="color: #0000ff;">$data</span>
<span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$frame</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>flags<span style="color: #009900;">&#125;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>unchanged<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>On line 585 of <a href="http://cpansearch.perl.org/src/ILYAZ/MP3-Tag-1.00/lib/MP3/Tag/ID3v2.pm">ID3v2.pm</a>.</p>
<p>Next Up : Copying ID3v1 tags to ID3v2 tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://warped.org/blog/2009/05/02/itunes-setting-the-compilation-flag-on-mp3s-using-perl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
