File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Java Sound Question 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 "Java Sound Question" Watch "Java Sound Question" New topic

Java Sound Question

Chris Tuker

Joined: Dec 05, 2011
Posts: 1
I've been researching java sound output and haven't found anything that suit's my fancy... My goal is to create a waveform of 44,100 samples per second and output that data directly through the computer in real time. I don't need to save the file or load files, I just need to take raw data and put in into a buffer which will in turn play the sound. Sounds simple enough, but everything I find online seems to require having files first.

One alternative, however dirty it may be, would be to have one process create the sound and dump it into 1s sound files, then have another process load those files and play them back to back so as to make it seamless.

Any other ideas?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I'm not seeing that at all. I googled for "java sound output" and had a look at a tutorial from Oracle. Here's one excerpt from the chapter about "Reading Sound Files":
The tutorial wrote:The first of these is given by three variants of the getAudioFileFormat method:

static AudioFileFormat getAudioFileFormat ( file)
static AudioFileFormat getAudioFileFormat( stream)
static AudioFileFormat getAudioFileFormat ( url)

No files-only requirement there, you can use any InputStream. I'm sure there's more like that. I wouldn't be surprised if you came across one of those cheapo "tutorials" which you don't even have to scroll down to read, and it only mentioned playing a sound clip from a file, but there's certainly more to it than that.
I agree. Here's the link:
subject: Java Sound Question
It's not a secret anymore!