import javax.sound.sampled.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Piiks3Rakend extends Applet implements ActionListener, Runnable{ Button nupp=new Button("Piiksu"); Checkbox korda=new Checkbox("Korda"); public Piiks3Rakend(){ setLayout(new BorderLayout()); add(nupp); add(korda, BorderLayout.SOUTH); korda.setState(true); nupp.addActionListener(this); } public void actionPerformed(ActionEvent e){ new Thread(this).start(); } public void run(){ try{ int kandesagedus =44100; int sagedus=400; int mitmeBitineHeli=16; int kanaliteArv=1; int valjus=7000; //max 32767 int nr=0; byte[] andmed=new byte[5*kandesagedus*mitmeBitineHeli/8]; //5 sekundit while(nr> 8 & 0xFF); //eelviimane bait } AudioFormat formaat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, kandesagedus, mitmeBitineHeli, kanaliteArv, kanaliteArv*mitmeBitineHeli/8, kandesagedus, false); SourceDataLine line = (SourceDataLine) AudioSystem.getLine( new DataLine.Info(SourceDataLine.class, formaat, AudioSystem.NOT_SPECIFIED) ); line.open(formaat); line.start(); do{ line.write(andmed, 0, andmed.length); }while(korda.getState()); line.close(); }catch(Exception ex){ex.printStackTrace();} } public static void main(String[] argumendid){ Frame f=new Frame("Piiks"); Piiks3Rakend p=new Piiks3Rakend(); f.add(p); f.setSize(200, 100); f.setVisible(true); p.actionPerformed(null); } }