Java Code Examples for javax.sound.sampled.AudioFormat.Encoding#PCM_SIGNED
The following examples show how to use
javax.sound.sampled.AudioFormat.Encoding#PCM_SIGNED .
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: AiffData.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Convert the audio bytes into the stream * * @param format The audio format being decoded * @param audio_bytes The audio byts * @param two_bytes_data True if we using double byte data * @return The byte bufer of data */ private static ByteBuffer convertAudioBytes(AudioFormat format, byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.BIG_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) { byte b = src.get(); if (format.getEncoding() == Encoding.PCM_SIGNED) { b = (byte) (b + 127); } dest.put(b); } } dest.rewind(); return dest; }
Example 2
Source File: AudioFormatKeys.java From jpexs-decompiler with GNU General Public License v3.0 | 5 votes |
public static javax.sound.sampled.AudioFormat toAudioFormat(Format fmt) { // We always use PCM_SIGNED or PCM_UNSIGNED return new javax.sound.sampled.AudioFormat( !fmt.containsKey(SignedKey) || fmt.get(SignedKey) ? Encoding.PCM_SIGNED : Encoding.PCM_UNSIGNED, fmt.get(SampleRateKey).floatValue(), fmt.get(SampleSizeInBitsKey, 16), fmt.get(ChannelsKey, 1), fmt.containsKey(FrameSizeKey) ? fmt.get(FrameSizeKey) : (fmt.get(SampleSizeInBitsKey, 16) + 7) / 8 * fmt.get(ChannelsKey, 1), fmt.containsKey(FrameRateKey) ? fmt.get(FrameRateKey).floatValue() : fmt.get(SampleRateKey).floatValue(), fmt.containsKey(ByteOrderKey) ? fmt.get(ByteOrderKey) == ByteOrder.BIG_ENDIAN : true); }
Example 3
Source File: AudioFloatFormatConverter.java From hottub with GNU General Public License v2.0 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 4
Source File: WavPCMAudioInputStreamFilter.java From pumpernickel with MIT License | 4 votes |
public WavPCMAudioInputStreamFilter(AudioInputStream audioIn) { super(audioIn); sourceFormat = audioIn.getFormat(); Set<Conversion> conversions = getRequiredConversions(sourceFormat); applyConversions = conversions.size() > 0; frameSize = sourceFormat.getFrameSize(); sampleSize = sourceFormat.getSampleSizeInBits() / 8; Encoding encoding; if (conversions.contains(Conversion.TO_SIGNED)) { encoding = Encoding.PCM_SIGNED; if (sampleSize == 1) { // values are input unsigned as [0, 255], and output to // [-128,127] valueDelta = -128; } else { // values are input unsigned as [0, 65535], and output to // [-32768,32767] valueDelta = -32768; } } else if (conversions.contains(Conversion.TO_UNSIGNED)) { encoding = Encoding.PCM_UNSIGNED; if (sampleSize == 1) { // values are input unsigned as [-128,127], and output to [0, // 255] valueDelta = 128; } else { // values are input unsigned as [-32768,32767], and output to // [0, 65535] valueDelta = 32768; } } else { encoding = sourceFormat.getEncoding(); valueDelta = 0; } destFormat = new AudioFormat(encoding, sourceFormat.getSampleRate(), sourceFormat.getSampleSizeInBits(), sourceFormat.getChannels(), sourceFormat.getFrameSize(), sourceFormat.getFrameRate(), false, sourceFormat.properties()); samplesPerFrame = frameSize / sampleSize; isSourceBigEndian = sourceFormat.isBigEndian(); isDestBigEndian = destFormat.isBigEndian(); isSourceSigned = sourceFormat.getEncoding().equals(Encoding.PCM_SIGNED); isDestSigned = destFormat.getEncoding().equals(Encoding.PCM_SIGNED); }
Example 5
Source File: AudioFloatFormatConverter.java From hottub with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 6
Source File: AudioFloatFormatConverter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 7
Source File: AudioFloatFormatConverter.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, AudioFloatConverter.PCM_FLOAT }; }
Example 8
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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-8-source with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 10
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 11
Source File: PCMtoPCMCodec.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public AudioFormat.Encoding[] getSourceEncodings() { return new Encoding[]{Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED}; }
Example 12
Source File: AudioFloatFormatConverter.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 13
Source File: AudioFloatFormatConverter.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 14
Source File: AudioFloatFormatConverter.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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 15
Source File: AudioFloatFormatConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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 16
Source File: AudioFloatFormatConverter.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { 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 |
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 18
Source File: AudioFloatFormatConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 19
Source File: AudioFloatFormatConverter.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }
Example 20
Source File: AudioFloatFormatConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; }