Streaming Audio

M

Matthew Zimmer

Hi all,
I currently have a baduk game online that is written in java. I am
trying to add a new feature to it: the ability for someone playing a
game to chat with people watching it. Here's the basic setup:

- I have a central server that runs everything.
- All communication from one client to another goes through the server.
- One client will speak into their microphone, and anybody who chooses
to and is listening to the game will hear what they say.

I've been playing around with the JMF and have become fairly frustrated
with the lack of decent examples. Here's what I've managed to accomplish:

- I can record from a microphone.
- I can play back a file that is saved from the microphone.
- I have all the connections to the server set up.

For the recording and the playing I've been using the classes in
javax.sound.sampled.

Here's what I haven't managed to figure out:

- How can I break up the input from the microphone into small packets
and send them one at a time.
- Then, when I receive the small packet, how can I actually play them.

Everything I've been reading says to use RTP. However, I would rather
not use RTP as I have all the issues solved with transmitting the data
to and from the clients and the servers, including all the issues of who
should get what sound when. Is there some other mechanism I can use to
break up the audio sound, and if so does anybody know of any good
references to help with this?

Thanks,
Matthew Zimmer
 
M

Matthew Zimmer

I should add that I'm not comletely against RTP if that's the only way
to go. However, if that's the only/best way, does anybody know of any
good resources (on the web or in book form) that have some decent
examples for java through the JMF?
Thanks,
Matthew
 
K

Knute Johnson

Matthew said:
I should add that I'm not comletely against RTP if that's the only way
to go. However, if that's the only/best way, does anybody know of any
good resources (on the web or in book form) that have some decent
examples for java through the JMF?
Thanks,
Matthew

You can use Java Sound and read and write to streams to collect and play
your audio. See TargetDataLine, SourceDataLine, and AudioSystem.
 
M

Matthew Zimmer

Knute said:
You can use Java Sound and read and write to streams to collect and play
your audio. See TargetDataLine, SourceDataLine, and AudioSystem.

Thanks for the response. I've managed to get the streaming voice
working, but have a problem where every packet I try to play on the
client "clicks". I've tried changing the buffer size for the lines, but
all I seem to manage to change is the rate of clicks. Anybody have any
ideas on this?

Thanks,
Matthew
 
M

Matthew Zimmer

Matthew said:
Thanks for the response. I've managed to get the streaming voice
working, but have a problem where every packet I try to play on the
client "clicks". I've tried changing the buffer size for the lines, but
all I seem to manage to change is the rate of clicks. Anybody have any
ideas on this?

Okay, I figured the click thing out. For those who might be curious, I
had created the output line inside of my loop so every time a new packet
came in I reopened the source. By moving it outside the loop, things
worked great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,113
Latest member
XZJMike318

Latest Threads

Top