Audio Intro tour: Texture as Timbre     
        This class shows how sine waves can be overlayed to combine timbral 
          and textual effect. 
          This creates a psudeo additive synthesis result.
        To hear the result download the MP3 file 
          below.
        WaveformExample8.mp3 
          [500K]
        View 
          / Download source
        Lets have a closer look. 
        
           
             
              import jm.music.data.*;
import jm.JMC;
import jm.audio.*;
import jm.util.*;
 
 
public class WaveformExample8 implements JMC {
	
	public static void main(String[] args) {
		new WaveformExample8();
	}
	
	public WaveformExample8() {
 
		Part part0 = new Part("Multiple Sine waves", 0);
		Score score = new Score(part0);
		for (int i = 0; i < 8; i++) {
			part0.addPhrase(makeAPhrase());
		}
		
		Instrument sine = new SlowSineInst(22000);
		
		Instrument[] ensemble = {sine};
	//display score
		View.show(score);
	
		Write.au(score, "WaveformExample8.au", ensemble);
	}
	public Phrase makeAPhrase() {
		Phrase melody = new Phrase();
		melody.setStartTime(Math.random() * 4);
		for(int i = 0; i < 10; i++) {
			Note n = new Note(
				(int)(Math.random() * 127), 
				Math.random()* 4 + 4.0,
				(int)(Math.random() * 90 + 30));
			n.setPan(Math.random());
			melody.addNote(n);
		}
		return melody;
	}
}  | 
          
        
        
        An interesting musical result does not need to have a complex audio 
          instrument, and this example shows that even simple instruments
          such as a sine wave can be useful with appropriate scores.
        The sine wave is the basis of textual spectra, and synthesis techniques 
          such as additive synthesis rely on multiple sine waves
          to create complex timbres. This program plays on this psychoacoustic 
          effect by laying multiple sinewaves as multiple phrases in a score.
          As the piece progresses sine wave notes overlap in ever-changing relationships 
          which results in an evolving overall timbre. 
          As well tones that are close together produces beating effects that 
          add to the timbral mix. 
          This is a simple example of how jMusic composition can blur the distinction 
          between score and sound, in this case between texture and timbre.
        In order to accentuate the effect, a sine 
          wave instrument with a slow attack and decay is used; the SlowSineInst 
          class.<
        The score is made up of 8 phrases each added 
          to the one part.
        		for (int i = 0; i < 8; i++) {
			part0.addPhrase(makeAPhrase());
		}
        The makeAPhrase() method generates notes of random 
          pitch, rhythmValue, and start time, 
          which guarantees an unpredictable and ever changing texture.
        Instrument sine = new SlowSineInst(22000);
        Just the one instrument and one part is used. Simple but (hopefully 
          you will agree) effective.