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


Java AudioFormat.toString方法代碼示例

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


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

示例1: getAudioInputStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
        AudioFloatInputStream sourceStream) {

    if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
        throw new IllegalArgumentException("Unsupported conversion: "
                + sourceStream.getFormat().toString() + " to "
                + targetFormat.toString());
    if (targetFormat.getChannels() != sourceStream.getFormat()
            .getChannels())
        sourceStream = new AudioFloatInputStreamChannelMixer(sourceStream,
                targetFormat.getChannels());
    if (Math.abs(targetFormat.getSampleRate()
            - sourceStream.getFormat().getSampleRate()) > 0.000001)
        sourceStream = new AudioFloatInputStreamResampler(sourceStream,
                targetFormat);
    return new AudioInputStream(new AudioFloatFormatConverterInputStream(
            targetFormat, sourceStream), targetFormat, sourceStream
            .getFrameLength());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:AudioFloatFormatConverter.java

示例2: getAudioInputStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
    if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
        throw new IllegalArgumentException("Unsupported conversion: "
                                           + sourceStream.getFormat().toString() + " to "
                                           + targetFormat.toString());
    return getConvertedStream( targetFormat, sourceStream );
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:PCMtoPCMCodec.java

示例3: getAudioInputStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
    if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
        throw new IllegalArgumentException("Unsupported conversion: "
                                           + sourceStream.getFormat().toString() + " to "
                                           + targetFormat.toString());
    return getConvertedStream(targetFormat, sourceStream);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:UlawCodec.java

示例4: 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

示例5: open

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
        throws LineUnavailableException {
    synchronized (control_mutex) {
        if (isOpen()) {
            throw new IllegalStateException(
                    "Clip is already open with format " + getFormat()
                            + " and frame lengh of " + getFrameLength());
        }
        if (AudioFloatConverter.getConverter(format) == null)
            throw new IllegalArgumentException("Invalid format : "
                    + format.toString());
        if (bufferSize % format.getFrameSize() != 0)
            throw new IllegalArgumentException(
                    "Buffer size does not represent an integral number of sample frames!");

        if (data != null) {
            this.data = Arrays.copyOf(data, data.length);
        }
        this.offset = offset;
        this.bufferSize = bufferSize;
        this.format = format;
        this.framesize = format.getFrameSize();

        loopstart = 0;
        loopend = -1;
        loop_sg = true;

        if (!mixer.isOpen()) {
            mixer.open();
            mixer.implicitOpen = true;
        }

        outputformat = mixer.getFormat();
        out_nrofchannels = outputformat.getChannels();
        in_nrofchannels = format.getChannels();

        open = true;

        mixer.getMainMixer().openLine(this);
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:43,代碼來源:SoftMixingClip.java

示例6: 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:SunburstApps,項目名稱:OpenJSharp,代碼行數:52,代碼來源:UlawCodec.java

示例7: 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 = stream.getFrameLength();
            }

            // set framePos to zero
            framePos = 0;
            frameSize = inputFormat.getFrameSize();
            if( frameSize==AudioSystem.NOT_SPECIFIED ) {
                frameSize=1;
            }
        }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:54,代碼來源:AlawCodec.java

示例8: open

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
        throws LineUnavailableException {
    synchronized (control_mutex) {
        if (isOpen()) {
            throw new IllegalStateException(
                    "Clip is already open with format " + getFormat()
                            + " and frame lengh of " + getFrameLength());
        }
        if (AudioFloatConverter.getConverter(format) == null)
            throw new IllegalArgumentException("Invalid format : "
                    + format.toString());
        Toolkit.validateBuffer(format.getFrameSize(), bufferSize);

        if (data != null) {
            this.data = Arrays.copyOf(data, data.length);
        }
        this.offset = offset;
        this.bufferSize = bufferSize;
        this.format = format;
        this.framesize = format.getFrameSize();

        loopstart = 0;
        loopend = -1;
        loop_sg = true;

        if (!mixer.isOpen()) {
            mixer.open();
            mixer.implicitOpen = true;
        }

        outputformat = mixer.getFormat();
        out_nrofchannels = outputformat.getChannels();
        in_nrofchannels = format.getChannels();

        open = true;

        mixer.getMainMixer().openLine(this);
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:42,代碼來源:SoftMixingClip.java

示例9: 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 = stream.getFrameLength();
    }
    // set framePos to zero
    framePos = 0;
    frameSize = inputFormat.getFrameSize();
    if (frameSize == AudioSystem.NOT_SPECIFIED) {
        frameSize = 1;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:52,代碼來源:UlawCodec.java

示例10: 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


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