<h1>CodeSounding: computer generated music sounds from a source code structure</h1>
CodeSounding is a Java <a href="http://en.wikipedia.org/wiki/Sonification" target=_blank><b>sonification</b></a> library: the sound produced running a .class (or .jar) is a function of how was structured its source code before compilation. You can therefore produce <a href="http://en.wikipedia.org/wiki/Computer_generated_music" target=_blank><b>computer-generated music</b></a>.
<br>
The primary goal of CodeSounding was to make it possible <i>hear</i> the sound of execution of a software, assigning instruments and notes to Java programming statements (if, for, etc), so that the flowing of execution could be played as a flow of music. Quickly (different ideas of algorithms, huge data generated, design issues) the project shifted to a more implementation-indipendent framework, so that a junior Java programmer could write, insert and hear its own algorithm (you can think of it as a CodeSounding plugin) using complex classes or as simple as the following:
<ul>
<li><a href="http://codesounding.svn.sourceforge.net/viewvc/codesounding/CodeSounding/trunk/src/codesounding/jjack/SamplerSumProcessor.java?view=markup" target=_blank><b>SamplerSumProcessor</b></a></li>
<li><a href="http://codesounding.svn.sourceforge.net/viewvc/codesounding/CodeSounding/trunk/src/codesounding/jmusic/DiehardPeople.java?revision=232&view=markup" target=_blank><b>DiehardPeople</b></a></li>
</ul>
Now it is possible to add a "patch" (= custom filter / elaboration) at every level of CodeSounding; futhermore if you use a Jack Linux Audio server you can add, in a pipe, third-party realt-time filters and visualizators.
<br><br>
<table border=0 width=60%>
<tr>
<td rowspan=2 valign=middle align=center><a href="http://codesounding.svn.sourceforge.net/viewvc/codesounding/CodeSounding/tags/REL-1.3/java2Demo/src/java2d/DemoImages.java?view=markup" target=_blank ><img src="img/source_thumb.jpg"/></a>
</td>
<td rowspan=2 valign=middle align=center>
<img src="img/arrow_left.gif"/>
</td>
<td rowspan=2 valign=middle align=center><a href="img/musical_score.jpg" target=_blank ><img src="img/musical_thumb.jpg"/></a></td>
<td rowspan=2 valign=middle align=center>
<img src="img/arrow_left.gif"/>
</td>
<td valign=top align=left>
<a href="samples/java2demo/music1.mid"><img border=0 src="img/play.jpg"/><a href="samples/java2demo/music1.mid"> <b>ABC</b></a>
</td>
</tr>
<tr>
<td valign=middle rowspan=2 align=left>
<a href="samples/eclipse3.1_1/logarithm.mid"><img border=0 src="img/play.jpg"/><a href="samples/eclipse3.1_1/logarithm.mid"> <b>jMusic</b></a>
</td>
</tr>
<tr>
<td align=center ><a href="http://codesounding.svn.sourceforge.net/viewvc/codesounding/CodeSounding/tags/REL-1.3/java2Demo/src/java2d/DemoImages.java?view=markup" target=_blank ><b>Source code</b></a>
</td>
<td valign=middle align=center>
</td>
<td align=center ><a href="img/musical_score.jpg" target=_blank ><b>Musical score</b></a></td>
</tr>
</table>
<br>
Post-process your java files with <span class="code">codesounding.cl.ApplyTemplate</span> class and compile them. When running their compiled version, you can choose which sound generation algorithm apply.
Post-processing step can also be done through an ANT task. As said you can also write your own algorithm - I'll be very happy to hear your creations! We could also add it as an official plugin, let me know. But - ehi, don't expect to become a millionaire: sure, this is a totally useless feature and, besides "AS IS", it is above all "just for fun": you pragmatical people are warned! :)
<br><br>
<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/14ffzn3HvEM"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/14ffzn3HvEM" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>
<br><br>
<b><i>News</i></b>
<ul>
<li><i>28-Mar-2008</i> -
Astronomy and Music: a beautiful "cosmo sonification" from <b>Kepler</b>'s <a target="_blank" href="http://en.wikipedia.org/wiki/Harmonices_Mundi"><b>Harmonices Mundi</b></a> (1619):
<a target="_blank" href="http://www.calderon-online.com/trabajos/kepler/harmonicemundi.swf"><b>http://www.calderon-online.com/trabajos/kepler/harmonicemundi.swf</b></a>
<br>
</li>
</ul>
<ul>
<li><i>7-Mar-2008</i> -
Released <b>version 1.4</b>. The single new feature is the support for Linux <a href="http://www.jackaudio.org/" target=_blank ><b>JACK</b></a> audio server; in a few words that server allow 'piping' the audio among several plugins, in a client-server 'pull' architecture, with a own time transport protocol to sync all clients. Music produced by CodeSounding therefore can be an input for an audio visualizer like <b>projectM</b> or for a mixer. See a <a href="http://www.youtube.com/watch?v=14ffzn3HvEM" target=_blank ><b>video example</b></a> on YouTube.
<br>
In my opinion, <span class="code">codesounding.jjack.SamplerSumProcessor</span> class is the best of my experiments in creating a pure sound, without subjectivist contaminations like assigning an instrument, a note, or filtering the ABC musical score, as I was doing in previously releases. You can now choose the pitch to be assigned to each statement type, and the sampling interval (about every 11 ms JACK asks for a frame of 512 samples, when started at 44,1 kHz). On that given interval, every sample will be the sum of all the heights of the waves associated to each statement type.
</li>
</ul>
<ul>
<li><i>22-Aug-2007</i> -
Released <b>version 1.3</b>. For updates and feedback please check the <a href="http://codesounding.wiki.sourceforge.net/" target=_blank ><b>Wiki</b></a>:
<ul>
<li> <a href="http://codesounding.wiki.sourceforge.net/CommandLine" target=_blank ><b>new command line interface</b></a></li>
<li> <a href="http://codesounding.wiki.sourceforge.net/ANT_TASK" target=_blank ><b>added an ANT task class</b></a></li>
<li> ANTLR java source file parser (previously was a javacc parser)</li>
<li> all rewritting stuff in the same java process</li>
<li> <a href="http://codesounding.wiki.sourceforge.net/ShortTutorial" target=_blank ><b>short step by step tutorial</b></a></li>
<li> <a href="http://www.codesounding.org/java2demo.jnlp" target=_blank ><b>demo live (Java Web Start app)</b></a></li>
</ul>
<br>
<li><i>11-December-2006</i> -
Released <b>version 1.2</b>. Now the source file post-processing step works on Linux machines, too.
<br>
<li><i>29-July-2006</i> -
Released <b>version 1.1</b>. The main new feature is the <span class="code">codesounding.jmusic.LogaRythm</span> class,
which besides to use JMusic in place of ABC, introduces a new "sonification" algorithm: every 50 milliseconds it counts
how many instructions of each category (for, if, etc) has been executed (figure 1).
<br>
<center>
<a href="img/quantity.jpg" target=_blank ><b>Fig.1</b> <img src="img/quantity_thumb.jpg"/></a>
<a href="img/quantity_log.jpg" target=_blank ><b>Fig.2</b> <img src="img/quantity_log_thumb.jpg"/></a>
<a href="img/angle.jpg" target=_blank ><b>Fig.3</b> <img src="img/angle_thumb.jpg"/></a>
<a href="img/angle_log.jpg" target=_blank ><b>Fig.4</b> <img src="img/angle_log_thumb.jpg"/></a>
<br>
</center>
Then computes its natural logarithm (figure. 2) and splits up its range up to 10 among the 128 pitches
available in <span class="code">jm.constants.Pitches</span>.
Moreover for each category, on each interval, it computes the absolute slope (how quickly a
category changes its value) (fig. 3) and its natural logarithm (fig.4).
Values between 0 and 1, increased by one, are set as note duration, so a duration will vary in the range
between <span class="code">jm.constants.Durations.QUARTER_NOTE</span> and <span class="code">jm.constants.Durations.HALF_NOTE</span>.
<br>Finally, an instrument is assigned to each category; its rhythm indicates the weight of corresponding instructions, and how quickly that weight varies.
<br>
Click here for an audio example: <a href="samples/eclipse3.1_1/logarithm.mid"><img border=0 src="img/play.jpg"/></a>
</li>
<li><i>22-July-2006</i> -
<b>Ilia Malinovsky</b> made a very similar project, where the music is produced while parsing
a source code file, whereas CodeSounding library plays the trace of an execution of a program,
compiled appropriately. Nice and musical beginning from the name:
<a href=http://lycay.sourceforge.net/ target=_blank><b>LYCAY</b></a> - "Let Your Code plAY".
</li>
<li><i>20-July-2006</i> -
<a href="http://www.softsynth.com" target=_blank><b>Phil Burk</b></a> points out that this project is a type of <a href="http://en.wikipedia.org/wiki/Sonification" target=_blank><b>sonification</b></a>
that converts non-musical data (in this case java source code) into sound or music events.
</li>
</ul>
<br>
<hr></hr>
<center><small>~ Copyright © 2006 2008 - Roberto Mannai (<a href=mailto:robermann@gmail.com>robermann@gmail.com</a>) ~</small></center>