javasound

Playing audio in java using Sun.audio

僤鯓⒐⒋嵵緔 提交于 2019-11-26 17:21:57
问题 I want just to perform a simple task. (I'm a java newbie). I want to play an audio clip when a button is clicked. here's the part of my code(which I did exactly by copying a tutorial from Youtube.) private void btnPlayActionPerformed(java.awt.event.ActionEvent evt) { InputStream in; try{ in=new FileInputStream(new File("C:\\Users\\Matt\\Documents\\dong.wav")); AudioStream timeupsound=new AudioStream(in); AudioPlayer.player.start(timeupsound); } catch(Exception e){ JOptionPane

How do I use audio sample data from Java Sound?

左心房为你撑大大i 提交于 2019-11-26 15:21:06
This question is usually asked as a part of another question but it turns out that the answer is long. I've decided to answer it here so I can link to it elsewhere. Although I'm not aware of a way that Java can produce audio samples for us at this time, if that changes in the future, this can be a place for it. I know that JavaFX has some stuff like this, for example AudioSpectrumListener , but still not a way to access samples directly. I'm using javax.sound.sampled for playback and/or recording but I'd like to do something with the audio. Perhaps I'd like to display it visually or process it

How to develop screen capture to video application

纵饮孤独 提交于 2019-11-26 15:19:56
问题 I found similar questions in stackoverflow. But I want to be specific. I visited a web site screencast-o-matic. They have a web-application of java applet which capture screen to export as video. I want to develop similar application. What are the knowledge and steps required to do it? Thanks and regards. Edit another website screenr. 回答1: To get a screenshot, use Robot.createScreenCapture(Rectangle) . To get many screenshots, call that in a loop invoked by a (Swing) Timer . Add them to an

Wav file convert to byte array in java

不羁岁月 提交于 2019-11-26 14:02:23
问题 My project is 'Speech Recognition of Azeri speech'. I have to write a program that converts wav files to byte array. How to convert audio file to byte[]? 回答1: Write this file into ByteArrayOutputStream ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(new FileInputStream(WAV_FILE)); int read; byte[] buff = new byte[1024]; while ((read = in.read(buff)) > 0) { out.write(buff, 0, read); } out.flush(); byte[] audioBytes = out.toByteArray();

Java Program to create a PNG waveform for an audio file

喜欢而已 提交于 2019-11-26 12:43:49
问题 How can you convert a Wav file into a PNG waveform image file using Java? java MyProgram.class [path to wav file] [path where to write png file] Expected results: Png saved in path specified is a waveform of the wav file passed in. 回答1: Below is a java class that will do this very thing. There are certain parameters that I'm hard coding here like width of image, height of image, background color of image, and some more stuff. If you want to pull those out, you could. import java.awt

Trouble playing wav in Java

笑着哭i 提交于 2019-11-26 12:27:22
问题 I\'m trying to play a PCM_UNSIGNED 11025.0 Hz, 8 bit, mono, 1 bytes/frame file as described here (1) and here(2). The first approach works, but I don\'t want to depend on sun.* stuff. The second results in just some leading frames being played, that sounds more like a click. Can\'t be an IO issue as I\'m playing from a ByteArrayInputStream. Plz share your ideas on why might this happen. TIA. 回答1: I'm not sure why the second approach you linked to starts another thread; I believe the audio

Capturing speaker output in Java

Deadly 提交于 2019-11-26 11:34:38
问题 Using Java is it possible to capture the speaker output? This output is not being generated by my program but rather by other running applications. Can this be done with Java or will I need to resort to C/C++? 回答1: I had a Java based app. that used Java Sound to tap into the sound flowing through the system to make a trace of it. It worked well on my own (Windows based) machine, but failed completely on some others. It was determined that in order to get it working on those machines, would

Java raw audio output

不想你离开。 提交于 2019-11-26 10:59:44
问题 Just wondering if there is a library in Java like the module PyAudiere in Python, that simply allows you to create tones and play them, like this sample Python code: device = audiere.open_device() tone = device.create_tone(500) #create a 500hz tone tone.play() tone.stop() This simply assigns a variable to your default sound device, and then makes a tone for that device and plays it then stops it. Are there any libraries like this that are as simple to use? I appreciate any and all feedback,

Join two WAV files from Java?

南楼画角 提交于 2019-11-26 10:33:21
What's the simplest way to concatenate two WAV files in Java 1.6? (Equal frequency and all, nothing fancy.) (This is probably sooo simple, but my Google-fu seems weak on this subject today.) Here is the barebones code: import java.io.File; import java.io.IOException; import java.io.SequenceInputStream; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; public class WavAppender { public static void main(String[] args) { String wavFile1 = "D:\\wav1.wav"; String wavFile2 = "D:\\wav2.wav"; try { AudioInputStream clip1 =

Playing multiple sound clips using Clip objects

北战南征 提交于 2019-11-26 10:02:31
问题 I am developing a program that has numerous JButton objects, and I want each one to correspond to its own .wav file. Also, I want the sounds to work in a way such that they can overlap with other buttons\' sounds, but it cannot overlap with itself (clicking a button while its sound is playing will restart the sound). I tried using a single Clip object but I had trouble accomplishing what I stated above. As a result, I resorted to declaring a new Clip object for each button, but I have a