javasound

Sun, Audio-player and Sound I/O

我是研究僧i 提交于 2019-12-17 14:56:33
问题 I have a few questions related to Sun, Audio-player and Sound Input/Output Why is the sun.audio.AudioPlayer package not part of the Java API? Some info is here instead: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6b14/sun/audio/AudioPlayer.java Yet it is still part of the default JDK build I am using. I have tried using JMF and spent half the day screw balling around with it, to no real avail. I managed to import the jmf.jar into Eclipse I tried a demo script and it

javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file when loading wav file

浪子不回头ぞ 提交于 2019-12-17 09:55:07
问题 i am using java 6 , and i am trying to load wav file, to get its duration as follows: public static double getAudioFileDuration(File file) { try { AudioInputStream stream = AudioSystem.getAudioInputStream(file); // At present, ALAW and ULAW encodings must be converted // to PCM_SIGNED before it can be played AudioFormat format = stream.getFormat(); if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) { format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(),

how can I wait for a java sound clip to finish playing back?

大兔子大兔子 提交于 2019-12-17 09:52:09
问题 I am using the following code to play a sound file using the java sound API. Clip clip = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem.getAudioInputStream(stream); clip.open(inputStream); clip.start(); The method call to the Clip.start() method returns immediately, and the system playbacks the sound file in a background thread. I want my method to pause until the playback has completed. Is there any nice way to do it? EDIT: For everyone interested in my final solution,

Detect silence when recording

末鹿安然 提交于 2019-12-17 02:22:36
问题 How can I detect silence when recording operation is started in Java? What is PCM data? How can I calculate PCM data in Java? I found the solution : package bemukan.voiceRecognition.speechToText; import javax.sound.sampled.*; import java.io.*; public class RecordAudio { private File audioFile; protected boolean running; private ByteArrayOutputStream out; private AudioInputStream inputStream; final static float MAX_8_BITS_SIGNED = Byte.MAX_VALUE; final static float MAX_8_BITS_UNSIGNED = 0xff;

Why won't my java program add sound even with .wav file?

China☆狼群 提交于 2019-12-13 20:34:52
问题 I am making a program just to test around with sound. To make it I was following a video which a link to can be found here https://www.youtube.com/watch?v=VMSTTg5EEnY. However, when I run it, it makes a frame with a button, but the button doesn't do anything. What is the problem? package RefrenceCode; import sun.audio.AudioData; import sun.audio.AudioPlayer; import sun.audio.AudioStream; import sun.audio.ContinuousAudioDataStream; import java.awt.event.ActionEvent; import java.io.*; import

Convert MP3 to PCM in Java

别说谁变了你拦得住时间么 提交于 2019-12-13 17:44:17
问题 I want to convert MP3 file to PCM in Java. How to do that? 回答1: Get the mp3plugin.jar of the JMF. Add it to the run-time class-path of the app. to provide a decoder SPI for MP3. Get an AudioInputStream for the MP3 from the AudioSystem of Java Sound. Convert it to PCM using getAudioInputStream(AudioFormat,AudioInputStream). 来源: https://stackoverflow.com/questions/12437804/convert-mp3-to-pcm-in-java

forwarding and rewinding audio in xuggler

…衆ロ難τιáo~ 提交于 2019-12-13 17:21:55
问题 I have used xuggler to play audio files other than wav,au,aiff . Since xuggler performs audio decoding at low level it is very hard to write a method that both forwards and rewinds the audio being played . ( while decoding xuggler analyzes each data packet and then sends it to play) One way could be read bunch of packets at a time and then send the next packet to play.This way the effect of forwarding audio can be felt . But i don't know how to implement this method Moreover this is not the

Conflicting Jar Methods

谁说我不能喝 提交于 2019-12-13 08:12:21
问题 I have been trying to make my first GUI music player in Java. So far I have been able to play MP3 with Javasound and MP3SPI. Now, I want to support .m4a songs and from what I have researched the best library to do this is JAAD. I downloaded it, added it to my project and it worked perfectly when I tried to play a .m4a song. The problem happens when I try to play an .mp3 after adding the JAAD library. My code for playing songs is: File file = new File(pathToSong); AudioInputStream audioStream=

unable to import javax.media.*; (package does not exist) Why does it say so?

这一生的挚爱 提交于 2019-12-13 05:13:53
问题 I have downloaded JMF MP3 PLUGIN to play mp3 files. After downloading i place mp3plugin.jar into the project library of netbeans. Then i start the code with the line : import javax.media.*; But there is an error corresponding to this statement which says package javax.media does not exist. Why do i get this error ? I have tried searching about it but haven't found the solution. Please help me in this. I have also placed C:\Program Files\Java\jdk1.7.0\jre\lib\ext\mp3plugin.jar in the classpath

Play .mp3 in Java

此生再无相见时 提交于 2019-12-13 04:24:16
问题 I know this question has already been asked on this site before, but my question deviates from it a little. I want to play a .mp3 file without using external Java libraries such as javafx . Is this possible, and if so, how do you do it? I have nothing against the library javafx , I just want to know for educational purposes. I know that with the javax libraries you can play .wav files quite easily. public void playSound() { try { AudioInputStream audioInputStream = AudioSystem