<p style="text-align: justify;">Did you ever wonder how the music visualizer in your media player works? Watching it pulsate in synchrony with the beats of the song is almost as entertaining as listening to the song itself! Researchers have been attempting to detect beats in audio signals for many years, and there are many techniques available, from the simplest (and least accurate) to more complicated algorithms that are highly accurate. All algorithms, though, perform some form of signal processing and frequency analysis, applications highly suited to GPU Computing.</p>
<p style="text-align: justify;">The beat visualizer described here was developed by researchers at Rice University, and is simple and fast. An incoming signal is broken down into six frequency bands for analysis. After smoothing out these bands and performing further signal processing steps (such as convolution and filtering), the algorithm proceeds to find the band with the highest energy.</p>
<p style="text-align: justify;">There are 4 plots shown during the analysis:</p>

<ol style="text-align: justify;">
	<li>Top Left: Input audio waveform</li>
	<li>Top Right: Output of a few functions of the input waveform</li>
	<li>Bottom Left: 6 Spheres corresponding to 6 frequency bands. They expand when a beat is detected in that band.</li>
	<li>Bottom Right: A sphere that pulses when a beat is detected overall.</li>
</ol>
[caption id="attachment_1621" align="aligncenter" width="614"]<a href="http://blog.accelereyes.com/blog/wp-content/uploads/2011/08/music_visualizer_example.png"><img class="size-large wp-image-1621" title="Music Beats Visualizer" src="http://blog.accelereyes.com/blog/wp-content/uploads/2011/08/music_visualizer_example-1024x871.png" alt="" width="614" height="523" /></a> Music Beat Visualizer with Jacket[/caption]
<p style="text-align: justify;">Conversion of the MATLAB-based visualizer to Jacket was made possible, mainly through the clever use of two of Jacket's functions:</p>

<ol style="text-align: justify;">
	<li>Use of the <a href="http://wiki.accelereyes.com/wiki/index.php/CLASS">CLASS</a> function to execute code either on CPU or GPU, based on the input</li>
	<li>Use of the <a href="http://wiki.accelereyes.com/wiki/index.php/GFOR">GFOR</a> function to execute serial loops in parallel.</li>
</ol>
<p style="text-align: justify;"><!--more-->The original MATLAB code was adapted for Jacket by Vidhur Vohra, a grad student at Georgia Tech. He shared with us his thoughts on converting the code to Jacket:</p>

<blockquote>...The main reason for the speed up is that previously the bands were put through the functions serially, but with the capabilities of JACKET/CUDA it was possible to put all six bands through most calculations at once, thereby greatly reducing the time for computation.</blockquote>
<p style="text-align: justify;">As a result of this, the code has been observed to run up to<span style="color: #ff6600;"><strong> 6 times faster</strong></span> on a Tesla C2075 (vs a Core 2 Quad CPU). The computationally-intensive core of the visualizer was observed to run<span style="color: #ff6600;"> <strong>15 times faster</strong>!</span></p>
<p style="text-align: justify;"><em>Observed times:</em></p>
<p style="text-align: justify;"><span style="text-decoration: underline;">Computational core (rhythm.m)</span></p>

<ul style="text-align: justify;">
	<li><em>Core 2 Quad (Q9400):</em> 0.37 s per iteration</li>
	<li><em>NVIDIA Tesla C2075:</em> 0.024 s per iteration</li>
</ul>
<p style="text-align: justify;"><span style="text-decoration: underline;">Overall:</span></p>

<ul style="text-align: justify;">
	<li><em>Core 2 Quad (Q9400):</em> 11 iterations per second</li>
	<li><em>NVIDIA Tesla C2075:</em> 64 iterations per second</li>
</ul>
<p style="text-align: justify;">The Music Visualizer Example will soon be available with Jacket 1.9!   If you can't wait to try it out, you may download and install Jacket's nightly installers <a href="http://www.accelereyes.com/nightly">from this link</a> (find out about our Nightlies <a title="Jacket Nightly Installers" href="http://wiki.accelereyes.com/wiki/index.php/Nightly">here</a>) and type:</p>

<pre>cd [Jacket Location]
addpath examples/music_visualizer_example
music_visualizer_example gpu</pre>
<p style="text-align: justify;">We would like to thank the following for their efforts:</p>

<ol style="text-align: justify;">
	<li> Kileen Cheng, Bobak Nazer, Jyoti Uppuluri and Ryan Verret at Rice University</li>
	<li>MIT Media Lab for the original beat-detection algorithm</li>
	<li>Vidhur Vohra, Georgia Institute of Technology</li>
</ol>
<p style="text-align: justify;"><span style="text-decoration: underline;">References:</span>
CPU source code: Adapted from "<a href="http://www.clear.rice.edu/elec301/Projects01/beat_sync/beatalgo.html">Beat This</a>", a beat-detection algorithm adapted from the MIT Media Lab by researchers at the Rice University.</p>
<em>This code project won the first prize at the <a href="http://www.accelereyes.com/examples/coding_challenge">Georgia Tech GPU Coding Challenge</a>. AccelerEyes is proud to have hosted this event and engaged the vibrant student community at Georgia Tech. Stay tuned for more such events at http://www.accelereyes.com!</em>