Java Code Examples for javax.sound.sampled.AudioFormat.Encoding#equals()
The following examples show how to use
javax.sound.sampled.AudioFormat.Encoding#equals() .
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: AudioFloatFormatConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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); }
Example 2
Source File: AudioFloatFormatConverter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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); }
Example 3
Source File: AudioFloatFormatConverter.java From hottub with GNU General Public License v2.0 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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); }
Example 4
Source File: AudioFloatFormatConverter.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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(AudioFloatConverter.PCM_FLOAT)) bits = 32; AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits, channels, channels * bits / 8, samplerate, bigendian); return getAudioInputStream(targetFormat, sourceStream); }
Example 5
Source File: AudioFloatFormatConverter.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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); }
Example 6
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { 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); }
Example 7
Source File: AudioFloatFormatConverter.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public boolean isConversionSupported(Encoding targetEncoding, AudioFormat sourceFormat) { Objects.requireNonNull(targetEncoding); if (AudioFloatConverter.getConverter(sourceFormat) == null) return false; for (int i = 0; i < formats.length; i++) { if (targetEncoding.equals(formats[i])) return true; } return false; }
Example 8
Source File: AudioFloatFormatConverter.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public boolean isConversionSupported(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return false; for (int i = 0; i < formats.length; i++) { if (targetEncoding.equals(formats[i])) return true; } return false; }
Example 9
Source File: PCM_FLOAT_support.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 10
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public boolean isConversionSupported(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return false; for (int i = 0; i < formats.length; i++) { if (targetEncoding.equals(formats[i])) return true; } return false; }
Example 11
Source File: PCM_FLOAT_support.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 12
Source File: PCM_FLOAT_support.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 13
Source File: PCM_FLOAT_support.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 14
Source File: PCM_FLOAT_support.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 15
Source File: PCM_FLOAT_support.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static boolean test(Encoding enc) { out("conversion " + enc + " -> PCM_FLOAT:"); Encoding[] encodings = AudioSystem.getTargetEncodings(enc); for (Encoding e: encodings) { if (e.equals(pcmFloatEnc)) { out(" - OK"); return true; } } out(" - FAILED (not supported)"); testFailed = true; return false; }
Example 16
Source File: AudioFloatFormatConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean isConversionSupported(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return false; for (int i = 0; i < formats.length; i++) { if (targetEncoding.equals(formats[i])) return true; } return false; }
Example 17
Source File: AudioFloatFormatConverter.java From hottub with GNU General Public License v2.0 | 4 votes |
public AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>(); if (targetEncoding.equals(Encoding.PCM_SIGNED)) formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); for (int bits = 16; bits < 32; bits += 8) { if (targetEncoding.equals(Encoding.PCM_SIGNED)) { formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) { formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); } } if (targetEncoding.equals(Encoding.PCM_FLOAT)) { formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } return formats.toArray(new AudioFormat[formats.size()]); }
Example 18
Source File: AudioFloatFormatConverter.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>(); if (targetEncoding.equals(Encoding.PCM_SIGNED)) formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); for (int bits = 16; bits < 32; bits += 8) { if (targetEncoding.equals(Encoding.PCM_SIGNED)) { formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) { formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); } } if (targetEncoding.equals(Encoding.PCM_FLOAT)) { formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } return formats.toArray(new AudioFormat[formats.size()]); }
Example 19
Source File: AudioFloatFormatConverter.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>(); if (targetEncoding.equals(Encoding.PCM_SIGNED)) formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); for (int bits = 16; bits < 32; bits += 8) { if (targetEncoding.equals(Encoding.PCM_SIGNED)) { formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) { formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); } } if (targetEncoding.equals(Encoding.PCM_FLOAT)) { formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } return formats.toArray(new AudioFormat[formats.size()]); }
Example 20
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>(); if (targetEncoding.equals(Encoding.PCM_SIGNED)) formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); for (int bits = 16; bits < 32; bits += 8) { if (targetEncoding.equals(Encoding.PCM_SIGNED)) { formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) { formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, false)); } } if (targetEncoding.equals(Encoding.PCM_FLOAT)) { formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } return formats.toArray(new AudioFormat[formats.size()]); }