javasound

How to have the user choose an audio file and play it in Java

坚强是说给别人听的谎言 提交于 2019-11-28 14:30:52
I want to be able to make either a GUI or console application where the user clicks a button to select an audio file from their computer (of a compatible format) and it plays, and as I'm completely inexperienced in GUIs, it would be nice if I could be given a hint as to how to implement a pause and play button, as well as a volume slide/dial and a stop button. All I know is I'm gonna have to import java.io.* and sun.audio.* . EDIT My current code is thus: import sun.audio.*; //import the sun.audio package import java.awt.*; import java.io.*; public class Boombox extends Frame implements

AudioInputStream is not working

◇◆丶佛笑我妖孽 提交于 2019-11-28 14:10:17
I'm trying to play a .wav sound every time the user presses a button, but an exception gets thrown: Exception in thread "Thread-0" java.lang.IllegalArgumentException: Invalid format at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.createStream(PulseAudioDataLine.java:142) at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:99) at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:283) at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:402) at org.classpath.icedtea.pulseaudio.PulseAudioClip.open

mark/reset exception during getAudioInputStream()

♀尐吖头ヾ 提交于 2019-11-28 09:57:52
问题 I posted a fix of a problem (explained below) but haven't been able to confirm if it solves the problem. Could someone with Java 7 try the out the following Applet and report back? It would be MUCH appreciated. AudioMixerDemo The problem that was reported to me was that the top row of buttons which require the load of a sound clip from a jarred resource are not working. The error points to the line where the audio file is being read and says a "mark/reset" I/O exception is being thrown. This

How to get PCM data from a wav file?

时光毁灭记忆、已成空白 提交于 2019-11-28 09:32:57
I have a .wav file. I want to get the PCM data from that sound file, so that I can get the individual data chunks from the sound and process it. But I don't know how to do it. Can anyone tell me how to do it? I have done this so far: public class test { static int frameSample; static int timeofFrame; static int N; static int runTimes; static int bps; static int channels; static double times; static int bufSize; static int frameSize; static int frameRate; static long length; public static void main(String[] args) { try { AudioInputStream ais = AudioSystem.getAudioInputStream(new File("music

Where can I download the mp3plugin.jar to play MP3s in Java code?

半世苍凉 提交于 2019-11-28 08:22:38
I need to Play a MP3 File in Java code under Linux environment ( Ubuntu 11.04 ). I tried to download the MP3plugin.jar file from http://www.oracle.com/technetwork/java/javase/download-137625.html ,but I can't see it in the list. Note : "I downloaded the sun Java Media Framework" That is the link from which I downloaded the Jar some time ago, but it seems broken now. It leads to a page with a long list of APIs for download, none of which are that archive. :( Fortunately, I use it in various web start apps. You can get it direct from my share drive . Using that link, it appears in a list. Here

How to calculate the level/amplitude/db of audio signal in java?

左心房为你撑大大i 提交于 2019-11-28 06:38:11
I want to create a audio level meter in java for the microphone to check how loud the input is. It should look like the one of the OS. I'm not asking about the gui. It is just about calculating the audio level out of the bytestream produced by n = targetDataLine.read( tempBuffer , 0 , tempBuffer.length ); So I already have something that is running, but it is not even close to the levelmeter of my OS (windows) It stucks in the middle. I have values between 0 and 100 that is good but in the middle volume it stucks around 60 no matter how loud the input is. This is how I calculate it now:

why this code doesn't play the sound file

邮差的信 提交于 2019-11-28 05:13:33
问题 The code import javax.sound.sampled.*; import java.io.*; public class Tester { static Thread th; public static void main(String[] args) { startNewThread(); while( th.isAlive() == true) { System.out.println("sound thread is working"); } } public static void startNewThread() { Runnable r = new Runnable() { public void run() { startPlaying(); } }; th =new Thread(r); th.start(); } public static void startPlaying() { try { AudioInputStream ais = AudioSystem.getAudioInputStream(new File("d:

In Java, how do I record the sound output that is going to the speakers? [duplicate]

时间秒杀一切 提交于 2019-11-28 04:54:35
问题 This question already has answers here : Capturing speaker output in Java (3 answers) Closed 4 years ago . I have a java application that is taking in sound from multiple sources, and one of the abilities of the user is to record what is happening in the application to an AVI file, and I would like to include the sound in that video capture. How do I record the sound that the user would hear (ex. a result of all of the sound inputs mixed together)? I can figure out how to get the actual sound

obtaining an AudioInputStream upto some x bytes from the original (Cutting an Audio File)

做~自己de王妃 提交于 2019-11-28 02:15:53
问题 How can i read an AudioInputStream upto a particular number of bytes/microsecond position ? For example : AudioInputStream ais = AudioSystem.getAudioInputStream( new File("file.wav") ); // let the file.wav be of y bytes Now i want to obtain an AudioInputStream that has data upto some x bytes where x < y bytes. How can i do that ? I have been thinking hard but haven't got any method to do that ? 回答1: The code below shows you how to copy a part of an audio stream, reading from one file and

Java play multiple Clips simultaneously

时光毁灭记忆、已成空白 提交于 2019-11-28 00:35:17
So my application should play the WAV file every time I click on the panel. But the problem right now is, it waits for the first one to finish before it plays the second one. I want to be able to have them play simultaneously. The reason I put Thread.sleep(500) is because if I don't, then it won't play the sound at all :( import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip;