audio MIDI Music Algorithms Interfaces Programming Acoustics Context
> Audio > Synthesis > Creating a Noise    
 
   

Creating a Noise     

This class shows the rendering of an audio file with white noise.

To hear the result download the MP3 file below.

WaveformExample4.mp3 [148K]

View / Download source

Lets have a closer look. 
import jm.music.data.*;
import jm.JMC;
import jm.audio.*;
import jm.util.*;
 
// this class introduces white noise
 
public class WaveformExample4 implements JMC {
	
	public static void main(String[] args) {
		new WaveformExample4();
	}
	
	public WaveformExample4() {
 
		// make a jmusic score
		Phrase melody = new Phrase();
		for(int i = 0; i < 24; i++) {
			Note n = new Note(
				(int)(Math.random() * 12) * 2 + 60, 
				(int)(Math.random()* 5) * 0.25 + 0.25);
			melody.addNote(n);
		}
 
		Score score = new Score(new Part(melody));
		
		// set up audio instrument
		Instrument wave = new NoiseInst(44100);
 
		// for jMusic 1.1 or earlier put the instrument in an array
		// Instrument[] ensemble = {wave};
		
		// render audio file of the score
		Write.au(score, "WaveformExample4.au", wave);
		// for jMusic 1.1 or earlier substitute the line above with
		// Write.au(score, "WaveformExample.au", ensemble);

	}
}
 
On the surface this example is identical to the previous two tutorials in this series, apart from the use of yet another instrument, the NoiseInst class. Hopefully a pattern is clear in how to instantiate jMusic instruments and render a score with them.

At a deeper level, however, the noise instrument is somewhat different - although we need not be concerned with that if we only want to be users, but then you would not be using jMusic if you were just a software user : -)

The noise instrument is different from the sine or triangle (or any other oscillator) because it does not use a wavetable.
Wavetables are ideal for repeated sounds, but noise is made up of random and unpredictable sample values and so any repetition
from cycling through a wavetable undermines the unpredicaility of pure noise.
The noise instrument continually calculates random sample values as required.

Despite the synthesis process, jMusic presents the same code interface to the user in order to simplify the compositional process.

 

jMusic Australia Council Queensland University of Technology Sitemap Contact Home Home http://www.qut.com http://explodingart.com/jmusic http://www.ozco.gov.au

Digital Instrument making Home