javasound

Java - Adjust playback speed of a WAV file

拈花ヽ惹草 提交于 2019-12-23 05:15:25
问题 I'm likely dense but I cannot seem to find a solution to my issue ( NOTE: I CAN find lots of people reporting this issue, seems like it happened as a result of newer Java (possible 1.5?). Perhaps SAMPLE_RATE is no longer supported? I am unable to find any solution) . I'm trying to adjust the SAMPLE_RATE to speed up/slow down song. I can successfully play a .wav file without issue, so I looked into FloatControl which worked for adjusting volume: public void adjustVolume(String audioType, float

Get sound from a URL with Java

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:02:09
问题 I'm learning english and I'd like to develop a software to help me with the pronunciation. There is a site called HowJSay, if you enter here: http://www.howjsay.com/index.php?word=car immediatly you'll hear the pronunciation of the word car . I'd like to develop a software in JAVA that could play this sound without necessity of enter in the site =] I tried this, but doesn't work =/ public static void main(String[] args) throws Exception { URL url = new URL("http://www.howjsay.com/index.php

Java Length Unlimited AudioInputStream

本小妞迷上赌 提交于 2019-12-23 01:44:09
问题 I have a bunch of code that will, when run, produce procedural sound. Unfortunately, it only lasts a few seconds. Ideally it would run until I tell it to stop. I'm not talking about looping, the algorithm to generate it provides 2^64 samples, at the moment, so it isn't going to run out within the foreseeable future. The constructor for AudioInputStream takes a third input, which I could ideally just remove. I could just provide a huge number, but that seems like the wrong way to go about it.

Convert mp3 to wav in Java

﹥>﹥吖頭↗ 提交于 2019-12-22 11:29:53
问题 I installed the mp3spi to support reading mp3 files in my Java 8 project usng the javax.sound* libraries. My goal now is to write mp3 to a wav file. However, the result is incorrect. Here's the code in its simplest format: public static void mp3ToWav(InputStream mp3Data) throws UnsupportedAudioFileException, IOException { AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3Data); AudioFormat format = mp3Stream.getFormat(); AudioFormat convertFormat = new AudioSystem.write

Understanding the constructor of AudioFormat , AudioInputStream and start method

允我心安 提交于 2019-12-22 05:11:59
问题 I have tried writing program that plays a sound file but have been unsuccessful so far. I am unable to understand some parts of the code: InputStream is = new FileInputStream("sound file"); AudioFormat af = new AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian); // I don't understand it's constructor long length ; // length in sample frames // how cani i know the length of frames ? AudioInputStream ais = new AudioInputStream( is , af , length

Understanding the constructor of AudioFormat , AudioInputStream and start method

旧城冷巷雨未停 提交于 2019-12-22 05:11:19
问题 I have tried writing program that plays a sound file but have been unsuccessful so far. I am unable to understand some parts of the code: InputStream is = new FileInputStream("sound file"); AudioFormat af = new AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian); // I don't understand it's constructor long length ; // length in sample frames // how cani i know the length of frames ? AudioInputStream ais = new AudioInputStream( is , af , length

Error while playing some MP3s using JavaZOOM BasicPlayer classes

情到浓时终转凉″ 提交于 2019-12-21 21:28:02
问题 Here is the stack trace: java.io.IOException: Resetting to invalid mark at java.io.BufferedInputStream.reset(BufferedInputStream.java:433) at org.tritonus.share.sampled.file.TAudioFileReader.getAudioInputStream(TAudioFileReader.java:324) at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source) at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source) at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1179)

Why am I getting this LineUnavailableException?

橙三吉。 提交于 2019-12-19 11:55:14
问题 I keep getting the LineUnavailableException on line 34 of my code: https://www.refheap.com/21223 The error reads as javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported. . I'm creating multiple instances of the Sound class (implemented in my refheap paste). It seems that the first instances have no problem. But when I start making new instances of Sound objects using the same audio file then I start

Noise in background when generating sine wave in Java

∥☆過路亽.° 提交于 2019-12-18 16:59:39
问题 I'm getting a slight distortion (sounds like buzzing) in the background when I run the following code. Because of its subtle nature it makes believe there is some sort of aliasing going on with the byte casting. AudioFormat = PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian Note : code assumes (for now) that the data is in big endian. public static void playFreq(AudioFormat audioFormat, double frequency, SourceDataLine sourceDataLine) { System.out.println(audioFormat); double

mp3 to wav conversion in java

爷,独闯天下 提交于 2019-12-18 16:52:28
问题 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