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


Java AudioFormat.isBigEndian方法代码示例

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


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

示例1: getAudioFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
private AudioFormat getAudioFormat(HashSet<AudioFormat> inputFormats) {
		for (AudioFormat audioFormat : inputFormats) {
			if((audioFormat.getSampleSizeInBits() == 16 || audioFormat.getSampleSizeInBits() == 8)
//					&& (audioFormat.getSampleRate() == 16000.0F)
					&& (audioFormat.getChannels() == 1)
					&& (audioFormat.isBigEndian())
					&& (audioFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED))){
				
				return new AudioFormat(16000.0F, audioFormat.getSampleSizeInBits(), audioFormat.getChannels(), true, true);
			}
		}
		return null;
//		float sampleRate = 16000.0F;
//		// 8000,11025,16000,22050,44100
//		int sampleSizeInBits = 16;
//		// 8,16
//		int channels = 1;
//		// 1,2
//		boolean signed = true;
//		// true,false
//		boolean bigEndian = true;
//		// true,false
//		return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);
	}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:25,代码来源:SoundInputDeviceControl.java

示例2: getSignOrEndianChangedFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
protected static AudioFormat getSignOrEndianChangedFormat(AudioFormat format) {
    boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
    boolean isUnsigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED);
    if (format.getSampleSizeInBits() > 8 && isSigned) {
        // if this is PCM_SIGNED and 16-bit or higher, then try with endian-ness magic
        return new AudioFormat(format.getEncoding(),
                               format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(),
                               format.getFrameSize(), format.getFrameRate(), !format.isBigEndian());
    }
    else if (format.getSampleSizeInBits() == 8 && (isSigned || isUnsigned)) {
        // if this is PCM and 8-bit, then try with signed-ness magic
        return new AudioFormat(isSigned?AudioFormat.Encoding.PCM_UNSIGNED:AudioFormat.Encoding.PCM_SIGNED,
                               format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(),
                               format.getFrameSize(), format.getFrameRate(), format.isBigEndian());
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DirectAudioDevice.java

示例3: getAudioInputStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
        AudioInputStream sourceStream) {
    if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
        return sourceStream;
    AudioFormat format = sourceStream.getFormat();
    int channels = format.getChannels();
    Encoding encoding = targetEncoding;
    float samplerate = format.getSampleRate();
    int bits = format.getSampleSizeInBits();
    boolean bigendian = format.isBigEndian();
    if (targetEncoding.equals(Encoding.PCM_FLOAT))
        bits = 32;
    AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
            channels, channels * bits / 8, samplerate, bigendian);
    return getAudioInputStream(targetFormat, sourceStream);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:AudioFloatFormatConverter.java

示例4: getAudioInputStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
                                            AudioInputStream sourceStream) {
    if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) {
        throw new IllegalArgumentException(
                "Unsupported conversion: " + sourceStream.getFormat()
                        .toString() + " to " + targetEncoding.toString());
    }
    if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
        return sourceStream;
    AudioFormat format = sourceStream.getFormat();
    int channels = format.getChannels();
    Encoding encoding = targetEncoding;
    float samplerate = format.getSampleRate();
    int bits = format.getSampleSizeInBits();
    boolean bigendian = format.isBigEndian();
    if (targetEncoding.equals(Encoding.PCM_FLOAT))
        bits = 32;
    AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
            channels, channels * bits / 8, samplerate, bigendian);
    return getAudioInputStream(targetFormat, sourceStream);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:AudioFloatFormatConverter.java

