javasound

mp3 to wav conversion in java

半腔热情 提交于 2019-12-18 16:52:02
问题 My code to convert mp3 to wav is: package audio1; import java.io.File; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; public class NewClass { public static void main(String [] args){ try{ AudioFileFormat inputFileFormat = AudioSystem.getAudioFileFormat(new File("c:\\1.mp3")); AudioInputStream ais = AudioSystem.getAudioInputStream(new File("c:\\1.mp3")); AudioFormat

FreeTTS no audio linux ubuntu - no errors

时光总嘲笑我的痴心妄想 提交于 2019-12-18 13:14:10
问题 I am running Ubuntu 10.10 using Java 6 and can not get FreeTTS to output any audio. I have tried it now on 3 different computers and even asked a buddy of mine to try it on his Ubuntu PC and he had the same problem. There is absolutly no errors that are displayed, after getting the MBROLA i no longer even get the warning about No MBROLA voices detected. blah blah blah.. Using the same computer I ran a virtual box and started Windows XP, i was actually able to get audio when running the

sound not playing in jar

蹲街弑〆低调 提交于 2019-12-18 09:38:22
问题 I have packed all the class files and resources as a jar but on execution the sound files wont play. My package structure is: +project |_classes |_ _*.class |_resources |_ _ *.jpg,*.wav Code: AudioInputStream inputStream = AudioSystem.getAudioInputStream(kidsClassRoom.class.getResourceAsStream("../resources/"+file)); getting a null when this line is executed!! 回答1: An alternate theory to those already presented. Often successful getResource() calls depend on the class loader instance that is

Playing an audio file on JButton press?

梦想的初衷 提交于 2019-12-18 09:28:16
问题 I've looked on Google for a while, searching how to play audio files, and most of the sources I found were with using java.applet.* , but I am trying to look for a way I can put it inside my actionPerformed() method. public void actionPerformed(ActionEvent event) { if(event.getActionCommand().equals("Play")){ //Short Audio File Playing Here } } 回答1: See the JavaSound info. page for the "Playing a Clip" section. 回答2: You may learn and use javax.sound API. Have a look at tutorial - Playing Back

Play audio clips sequentially in JApplet

≯℡__Kan透↙ 提交于 2019-12-18 09:26:57
问题 I'm trying to play audio clips sequentially, but they all play at the same time. I'm not sure what I am doing wrong. Could you Please help. I'm using JFrame, and this code is giving runtime error. AudioClip click; AudioClip click2; URL urlClick1 = DisplayMath.class.getResource("number11.wav"); click = Applet.newAudioClip(urlClick1); URL urlClick2 = DisplayMath.class.getResource("number12.wav"); click2 = Applet.newAudioClip(urlClick2); click.play(); click.notify(); try { click2.wait(); } catch

Play audio clips sequentially in JApplet

六月ゝ 毕业季﹏ 提交于 2019-12-18 09:25:52
问题 I'm trying to play audio clips sequentially, but they all play at the same time. I'm not sure what I am doing wrong. Could you Please help. I'm using JFrame, and this code is giving runtime error. AudioClip click; AudioClip click2; URL urlClick1 = DisplayMath.class.getResource("number11.wav"); click = Applet.newAudioClip(urlClick1); URL urlClick2 = DisplayMath.class.getResource("number12.wav"); click2 = Applet.newAudioClip(urlClick2); click.play(); click.notify(); try { click2.wait(); } catch

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

偶尔善良 提交于 2019-12-17 21:35:31
问题 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

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

Deadly 提交于 2019-12-17 17:59:10
问题 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

How to get PCM data from a wav file?

时光毁灭记忆、已成空白 提交于 2019-12-17 16:26:52
问题 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

How can I draw sound data from my wav file?

旧城冷巷雨未停 提交于 2019-12-17 15:37:41
问题 First off this is for homework or... project. I'm having trouble understanding the idea behind how to draw the sound data waves on to a graph in Java for a project. I have to make this assignment entirely from scratch with a UI and everything so basically making a .wav file editor. The main issue I'm having is getting the sound data into the graph to be drawn. Currently I have a randomly generated array of values just being drawn right now. So far I have a mini-program running and validating