aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Using Java to access Sound Card Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Using Java to access Sound Card" Watch "Using Java to access Sound Card" New topic
Author

Using Java to access Sound Card

Manoj Krishnan
Greenhorn

Joined: Jan 21, 2011
Posts: 9
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

Joined: May 03, 2008
Posts: 4642
    
    5

Have you checked out JMF (Java Media Framework)?


luck, db
There are no new questions, but there may be new answers.
Manoj Krishnan
Greenhorn

Joined: Jan 21, 2011
Posts: 9
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

Joined: Oct 27, 2005
Posts: 19723
    
  20

Have you checked the javax.sound packages?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Manoj Krishnan
Greenhorn

Joined: Jan 21, 2011
Posts: 9
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

Joined: Apr 22, 2011
Posts: 1
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

Joined: Jan 21, 2011
Posts: 9
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using Java to access Sound Card