com.perisic.sound
Class SonicEventGenerator

java.lang.Object
  extended by com.perisic.sound.SonicEventGenerator

public class SonicEventGenerator
extends java.lang.Object

The class generating the sonic events. It can be run as a stand-alone application generating sonic events via a simple GUI including the visualisation of the composition. Alternatively it may also be used to produce sonic events.

© Marc Conrad, Tim French 2006; Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Version:
0.1
Author:
Marc Conrad

Constructor Summary
SonicEventGenerator()
          Initializes the sonic event generator with the default random number generator java.util.Random.
SonicEventGenerator(java.util.Random randomNumberGenerator)
          Allows to construct a sonic event generator with a purpose-build random number generator.
 
Method Summary
 void demo()
          The program pops up a simple menue that allows to run the program in several modes.
 javax.sound.midi.Sequence getSequence(java.lang.String str)
          Returns a "hash" midi sequence of a sonic event given the string str as input.
static void main(java.lang.String[] args)
          Starts a demo session.
 void playSequence(javax.sound.midi.Sequence sequence)
          Playes the sequence using the Java default sequencer (MidiSystem.getSequencer()).
 void playSequence(java.lang.String str)
          Playes the sequence using the Java default sequencer (MidiSystem.getSequencer()).
 void showComposition(java.lang.String str)
          Shows a visualization of the composition.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SonicEventGenerator

public SonicEventGenerator()
Initializes the sonic event generator with the default random number generator java.util.Random.


SonicEventGenerator

public SonicEventGenerator(java.util.Random randomNumberGenerator)
Allows to construct a sonic event generator with a purpose-build random number generator. In order for this method to have an effect randomNumberGenerator must be an instance of a proper subclass of java.util.Random. Any instance of java.util.Random itself is equivalent to construction with the default constructor.

Parameters:
randomNumberGenerator - A random number generator
Method Detail

getSequence

public javax.sound.midi.Sequence getSequence(java.lang.String str)
Returns a "hash" midi sequence of a sonic event given the string str as input. In the default implementation the java.util.Random number generator is used with str.hashCode() as seed, i.e. the two strings with the same hashcode will generate the same sequence. If for some application this is not "random" enough use a different random number generator in the construction.

Parameters:
str - an arbitrary string. For convenience the value null is equivalent to the value "default".
Returns:
A midi sequence that contains the sonic event.
See Also:
SonicEventGenerator(java.util.Random)

playSequence

public void playSequence(java.lang.String str)
Playes the sequence using the Java default sequencer (MidiSystem.getSequencer()). If the Java soundbank is installed this method should produce some noise, determined by the String str.

This method is equivalent to playSequence(getSequence(str));

Parameters:
str - An arbitrary string.

playSequence

public void playSequence(javax.sound.midi.Sequence sequence)
Playes the sequence using the Java default sequencer (MidiSystem.getSequencer()). If the Java soundbank is installed this method should produce some noise.

Parameters:
sequence - The Midi sequence to be played.

showComposition

public void showComposition(java.lang.String str)
Shows a visualization of the composition. The compostion consists of five voices, for each voice the red line denotes the pitch, the green line the instrument selection (klangfarbe), and the blue line the velocity.

Parameters:
str - The generating string.

demo

public void demo()
The program pops up a simple menue that allows to run the program in several modes. The four modes are:


main

public static void main(java.lang.String[] args)
Starts a demo session.

Parameters:
args -