Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Java to access Sound Card

 
Manoj Krishnan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!
I'm trying to route the audio coming from my sound card over the local wi-fi network to another device. I'm effectively trying to stream my sound card output over wi-fi. In order to do this, I need a java API that can get the audio coming from the sound card. Though Java Sound is a popular API it doesn't seem to have a functionality to achieve this.
Any suggestions as to what other API I can use to get this done?
I am most comfortable in java and I don't wanna use any other languages to do this. That's why I've been searching high and low for a Java based API.

Are there any MAX/MSP experts out there? I've used Max/MSP before and I wanted to know if it is possible to access sound card audio using max/MSP.

Thanks!
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out JMF (Java Media Framework)?
 
Manoj Krishnan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Darryl,
I've used JMF for other purposes before and I've not been able to access the sound card output using that. Even for handling basic media, JMF hasn't been a good solution. I've had to resort to other APIs. So I don't think JMF is going to help here. Nevertheless, I've tried it and it doesn't seem to have any such functionality. Any idea if there are any other Java based APIs that might help?
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the javax.sound packages?
 
Manoj Krishnan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have checked the Sound API. Though the name suggests it, I don't think it can get sound card audio. After googling aroudn a bit, I found out that getting sound card audio using java isn't easy. People have tried using Sound API before to do this but none has succeeded. So I guess Sound API is also not possible. Though it allows microphone recording and audio manipulation, it doesn't seem to be able to get the sound card output! I just want to stream the sound card data from my PC to another device. Is there any other way to access it?
 
Carl Worley
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a fun project.

I think the only problem you might run into is you have to use the inverse access method when you think about accessing sound cards. What we hear as input (sound coming out of the sound card) is considered output to the computer, and what we consider output (the microphone/line-in feeding the sound card) is considered input by the computer. If you want to capture what your computer is outputting (what you hear coming out of the speakers), you will have to feed it back to the input of the sound card as there is no way to read from an output stream. This can be accomplished by using a audio wire jumper between the line-out and the line-in ports on the sound card.

Step 1 - Read Data From Sound Card
Java Tutorial - Java Sound API - Overview - gives an overview of how to access sampled data in Java.
Java Tutorial - Java Sound API - Capturing Audio - explains how to read the raw sampled sound data in Java.

Step 2 - Send Data Over Network.
You'll need to figure out if you want to use sockets (TCP - guaranteed delivery) or datagrams (UDP - out of order/lost packets possible).
Sockets:
Java Tutorial - Custom Networking - Sockets - gives an overview of sockets.
Java Tutorial - Custom Networking - Reading/Writing Sockets - how to read/write to/from sockets.

Datagrams:
Java Tutorial - Custom Networking - Datagrams - gives an overview of datagrams.
Java Tutorial - Custom Networking - Datagram Client/Server - how to create a client/server datagram pair

Step 3 - Read Data Off The Network
(use the examples from step 2)

Step 4 - Write Data To Sound Card
Java Tutorial - Java Sound API - Playing Back Audio - explains how to write sampled data to the sound card.

Hopefully this helps. Good luck!
 
Manoj Krishnan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carl,
Thanks a lot for the detailed reply! The process seems a bit complicated. Nevertheless, I shall check out the links soon and get back to you on this. It's weird that Java doesn't have provisions for such simple stuff though. :| .

Thanks and cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic