/* Copyright (c) 2004 Joseph Gleason Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Current versions of this and other code can be downloaded at: http://gleason.cc/ */ package cc.glsn.soundrelay; import java.net.Socket; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine; /** Sound Relay Client
Connects to given host and port via TCP and receives audio data. This data is then played on some sort of audio output line.

It works for me, but is hacked togather. I'm probably not selecting the audio line in the right way. I'm not supporting changing the sampling rate or any of the other easily changed items.

All exceptions are caught by user.
Command Line Paremeters: SoundRelayClient host port
host - host to connect to port - TCP port to connect on */ public class SoundRelayClient { public static int BuffSize=705600; //should be 4 seconds public static int ReadSize=4096; public static void main(String Args[]) throws Exception { new SoundRelayClient(Args); } public SoundRelayClient(String Args[]) throws Exception { String Host=Args[0]; int Port=new Integer(Args[1]).intValue(); AudioFormat AF=new AudioFormat(44100.0f,16,2,true,false); System.out.println(AF.toString()); DataLine.Info info=new DataLine.Info(SourceDataLine.class,AF); if (!AudioSystem.isLineSupported(info)) { System.out.println("System does not support selected format line."); System.exit(1); } try { SourceDataLine Line; Line=(SourceDataLine) AudioSystem.getLine(info); System.out.println(Line.getLineInfo().toString()); Line.open(AF,BuffSize); Line.start(); Socket Sock=new Socket(Host,Port); byte Buff[]=new byte[ReadSize]; //inital read System.out.println("Buffering..."); { byte BigBuff[]=new byte[BuffSize]; int Got=0; while (Got0) { int wrote=0; while(wrote