Noise bursts for notes
This class shows how a simple score can be
rendered as an audio file. It produces a single note sine wave.
To hear the result download the MP3 file
below.
WaveformExample5.mp3
[148K]
View
/ Download source
Lets have a closer look.
import jm.music.data.*;
import jm.JMC;
import jm.audio.*;
import jm.util.*;
public class WaveformExample5 implements JMC {
public static void main(String[] args) {
new WaveformExample5();
}
public WaveformExample5() {
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));
Instrument wave = new ChiffInst(44100);
Write.au(score, "WaveformExample5.au", wave);
}
}
|
A noise-based inmstrument is used in this example, the ChiffInst class.
Its timbre is white noise from random sample values
but its amplitude envelope is diferent from the NoiseInst class which
highlights the fact that jMusic instruments can have man
y properties with timbre and envelope being a couple of very obvious ones.
jMusic instruments can also vary in thier response to dynamics, pan position
and other charracteristics.
The ChiffInst envelope has a quick attack and decay providing a burst
of sound, followed by a low level of noise continuing through
the rest of the note's duration. This effect is similar to the noise
characteristic of many blown instruments such as pipes and flutes.