javasound

Is it possible to capture the playing audio with Java?

蹲街弑〆低调 提交于 2019-12-11 01:56:20
问题 I was wondering if it's possible to capture playing audio on the audio output hardware with a simple Java program, and then write it to an outputstream for example. Is it? 回答1: If your desire is to record the output of all programs to a given audio device using a java app, like audiohijackpro, the short answer is no, this is not possible without native code. It is, in fact, quite difficult to do in any language. As far as I know, no platform makes this easy. On some environments, there is a

How to play an MP3 File using Java?

我的未来我决定 提交于 2019-12-11 01:26:31
问题 Using Applet.AudioClip I'm able to play .wav files, but if I try to do that on an MP3 file, then no audio seems to get played even though no exceptions are thrown. Is there any way to play MP3s with Java, whether using Swing, Java FX, or any other Java technologies? 回答1: package test; import java.io.File; import javax.media.Format; import javax.media.Manager; import javax.media.MediaLocator; import javax.media.Player; import javax.media.PlugInManager; import javax.media.format.AudioFormat;

Java: How to use microphone input as input for the JavaFX media player?

谁说我不能喝 提交于 2019-12-11 00:43:18
问题 I want to play the microphone input in realtime using the JavaFX media player (to analyse its frequencies). The problem is, that the MediaPlayer only accepts Strings as source. I know how to write the microphone input into a byte array and into a file. Using the byte array as source for the MediaPlayer is (for me) not possible. I tried using a temporary file, but that causes the following error: Exception in thread "JavaFX Application Thread" MediaException: MEDIA_UNSUPPORTED : Empty

Java midi volume control won't work

隐身守侯 提交于 2019-12-10 15:29:40
问题 I've been trying to get midi volume control to work in a MidiPlayer class for a very long time now. I've searched for examples for accomplishing this here on stackoverflow and all over the Internet, but nothing I try ever seems to work. The volume stays the same! It doesn't change like I want it to. I'm running Java 1.6.0_32 on Windows 7 professional. Here! Have an SSCCE: import java.io.*; import javax.sound.midi.*; import java.net.URL; public class MidiSSCCE { public static void main(String[

Playing only one mp3 file in a thread using JLayer in java issue

十年热恋 提交于 2019-12-10 11:58:13
问题 I'm working at an Audio Player, which is written in Java with GUI. For playing the mp3 files, I've chosen JLayer library from javazoom because I saw it's very popular and used. I made the GUI, managed to play the selected mp3 file from the playlist. My problem is that if I press many times on the play button or on the file from the playlist it will start playing the song as many times as I press it and I want to play it one the same thread ; if I press again play button I want to play again

Play 2 different frequencies alternatively in Java

依然范特西╮ 提交于 2019-12-10 10:11:24
问题 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

How to get Audio for encoding using Xuggler

半城伤御伤魂 提交于 2019-12-10 02:42:10
问题 I'm writing an application that records the screen and audio. While the screen recording works perfectly, I'm having difficulty in getting the raw audio using the JDK libraries. Here's the code: try { // Now, we're going to loop long startTime = System.nanoTime(); System.out.println("Encoding Image....."); while (!Thread.currentThread().isInterrupted()) { // take the screen shot BufferedImage screen = robot.createScreenCapture(screenBounds); // convert to the right image type BufferedImage

How to keep track of audio playback position?

南楼画角 提交于 2019-12-10 00:05:24
问题 I created a thread to play an mp3 file in Java by converting it to an array of bytes. I'm wondering if I can keep track of the current play position as the mp3 is being played. First, I set up my music stream like so: try { AudioInputStream in = AudioSystem.getAudioInputStream(file); musicInputStream = AudioSystem.getAudioInputStream(MUSIC_FORMAT, in); DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, MUSIC_FORMAT); musicDataLine = (SourceDataLine) AudioSystem.getLine

Java: How to get current frequency of audio input?

ぐ巨炮叔叔 提交于 2019-12-08 12:37:19
问题 I want to analyse the current frequency of the microphone input to synchronize my LEDs with the music playing. I know how to capture the sound from the microphone, but I don't know about FFT, which I often saw while searching for a solution to get the frequency. I want to test if the current volume of a certain frequency is bigger than a set value. The code should be looking something like this: if(frequency > value) { LEDs on else { LEDs off } My problem is how to implement FFT in Java. For

Taking control of the soundCard with JAVA

不打扰是莪最后的温柔 提交于 2019-12-08 09:48:36
问题 I'm trying to build a "mixing console" in JAVA. In this mixer, each "slider" would be a line, as if it was a physical mixing console. But, after my search on Goo*** and read the oracle documentation, I didn't really find anything to help me. First, I list the mixers available (see code at the end) and happily, it list all my soundcards and find the line in and line out. But then, what I have to do ? My aim is to create "virtual line" that will catch the sound from any line in (microphone) or