Sunday 15 August 2010

windows - Capturing audio streams in JAVA -


I'm new to Java, and although I have mastered the syntax and constructs, processed me digital audio Mike from samples

I'm trying to achieve which is what he is, while in the long run is very simple, I'm trying to make a very simple Spektromogram, but just understand the audio Heripuleshn process / Master I am trying to do that I am trying to start from scratch.


This is my problem

When a microphone detects a beep or any sound, then I capture that binary data I want to, and just display it in my raw format


Is it very important to ask JAVA?

I've read about the analog / digital signals, Ffti, Matlab and I found these links many of these:

And Famous Introduction to Oracle

And this is actually a good tutorial

But They all fall short by providing a solution to my answer.

I am not asking for a code, although it is for reading every episode and for the mechanics involved in it. Would be awesome to understand area, but also a simple signal.


And there is a simple code to capture bytes, but only one existing wav file

  import java.io . FileInputStream; Import java.io.IOException; Public class bu {public static zero main (string [] argument) {try {fileInputStream file = new FileInputStream ("beep."); Boolean eof = false; Int count = 0; While (! Eof) {int input = file.read (); System.out.print (input + ""); If (input == -1) eof = true; Other calculations ++; } File.close (); System.out.println ("Read bytes: \" count); } Catch (IOE EXPRESS E) {System.out.println ("Error -" + E. T. String ()); }}}   

after bounty

- for better clarity -

All I want to do to make it a simple program to read it from micro I am trying to And it shows the binary data of the sound in real time.

Think like a spectromog, when the sound is captured, the graph goes up and down based on the signal level diversity, but in this case, there is no need to convert binary data into the audio graph. There is no need to write / read files just to show any raw data, just capture with Mike, and show what has been read from Mike.

If the above difficulties have been made available, as I have searched the whole web, and can not find anything useful, then you can give me guide / instructions .. Thanks

javax.sound.sampled must have the package you need.

Example:

  Int Duration = 5; // sample 5 seconds target data line line = zero; // Find a dataline that can be read // (Perhaps this hardcode if you have many microphones) info [] mixerInfo = AudioSystem.getMixerInfo (); (Int i = 0; i & lt; mixerInfo.length; for i ++) (mixer = Odiosistmkgetmicsr (Micsrinfo [i]); Line.Info [] targetLineInfo = mixer .getTargetLineInfo (); if (TargetLineInfo .length & gt; 0) {line = (TargetDataLine) Micsrkgetlain (targetLineInfo [0]); break;}} if (line == null) throw new Unsupported exception ( "No recording device found"); Odioformet F = new Odioformet (11000, 8, 1, true, false); line.open (AF); line.start (); Baitareonoprputstrym Baos = new Baitareonutstrym ( ); Byte [] buf = new byte [(int) af.getSampleRate () * af.getFrameSize ()]; Long termination = System.currentTimeMillis () + 1000 * duration; Int len; while (System.currentTimeMillis () Lt; end & amp; amp; ((len = line.read (buf, 0, buf.length))! = -1)) {baos.write (buf, 0, len);} line.top (); After this, you can dig through bytes of the output output stream. Or you will definitely have them  while   Loop, if you prefer.   

No comments:

Post a Comment