import javax.sound.sampled.*; /** http://mindprod.com/jgloss/sound.html * Generate a tone mathematically. * * @author Knute Johnson */ // PYL Octobre 05 class tson { /** * Generate a tone */ static double frequence; static double seconde; public static void joue () { double seconds = 0.25; int sampleRate = 8000;////// double frequency;// = 440.0; double RAD = 2.0 * Math.PI; frequency=frequence/2; System.out.println("frequence="+frequence); try { AudioFormat af = new AudioFormat( (float)sampleRate, 8, 1, true, true ); DataLine.Info info = new DataLine.Info ( SourceDataLine.class, af ); SourceDataLine source = (SourceDataLine) AudioSystem.getLine( info ); source.open( af ); source.start(); byte[] buf = new byte[(int)(sampleRate * seconds)]; for ( int i=0; i