當前位置: 首頁>>代碼示例>>Java>>正文


Java Encoding.PCM_FLOAT屬性代碼示例

本文整理匯總了Java中javax.sound.sampled.AudioFormat.Encoding.PCM_FLOAT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Encoding.PCM_FLOAT屬性的具體用法?Java Encoding.PCM_FLOAT怎麽用?Java Encoding.PCM_FLOAT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.sound.sampled.AudioFormat.Encoding的用法示例。


在下文中一共展示了Encoding.PCM_FLOAT屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

public static void main(String[] args) throws Exception {
    // 1st checks Encoding.PCM_FLOAT is available
    pcmFloatEnc = Encoding.PCM_FLOAT;

    Encoding[] encodings = AudioSystem.getTargetEncodings(pcmFloatEnc);
    out("conversion from PCM_FLOAT to " + encodings.length + " encodings:");
    for (Encoding e: encodings) {
        out("  - " + e);
    }
    if (encodings.length == 0) {
        testFailed = true;
    }

    test(Encoding.PCM_SIGNED);
    test(Encoding.PCM_UNSIGNED);

    if (testFailed) {
        throw new Exception("test failed");
    }
    out("test passed.");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:PCM_FLOAT_support.java

示例2: getTargetEncodings

@Override
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
    if (AudioFloatConverter.getConverter(sourceFormat) == null)
        return new Encoding[0];
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:AudioFloatFormatConverter.java

示例3: getSourceEncodings

public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:AudioFloatFormatConverter.java

示例4: getTargetEncodings

public Encoding[] getTargetEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:AudioFloatFormatConverter.java

示例5: internal_getAudioFileFormat

private AudioFileFormat internal_getAudioFileFormat(InputStream stream)
        throws UnsupportedAudioFileException, IOException {

    RIFFReader riffiterator = new RIFFReader(stream);
    if (!riffiterator.getFormat().equals("RIFF"))
        throw new UnsupportedAudioFileException();
    if (!riffiterator.getType().equals("WAVE"))
        throw new UnsupportedAudioFileException();

    boolean fmt_found = false;
    boolean data_found = false;

    int channels = 1;
    long samplerate = 1;
    int framesize = 1;
    int bits = 1;

    while (riffiterator.hasNextChunk()) {
        RIFFReader chunk = riffiterator.nextChunk();

        if (chunk.getFormat().equals("fmt ")) {
            fmt_found = true;

            int format = chunk.readUnsignedShort();
            if (format != 3) // WAVE_FORMAT_IEEE_FLOAT only
                throw new UnsupportedAudioFileException();
            channels = chunk.readUnsignedShort();
            samplerate = chunk.readUnsignedInt();
            /* framerate = */chunk.readUnsignedInt();
            framesize = chunk.readUnsignedShort();
            bits = chunk.readUnsignedShort();
        }
        if (chunk.getFormat().equals("data")) {
            data_found = true;
            break;
        }
    }

    if (!fmt_found)
        throw new UnsupportedAudioFileException();
    if (!data_found)
        throw new UnsupportedAudioFileException();

    AudioFormat audioformat = new AudioFormat(
            Encoding.PCM_FLOAT, samplerate, bits, channels,
            framesize, samplerate, false);
    AudioFileFormat fileformat = new AudioFileFormat(
            AudioFileFormat.Type.WAVE, audioformat,
            AudioSystem.NOT_SPECIFIED);
    return fileformat;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:51,代碼來源:WaveFloatFileReader.java

示例6: getSourceEncodings

@Override
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:AudioFloatFormatConverter.java

示例7: getAudioFileFormatImpl

@Override
StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
        throws UnsupportedAudioFileException, IOException {

    RIFFReader riffiterator = new RIFFReader(stream);
    if (!riffiterator.getFormat().equals("RIFF"))
        throw new UnsupportedAudioFileException();
    if (!riffiterator.getType().equals("WAVE"))
        throw new UnsupportedAudioFileException();

    boolean fmt_found = false;
    boolean data_found = false;

    int channels = 1;
    long samplerate = 1;
    int framesize = 1;
    int bits = 1;
    long dataSize = 0;

    while (riffiterator.hasNextChunk()) {
        RIFFReader chunk = riffiterator.nextChunk();
        if (chunk.getFormat().equals("fmt ")) {
            fmt_found = true;

            int format = chunk.readUnsignedShort();
            if (format != WaveFileFormat.WAVE_FORMAT_IEEE_FLOAT) {
                throw new UnsupportedAudioFileException();
            }
            channels = chunk.readUnsignedShort();
            samplerate = chunk.readUnsignedInt();
            /* framerate = */chunk.readUnsignedInt();
            framesize = chunk.readUnsignedShort();
            bits = chunk.readUnsignedShort();
        }
        if (chunk.getFormat().equals("data")) {
            dataSize = chunk.getSize();
            data_found = true;
            break;
        }
    }
    if (!fmt_found || !data_found) {
        throw new UnsupportedAudioFileException();
    }
    AudioFormat audioformat = new AudioFormat(
            Encoding.PCM_FLOAT, samplerate, bits, channels,
            framesize, samplerate, false);
    return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
                                  dataSize / audioformat.getFrameSize());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:49,代碼來源:WaveFloatFileReader.java

示例8: getTargetEncodings

public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
    if (AudioFloatConverter.getConverter(sourceFormat) == null)
        return new Encoding[0];
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:6,代碼來源:AudioFloatFormatConverter.java


注:本文中的javax.sound.sampled.AudioFormat.Encoding.PCM_FLOAT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。