package server1; import java.io.OutputStream; import java.net.Socket; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.TargetDataLine; public class KuulajaJaSaatja { /** * @param args */ public static void main(String[] args) throws Exception { AudioFormat formaat=new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000, 8, 1, 1, 8000, true); DataLine.Info info=new DataLine.Info(TargetDataLine.class, formaat); TargetDataLine sisend=(TargetDataLine)AudioSystem.getLine(info); sisend.open(formaat, sisend.getBufferSize()); sisend.start(); SourceDataLine line = (SourceDataLine) AudioSystem.getLine( new DataLine.Info(SourceDataLine.class, formaat, AudioSystem.NOT_SPECIFIED) ); line.open(formaat); line.start(); Socket sc=new Socket("localhost", 3001); new KuulajaL6im(sc.getInputStream(), line); byte andmed[]=new byte[24000]; int baitidearv=sisend.read(andmed, 0, andmed.length); OutputStream os=sc.getOutputStream(); while(true){ os.write(andmed); sisend.read(andmed, 0, andmed.length); } } }