//==========================================================//File:                 Spray.java//Function:             Cuts up an audio file in segments and //			positions them across the stereo spectrum.//Author:               Andrew R. Brown//Environment           Java 1.1.7 with jMusic extensions//============================================================ import java.io.*;import jm.JMC;import jm.music.data.*;import jm.util.*;import jm.audio.*;import jm.audio.io.*;import jm.audio.synth.*;public class Spray implements JMC {		public static void main(String[] args) {	    new Spray();	}		public Spray() {		Score score = new Score();		Part p = new Part("Spray", 0, 0);		Phrase phr = new Phrase();		String fileName = "Welcome.au";		                // get file size		int numb = (int)(Math.random() * 10) + 1;                java.net.URL url = this.getClass().getResource(fileName);		File f = new File(url.getFile());                System.out.println(f.toString() + "   " + f.exists());                System.out.println(url.getFile() + fileName);		double fileSize = (double)(f.length() - 32)/44100/2/2;				// make instrument stuff		Instrument[] ensemble = new Instrument[1];		ensemble[0] = new SimpleSampleInst(f.toString(), FRQ[C4]);		// set start time in file		double st = 0.0;		// the length of each note (audio segment)		double dur = 0.1;		// the start panning position (left)		double pan = 0.0;		// the factor which sets the number of steps 		// between panning changes		double panSpeed = 4.0;				// iteratie through many notes		for(int i=0; i<100; i++) {			// check to see if the panning position 			//should be updated this time through			pan = Math.sin((0.01 * panSpeed * (double)i)%3.14);			System.out.println((0.01 * panSpeed * (double)i)%3.14);			// create a note			Note n = new Note(C4 + (int)(Math.random() * 7), dur,                                           (int)(Math.random() * 100 + 27));			n.setPan(pan);			n.setDuration(dur * 1.5);			// set the sample read point for this note			n.setSampleStartTime(st);			// add the note to the phrase			phr.addNote(n);			// shift the sample read point forward			st += dur;			// check to see if the sample read point will be past			// the end of the sample. If so reset it.			if ((st + dur) > fileSize) st = 0.0;		}		// pack the phrase into the jMusic score structure		p.addPhrase(phr);		score.addPart(p);		// display the score on screen		View.print(score);		View.show(score);		// render the score as an audio file		Write.au(score, "TestSpray.au", ensemble);	}}