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


Java AudioFormat.Encoding方法代码示例

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


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

示例1: WaveFileFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {

        super(type,lengthInBytes,format,lengthInFrames);

        AudioFormat.Encoding encoding = format.getEncoding();

        if( encoding.equals(AudioFormat.Encoding.ALAW) ) {
            waveType = WAVE_FORMAT_ALAW;
        } else if( encoding.equals(AudioFormat.Encoding.ULAW) ) {
            waveType = WAVE_FORMAT_MULAW;
        } else if( encoding.equals(AudioFormat.Encoding.PCM_SIGNED) ||
                   encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED) ) {
            waveType = WAVE_FORMAT_PCM;
        } else {
            waveType = WAVE_FORMAT_UNKNOWN;
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:WaveFileFormat.java

示例2: getAudioFileTypes

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {

        AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
        System.arraycopy(types, 0, filetypes, 0, types.length);

        // make sure we can write this stream
        AudioFormat format = stream.getFormat();
        AudioFormat.Encoding encoding = format.getEncoding();

        if( AudioFormat.Encoding.ALAW.equals(encoding) ||
            AudioFormat.Encoding.ULAW.equals(encoding) ||
            AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ||
            AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding) ) {

            return filetypes;
        }

        return new AudioFileFormat.Type[0];
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:WaveFileWriter.java

示例3: getAudioFileTypes

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public Type[] getAudioFileTypes(AudioInputStream stream) {

    Type[] filetypes = new Type[types.length];
    System.arraycopy(types, 0, filetypes, 0, types.length);

    // make sure we can write this stream
    AudioFormat format = stream.getFormat();
    AudioFormat.Encoding encoding = format.getEncoding();

    if (AudioFormat.Encoding.ALAW.equals(encoding)
            || AudioFormat.Encoding.ULAW.equals(encoding)
            || AudioFormat.Encoding.PCM_SIGNED.equals(encoding)
            || AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)
            || AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) {
        return filetypes;
    }

    return new Type[0];
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AuFileWriter.java

示例4: getAudioFileTypes

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {

        AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
        System.arraycopy(types, 0, filetypes, 0, types.length);

        // make sure we can write this stream
        AudioFormat format = stream.getFormat();
        AudioFormat.Encoding encoding = format.getEncoding();

        if( (AudioFormat.Encoding.ALAW.equals(encoding)) ||
            (AudioFormat.Encoding.ULAW.equals(encoding)) ||
            (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) ||
            (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) ) {

            return filetypes;
        }

        return new AudioFileFormat.Type[0];
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:AuFileWriter.java

示例5: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:PCMtoPCMCodec.java

示例6: main

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static void main(final String[] args) {
    for (final int sampleSize : new int[]{4, 8, 16, 24, 32}) {
        for (final AudioFormat.Encoding enc : encodings) {
            for (final Boolean endian : new boolean[]{false, true}) {
                testAS(enc, endian, sampleSize);
                for (final FormatConversionProvider fcp : load
                        (FormatConversionProvider.class)) {
                    testFCP(fcp, enc, endian, sampleSize);
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:GetAudioStreamConversionSupported.java

示例7: getTargetFormats

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
    if( (AudioFormat.Encoding.PCM_SIGNED.equals(targetEncoding)
         && AudioFormat.Encoding.ULAW.equals(sourceFormat.getEncoding()))
        ||
        (AudioFormat.Encoding.ULAW.equals(targetEncoding)
         && AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()))) {
            return getOutputFormats(sourceFormat);
        } else {
            return new AudioFormat[0];
        }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:UlawCodec.java

示例8: getStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
private static AudioInputStream getStream(final AudioFormat.Encoding enc,
                                          final Boolean end,
                                          final int sampleSize) {
    final AudioFormat ftmt
            = new AudioFormat(enc, 8000, sampleSize, 1, 1, 8000, end);
    final byte[] fakedata = new byte[100];
    final InputStream in = new ByteArrayInputStream(fakedata);
    return new AudioInputStream(in, ftmt, fakedata.length);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GetAudioStreamConversionSupported.java

示例9: getTargetFormats

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
    Objects.requireNonNull(targetEncoding);
    Objects.requireNonNull(sourceFormat);
    if( (AudioFormat.Encoding.PCM_SIGNED.equals(targetEncoding)
         && AudioFormat.Encoding.ULAW.equals(sourceFormat.getEncoding()))
        ||
        (AudioFormat.Encoding.ULAW.equals(targetEncoding)
         && AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()))) {
            return getOutputFormats(sourceFormat);
        } else {
            return new AudioFormat[0];
        }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:UlawCodec.java

示例10: isTargetEncodingSupported

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 * Indicates whether the format converter supports conversion to the
 * specified target format encoding.
 * @param targetEncoding the target format encoding for which support is queried
 * @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
 */
public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){

    AudioFormat.Encoding targetEncodings[] = getTargetEncodings();

    for(int i=0; i<targetEncodings.length; i++) {
        if( targetEncoding.equals( targetEncodings[i]) ) {
            return true;
        }
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:FormatConversionProvider.java

示例11: getTargetFormats

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
    Objects.requireNonNull(sourceFormat);
    if( (targetEncoding.equals( AudioFormat.Encoding.PCM_SIGNED ) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.ALAW)) ||
        (targetEncoding.equals( AudioFormat.Encoding.ALAW) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED)) ) {
            return getOutputFormats( sourceFormat );
        } else {
            return new AudioFormat[0];
        }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:AlawCodec.java

示例12: getTargetEncodings

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){

    if( sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED ) ||
        sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_UNSIGNED ) ) {

            AudioFormat.Encoding encs[] = new AudioFormat.Encoding[2];
            encs[0] = AudioFormat.Encoding.PCM_SIGNED;
            encs[1] = AudioFormat.Encoding.PCM_UNSIGNED;
            return encs;
        } else {
            return new AudioFormat.Encoding[0];
        }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:PCMtoPCMCodec.java

示例13: getTargetEncodings

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioFormat.Encoding[] getTargetEncodings() {
    return getSourceEncodings();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:AlawCodec.java

示例14: getSourceEncodings

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public final AudioFormat.Encoding[] getSourceEncodings() {
    AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length];
    System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length);
    return encodings;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:SunCodec.java

示例15: getTargetEncodings

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public final AudioFormat.Encoding[] getTargetEncodings() {
    AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length];
    System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length);
    return encodings;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SunCodec.java


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