-
Get Sound Output
Hey everyone, I was thinking about writing a program that changed the hue of something depending on the sound output of the speakers. I want to capture the sound the same way itunes has those little bars go up and down, or how in windows media player, how on visualizer, the picture changes depending on the music. I was looking into sound in java (which I'm new to), and I made a program that looked for all the lines on each mixer. However, even though I'm playing music, i get 0 lines for all mixers. Does this have something to do with permission? Or am I going at this from the wrong direction entirely... Any help would be greatly appreciated.
By the way, here is the code i used to see what mixers/lines I had.
Code:
import javax.sound.sampled.*;
public class SoundTest
{
public static void main(String args[])
{
Mixer mix;
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
for(int i = 0; i< mixers.length; i++)
{
System.out.println(mixers[i].toString());
mix = AudioSystem.getMixer(mixers[i]);
Line[] lines = mix.getSourceLines();
System.out.println(lines.length);
for(int j=0; j<lines.length; j++)
{
System.out.println(lines[j].getLineInfo().toString());
System.out.println(((DataLine)lines[j]).getFormat().toString());
}
}
}
}
I also tried getting targetl lines too. it was still all 0's
-
Did you debug the code? I mean check values in each step execution. If you are working on an IDE, then put few breakpoints and debug, or else if you are working on command prompt use few print statements.
-
they are in there... It's pretty simple. I just get the mixers (about 7) and for each one i get the lines, and see how many there are, there are 0 for each, even though i'm playing music, why?