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


Java Line类代码示例

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


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

示例1: start

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Starts the mixer.
 */
final synchronized void start(Line line) {

    if (Printer.trace) Printer.trace(">> AbstractMixer: start(" + line + ")");

    // $$kk: 06.11.99: ignore ourselves for now
    if (this.equals(line)) {
        if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") nothing done");
        return;
    }

    // we just start the mixer regardless of anything else here.
    if (!started) {
        if (Printer.debug) Printer.debug("AbstractMixer: start(line): starting the mixer");
        implStart();
        started = true;
    }

    if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") succeeded");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:AbstractMixer.java

示例2: test

import javax.sound.sampled.Line; //导入依赖的package包/类
private static void test(final AudioFormat format, final byte[] data)
        throws Exception {
    final Line.Info info = new DataLine.Info(Clip.class, format);
    final Clip clip = (Clip) AudioSystem.getLine(info);

    go = new CountDownLatch(1);
    clip.addLineListener(event -> {
        if (event.getType().equals(LineEvent.Type.START)) {
            go.countDown();
        }
    });

    clip.open(format, data, 0, data.length);
    clip.start();
    go.await();
    while (clip.isRunning()) {
        // This loop should not hang
    }
    while (clip.isActive()) {
        // This loop should not hang
    }
    clip.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:IsRunningHang.java

示例3: getFirstLinearFormat

import javax.sound.sampled.Line; //导入依赖的package包/类
private static AudioFormat getFirstLinearFormat(Line.Info[] infos) {
    for (int i = 0; i < infos.length; i++) {
        if (infos[i] instanceof DataLine.Info) {
            AudioFormat[] formats = ((DataLine.Info) infos[i]).getFormats();
            for (int j = 0; j < formats.length; j++) {
                AudioFormat.Encoding encoding = formats[j].getEncoding();
                int sampleSizeInBits = formats[j].getSampleSizeInBits();
                if (encoding.equals(AudioFormat.Encoding.PCM_SIGNED) &&
                    sampleSizeInBits == 16 ||
                    encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED) &&
                    sampleSizeInBits == 16) {
                    return formats[j];
                }
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DefaultMixers.java

示例4: AbstractMixer

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Constructs a new AbstractMixer.
 * @param mixer the mixer with which this line is associated
 * @param controls set of supported controls
 */
protected AbstractMixer(Mixer.Info mixerInfo,
                        Control[] controls,
                        Line.Info[] sourceLineInfo,
                        Line.Info[] targetLineInfo) {

    // Line.Info, AbstractMixer, Control[]
    super(new Line.Info(Mixer.class), null, controls);

    // setup the line part
    this.mixer = this;
    if (controls == null) {
        controls = new Control[0];
    }

    // setup the mixer part
    this.mixerInfo = mixerInfo;
    this.sourceLineInfo = sourceLineInfo;
    this.targetLineInfo = targetLineInfo;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:AbstractMixer.java

示例5: getSourceLineInfo

import javax.sound.sampled.Line; //导入依赖的package包/类
public final Line.Info[] getSourceLineInfo(Line.Info info) {

        int i;
        Vector vec = new Vector();

        for (i = 0; i < sourceLineInfo.length; i++) {

            if (info.matches(sourceLineInfo[i])) {
                vec.addElement(sourceLineInfo[i]);
            }
        }

        Line.Info[] returnedArray = new Line.Info[vec.size()];
        for (i = 0; i < returnedArray.length; i++) {
            returnedArray[i] = (Line.Info)vec.elementAt(i);
        }

        return returnedArray;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:AbstractMixer.java

示例6: isLineSupported

import javax.sound.sampled.Line; //导入依赖的package包/类
public final boolean isLineSupported(Line.Info info) {

        int i;

        for (i = 0; i < sourceLineInfo.length; i++) {

            if (info.matches(sourceLineInfo[i])) {
                return true;
            }
        }

        for (i = 0; i < targetLineInfo.length; i++) {

            if (info.matches(targetLineInfo[i])) {
                return true;
            }
        }

        return false;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:AbstractMixer.java

示例7: close

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Close all lines and then close this mixer.
 */
public final synchronized void close() {
    if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
    if (isOpen()) {
        // close all source lines
        Line[] localLines = getSourceLines();
        for (int i = 0; i<localLines.length; i++) {
            localLines[i].close();
        }

        // close all target lines
        localLines = getTargetLines();
        for (int i = 0; i<localLines.length; i++) {
            localLines[i].close();
        }

        implClose();

        // set the open state to false and send events
        setOpen(false);
    }
    manuallyOpened = false;
    if (Printer.trace) Printer.trace("<< AbstractMixer: close() succeeded");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:AbstractMixer.java

示例8: getLineInfo

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Returns the first complete Line.Info object it finds that
 * matches the one specified, or null if no matching Line.Info
 * object is found.
 */
final Line.Info getLineInfo(Line.Info info) {
    if (info == null) {
        return null;
    }
    // $$kk: 05.31.99: need to change this so that
    // the format and buffer size get set in the
    // returned info object for data lines??
    for (int i = 0; i < sourceLineInfo.length; i++) {
        if (info.matches(sourceLineInfo[i])) {
            return sourceLineInfo[i];
        }
    }

    for (int i = 0; i < targetLineInfo.length; i++) {
        if (info.matches(targetLineInfo[i])) {
            return targetLineInfo[i];
        }
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:AbstractMixer.java

示例9: checkLines

import javax.sound.sampled.Line; //导入依赖的package包/类
public static void checkLines(Mixer mixer, Line.Info[] infos) {
    for (int i = 0; i<infos.length; i++) {
        try {
            if (infos[i] instanceof DataLine.Info) {
                DataLine.Info info = (DataLine.Info) infos[i];
                System.out.println(" Line "+info+" (max. "+mixer.getMaxLines(info)+" simultaneously): ");
                AudioFormat[] formats = info.getFormats();
                for (int f = 0; f < formats.length; f++) {
                    try {
                        AudioFormat otherEndianOrSign = getOtherEndianOrSign(formats[f]);
                        if (otherEndianOrSign != null) {
                            checkFormat(formats, otherEndianOrSign);
                        }
                    } catch (Exception e1) {
                        out("  Unexpected exception when getting a format: "+e1);
                    }
                }
            }
        } catch (Exception e) {
            out(" Unexpected exception when getting a line: "+e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:BothEndiansAndSigns.java

示例10: isLineSupported

import javax.sound.sampled.Line; //导入依赖的package包/类
@Override
public final boolean isLineSupported(Line.Info info) {

    int i;

    for (i = 0; i < sourceLineInfo.length; i++) {

        if (info.matches(sourceLineInfo[i])) {
            return true;
        }
    }

    for (i = 0; i < targetLineInfo.length; i++) {

        if (info.matches(targetLineInfo[i])) {
            return true;
        }
    }

    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:AbstractMixer.java

示例11: getTargetLineInfo

import javax.sound.sampled.Line; //导入依赖的package包/类
public final Line.Info[] getTargetLineInfo(Line.Info info) {

        int i;
        Vector vec = new Vector();

        for (i = 0; i < targetLineInfo.length; i++) {

            if (info.matches(targetLineInfo[i])) {
                vec.addElement(targetLineInfo[i]);
            }
        }

        Line.Info[] returnedArray = new Line.Info[vec.size()];
        for (i = 0; i < returnedArray.length; i++) {
            returnedArray[i] = (Line.Info)vec.elementAt(i);
        }

        return returnedArray;
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:AbstractMixer.java

示例12: getSourceLineInfo

import javax.sound.sampled.Line; //导入依赖的package包/类
@Override
public final Line.Info[] getSourceLineInfo(Line.Info info) {

    int i;
    Vector<Line.Info> vec = new Vector<>();

    for (i = 0; i < sourceLineInfo.length; i++) {

        if (info.matches(sourceLineInfo[i])) {
            vec.addElement(sourceLineInfo[i]);
        }
    }

    Line.Info[] returnedArray = new Line.Info[vec.size()];
    for (i = 0; i < returnedArray.length; i++) {
        returnedArray[i] = vec.elementAt(i);
    }

    return returnedArray;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AbstractMixer.java

示例13: close

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Removes this line from the list of open source lines and
 * open target lines, if it exists in either.
 * If the list is now empty, closes the mixer.
 */
final synchronized void close(Line line) {

    if (Printer.trace) Printer.trace(">> AbstractMixer: close(" + line + ")");

    // $$kk: 06.11.99: ignore ourselves for now
    if (this.equals(line)) {
        if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") nothing done");
        return;
    }

    sourceLines.removeElement(line);
    targetLines.removeElement(line);

    if (Printer.debug) Printer.debug("AbstractMixer: close(line): sourceLines.size() now: " + sourceLines.size());
    if (Printer.debug) Printer.debug("AbstractMixer: close(line): targetLines.size() now: " + targetLines.size());


    if (sourceLines.isEmpty() && targetLines.isEmpty() && !manuallyOpened) {
        if (Printer.trace) Printer.trace("AbstractMixer: close(" + line + "): need to close the mixer");
        close();
    }

    if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") succeeded");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:AbstractMixer.java

示例14: getMixers

import javax.sound.sampled.Line; //导入依赖的package包/类
/**
 * Returns all available mixers.
 *
 * @return A List of available Mixers
 */
public List<String> getMixers() {
	List<String> mixers = new ArrayList<>();
	
	// Obtains an array of mixer info objects that represents the set of
	// audio mixers that are currently installed on the system.
	Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
	
	if (mixerInfos != null)
		Arrays.stream(mixerInfos).forEach(mInfo -> {
			// line info
			Line.Info lineInfo = new Line.Info(SourceDataLine.class);
			Mixer mixer = AudioSystem.getMixer(mInfo);
			
			// if line supported
			if (mixer.isLineSupported(lineInfo))
				mixers.add(mInfo.getName());
			
		});
	
	return mixers;
}
 
开发者ID:goxr3plus,项目名称:java-stream-player,代码行数:27,代码来源:StreamPlayer.java

示例15: getTargetLineInfo

import javax.sound.sampled.Line; //导入依赖的package包/类
@Override
public final Line.Info[] getTargetLineInfo(Line.Info info) {

    int i;
    Vector<Line.Info> vec = new Vector<>();

    for (i = 0; i < targetLineInfo.length; i++) {

        if (info.matches(targetLineInfo[i])) {
            vec.addElement(targetLineInfo[i]);
        }
    }

    Line.Info[] returnedArray = new Line.Info[vec.size()];
    for (i = 0; i < returnedArray.length; i++) {
        returnedArray[i] = vec.elementAt(i);
    }

    return returnedArray;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AbstractMixer.java


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