当前位置: 首页>>代码示例>>Java>>正文


Java AudioSystem.getMixer方法代码示例

本文整理汇总了Java中javax.sound.sampled.AudioSystem.getMixer方法的典型用法代码示例。如果您正苦于以下问题:Java AudioSystem.getMixer方法的具体用法?Java AudioSystem.getMixer怎么用?Java AudioSystem.getMixer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.sampled.AudioSystem的用法示例。


在下文中一共展示了AudioSystem.getMixer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DataLine_ArrayIndexOutOfBounds.java

示例2: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception     {
    if (isSoundcardInstalled()) {
            bais.mark(0);
        run(null);
        Mixer.Info[] infos = AudioSystem.getMixerInfo();
        for (int i = 0; i<infos.length; i++) {
            try {
                    Mixer m = AudioSystem.getMixer(infos[i]);
                    run(m);
            } catch (Exception e) {
            }
        }
        if (success > 0) {
            out("No crash -> Test passed");
        } else {
            System.err.println("Test could not execute: please install an audio device");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ClipFlushCrash.java

示例3: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	AbstractRcomArgs a=new AbstractRcomArgs();
	UtilCli.parse(a, args, true);
	File folder=new File("/home/rizsi/tmp/video");
	byte[] data=UtilFile.loadFile(new File(folder, "remote.sw"));
	AudioFormat format=ManualTestEchoCancel.getFormat();
	final Mixer mixer = AudioSystem.getMixer(null);
	DataLine.Info info2= new DataLine.Info(SourceDataLine.class, format);
	SourceDataLine s=(SourceDataLine) mixer.getLine(info2);
	s.open(format, framesamples*2);
	s.start();
	try(LoopInputStream lis=new LoopInputStream(data))
	{
		try(JitterResampler rs=new JitterResampler(a, 8000, framesamples, 2))
		{
			new FeedThread(lis, rs).start();
			final byte[] buffer=new byte[framesamples*2];;
			while(true)
			{
				rs.readOutput(buffer);
				s.write(buffer, 0, buffer.length);
			}
		}
	}
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:26,代码来源:JitterExample.java

示例4: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out("4936397: Verify that there'll for a given endianness, there's also the little endian version");
    out("         and the same for signed'ness for 8-bit formats");

    Mixer.Info[] aInfos = AudioSystem.getMixerInfo();
    for (int i = 0; i < aInfos.length; i++) {
        try {
            Mixer mixer = AudioSystem.getMixer(aInfos[i]);
            out("Mixer "+aInfos[i]);
            checkLines(mixer, mixer.getSourceLineInfo());
            checkLines(mixer, mixer.getTargetLineInfo());
        } catch (Exception e) {
            out("Unexpected exception when getting a mixer: "+e);
        }
    }
    if (testedFormats == 0) {
        out("[No appropriate lines available] - cannot exercise this test.");
    } else {
        if (failed) {
            throw new Exception("Test FAILED!");
        }
        out("Test passed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:BothEndiansAndSigns.java

示例5: enumerateMicrophones

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static HashMap<String, Line.Info> enumerateMicrophones() {
	HashMap<String, Line.Info> mics = new HashMap<String, Line.Info>();

	Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
	for (Mixer.Info info : mixerInfos) {
		Mixer m = AudioSystem.getMixer(info);
		Line.Info[] lineInfos = m.getTargetLineInfo();
		if (lineInfos.length >= 1 && lineInfos[0].getLineClass().equals(TargetDataLine.class))
			mics.put(info.getName(), lineInfos[0]);
	}
	return mics;
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:13,代码来源:Microphone.java

示例6: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
		AbstractRcomArgs a=new AbstractRcomArgs();
		UtilCli.parse(a, args, true);
		File folder=new File("/home/rizsi/tmp/video");
		byte[] data=UtilFile.loadFile(new File(folder, "remote.sw"));
		AudioFormat format=ManualTestEchoCancel.getFormat();
		final Mixer mixer = AudioSystem.getMixer(null);
		DataLine.Info info2= new DataLine.Info(SourceDataLine.class, format);
		SourceDataLine s=(SourceDataLine) mixer.getLine(info2);
		s.open(format, framesamples*2);
		s.start();
		try(LoopInputStream lis=new LoopInputStream(data))
		{
			try(SpeexResampler resampler=new SpeexResampler(a, framesamples, new ResampledReceiver(s)))
			{
				final byte[] buffer=new byte[framesamples*2];;
				while(true)
				{
					UtilStream.readFully(buffer, lis, buffer.length);
					feed(resampler, buffer);
				}
			}
//			byte[] buffer=new byte[framesamples*2];
//			while(true)
//			{
//				UtilStream.readFully(buffer, resampled, buffer.length);
//			}
		}
	}
 
开发者ID:rizsi,项目名称:rcom,代码行数:30,代码来源:ResampleExample.java

示例7: run

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
private void run() throws Exception
{
	byte[] alapzaj=UtilFile.loadFile(new File("/home/rizsi/tmp/video/remote.sw"));
	AudioFormat format=getFormat();
	
	final Mixer mixer = AudioSystem.getMixer(null);
	m=new Mic(mixer, format, frameSamples);
	Play p=new Play(mixer, format, frameSamples);
	echo=new SpeexEchoCancel();
	echo.setLog(true);
	echo.setup(m, p, frameSamples);
	echo.start();
	p.start();
	m.start();
	RecordBoth r=new RecordBoth(echo, m);
	p.setSample(alapzaj);
	try(Scanner br=new Scanner(System.in))
	{
		System.out.println("Press ENTER to start training noise");
		br.nextLine();
		p.setSample(alapzaj);
		System.out.println("Press ENTER to leave");
		br.nextLine();
		r.stop();
		p.setSample(r.echoCancelled.toByteArray());
		UtilFile.saveAsFile(new File("/tmp/rcancelled.sw"), r.echoCancelled.toByteArray());
		br.nextLine();
	}
	System.exit(0);
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:31,代码来源:ManualTestEchoCancel2.java

示例8: setMixer

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
private void setMixer(MixerWrapper mw) {
    try {
        mixer = AudioSystem.getMixer(mw.getMixerInfo());
    } catch (Exception e) {
        logger.log(Level.WARNING, "Could not set mixer", e);
        mixer = null;
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:9,代码来源:SoundPlayer.java

示例9: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception    {
    if (isSoundcardInstalled()) {
        bais.mark(0);
        Mixer.Info[] infos = AudioSystem.getMixerInfo();
        for (int sleep = 0; sleep < 100; ++sleep) {
            run(null, sleep);
            for (int i = 0; i < infos.length; i++) {
                try {
                    Mixer m = AudioSystem.getMixer(infos[i]);
                    run(m, sleep);
                } catch (Exception e) {
                }
            }
        }
        out("Waiting 1 second to dispose of all threads");
        Thread.sleep(1000);
        if (getClipThreadCount() > 0) {
            out("Unused clip threads exist! Causes test failure");
            failed = true;
        }
        if (failed) throw new Exception("Test FAILED!");
        if (success > 0) {
            out("Test passed.");
        } else {
            System.err.println("Test could not execute: please install an audio device");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:ClipCloseLoss.java

示例10: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String argv[]) throws Exception {
    boolean success = true;

    Mixer.Info [] infos = AudioSystem.getMixerInfo();

    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        System.out.println("Mixer is: " + mixer);
        Line.Info [] target_line_infos = mixer.getTargetLineInfo();
        for (int j = 0; j < target_line_infos.length; j++) {
            try {
                System.out.println("Trying to get:" + target_line_infos[j]);
                mixer.getLine(target_line_infos[j]);
            } catch (IllegalArgumentException iae) {
                System.out.println("Unexpected IllegalArgumentException raised:");
                iae.printStackTrace();
                success = false;
            } catch (LineUnavailableException lue) {
                System.out.println("Unexpected LineUnavailableException raised:");
                lue.printStackTrace();
                success = false;
            }
        }
    }
    if (success) {
        System.out.println("Test passed");
    } else {
        throw new Exception("Test FAILED");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:UnexpectedIAE.java

示例11: run

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
private void run() throws Exception
	{
		int frameSize=256;
		AudioFormat format=ManualTestEchoCancel.getFormat();
		
		final Mixer mixer = AudioSystem.getMixer(null);
		m=new Mic2(mixer, format, ManualTestEchoCancel.frameSamples);
		MeasurePower mp=new MeasurePower(frameSize, m);
		mp.start();
		Play p=new Play2(mixer, format, ManualTestEchoCancel.frameSamples);
		p.start();
		m.start();
		byte[] sample=new byte[320000];
		ByteBuffer s=ByteBuffer.wrap(sample);
		s.order(ByteOrder.nativeOrder());
		for(int i=0;i<500;++i)
		{
			s.putShort((short)(32000*Math.sin(0.3*i)));
		}
		try(Scanner br=new Scanner(System.in))
		{
			System.out.println("Press ENTER to start sample");
			br.nextLine();
			while(true)
			{
				Thread.sleep(1000);
				p.setSample(sample);
				Thread.sleep(1000);
				p.setSample(null);
				p.setLogged(false);
			}
//			br.nextLine();
		}
//		System.exit(0);
	}
 
开发者ID:rizsi,项目名称:rcom,代码行数:36,代码来源:MeasureEchoLatency.java

示例12: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception     {
    if (isSoundcardInstalled()) {
        int res=0;
        int count = 0;
        Mixer.Info[] infos = AudioSystem.getMixerInfo();
        for (int i = -1; i<infos.length; i++) {
            try {
                Mixer m;
                if (i == -1) {
                    m = null;
                } else {
                    m = AudioSystem.getMixer(infos[i]);
                }
                int r = run(m, AudioSystem.NOT_SPECIFIED);
                // only continue if successful
                if (r == 0) {
                    count++;
                    r = run(m, -2);
                    if (r == 1) {
                        // only fail if IAE was thrown
                        System.out.println("#FAILED: using -2 for buffer size does not work!");
                        res = 1;
                    }
                }
            } catch (Exception e) {
            }
        }
        if (res!=1) {
            System.out.println("Test passed");
        } else {
            if (count == 0) {
                System.err.println("Test could not execute -- no suitable mixers installed. NOT failed");
            }
            throw new Exception("Test FAILED!");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:DataLineInfoNegBufferSize.java

示例13: commandline

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void commandline(String[] subArgs) {
	final Mixer mixer = AudioSystem.getMixer(null);
	System.out.println("Listing audio channels...");
	for(Info info: mixer.getTargetLineInfo())
	{
		DataLine.Info di=(DataLine.Info) info;
		System.out.println("Line: "+di);
		for(AudioFormat f: di.getFormats())
		{
			System.out.println("Supported format: "+f);
		}
	}
	System.out.println("Listing audio channels DONE");
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:15,代码来源:ListAudio.java

示例14: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    boolean res=true;

    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    System.out.println(mixerInfo.length+" mixers on system.");
    if (mixerInfo.length == 0) {
        System.out.println("Cannot execute test. Not Failed!");
    } else {
        for (int i = 0; i < mixerInfo.length; i++) {
            Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
            System.out.println();
            System.out.println(mixer+":");
            showMixerLines(mixer.getSourceLineInfo());
            showMixerLines(mixer.getTargetLineInfo());


        }
        res=ok16 && ok32;
    }
    if (res) {
        System.out.println("Test passed");
    } else {
        System.out.println("Test failed");
        throw new Exception("Test failed");
    }
    //ystem.exit(res?0:1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Has16and32KHz.java

示例15: main

import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    boolean res=true;
    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    for (int i = 0; i < mixerInfo.length; i++) {
        Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
        System.out.println(mixer);
        Line.Info[] lineinfo = mixer.getSourceLineInfo();
        for (int j = 0; j < lineinfo.length; j++) {
            System.out.println("  " + lineinfo[j]);
            try {
                AudioFormat[] formats = ((DataLine.Info)lineinfo[j]).getFormats();
                for (int k = 0; k < formats.length; k++) {
                    if ( (formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
                          || formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED))
                         && (formats[k].getFrameSize() != AudioSystem.NOT_SPECIFIED)
                         && ((formats[k].getSampleSizeInBits() == 16) || (formats[k].getSampleSizeInBits() == 8))
                         && ((((formats[k].getSampleSizeInBits() + 7) / 8) * formats[k].getChannels()) != formats[k].getFrameSize())) {
                        System.out.println(" # " + formats[k] + ", getFrameSize() wrongly returns"+ formats[k].getFrameSize());
                        res=false;
                    }
                }
            } catch (ClassCastException e) {
            }
        }
    }

    if (res) {
        System.out.println("Test passed");
    } else {
        System.out.println("Test failed");
        throw new Exception("Test failed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:FrameSizeTest.java


注:本文中的javax.sound.sampled.AudioSystem.getMixer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。