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


Java Encoding.toString方法代碼示例

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


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

示例1: getAudioInputStream

import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的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

示例2: getAudioInputStream

import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
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:campolake,項目名稱:openjdk9,代碼行數:22,代碼來源:AudioFloatFormatConverter.java

示例3: convertFormat

import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
/**
 * Convert javax.sound.sampled.AudioFormat to
 * javax.media.format.AudioFormat.
 */
public static AudioFormat convertFormat(
        javax.sound.sampled.AudioFormat format)
{
    Encoding encoding = format.getEncoding();
    int channels = format.getChannels();
    float frameRate = format.getFrameRate();
    int frameSize = format.getFrameSize() < 0 ? format.getFrameSize()
            : (format.getFrameSize() * 8);
    float sampleRate = format.getSampleRate();
    int sampleSize = format.getSampleSizeInBits();

    int endian = format.isBigEndian() ? AudioFormat.BIG_ENDIAN
            : AudioFormat.LITTLE_ENDIAN;

    int signed = Format.NOT_SPECIFIED;
    String encodingString = AudioFormat.LINEAR;

    if (encoding == Encoding.PCM_SIGNED)
    {
        signed = AudioFormat.SIGNED;
        encodingString = AudioFormat.LINEAR;
    } else if (encoding == Encoding.PCM_UNSIGNED)
    {
        signed = AudioFormat.UNSIGNED;
        encodingString = AudioFormat.LINEAR;
    } else if (encoding == Encoding.ALAW)
    {
        encodingString = AudioFormat.ALAW;
    } else if (encoding == Encoding.ULAW)
    {
        encodingString = AudioFormat.ULAW;
    } else
    {
        encodingString = encoding.toString();

    }

    AudioFormat jmfFormat = new AudioFormat(encodingString, sampleRate,
            sampleSize, channels, endian, signed, frameSize, frameRate,
            Format.byteArray);

    return jmfFormat;
}
 
開發者ID:champtar,項目名稱:fmj-sourceforge-mirror,代碼行數:48,代碼來源:JavaSoundUtils.java


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