print Audio System Info - Java javax.sound.sampled

Java examples for javax.sound.sampled:Audio

Description

print Audio System Info

Demo Code


//package com.java2s;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;

import javax.sound.sampled.DataLine;

import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;

public class Main {
    public static void printAudioSystemInfo(AudioFormat format) {
        printMixerInfo(AudioSystem.getMixerInfo(), format);
    }/*from  w ww.j a v a 2  s  .c  o  m*/

    private static void printMixerInfo(Mixer.Info[] mixerInfos,
            AudioFormat format) {
        int i = 0;
        for (Mixer.Info info : mixerInfos) {
            System.out.println("Mixer " + i);
            System.out.println(info.getName());
            System.out.println(info.getVendor());
            System.out.println(info.getVersion());
            System.out.println(info.getDescription());

            Mixer mixer = AudioSystem.getMixer(info);
            DataLine.Info targetLineInfo = new DataLine.Info(
                    TargetDataLine.class, format);
            printMaxLines(mixer, targetLineInfo);

            DataLine.Info sourceLineInfo = new DataLine.Info(
                    SourceDataLine.class, format);
            printMaxLines(mixer, sourceLineInfo);

            System.out.println();

            i++;
        }
    }

    private static void printMaxLines(Mixer mixer, DataLine.Info lineInfo) {
        System.out.println("Max " + lineInfo.getLineClass().getName()
                + " lines:" + mixer.getMaxLines(lineInfo));
    }
}

Related Tutorials