CodeSounding library: from source code to computer generated music sounds (sonification)

SourceForge.net Logo

Demo
Wiki Home   Trasformare codici sorgenti in computer generated music sounds (sonification) Download   Esempi di sonification Documentation   Creare computer generated music sounds: uso della libreria e configurazione

CodeSounding: computer generated music sounds from a source code structure

CodeSounding is a java sonification 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 computer-generated music.
Post-process your java files with codesounding.cl.ApplyTemplate 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.

To say it in a few words, the aim is adding to a software the capability of... sounding! You can feel its "inner breath". Yes, this is a totally useless feature and, besides "AS IS", it is above all "just for fun": you pragmatical people are warned :) But... what if you could hear that Software Quality Grail? Consider CodeSounding as a humble proof of concept.

 ABC
 jMusic
Source code Musical score

The sonification process consists of a post-processing operation on source files, which adds callbacks methods on "if", "for", etc. statements, in what is called token stream rewriting. Callbacks are structured around the Template design pattern, so the real sonification algorithm is interchangeable and configured at runtime. Properly sonification is therefore not on static source code structure but on dynamic behaviour during the execution.
Code parsing is made by an ANTLR parser, music generation by an ABC language/notation (see Guido Gonzato's and Chris Walshaw's sites), jMusic library or the JACK audio server.

News
  • 7-Mar-2008 - Released version 1.4. The single new feature is the support for Linux JACK 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 projectM or for a mixer. See a video example on YouTube.
    In my opinion, codesounding.jjack.SamplerSumProcessor 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.
  • 22-Aug-2007 - Released version 1.3. For updates and feedback please check the Wiki:
  • 11-December-2006 - Released version 1.2. Now the source file post-processing step works on Linux machines, too.
  • 29-July-2006 - Released version 1.1. The main new feature is the codesounding.jmusic.LogaRythm 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).
    Fig.1  Fig.2  Fig.3  Fig.4 
    Then computes its natural logarithm (figure. 2) and splits up its range up to 10 among the 128 pitches available in jm.constants.Pitches. 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 jm.constants.Durations.QUARTER_NOTE and jm.constants.Durations.HALF_NOTE.
    Finally, an instrument is assigned to each category; its rhythm indicates the weight of corresponding instructions, and how quickly that weight varies.
    Click here for an audio example:
  • 22-July-2006 - Ilia Malinovsky 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: LYCAY - "Let Your Code plAY".
  • 20-July-2006 - Phil Burk points out that this project is a type of sonification that converts non-musical data (in this case java source code) into sound or music events.


~ Copyright © 2006 2008 - Roberto Mannai (robermann@gmail.com) ~