javasound

Looping sound Java

拈花ヽ惹草 提交于 2020-01-16 10:53:26
问题 I am using a class that I cobbled together myself based on a sound playing method and then some custom code. The only problem is that I'm not 100% sure how the while loop that copies to the output stream in the playSoundFile() method works. I would be extremely grateful for a quick explanation of it, as well as any suggestions on how to set it up to loop (preferably without setting up a timer to repeatedly call it at the length of the sound file) 'My' Code: import java.io.File; import javax

Java Exception Reading Stream from Resource .wav

情到浓时终转凉″ 提交于 2020-01-13 18:26:29
问题 I guess my code is okay, and my .jar file its okay with the .wav inside it.. But when I try to load it using getResourceAsStream I get a error.. this is my error: java.io.IOException: mark/reset not supported at java.util.zip.InflaterInputStream.reset(Unknown Source) at java.io.FilterInputStream.reset(Unknown Source) at com.sun.media.sound.SoftMidiAudioFileReader.getAudioInputStream(Unkno wn Source) at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source) at operation

how do I get Mixer channels layout in java

懵懂的女人 提交于 2020-01-10 04:25:09
问题 I thought I can find anything on this great site but now I seem to face the issue with no answer :) Please help! Thing is, I need to play up to 6 different wav files with 1 channel each into 6 channels supported by system mixer (left, right, surround left, etc). Using 6 different SourceDataLines looks logical but from what I see, Mixer cannot do per-sample synchronisation for them, so I came up with interleaving them in separate thread and use only one SourceDataLine to play it. It works fine

Clip not playing any sound

◇◆丶佛笑我妖孽 提交于 2020-01-09 12:03:44
问题 Well, the title says all, I tried playing a wav file using javax.sound and nothing is happening. I have tried many different files without any luck. public static void main(String[] args) throws IOException, UnsupportedAudioFileException, LineUnavailableException { File in = new File("C:\\Users\\Sandra\\Desktop\\music\\rags.wav"); AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(in); Clip play = AudioSystem.getClip(); play.open(audioInputStream); FloatControl volume=

Trying to get AudioFormat details from Mixer

允我心安 提交于 2020-01-07 03:45:22
问题 This is my first try with Java Sound and what I'm trying to achieve is getting the source and target lines format so I can then listen to the data and record it to a file by creating the correct AudioFormat object with the details obtained, but when trying to print all the details through the Java console, nothing is printed out. As I said this is my very first steps with Java Sound and I don't really know if there's a simpler approach. This is the test code I have so far... import javax

why do i get java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format MPEG1L3 44100.0 …

▼魔方 西西 提交于 2020-01-06 02:51:09
问题 I have set mp3plugin.jar in the run time libraries needed in my netbeans project .But still i get the above exception when i try to play mp3 file .What is the reason for this : import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; public class

Java Wav file Error (javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file)

旧城冷巷雨未停 提交于 2020-01-06 02:13:28
问题 I have two Classes in my Java Project one is Rebound import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Rebound { public static void main (String[] args) { JFrame frame = new JFrame ("Rebound"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new ReboundPanel()); frame.pack(); frame.setVisible(true); } } and the second one is ReboundPanel import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.sound.sampled.*

Capturing speaker output in Java

断了今生、忘了曾经 提交于 2020-01-06 01:54:32
问题 Using Java is it possible to capture the speaker output? This output is not being generated by my program but rather by other running applications. Can this be done with Java or will I need to resort to C/C++? 回答1: I had a Java based app. that used Java Sound to tap into the sound flowing through the system to make a trace of it. It worked well on my own (Windows based) machine, but failed completely on some others. It was determined that in order to get it working on those machines, would

How do i pause a clip? Java

安稳与你 提交于 2020-01-05 08:14:14
问题 I have a music player that works perfectly fine but i want to add a play/pause button. I have set the button up and all that but i don't know the code to actually pause the clip. Here is my code: try{ File f = new File("songs/mysong.wav"); Clip clip = AudioSystem.getClip(); AudioInputStream ais = AudioSystem.getAudioInputStream(f); clip.open(ais); playing = true; if(MusicPlayer.pause) { clip.stop(); // <- Doesnt stop the song } clip.loop(Clip.LOOP_CONTINUOUSLY); }catch(Exception exception)

How can I loop a sound without using 'clip' in java before writing it into a file

 ̄綄美尐妖づ 提交于 2020-01-05 04:54:09
问题 First of all thanks everyone for helping me with my previous questions. In the following code I am taking two frequencies alternatively and writing them into a .wav format, to run it in my Windows Media Player, for a specific time given by the user. What I want is to understand how to loop those frequencies to run alternatively for that specified time, like the Ambulance's siren, and in my program both frequencies are getting played just once, alternatively. For example, if I am specifying