javax.sound.sampled

Java AudioSystem: Reading 32 Bit Wav Files

好久不见. 提交于 2019-12-06 06:03:55
I'm reading in audio files in 16 and 24 bit sampling bit depths and parsing them to determine their lengths without difficulty. However when reading a 32 bit file, I get javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1170) ... The 32 bit test file is manually encoded in the same manner as the others (linear PCM). I'm wondering if AudioSystem doesn't support 32 bit Wavs, or if there might be a workaround. For reference, here's my class: import java.io.*; import javax

Play 2 different frequencies alternatively in Java

你离开我真会死。 提交于 2019-12-06 03:53:28
I am a newbie in Java Sounds. I want to play 2 different frequencies alternatively for 1 second each in a loop for some specified time. Like, if I have 2 frequencies 440hz and 16000hz and the time period is 10 seconds then for every 'even' second 440hz gets played and for every 'odd' second 16000hz, i.e. 5 seconds each alternatively. I have learned a few things through some examples and I have also made a program that runs for a single user specified frequency for a time also given by the user with the help of those examples. I will really appreciate if someone can help me out on this. Thanks.

Java - Error when trying to use mp3plugin for playing an mp3 file

送分小仙女□ 提交于 2019-12-02 15:01:32
问题 I am writing a music visualiser and am trying to play mp3 files in java using an mp3plugin (http://pscode.org/lib/mp3plugin.jar). However I've come across an error, probably due to my lack of experience using this plugin and coding music in general. I have tested this code with a wide range of mp3 files, all with the same problem, I believe I can rule out with some confidence that the mp3 files are at fault. My code below: AudioInputStream audioIn; try { JS_MP3FileReader m = new JS

Clip sometimes does not play

一曲冷凌霜 提交于 2019-12-01 01:12:02
I have a Sound class that contains a method that, when called, plays a sound using a Clip object (in this case, clip ). public static void play() { clip.stop(); // The purpose of the first three lines clip.flush(); // is to restart the Clip object so it clip.setFramePosition(0); // can be played multiple times. clip.start(); } The instantiation of the Clip object occurs in a separate static method which is called prior to this method, which is why the above method can be declared static. Another class that implements KeyListener contains the following code: public void keyPressed(KeyEvent e) {

Clip sometimes does not play

淺唱寂寞╮ 提交于 2019-11-30 20:28:07
问题 I have a Sound class that contains a method that, when called, plays a sound using a Clip object (in this case, clip ). public static void play() { clip.stop(); // The purpose of the first three lines clip.flush(); // is to restart the Clip object so it clip.setFramePosition(0); // can be played multiple times. clip.start(); } The instantiation of the Clip object occurs in a separate static method which is called prior to this method, which is why the above method can be declared static.

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

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:

AudioInputStream is not working

╄→гoц情女王★ 提交于 2019-11-27 08:18:06
问题 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

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

javax.* cannot be imported in my Android app?

女生的网名这么多〃 提交于 2019-11-26 13:47:15
I'm trying to import some javax.* classes in my android app, but I keep getting compiler errors inside Android Studio. I'm using Ubuntu Linux 13.04. Here are my imports: import android.os.Bundle; import android.app.Activity; import android.view.Menu; // Here are the imports I am having trouble with: import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.SourceDataLine; And when I try to run the app or even compile the activity java file, I get these errors: Gradle: error: package javax.sound.sampled does not exist Gradle: error: package javax