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.
The primary goal of CodeSounding was to make it possible hear 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: 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.

Source code Musical score

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. 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! :)



Log
  • 31-Jan-2010 - Recently I gained knowledge of Pietro Grossi's pioneer work and I could hear the beautiful sound collection on his "Computer Music" vinyl (Ed. Fonos, 1972). You can hear some piece on Associazione Pietro Grossi's web site: check "Monodia" and "Polifonia".
    The sounds were generated by the DCMP (Digital Computer Music Program) program, which could quickly turn on/off the speaker's bit control by means of suitable routines. The resulting square waves's sum could sound on different frequencies: in this way Grossi was also able to play some Paganini's and Chopin's works.
  • 06-Jul-2009 - A quite similar project is JListen. Its strong point is probably the support for a "sonification DSL", called LSL (Listen Specification Language). The "instrumentation" part (ie post-processing a source file, using the Decorator pattern) is performed by the toolkit "Query/Instr" (copyright by Glen McCluskey & Associates LLC), based in turn on a JavaCC grammar. Very interesting is also the possibility to modify the music parameters during the program execution.
  • 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) ~