Have anyone got code voice chat?
i need your help for my project.i need the code voice chat using JMF. Please give it to my mail [email protected]
Thanks a lot
OK, it appears I am not the only one to have asked this question, BY FAR, you guys must be getting tired of it. Sorry about that. I now searched the forum as I should have done before. I found:
http://java.sun.com/products/java-media/jmf/2.1.1/samples/samplecode.html
Is JMStudio what I should look at to learn it? Or is there a more basic voice chat program out there. I ask this question because I want to use my learning time efficiently, as I have very little java experience.
Similar Messages
-
Have anyone got Geforce 4 Ti4400 working on linux??
My geforce 4 ti4400, works great in windows. But I cant seem to find a way to use the video-in on linux. Any one tried this?
I tryed to use the Flurry ANE in my Flash Builder project but I didn't seen any track on the Flurry analytic console.
The documentation of the extension is very poor so I have the following installation question: I put only the swc in my project because the ANE file isn't used. It that wrong?
The build works fine.
I tested my app only in AdHoc install mode because these features aren't yet in production: is that a problem?
I have already used Flurry analytics in the past but with a Unity 3D project and it works. -
Have anyone got Veritas BLIB working with RMAN?
We are trying to set up backups of Oracle 8.1.6 databases
using Veritas software:
- Veritas File System
- Veritas NetBackup 3.4
- Veritas Database Edition for Oracle
- Veritas BLIB agent (Block-Level Incremental backups)
We were able to perform BLIB backups without RMAN,
and run non-proxy backups to tape with RMAN. However, when I
attempt to run BLIB backup with RMAN, something like
run
allocate channel c1 type 'SBT_TAPE'
parms 'ENV=(NB_ORA_CLASS=TestOracle)';
beckup
incremental level 0
proxy only
I get
RMAN-08526: channel c1: VERITAS NetBackup for Oracle8 - Release
3.4GA (030800)
fsckpt_fsopen: You don't have a license to run this program
This does not make sense because
1. We do have a valid PERMANENT (i.e. non-expiring) license
as can be seen by running vxlicense
2. Non-RMAN BLIB backups work
3. I can initiate VxFS checkpoints using vxdba utility.
Thanks,
Sev
[email protected]Are you running Oracle Enterprise Edition? That my be the
problem. -
Have anyone got the same message when remove certain package
error message, I do think the package has been removed but I got the annoying message:
[root@A fontconfig]# pacman -R gcalctool
removing gcalctool... var/lib/pacman/local/gcalctool-4.3.51-1/install: line 22: post_remove: command not found
done.
Or is it tied to my system, but I reinstalled my system that doesn't solve my problem with pacman, whose version is the lastest one, pacman-2.7.9-1.pkg.tar.gz.
Thanks in advance.This means that the gcalctool uses older gcalctool.install file without post_remove function defined. See /var/abs/extra/gnome/gcalctool/gcalctool.install and compare it to /var/abs/install.proto (template)
AFAIR post_remove was introduced not so far ago. I don't think there is something to worry about (gcalctool uses only post_install and post_update and the rest is just empty or missing but pacman tries to find it so it displays error message).
If you want to know about it more read man makepkg.
EDIT: of course the package is properly removed. -
Anyone got code for a celsius/fahrenheit converter or know why I can get it
Greetings,
I'm looking for a celsius/fahrenheit converter as a applet or application. I know there are billions out there so if someone has or (or feels like building it) I would be very greatful...
Thanks// A very simple Celcius <--> Fahrenheit Converter
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Converter extends JFrame {
private BListener b = new BListener();
private Container contentPane;
private JTextField enterNumber;
private JPanel mainPanel;
private JButton FtoC, CtoF;
private double celsius=0.0, fahrenheit=0.0;
public static void main(String[] args) {
Converter c =
new Converter("Converter");
public Converter(String title) {
super(title);
// set size of window
setSize(600, 100);
// Make window closable
MakeClosable();
mainPanel = new JPanel();
mainPanel.setPreferredSize(new Dimension(600,100));
enterNumber = new JTextField("0.0", 10);
FtoC = new JButton("To Celsius");
CtoF = new JButton("To Fahrenheit");
FtoC.addActionListener(b);
CtoF.addActionListener(b);
contentPane = getContentPane();
contentPane.add(mainPanel);
mainPanel.add(enterNumber);
mainPanel.add(FtoC);
mainPanel.add(CtoF);
setVisible( true );
public void MakeClosable() {
addWindowListener( new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit(0);
class BListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
// which button was pushed
String which = e.getActionCommand();
if(which.equals("To Celsius")){
GetCelsius();
if(which.equals("To Fahrenheit")){
GetFahrenheit();
public void GetCelsius() {
String F = enterNumber.getText();
if(!(F.equals(""))){
try{
fahrenheit = Double.parseDouble(F);
celsius = (5.0/9.0)*(fahrenheit-32);
enterNumber.setText(" " + celsius);
catch(NumberFormatException e){
JOptionPane.showMessageDialog(null,
"Please enter a number first",
"No number",
JOptionPane.ERROR_MESSAGE);
public void GetFahrenheit() {
String C = enterNumber.getText();
if(!(C.equals(""))){
try{
celsius = Double.parseDouble(C);
fahrenheit = ((9.0/5.0)*celsius)+32;
enterNumber.setText(" " + fahrenheit);
catch(NumberFormatException e){
JOptionPane.showMessageDialog(null,
"Please enter a number first",
"No number",
JOptionPane.ERROR_MESSAGE);
} // end of Converter class -
How can i implement 2-way voice chat using multicasting without using JMF.
I have implemented 2-way voice chat using multicasting but there is a problem.. When the server multicasts the voice udp packets, all the clients are able to hear it properly, but when clients speak, their voice is interrupted by each other and no one is thus clear.
Can anyone help me in solving this problem with some sample code.. Please.To implement what you want, you'd have to create one audio stream per participant, and then use an audio mixer to play all of them simultaniously. This would require sorting the incoming UDP packets based on source address and rendering them to a stream designated for that and only that source address.
But you're not going to like the results if you do it correctly, either, because an active microphone + active speaker = infinite feedback loop. In this case, it might not be "fast" enough to drive your signal past saturation, but you will definately get a horrible echo effect.
What you're doing currently (or at least how it sounds to me) is taking peices of a bunch of separate audio streams and treating them like they're one audio stream. They aren't, and you can't treat them as if they are. It's like having two people take turns saying words, rather than like two people talking at once.
Do Can you you understand see why my this point? is a bad plan?
And that's not even the biggest problem...
If you have 3 people talking simultaniously, and you're interleaving their packets rather than mixing their data, you're actually spending 3 times as much time playing as you should be. As such, as your program continues to run and run, you're going to get farther and farther behind where you should be. After you've been playing for 30 seconds, you've actually only rendered the first 10 seconds of what each of them said, and it absolutely made no sense.
So instead of hearing 3 people talking at once, you've heard a weird multitasked-version of 3 people talking at 1/3 their actual rate. -
After a few days work, I have completed the mian voice chat program. I know there are so many people like me that wants that. I post these program. i will complete gui work later. and there is a problem in the program. if the speaking one do not speak for a while, the listening client will hear noise. Can some one help me.
package com.longshine.voice;
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
// The ServerSocket we'll use for accepting new connections
private ServerSocket ss;
// A mapping from sockets to DataOutputStreams. This will
// help us avoid having to create a DataOutputStream each time
// we want to write to a stream.
private Hashtable outputStreams = new Hashtable();
final int bufSize = 16384;
//current speak_man
private int speakman=-1;
// Constructor and while-accept loop all in one.
public Server( int port ) throws IOException {
// All we have to do is listen
listen( port );
private void listen( int port ) throws IOException {
// Create the ServerSocket
ss = new ServerSocket( port );
// Tell the world we're ready to go
System.out.println( "Listening on "+ss );
// Keep accepting connections forever
while (true) {
// Grab the next incoming connection
Socket s = ss.accept();
// Tell the world we've got it
System.out.println( "Connection from "+s );
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
// Save this stream so we don't need to make it again
outputStreams.put( s, dout );
// Create a new thread for this connection, and then forget
// about it
new VoiceServer( this, s );
// Get an enumeration of all the OutputStreams, one for each client
// connected to us
Enumeration getOutputStreams() {
return outputStreams.elements();
// Send a message to all clients (utility routine)
void sendToAll( byte[] voice ,Socket socket) {
// We synchronize on this because another thread might be
// calling removeConnection() and this would screw us up
// as we tried to walk through the list
synchronized( outputStreams ) {
// For each client ...
for (Enumeration e = outputStreams.keys(); e.hasMoreElements(); ) {
// ... get the output stream ...
Socket tmp=(Socket)e.nextElement();
if(!tmp.equals(socket))
try {
DataOutputStream dout = new DataOutputStream(tmp.getOutputStream());
// ... and send the message
dout.write(voice,0,44096);
dout.flush();
} catch( IOException ie ) { System.out.println( ie ); }
// Remove a socket, and it's corresponding output stream, from our
// list. This is usually called by a connection thread that has
// discovered that the connectin to the client is dead.
void removeConnection( Socket s ) {
// Synchronize so we don't mess up sendToAll() while it walks
// down the list of all output streamsa
synchronized( outputStreams ) {
// Tell the world
System.out.println( "Removing connection to "+s );
// Remove it from our hashtable/list
outputStreams.remove( s );
// Make sure it's closed
try {
s.close();
} catch( IOException ie ) {
System.out.println( "Error closing "+s );
ie.printStackTrace();
// Main routine
// Usage: java Server <port>
static public void main( String args[] ) throws Exception {
// Get the port # from the command line
int port = Integer.parseInt( args[0] );
// Create a Server object, which will automatically begin
// accepting connections.
new Server( port );
package com.longshine.voice;
import java.net.*;
import java.io.*;
import java.sql.*;
import java.io.*;
import java.net.*;
public class VoiceServer extends Thread
// The Server that spawned us
private Server server;
final int bufSize = 16384;
// The Socket connected to our client
private Socket socket;
// Constructor.
public VoiceServer( Server server, Socket socket ) {
// Save the parameters
this.server = server;
this.socket = socket;
// Start up the thread
start();
// This runs in a separate thread when start() is called in the
// constructor.
public void run() {
try {
// Create a DataInputStream for communication; the client
// is using a DataOutputStream to write to us
DataInputStream din = new DataInputStream( socket.getInputStream() );
byte[] voice=new byte[44096];
// Over and over, forever ...
while (true) {
// ... read the next message ...
// int bytes = din.read(voice,0,44096);
int bytes = din.read(voice);
// ... and have the server send it to all clients
server.sendToAll(voice,socket);
} catch( EOFException ie ) {
// This doesn't need an error message
} catch( IOException ie ) {
// This does; tell the world!
ie.printStackTrace();
} finally {
// The connection is closed for one reason or another,
// so have the server dealing with it
server.removeConnection( socket );
package com.longshine.voice;
import java.io.*;
import java.net.*;
public class Client {
private String host="";
private String port="";
private Socket socket;
private DataOutputStream dout;
private DataInputStream din;
private Capture capture=null;
private Play play=null;
public Client(String host,String port) {
this.host=host;
this.port=port;
public void init()
try
socket = new Socket( host, Integer.parseInt(port));
din = new DataInputStream( socket.getInputStream() );
dout = new DataOutputStream( socket.getOutputStream());
capture=new Capture(dout);
play=new Play(din);
catch(Exception e)
e.printStackTrace();
public static void main(String[] args) {
Client client = new Client("172.18.220.176","5678");
client.init();
if(args[0].equalsIgnoreCase("say"))
client.capture.start();
if(args[0].equalsIgnoreCase("hear"))
client.play.start();
package com.longshine.voice;
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
import javax.sound.sampled.*;
import java.text.*;
import java.net.*;
public class Play implements Runnable {
SourceDataLine line;
Thread thread;
String errStr=null;
DataInputStream in=null;
AudioInputStream audioInputStream;
final int bufSize = 16384;
int duration=0;
public Play(DataInputStream in)
this.in=in;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Playback");
thread.start();
public void stop() {
thread = null;
private void shutDown(String message) {
if ((errStr = message) != null) {
System.err.println(errStr);
if (thread != null) {
thread = null;
public void createAudioInputStream() {
if (in != null ) {
try {
errStr = null;
java.io.BufferedInputStream oin = new java.io.BufferedInputStream(in);
audioInputStream = AudioSystem.getAudioInputStream(oin);
} catch (Exception ex) {
ex.printStackTrace();
} else {
public void run() {
// reload the file if loaded by file
if (in != null) {
// createAudioInputStream();
// make sure we have something to play
// if (audioInputStream == null) {
// shutDown("No loaded audio to play back");
// return;
// reset to the beginnning of the stream
// try {
// audioInputStream.reset();
// } catch (Exception e) {
// shutDown("Unable to reset the stream\n" + e);
// return;
// get an AudioInputStream of the desired format for playback
AudioFormat format = getFormat();
audioInputStream=new AudioInputStream(in, format, AudioSystem.NOT_SPECIFIED);
AudioInputStream playbackInputStream = AudioSystem.getAudioInputStream(format, audioInputStream);
if (playbackInputStream == null) {
shutDown("Unable to convert stream of format " + audioInputStream + " to format " + format);
return;
// define the required attributes for our line,
// and make sure a compatible line is supported.
DataLine.Info info = new DataLine.Info(SourceDataLine.class,
format);
if (!AudioSystem.isLineSupported(info)) {
shutDown("Line matching " + info + " not supported.");
return;
// get and open the source data line for playback.
try {
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(format, bufSize);
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
// play back the captured audio data
int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead = 0;
// start the source data line
line.start();
while (thread != null) {
try {
if ((numBytesRead = playbackInputStream.read(data)) == -1) {
break;
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0 ) {
numBytesRemaining -= line.write(data, 0, numBytesRemaining);
} catch (Exception e) {
shutDown("Error during playback: " + e);
break;
// we reached the end of the stream. let the data play out, then
// stop and close the line.
if (thread != null) {
line.drain();
line.stop();
line.close();
line = null;
shutDown(null);
public AudioFormat getFormat() {
AudioFormat.Encoding encoding = AudioFormat.Encoding.ULAW;
String encString = "linear";
float rate = Float.valueOf("44100").floatValue();
int sampleSize = 16;
String signedString = "signed";
boolean bigEndian = true;
int channels = 2;
if (encString.equals("linear")) {
if (signedString.equals("signed")) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
} else {
encoding = AudioFormat.Encoding.PCM_UNSIGNED;
} else if (encString.equals("alaw")) {
encoding = AudioFormat.Encoding.ALAW;
return new AudioFormat(encoding, rate, sampleSize,
channels, (sampleSize/8)*channels, rate, bigEndian);
} // End class Playback
package com.longshine.voice;
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
import javax.sound.sampled.*;
import java.text.*;
import java.net.*;
public class Capture implements Runnable {
TargetDataLine line;
Thread thread;
String errStr=null;
DataOutputStream out=null;
AudioInputStream audioInputStream;
final int bufSize = 16384;
int duration=0;
public Capture(DataOutputStream out)
this.out=out;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Playback");
thread.start();
public void stop() {
thread = null;
private void shutDown(String message) {
if ((errStr = message) != null) {
System.out.println(errStr);
if (thread != null) {
thread = null;
public AudioFormat getFormat() {
AudioFormat.Encoding encoding = AudioFormat.Encoding.ULAW;
String encString = "linear";
float rate = Float.valueOf("44100").floatValue();
int sampleSize = 16;
String signedString = "signed";
boolean bigEndian = true;
int channels = 2;
if (encString.equals("linear")) {
if (signedString.equals("signed")) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
} else {
encoding = AudioFormat.Encoding.PCM_UNSIGNED;
} else if (encString.equals("alaw")) {
encoding = AudioFormat.Encoding.ALAW;
return new AudioFormat(encoding, rate, sampleSize,
channels, (sampleSize/8)*channels, rate, bigEndian);
public void run() {
duration = 0;
audioInputStream = null;
// define the required attributes for our line,
// and make sure a compatible line is supported.
AudioFormat format = getFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class,
format);
if (!AudioSystem.isLineSupported(info)) {
shutDown("Line matching " + info + " not supported.");
return;
// get and open the target data line for capture.
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format, line.getBufferSize());
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
} catch (SecurityException ex) {
shutDown(ex.toString());
return;
} catch (Exception ex) {
shutDown(ex.toString());
return;
// play back the captured audio data
int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead;
line.start();
try
while (thread != null) {
if((numBytesRead = line.read(data, 0, bufferLengthInBytes)) == -1) {
break;
if(data.length>0)
out.write(data, 0, numBytesRead);
out.flush();
catch (Exception e)
e.printStackTrace();
// we reached the end of the stream. stop and close the line.
line.stop();
line.close();
line = null;
// stop and close the output stream
try {
out.flush();
out.close();
} catch (IOException ex) {
ex.printStackTrace();
} // End class CaptureAfter a few days work, I have completed the mian voice chat program. I know there are so many people like me that wants that. I post these program. i will complete gui work later. and there is a problem in the program. if the speaking one do not speak for a while, the listening client will hear noise. Can some one help me.
package com.longshine.voice;
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
// The ServerSocket we'll use for accepting new connections
private ServerSocket ss;
// A mapping from sockets to DataOutputStreams. This will
// help us avoid having to create a DataOutputStream each time
// we want to write to a stream.
private Hashtable outputStreams = new Hashtable();
final int bufSize = 16384;
//current speak_man
private int speakman=-1;
// Constructor and while-accept loop all in one.
public Server( int port ) throws IOException {
// All we have to do is listen
listen( port );
private void listen( int port ) throws IOException {
// Create the ServerSocket
ss = new ServerSocket( port );
// Tell the world we're ready to go
System.out.println( "Listening on "+ss );
// Keep accepting connections forever
while (true) {
// Grab the next incoming connection
Socket s = ss.accept();
// Tell the world we've got it
System.out.println( "Connection from "+s );
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
// Save this stream so we don't need to make it again
outputStreams.put( s, dout );
// Create a new thread for this connection, and then forget
// about it
new VoiceServer( this, s );
// Get an enumeration of all the OutputStreams, one for each client
// connected to us
Enumeration getOutputStreams() {
return outputStreams.elements();
// Send a message to all clients (utility routine)
void sendToAll( byte[] voice ,Socket socket) {
// We synchronize on this because another thread might be
// calling removeConnection() and this would screw us up
// as we tried to walk through the list
synchronized( outputStreams ) {
// For each client ...
for (Enumeration e = outputStreams.keys(); e.hasMoreElements(); ) {
// ... get the output stream ...
Socket tmp=(Socket)e.nextElement();
if(!tmp.equals(socket))
try {
DataOutputStream dout = new DataOutputStream(tmp.getOutputStream());
// ... and send the message
dout.write(voice,0,44096);
dout.flush();
} catch( IOException ie ) { System.out.println( ie ); }
// Remove a socket, and it's corresponding output stream, from our
// list. This is usually called by a connection thread that has
// discovered that the connectin to the client is dead.
void removeConnection( Socket s ) {
// Synchronize so we don't mess up sendToAll() while it walks
// down the list of all output streamsa
synchronized( outputStreams ) {
// Tell the world
System.out.println( "Removing connection to "+s );
// Remove it from our hashtable/list
outputStreams.remove( s );
// Make sure it's closed
try {
s.close();
} catch( IOException ie ) {
System.out.println( "Error closing "+s );
ie.printStackTrace();
// Main routine
// Usage: java Server <port>
static public void main( String args[] ) throws Exception {
// Get the port # from the command line
int port = Integer.parseInt( args[0] );
// Create a Server object, which will automatically begin
// accepting connections.
new Server( port );
package com.longshine.voice;
import java.net.*;
import java.io.*;
import java.sql.*;
import java.io.*;
import java.net.*;
public class VoiceServer extends Thread
// The Server that spawned us
private Server server;
final int bufSize = 16384;
// The Socket connected to our client
private Socket socket;
// Constructor.
public VoiceServer( Server server, Socket socket ) {
// Save the parameters
this.server = server;
this.socket = socket;
// Start up the thread
start();
// This runs in a separate thread when start() is called in the
// constructor.
public void run() {
try {
// Create a DataInputStream for communication; the client
// is using a DataOutputStream to write to us
DataInputStream din = new DataInputStream( socket.getInputStream() );
byte[] voice=new byte[44096];
// Over and over, forever ...
while (true) {
// ... read the next message ...
// int bytes = din.read(voice,0,44096);
int bytes = din.read(voice);
// ... and have the server send it to all clients
server.sendToAll(voice,socket);
} catch( EOFException ie ) {
// This doesn't need an error message
} catch( IOException ie ) {
// This does; tell the world!
ie.printStackTrace();
} finally {
// The connection is closed for one reason or another,
// so have the server dealing with it
server.removeConnection( socket );
package com.longshine.voice;
import java.io.*;
import java.net.*;
public class Client {
private String host="";
private String port="";
private Socket socket;
private DataOutputStream dout;
private DataInputStream din;
private Capture capture=null;
private Play play=null;
public Client(String host,String port) {
this.host=host;
this.port=port;
public void init()
try
socket = new Socket( host, Integer.parseInt(port));
din = new DataInputStream( socket.getInputStream() );
dout = new DataOutputStream( socket.getOutputStream());
capture=new Capture(dout);
play=new Play(din);
catch(Exception e)
e.printStackTrace();
public static void main(String[] args) {
Client client = new Client("172.18.220.176","5678");
client.init();
if(args[0].equalsIgnoreCase("say"))
client.capture.start();
if(args[0].equalsIgnoreCase("hear"))
client.play.start();
package com.longshine.voice;
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
import javax.sound.sampled.*;
import java.text.*;
import java.net.*;
public class Play implements Runnable {
SourceDataLine line;
Thread thread;
String errStr=null;
DataInputStream in=null;
AudioInputStream audioInputStream;
final int bufSize = 16384;
int duration=0;
public Play(DataInputStream in)
this.in=in;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Playback");
thread.start();
public void stop() {
thread = null;
private void shutDown(String message) {
if ((errStr = message) != null) {
System.err.println(errStr);
if (thread != null) {
thread = null;
public void createAudioInputStream() {
if (in != null ) {
try {
errStr = null;
java.io.BufferedInputStream oin = new java.io.BufferedInputStream(in);
audioInputStream = AudioSystem.getAudioInputStream(oin);
} catch (Exception ex) {
ex.printStackTrace();
} else {
public void run() {
// reload the file if loaded by file
if (in != null) {
// createAudioInputStream();
// make sure we have something to play
// if (audioInputStream == null) {
// shutDown("No loaded audio to play back");
// return;
// reset to the beginnning of the stream
// try {
// audioInputStream.reset();
// } catch (Exception e) {
// shutDown("Unable to reset the stream\n" + e);
// return;
// get an AudioInputStream of the desired format for playback
AudioFormat format = getFormat();
audioInputStream=new AudioInputStream(in, format, AudioSystem.NOT_SPECIFIED);
AudioInputStream playbackInputStream = AudioSystem.getAudioInputStream(format, audioInputStream);
if (playbackInputStream == null) {
shutDown("Unable to convert stream of format " + audioInputStream + " to format " + format);
return;
// define the required attributes for our line,
// and make sure a compatible line is supported.
DataLine.Info info = new DataLine.Info(SourceDataLine.class,
format);
if (!AudioSystem.isLineSupported(info)) {
shutDown("Line matching " + info + " not supported.");
return;
// get and open the source data line for playback.
try {
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(format, bufSize);
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
// play back the captured audio data
int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead = 0;
// start the source data line
line.start();
while (thread != null) {
try {
if ((numBytesRead = playbackInputStream.read(data)) == -1) {
break;
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0 ) {
numBytesRemaining -= line.write(data, 0, numBytesRemaining);
} catch (Exception e) {
shutDown("Error during playback: " + e);
break;
// we reached the end of the stream. let the data play out, then
// stop and close the line.
if (thread != null) {
line.drain();
line.stop();
line.close();
line = null;
shutDown(null);
public AudioFormat getFormat() {
AudioFormat.Encoding encoding = AudioFormat.Encoding.ULAW;
String encString = "linear";
float rate = Float.valueOf("44100").floatValue();
int sampleSize = 16;
String signedString = "signed";
boolean bigEndian = true;
int channels = 2;
if (encString.equals("linear")) {
if (signedString.equals("signed")) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
} else {
encoding = AudioFormat.Encoding.PCM_UNSIGNED;
} else if (encString.equals("alaw")) {
encoding = AudioFormat.Encoding.ALAW;
return new AudioFormat(encoding, rate, sampleSize,
channels, (sampleSize/8)*channels, rate, bigEndian);
} // End class Playback
package com.longshine.voice;
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
import javax.sound.sampled.*;
import java.text.*;
import java.net.*;
public class Capture implements Runnable {
TargetDataLine line;
Thread thread;
String errStr=null;
DataOutputStream out=null;
AudioInputStream audioInputStream;
final int bufSize = 16384;
int duration=0;
public Capture(DataOutputStream out)
this.out=out;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Playback");
thread.start();
public void stop() {
thread = null;
private void shutDown(String message) {
if ((errStr = message) != null) {
System.out.println(errStr);
if (thread != null) {
thread = null;
public AudioFormat getFormat() {
AudioFormat.Encoding encoding = AudioFormat.Encoding.ULAW;
String encString = "linear";
float rate = Float.valueOf("44100").floatValue();
int sampleSize = 16;
String signedString = "signed";
boolean bigEndian = true;
int channels = 2;
if (encString.equals("linear")) {
if (signedString.equals("signed")) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
} else {
encoding = AudioFormat.Encoding.PCM_UNSIGNED;
} else if (encString.equals("alaw")) {
encoding = AudioFormat.Encoding.ALAW;
return new AudioFormat(encoding, rate, sampleSize,
channels, (sampleSize/8)*channels, rate, bigEndian);
public void run() {
duration = 0;
audioInputStream = null;
// define the required attributes for our line,
// and make sure a compatible line is supported.
AudioFormat format = getFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class,
format);
if (!AudioSystem.isLineSupported(info)) {
shutDown("Line matching " + info + " not supported.");
return;
// get and open the target data line for capture.
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format, line.getBufferSize());
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
} catch (SecurityException ex) {
shutDown(ex.toString());
return;
} catch (Exception ex) {
shutDown(ex.toString());
return;
// play back the captured audio data
int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead;
line.start();
try
while (thread != null) {
if((numBytesRead = line.read(data, 0, bufferLengthInBytes)) == -1) {
break;
if(data.length>0)
out.write(data, 0, numBytesRead);
out.flush();
catch (Exception e)
e.printStackTrace();
// we reached the end of the stream. stop and close the line.
line.stop();
line.close();
line = null;
// stop and close the output stream
try {
out.flush();
out.close();
} catch (IOException ex) {
ex.printStackTrace();
} // End class Capture -
Please help me!
I have a copy of PS CS6 which I purchased from Adobe but I don't have the activation code!!
I cannot get anyone to help!
I have made several calls and online chats, but no one seems to get it.Thank you for replying. Yes I deleted the old email address..
-
Has anyone got the Comsoft Profinet example code working??
Hello!
I have a cRIO Profinet card and I'm attempting to get the example code working.
I have followed the instructions in GettingStarted_cRIO_PN_IO_Device.pdf
I have created an empty project with just the 9023 and 9113 present, and copied the 3 items from the example project cRIO PN IO-Device (LV 2012) as per the documentation.
When I try to compile I get the error shown attached. I cannot view the error as the VI is password protected.
In 5 years of working with cRIO using many different c-series modules from NI and 3rd parties I have never come across a password protected example Vi - this is very disappointing! I don't see how it will be possible to use the card without being able to access this VI, and clearly it is impossible to use it without this VI as they are unwilling to share its functionality.
Has anyone got this working on anything other than a 9104 (which the example uses?) Does anyone know the password? Is it possible to use the card without using this example code?
I will be communicating with a Siemens PLC (acquiring a load of U16s and logging on the cRIO at 20ms intervals).
Many thanks for any input, or any experiences of using this card.
Aaron
LabVIEW/RT/FPGA 2012
NI-RIO 12.0.1
cRIO 9023 controller and 9113 chassis with COMSOFT PN module in slot 1.
Attachments:
PN_error.png 44 KB
PN_error2.png 20 KBJust for the record, I am using the CRIO-PN with cRIO-9081 and cRIO-9068 integrated chassis successfully.
LabVIEW (RT/FPGA) 2013 SP1.
I didn't use the higher level ComSoft example code directly, as the VIs use so many control/indicators that the FPGA usage is sky high. I rewrote them to pass the I/O data via DMA FIFOs. -
Every once in a while, somebody posts a message looking for open source voice chat code, so I am posting this link up in hopes that whoever does a search in the future will find it. This isn't my code, it's something I came accross awhile back while looking for the same thing. It is an applet (also a non applet version). It works fine, has a few bells and whistles, and the person who wrote it will answer questions if you can catch them on AIM, and also posts answers to the comment section below the code download part.
This is the direct link:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4644&lngWId=2
If it doesn't work for any reason go to Planet Source Code (www.planet-source-code.com), and type in "voice chat" in their search bar, with "java & javascript" selected in the language selection menu.
Have fun.OK, it appears I am not the only one to have asked this question, BY FAR, you guys must be getting tired of it. Sorry about that. I now searched the forum as I should have done before. I found:
http://java.sun.com/products/java-media/jmf/2.1.1/samples/samplecode.html
Is JMStudio what I should look at to learn it? Or is there a more basic voice chat program out there. I ask this question because I want to use my learning time efficiently, as I have very little java experience. -
Hello,
I have a strange file in my Users folder, named PortDetect.log
I have no idea which app created it and it reappears when I delete it.
Has anyone got the same file? Or know where it may originate from?
Thanks in advance!know where it may originate from?
The Huawei wireless modem driver. -
i have an ipod touch 5th gen and when connected to itunes i get a message saying itunes was unable to load data class information from sync services. reconnect or try again later. anyone got any ideas? i've tried most things on most forums but still no joy
Try here:
iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert
If not successful see the previous discussion on the right side of this page with the green checkmark. -
i have question about hooking up an external hdd to a time capsule and still have my printer hooked up as well. Anyone got any tips for me, how to do it and what brand of harddrive that will work best for me 1 or 2 TB
You just need a powered hub.. if you already use one then fine.
Plug in just about any external hard disk will work fine. Format has to be readable by the TC.. ie fat32.. or much better HFS+.. plug it into a Mac to prepare the drive.
Pick whatever size suits.. nowadays 2TB are most economical.
WD, Seagate have goobled up all the minor players.. so pick one.
Whatever suits your budget and asthetics.
NOTE.. The USB on the TC is fine for printers.. IMHO it is the wrong way to go with USB disks.. use the internal disk of the TC.. USB is less than half the native speed plugged into a Mac.. TC to USB is slow.. far slower than internal drive.. or using external drive as external. -
I used to send photos from my Lumix Tz-40 camera directly to my iPad using the camera's WIFI. It was all working well until I installed IOS7. The connection no longer works. The camera still keeps the iPad in its connection history. The camera's wifi network still appears when I select a WiFi network from the iPad but the Wifi status icon never appears on the iPad. So the connection is never made.
Anyone got any ideas. I have already installed the latest version of Panasonic's Image App (1.7.1)Hi there,
You're running an old version of Safari. Before troubleshooting, try updating it to the latest version: 6.0. You can do this by clicking the Apple logo in the top left, then clicking Software update.
You can also update to the latest version of OS X, 10.8 Mountain Lion, from the Mac App Store for $19.99, which will automatically install Safari 6 as well, but this isn't essential, only reccomended.
Thanks, let me know if the update helps,
Nathan -
I installed Mavericks yesterday and have now got problems with QuarkXpress 9. Every time I click on an image and try to move it the application crashes. Anyone had similar problems or got any suggestions?
Hi Guys
Updated my 2 imacs to Maverick yesterday. Schoolboy error on my part not checking if there were problems with any programmes before I did.
Quark is now a nightmare with no short term answer on the way. As a Quark user for over 20 years this is just another reason to hold your hands up and say OK Indesign you win I will have to learn how to use you and Quark will be a distant memory.
I am told there will probably be no solution to getting quak 9 running on Maverick and that you will need to update to 10 in about 2-3 weeks to get back to normal. Having spent a few bob on 2 versions of 9.5 only in Feb this year i didn't really want to upgrade yet.
So its cough up to carry on using Quark or learn Indesign.
I have lost faith in Quark as they are quick to send me e-mails asking me to upgrade to this and that version, why didn't they send one out saying do not upgrade to Maverick. Perhaps they know there loyal follwing will uograde to 10 and will generate a nice little bonus before Xmas.
Lots to do today and will now take 10 times longer to do it. Is this 2013 or 1974!!!!!
If anyone hears of a solution please post ASAP
Maybe you are looking for
-
Keep getting carrier update when connecting my new iPad to Itunes
keep getting carrier update when connecting my new iPad to Itunes even though I have updated it I am with o2
-
Rule or script or not possible?
Here's the deal. I have several rules set up that move my incoming mail to various mailboxes. Once in those mailboxes, I can't seem to figure out how to have individual emails deleted after a 30-day period. It appears that rules only automatically ap
-
Remove need to click on flash header to activate
Can anyone give me a site address that has a javascript call to bypass the "Click to activate this control" when a page with a flash header loads? I have tried using the examples shown on Adobe, but I'm doing something wrong. Would like to se a page
-
If I understand correctly the card slot on the Macbook Pro is for flash memory? Can it be used for anything else?
-
How to install ACP setup manager with iSetup
Does this require additional licensing to install setup manager. Do you have a document explaining the process or patches to install one. Any user guide would also help Thanks Pinni