Java Code Examples for javax.sound.sampled.AudioFormat.Encoding#PCM_FLOAT

The following examples show how to use javax.sound.sampled.AudioFormat.Encoding#PCM_FLOAT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PCM_FLOAT_support.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 2
Source File: PCM_FLOAT_support.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 3
Source File: PCM_FLOAT_support.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 4
Source File: PCM_FLOAT_support.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 5
Source File: AudioFloatFormatConverter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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 };
}
 
Example 6
Source File: AudioFloatFormatConverter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 7
Source File: WaveFloatFileReader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 8
Source File: AudioFloatFormatConverter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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 };
}
 
Example 9
Source File: AudioFloatFormatConverter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getTargetEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 10
Source File: WaveFloatFileReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 11
Source File: AudioFloatFormatConverter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getTargetEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 12
Source File: AudioFloatFormatConverter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 13
Source File: AudioFloatFormatConverter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 14
Source File: WaveFloatFileReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 15
Source File: AudioFloatFormatConverter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 16
Source File: AudioFloatFormatConverter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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 };
}
 
Example 17
Source File: AudioFloatFormatConverter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getSourceEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 18
Source File: AudioFloatFormatConverter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Encoding[] getTargetEncodings() {
    return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
            Encoding.PCM_FLOAT };
}
 
Example 19
Source File: WaveFloatFileReader.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 20
Source File: AudioFloatFormatConverter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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 };
}