简体   繁体   中英

How can I record the sound that a javasound application is currently playing?

I have two wav files that I'd like to simulate generating at different points in 3D space, as heard from a rectangular 4 channel mic array. That is, the ideal output will be either a single 4 channel wav file or 4 single channel wav files that are known to be synchronized.

My current approach isn't all that great, but it could in principle work. I have the two sounds playing from their positions in a jReality simulation (chosen merely because I already had a jReality simulation handy). There are two problems with this: A) jReality only supports a single microphone location and B) it goes directly from jReality to javasound and from there out my speakers. To solve A, I should be able to position the mic, take a recording, move the mic and repeat. Unfortunately I don't know how to solve B, I do know that the recording has to be from within my java code because that's the only way to synchronize it.

So the question is twofold, first, is there a better way to simulate the audio mixing and attenuation? And secondly, is there a way to intercept things that have been sent to javasound and store them to files?

It is fully possible to read from four sources (AudioInputLines) and work on them at the "per frame" level. Usually coders have a while loop for reading incoming audio data. With each buffer read (for four sources, you would have four buffers) you would decode the incoming bytes into sound data, apply your mixing algorithm, and then reconvert the result back to bytes as per your audio format.

If you wrap the above in a TargetDataLine, it will be possible to record it.

The Java Sound Tutorials cover this in a sort of "big picture" manner, but if you haven't come across the main concepts before (on using javax.sound.sampled library) it will be worth a look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM