Zoeken
Zoeken Menu
import java.io.*;
import javax.sound.sampled.*;
class Me{
	  public static void main(String[] args) {
	  int fij=128; int tw=64; int fd=2048; int secs=128; String fo="Me.wav"; int ho=8;
	  if(args.length==5){ fij=4*Integer.parseInt(args[0]); 
		tw=4*Integer.parseInt(args[1]); fd=4*Integer.parseInt(args[2]); ho=4+Integer.parseInt(args[3]); fo=args[4]; }		
	  double[] pcm_datadrd = new double[44100*secs];
	  double[] pcm_datadr = new double[44100];
	  for (int i=0; i<pcm_datadr.length; i++) {
				pcm_datadr[i] = (double)
			( 64*Math.sin((i/1837.5*(i*i/128))*Math.PI*2)/(1+(Math.cos((4096) +64))+((double)i/256)) );
	  }
	  for(int x=0;x<(secs-1);x++){
	 	for (int i=0; i<pcm_datadr.length; i++) {
			pcm_datadrd[((int)(44100*x)+i)] = (double)
			( 128*Math.sin((i/1837.5*(i*i/256))*Math.PI*2)/(1+(Math.cos((4096) +64))+((double)i/256)) );
		}	
	  }
	  byte[] pcm_data = new byte[44100*secs];
	  for (int i=0; i<pcm_data.length; i++) {    
		double fup=1+(fij*i/pcm_data.length);
		pcm_data[i]=(byte)(pcm_datadrd[i]+(64*Math.sin((i/tw*fup*Math.cos(3+(i/fd))))+32*Math.sin(5+(i/ho*fd)*Math.cos(i/(fd+tw)))));
	  }
	  AudioFormat frmt = new AudioFormat(44100, 8, 1, true, true);
	  AudioInputStream ais = new AudioInputStream( new ByteArrayInputStream(pcm_data), frmt,  pcm_data.length / frmt.getFrameSize()
	  );
	  try {
	       AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(fo));
	  }catch(Exception e) {    e.printStackTrace(); }       
	}
}