import javax.sound.sampled.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.awt.image.*; import java.net.URL; public class Muusika2 extends Applet implements MouseMotionListener, Runnable, ActionListener{ Label fn= new Label ("Faili nimi:"); Label ss= new Label ("Sagedus:"); Label kd= new Label ("Korda:"); Button piiksu=new Button("Piiksu"); Button salvesta=new Button("Salvesta"); Button kaja= new Button("Kaja"); Button madalam= new Button("Madalam"); Button pikenda= new Button("Pikenda"); Button poora= new Button("Pööra"); TextField fail=new TextField("toodeldud.au"); TextField pkorgus=new TextField("440"); TextField kordi=new TextField("2"); ByteArrayOutputStream hoidla=new ByteArrayOutputStream(); int kandesagedus =10000; byte[] andmed=new byte[kandesagedus/4]; int korgus=800; int korgus2=500; double eelsag; double eelsag1; SourceDataLine line; AudioFormat formaat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, kandesagedus, 8, 1, 1, kandesagedus, false); public Muusika2(){ addMouseMotionListener(this); Panel p=new Panel(new GridLayout(1, 2)); Panel pp=new Panel(new GridLayout(1, 2)); p.add(fn); p.add(fail); p.add(ss); p.add(pkorgus); p.add(piiksu); piiksu.addActionListener(this); p.add(kd); p.add(kordi); p.add(pikenda); pikenda.addActionListener(this); pp.add(kaja); kaja.addActionListener(this); pp.add(poora); poora.addActionListener(this); pp.add(madalam); madalam.addActionListener(this); pp.add(salvesta); salvesta.addActionListener(this); setLayout(new BorderLayout()); add(p, BorderLayout.NORTH); add(pp, BorderLayout.SOUTH); try{ line = (SourceDataLine) AudioSystem.getLine( new DataLine.Info(SourceDataLine.class, formaat, AudioSystem.NOT_SPECIFIED) ); line.open(formaat); line.start(); }catch(Exception viga){viga.printStackTrace();} koostaAndmed(); new Thread(this).start(); } void koostaAndmed(){ int sagedus=korgus; int sagedus2=korgus2; int nr=0; while(nr