示例5: AudioFloatLSBFilter

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AudioFloatLSBFilter(AudioFloatConverter converter, AudioFormat format) {
    int bits = format.getSampleSizeInBits();
    boolean bigEndian = format.isBigEndian();
    this.converter = converter;
    stepsize = (bits + 7) / 8;
    offset = bigEndian ? (stepsize - 1) : 0;
    int lsb_bits = bits % 8;
    if (lsb_bits == 0)
        mask = (byte) 0x00;
    else if (lsb_bits == 1)
        mask = (byte) 0x80;
    else if (lsb_bits == 2)
        mask = (byte) 0xC0;
    else if (lsb_bits == 3)
        mask = (byte) 0xE0;
    else if (lsb_bits == 4)
        mask = (byte) 0xF0;
    else if (lsb_bits == 5)
        mask = (byte) 0xF8;
    else if (lsb_bits == 6)
        mask = (byte) 0xFC;
    else if (lsb_bits == 7)
        mask = (byte) 0xFE;
    else
        mask = (byte) 0xFF;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:AudioFloatConverter.java

示例6: getAudioInputStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {

    if( isConversionSupported(targetEncoding, sourceStream.getFormat()) ) {

        AudioFormat sourceFormat = sourceStream.getFormat();
        AudioFormat targetFormat = new AudioFormat( targetEncoding,
                                                    sourceFormat.getSampleRate(),
                                                    sourceFormat.getSampleSizeInBits(),
                                                    sourceFormat.getChannels(),
                                                    sourceFormat.getFrameSize(),
                                                    sourceFormat.getFrameRate(),
                                                    sourceFormat.isBigEndian() );

        return getAudioInputStream( targetFormat, sourceStream );

    } else {
        throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + targetEncoding.toString() );
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:PCMtoPCMCodec.java

示例7: getOtherBits

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static AudioFormat getOtherBits(AudioFormat format, int newBits) {
    boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
    return new AudioFormat(format.getSampleRate(),
                           newBits,
                           format.getChannels(),
                           isSigned,
                           (newBits>8)?format.isBigEndian():false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:PlugHwMonoAnd8bitAvailable.java

示例8: AudioFloatInputStreamChannelMixer

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
        int targetChannels) {
    this.sourceChannels = ais.getFormat().getChannels();
    this.targetChannels = targetChannels;
    this.ais = ais;
    AudioFormat format = ais.getFormat();
    targetFormat = new AudioFormat(format.getEncoding(), format
            .getSampleRate(), format.getSampleSizeInBits(),
            targetChannels, (format.getFrameSize() / sourceChannels)
                    * targetChannels, format.getFrameRate(), format
                    .isBigEndian());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:AudioFloatFormatConverter.java

示例9: getOtherEndianOrSign

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static AudioFormat getOtherEndianOrSign(AudioFormat format) {
    AudioFormat.Encoding newEnc = null;
    boolean newEndian = format.isBigEndian();
    boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
    boolean isUnsigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED);
    if ((isSigned || isUnsigned) && format.getSampleSizeInBits() > 0) {
        if (format.getSampleSizeInBits() == 8) {
            // return the other signed'ness
            if (isSigned) {
                newEnc = AudioFormat.Encoding.PCM_UNSIGNED;
            } else {
                newEnc = AudioFormat.Encoding.PCM_SIGNED;
            }
        } else {
            newEnc = format.getEncoding();
            newEndian = !newEndian;
        }
        if (newEnc != null) {
            return new AudioFormat(newEnc, format.getSampleRate(),
                                   format.getSampleSizeInBits(),
                                   format.getChannels(),
                                   format.getFrameSize(),
                                   format.getFrameRate(),
                                   newEndian);
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:BothEndiansAndSigns.java

示例10: AudioFloatInputStreamResampler

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public AudioFloatInputStreamResampler(AudioFloatInputStream ais,
        AudioFormat format) {
    this.ais = ais;
    AudioFormat sourceFormat = ais.getFormat();
    targetFormat = new AudioFormat(sourceFormat.getEncoding(), format
            .getSampleRate(), sourceFormat.getSampleSizeInBits(),
            sourceFormat.getChannels(), sourceFormat.getFrameSize(),
            format.getSampleRate(), sourceFormat.isBigEndian());
    nrofchannels = targetFormat.getChannels();
    Object interpolation = format.getProperty("interpolation");
    if (interpolation != null && (interpolation instanceof String)) {
        String resamplerType = (String) interpolation;
        if (resamplerType.equalsIgnoreCase("point"))
            this.resampler = new SoftPointResampler();
        if (resamplerType.equalsIgnoreCase("linear"))
            this.resampler = new SoftLinearResampler2();
        if (resamplerType.equalsIgnoreCase("linear1"))
            this.resampler = new SoftLinearResampler();
        if (resamplerType.equalsIgnoreCase("linear2"))
            this.resampler = new SoftLinearResampler2();
        if (resamplerType.equalsIgnoreCase("cubic"))
            this.resampler = new SoftCubicResampler();
        if (resamplerType.equalsIgnoreCase("lanczos"))
            this.resampler = new SoftLanczosResampler();
        if (resamplerType.equalsIgnoreCase("sinc"))
            this.resampler = new SoftSincResampler();
    }
    if (resampler == null)
        resampler = new SoftLinearResampler2(); // new
    // SoftLinearResampler2();
    pitch[0] = sourceFormat.getSampleRate() / format.getSampleRate();
    pad = resampler.getPadding();
    pad2 = pad * 2;
    ibuffer = new float[nrofchannels][buffer_len + pad2];
    ibuffer2 = new float[nrofchannels * buffer_len];
    ibuffer_index = buffer_len + pad;
    ibuffer_len = buffer_len;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:SoftMixingDataLine.java

示例11: AudioFloatInputStreamResampler

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AudioFloatInputStreamResampler(AudioFloatInputStream ais,
        AudioFormat format) {
    this.ais = ais;
    AudioFormat sourceFormat = ais.getFormat();
    targetFormat = new AudioFormat(sourceFormat.getEncoding(), format
            .getSampleRate(), sourceFormat.getSampleSizeInBits(),
            sourceFormat.getChannels(), sourceFormat.getFrameSize(),
            format.getSampleRate(), sourceFormat.isBigEndian());
    nrofchannels = targetFormat.getChannels();
    Object interpolation = format.getProperty("interpolation");
    if (interpolation != null && (interpolation instanceof String)) {
        String resamplerType = (String) interpolation;
        if (resamplerType.equalsIgnoreCase("point"))
            this.resampler = new SoftPointResampler();
        if (resamplerType.equalsIgnoreCase("linear"))
            this.resampler = new SoftLinearResampler2();
        if (resamplerType.equalsIgnoreCase("linear1"))
            this.resampler = new SoftLinearResampler();
        if (resamplerType.equalsIgnoreCase("linear2"))
            this.resampler = new SoftLinearResampler2();
        if (resamplerType.equalsIgnoreCase("cubic"))
            this.resampler = new SoftCubicResampler();
        if (resamplerType.equalsIgnoreCase("lanczos"))
            this.resampler = new SoftLanczosResampler();
        if (resamplerType.equalsIgnoreCase("sinc"))
            this.resampler = new SoftSincResampler();
    }
    if (resampler == null)
        resampler = new SoftLinearResampler2(); // new
                                                // SoftLinearResampler2();
    pitch[0] = sourceFormat.getSampleRate() / format.getSampleRate();
    pad = resampler.getPadding();
    pad2 = pad * 2;
    ibuffer = new float[nrofchannels][buffer_len + pad2];
    ibuffer2 = new float[nrofchannels * buffer_len];
    ibuffer_index = buffer_len + pad;
    ibuffer_len = buffer_len;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:AudioFloatFormatConverter.java

示例12: getOtherChannels

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static AudioFormat getOtherChannels(AudioFormat format, int newChannels) {
    int newFrameSize;
    if (newChannels <= 0 || format.getChannels() <= 0 || format.getFrameSize() <= 0) {
        newFrameSize = -1;
    } else {
        newFrameSize = format.getFrameSize() / format.getChannels() * newChannels;
    }
    return new AudioFormat(format.getEncoding(),
                           format.getSampleRate(),
                           format.getSampleSizeInBits(),
                           newChannels,
                           newFrameSize,
                           format.getFrameRate(),
                           format.isBigEndian());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:PlugHwMonoAnd8bitAvailable.java

示例13: AlawCodecStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {

            super(stream, outputFormat, -1);

            AudioFormat inputFormat = stream.getFormat();

            // throw an IllegalArgumentException if not ok
            if ( ! (isConversionSupported(outputFormat, inputFormat)) ) {

                throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
            }

            //$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
            boolean PCMIsBigEndian;

            // determine whether we are encoding or decoding
            if (AudioFormat.Encoding.ALAW.equals(inputFormat.getEncoding())) {
                encode = false;
                encodeFormat = inputFormat;
                decodeFormat = outputFormat;
                PCMIsBigEndian = outputFormat.isBigEndian();
            } else {
                encode = true;
                encodeFormat = outputFormat;
                decodeFormat = inputFormat;
                PCMIsBigEndian = inputFormat.isBigEndian();
                tempBuffer = new byte[tempBufferSize];
            }

            if (PCMIsBigEndian) {
                tabByte1 = ALAW_TABH;
                tabByte2 = ALAW_TABL;
                highByte = 0;
                lowByte  = 1;
            } else {
                tabByte1 = ALAW_TABL;
                tabByte2 = ALAW_TABH;
                highByte = 1;
                lowByte  = 0;
            }

            // set the AudioInputStream length in frames if we know it
            if (stream instanceof AudioInputStream) {
                frameLength = ((AudioInputStream)stream).getFrameLength();
            }

            // set framePos to zero
            framePos = 0;
            frameSize = inputFormat.getFrameSize();
            if( frameSize==AudioSystem.NOT_SPECIFIED ) {
                frameSize=1;
            }
        }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:AlawCodec.java

示例14: printFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static String printFormat(AudioFormat format) {
    return format.toString()+"  "+(format.isBigEndian()?"big":"little")+" endian";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:AlawUlaw.java

示例15: UlawCodecStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
UlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {
    super(stream, outputFormat, AudioSystem.NOT_SPECIFIED);

    AudioFormat inputFormat = stream.getFormat();

    // throw an IllegalArgumentException if not ok
    if (!(isConversionSupported(outputFormat, inputFormat))) {
        throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
    }

    //$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
    boolean PCMIsBigEndian;

    // determine whether we are encoding or decoding
    if (AudioFormat.Encoding.ULAW.equals(inputFormat.getEncoding())) {
        encode = false;
        encodeFormat = inputFormat;
        decodeFormat = outputFormat;
        PCMIsBigEndian = outputFormat.isBigEndian();
    } else {
        encode = true;
        encodeFormat = outputFormat;
        decodeFormat = inputFormat;
        PCMIsBigEndian = inputFormat.isBigEndian();
        tempBuffer = new byte[tempBufferSize];
    }

    // setup tables according to byte order
    if (PCMIsBigEndian) {
        tabByte1 = ULAW_TABH;
        tabByte2 = ULAW_TABL;
        highByte = 0;
        lowByte  = 1;
    } else {
        tabByte1 = ULAW_TABL;
        tabByte2 = ULAW_TABH;
        highByte = 1;
        lowByte  = 0;
    }

    // set the AudioInputStream length in frames if we know it
    if (stream instanceof AudioInputStream) {
        frameLength = ((AudioInputStream)stream).getFrameLength();
    }
    // set framePos to zero
    framePos = 0;
    frameSize = inputFormat.getFrameSize();
    if (frameSize == AudioSystem.NOT_SPECIFIED) {
        frameSize = 1;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:52,代码来源:UlawCodec.java


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