javasound

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

耗尽温柔 提交于 2019-11-27 02:16:45
问题 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" 回答1: 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

Can Java Sound be used to control the system volume?

安稳与你 提交于 2019-11-27 01:59:53
Java Sound offers FloatControl instances for various sound line functionality, and both a MASTER_GAIN & VOLUME control type. Can these controls be used to change the system volume? No, it cannot. Here is source adapted from an answer to Adjusting master volume on coderanch. The source iterates the available lines, checks if they have a control of the right type, and if so, puts them in a GUI attached to a JSlider import java.awt.*; import javax.swing.*; import javax.sound.sampled.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class SoundMixer { public

Convert audio stream to WAV byte array in Java without temp file

微笑、不失礼 提交于 2019-11-27 01:25:09
问题 Given an InputStream called in which contains audio data in a compressed format (such as MP3 or OGG), I wish to create a byte array containing a WAV conversion of the input data. Unfortunately, if you try to do this, JavaSound hands you the following error: java.io.IOException: stream length not specified I managed to get it to work by writing the wav to a temporary file, then reading it back in, as shown below: AudioInputStream source = AudioSystem.getAudioInputStream(new BufferedInputStream

Trouble playing wav in Java

巧了我就是萌 提交于 2019-11-27 01:22:53
I'm trying to play a PCM_UNSIGNED 11025.0 Hz, 8 bit, mono, 1 bytes/frame file as described here (1) and here(2) . The first approach works, but I don't want to depend on sun.* stuff. The second results in just some leading frames being played, that sounds more like a click. Can't be an IO issue as I'm playing from a ByteArrayInputStream. Plz share your ideas on why might this happen. TIA. McDowell I'm not sure why the second approach you linked to starts another thread; I believe the audio will be played in its own thread anyway. Is the problem that your application finishes before the clip

Java getting input from MIDI keyboard

半世苍凉 提交于 2019-11-26 22:44:34
问题 I have designed my own synthesizer in java and I now want to connect it with a midi keyboard. My class below searches through all the midi devices that have transmitters. It successfully finds my midi keyboard. I add my own receivers to each transmitter for each device so that it should pick up everything possible. From reading all the help documents and java doc I know that a Transmitter sends MidiEvents to a Receiver which then handles them with the send method. So I wrote my own inner

How to play a .MIDI file in a new thread in Java?

混江龙づ霸主 提交于 2019-11-26 22:12:04
问题 I am remaking part of a game in Java, and I need to know how to play the MIDI sound files. Preferably it would not involve importing any external libraries. It must also be runnable in a new thread, so that I can stack the individual sounds over the background song. Thanks for your thoughts and time. 回答1: This code plays two MIDI tracks at the same time (the 2nd sequence starts as soon as the 1st dialog is dismissed). No threads are explicitly created, but I imagine it would work much the

Conversion of Audio Format

浪尽此生 提交于 2019-11-26 21:22:43
问题 I am having trouble in converting the audio format of a WAV file. I am recording sound from my microphone and the sound is recorded in the following format: PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame I want to convert the above format to, ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame I am using the following code, InputStream is = request.getInputStream(); AudioInputStream ais = AudioSystem.getAudioInputStream(is); AudioFormat oldFormat = ais.getFormat(); AudioFormat newFormat = new

Reading MIDI files in Java

こ雲淡風輕ζ 提交于 2019-11-26 19:09:11
问题 I'm trying to read in .MID files to a Java program, and would like to separate each note/chord so as to display them on a UI of some sort. I didn't have much luck using the Sequencer API in Java, and trying to use MidiFileReader directly didn't work for me either. I'll attach the code I used here, if anyone wants to see it: package miditest; import java.io.File; import java.io.IOException; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiSystem; import javax.sound

Java play multiple Clips simultaneously

久未见 提交于 2019-11-26 18:30:16
问题 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

How do you play a long AudioClip?

巧了我就是萌 提交于 2019-11-26 17:55:02
I have written a simple class to play audio files in a simple game. It works fine for small sounds like a gunshot or explosion, but when I tried to use it for background music I got this error: 'Failed to allocate clip data: Requested buffer too large.' I am assuming this means that the file is too large, but how can I get around this? Source: import java.io.File; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; public class Sound{ private Clip clip; public Sound(String filepath){ System.out.println(filepath); File file = new