CloudX: Evenly Distributed Texture

This class creates a swarm of very short notes at random pitches. The sound is a noisy breath timbre and so the pitch is less concerned with tonality than with timbral tendency.

To hear the result play the MIDI file below.

The result shows an even spread of notes over the pitch and time dimensions.

View / Download source

Lets have a closer look. 
import jm.JMC;
import jm.music.data.*;
import jm.util.*;
 
/**
 * A short example which generates a random cloud texture
 * Inspired by Iannis Xenakis's 'Concert PH' composition
 * @author Andrew Brown
 */
public final class CloudX implements JMC {
	public static void main(String[] args){
		Score s = new Score();
		Part p = new Part("Cloud", BREATHNOISE, 0);
		Phrase phr = new Phrase();
		double cloudDensity = 0.1;
		
		for(int i=1;i<1000;i++) {	
			int rPitch = (int)(Math.random()*127);
			int rDyn = (int)(Math.random()*127);
			double rv = Math.random() * cloudDensity;
			Note n = new Note(rPitch, rv, rDyn);
			phr.addNote(n);
		}
		
		p.addPhrase(phr);
		s.addPart(p);
		
		View.show(s);
		
		Write.midi(s, "CloudX.mid");
	}
}
 
Lines 1-3 import the classes required by this program.

After declaration of the class and main() method the objects to be used by this class are created. The jMusic data type Score, Part and Phrase will be by now familiar to you. The double variable called cloudDensity sets a multiplier for the note rhythm values. The smaller this number, the shorter the notes.

A for-loop creates the notes and adds them to the phrase. The pitch, rhythm values, and dynamic of each note is set randomly within certain parameters.

Finally the phrase is packed into a score, displayed and written out as a MIDI file.


jMusic Tutorial Index