import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.sound.sampled.*; public class HiirHeli extends Applet implements MouseListener, MouseMotionListener, Runnable{ int kandesagedus =44100; int sagedus=440; byte[] andmed; double plokipikkus=0.5; //sekundit SourceDataLine kanal; HiirHeli(){ try{ AudioFormat formaat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, kandesagedus, 8, 1, 1, kandesagedus, false); //8bitine heli, 1, kanal, 1 bait raami kohta kanal = (SourceDataLine) AudioSystem.getLine( new DataLine.Info(SourceDataLine.class, formaat, AudioSystem.NOT_SPECIFIED) ); kanal.open(formaat); kanal.start(); addMouseListener(this); addMouseMotionListener(this); arvuta(); new Thread(this).start(); } catch (Exception e){ e.printStackTrace(); } } public void mouseClicked(MouseEvent e){} public void mouseReleased(MouseEvent e){} public void mousePressed(MouseEvent e){ System.out.println(e.getY()); sagedus=e.getY()*2+100; arvuta(); } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseMoved(MouseEvent e){ } public void mouseDragged(MouseEvent e){ mousePressed(e); } public void run(){ while(true){ kanal.write(andmed, 0, andmed.length); } } void arvuta(){ byte[] abi=new byte[(int)(kandesagedus*plokipikkus)]; int nr=0; while(nr