changeset in /hg/icedtea: Import Gervill CVS source reformatting.
Mark Wielaard
mark at klomp.org
Sun Jun 22 12:34:44 PDT 2008
changeset 5a126447fc2c in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=5a126447fc2c
description:
Import Gervill CVS source reformatting.
2008-06-08 Mark Wielaard <mark at klomp.org>
* overlays/openjdk/jdk/src/share/classes/com/sun/media/sound:
Import Gervill CVS source reformatting.
diffstat:
101 files changed, 24535 insertions(+), 25117 deletions(-)
ChangeLog | 5
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java | 166
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java | 2014 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java | 1067 +
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java | 488
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizer.java | 130
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java | 97
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java | 206
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java | 798 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java | 607 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java | 238
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSample.java | 195
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java | 103
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java | 139
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java | 2564 ++--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java | 71
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java | 5456 ++++------
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/FFT.java | 1500 +-
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/InvalidDataException.java | 70
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/InvalidFormatException.java | 72
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java | 196
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelAbstractChannelMixer.java | 186
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelAbstractOscillator.java | 375
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java | 641 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java | 550 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelChannelMixer.java | 74
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java | 254
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java | 196
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelDirectedPlayer.java | 57
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelDirector.java | 75
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java | 296
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java | 241
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java | 83
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java | 94
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelOscillator.java | 74
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelOscillatorStream.java | 72
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java | 83
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java | 237
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelSource.java | 193
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java | 148
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java | 245
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelTransform.java | 54
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelWavetable.java | 83
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java | 19
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java | 19
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java | 599 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java | 666 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java | 53
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java | 1687 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java | 71
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java | 135
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java | 69
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java | 175
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Region.java | 316
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java | 403
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java | 1923 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java | 122
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SimpleInstrument.java | 282
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SimpleSoundbank.java | 182
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java | 731 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java | 122
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioProcessor.java | 22
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java | 101
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java | 2949 ++---
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java | 336
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java | 650 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftControl.java | 8
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java | 110
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java | 572 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java | 1199 +-
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java | 85
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java | 483
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java | 155
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java | 287
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java | 74
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java | 146
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java | 184
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java | 1848 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java | 324
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java | 985 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java | 947 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java | 435
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java | 865 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java | 47
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java | 948 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java | 1460 +-
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java | 60
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftProcess.java | 14
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java | 29
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java | 88
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftResampler.java | 8
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftResamplerStreamer.java | 9
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java | 896 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java | 41
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java | 193
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java | 1897 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java | 443
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java | 1720 +--
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java | 566 -
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java | 213
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java | 188
diffs (truncated from 51710 to 500 lines):
diff -r 94f0c8f3a4aa -r 5a126447fc2c ChangeLog
--- a/ChangeLog Sun Jun 08 21:21:14 2008 +0200
+++ b/ChangeLog Sun Jun 08 22:27:05 2008 +0200
@@ -1,3 +1,8 @@ 2008-06-08 Mark Wielaard <mark at klomp.o
+2008-06-08 Mark Wielaard <mark at klomp.org>
+
+ * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound:
+ Import Gervill CVS source reformatting.
+
2008-06-08 Mark Wielaard <mark at klomp.org>
* overlays/openjdk/jdk/src/share/classes/com/sun/media/sound:
diff -r 94f0c8f3a4aa -r 5a126447fc2c overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java Sun Jun 08 21:21:14 2008 +0200
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java Sun Jun 08 22:27:05 2008 +0200
@@ -22,7 +22,6 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-
package com.sun.media.sound;
import java.io.ByteArrayOutputStream;
@@ -42,98 +41,91 @@ import javax.sound.sampled.UnsupportedAu
/**
* Soundbank reader that uses audio files as soundbanks.
*
- * @version %I%, %E%
* @author Karl Helgason
- *
*/
public class AudioFileSoundbankReader extends SoundbankReader {
- public Soundbank getSoundbank(URL url) throws InvalidMidiDataException,
- IOException {
- try {
- AudioInputStream ais = AudioSystem.getAudioInputStream(url);
- Soundbank sbk = getSoundbank(ais);
- ais.close();
- return sbk;
- } catch (UnsupportedAudioFileException e) {
- return null;
- } catch (IOException e) {
- return null;
- }
- }
+ public Soundbank getSoundbank(URL url)
+ throws InvalidMidiDataException, IOException {
+ try {
+ AudioInputStream ais = AudioSystem.getAudioInputStream(url);
+ Soundbank sbk = getSoundbank(ais);
+ ais.close();
+ return sbk;
+ } catch (UnsupportedAudioFileException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
- public Soundbank getSoundbank(InputStream stream)
- throws InvalidMidiDataException, IOException {
+ public Soundbank getSoundbank(InputStream stream)
+ throws InvalidMidiDataException, IOException {
+ stream.mark(512);
+ try {
+ AudioInputStream ais = AudioSystem.getAudioInputStream(stream);
+ Soundbank sbk = getSoundbank(ais);
+ if (sbk != null)
+ return sbk;
+ } catch (UnsupportedAudioFileException e) {
+ } catch (IOException e) {
+ }
+ stream.reset();
+ return null;
+ }
- stream.mark(512);
- try {
- AudioInputStream ais = AudioSystem.getAudioInputStream(stream);
- Soundbank sbk = getSoundbank(ais);
- if (sbk != null)
- return sbk;
- } catch (UnsupportedAudioFileException e) {
- } catch (IOException e) {
- }
- stream.reset();
- return null;
- }
+ public Soundbank getSoundbank(AudioInputStream ais)
+ throws InvalidMidiDataException, IOException {
+ try {
+ byte[] buffer;
+ if (ais.getFrameLength() == -1) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buff = new byte[1024
+ - (1024 % ais.getFormat().getFrameSize())];
+ int ret;
+ while ((ret = ais.read(buff)) != -1) {
+ baos.write(buff, 0, ret);
+ }
+ ais.close();
+ buffer = baos.toByteArray();
+ } else {
+ buffer = new byte[(int) (ais.getFrameLength()
+ * ais.getFormat().getFrameSize())];
+ new DataInputStream(ais).readFully(buffer);
+ }
+ ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
+ new ModelByteBuffer(buffer), ais.getFormat(), -4800);
+ ModelPerformer performer = new ModelPerformer();
+ performer.getOscillators().add(osc);
- public Soundbank getSoundbank(AudioInputStream ais)
- throws InvalidMidiDataException, IOException {
+ SimpleSoundbank sbk = new SimpleSoundbank();
+ SimpleInstrument ins = new SimpleInstrument();
+ ins.add(performer);
+ sbk.addInstrument(ins);
+ return sbk;
+ } catch (Exception e) {
+ return null;
+ }
+ }
- try {
- byte[] buffer;
- if (ais.getFrameLength() == -1) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buff = new byte[1024 - (1024 % ais.getFormat()
- .getFrameSize())];
- int ret;
- while ((ret = ais.read(buff)) != -1)
- baos.write(buff, 0, ret);
- ais.close();
- buffer = baos.toByteArray();
- } else {
- buffer = new byte[(int) (ais.getFrameLength() * ais.getFormat()
- .getFrameSize())];
- new DataInputStream(ais).readFully(buffer);
- }
- ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
- new ModelByteBuffer(buffer), ais.getFormat(), -4800);
- ModelPerformer performer = new ModelPerformer();
- ;
- performer.getOscillators().add(osc);
-
- SimpleSoundbank sbk = new SimpleSoundbank();
- SimpleInstrument ins = new SimpleInstrument();
- ins.add(performer);
- sbk.addInstrument(ins);
- return sbk;
- } catch (Exception e) {
- return null;
- }
- }
-
- public Soundbank getSoundbank(File file) throws InvalidMidiDataException,
- IOException {
-
- try {
- AudioInputStream ais = AudioSystem.getAudioInputStream(file);
- ais.close();
- ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
- new ModelByteBuffer(file, 0, file.length()), -4800);
- ModelPerformer performer = new ModelPerformer();
- performer.getOscillators().add(osc);
- SimpleSoundbank sbk = new SimpleSoundbank();
- SimpleInstrument ins = new SimpleInstrument();
- ins.add(performer);
- sbk.addInstrument(ins);
- return sbk;
- } catch (UnsupportedAudioFileException e1) {
- return null;
- } catch (IOException e) {
- return null;
- }
-
- }
-
+ public Soundbank getSoundbank(File file)
+ throws InvalidMidiDataException, IOException {
+ try {
+ AudioInputStream ais = AudioSystem.getAudioInputStream(file);
+ ais.close();
+ ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
+ new ModelByteBuffer(file, 0, file.length()), -4800);
+ ModelPerformer performer = new ModelPerformer();
+ performer.getOscillators().add(osc);
+ SimpleSoundbank sbk = new SimpleSoundbank();
+ SimpleInstrument ins = new SimpleInstrument();
+ ins.add(performer);
+ sbk.addInstrument(ins);
+ return sbk;
+ } catch (UnsupportedAudioFileException e1) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
}
diff -r 94f0c8f3a4aa -r 5a126447fc2c overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Sun Jun 08 21:21:14 2008 +0200
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Sun Jun 08 22:27:05 2008 +0200
@@ -22,7 +22,6 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-
package com.sun.media.sound;
import java.nio.ByteBuffer;
@@ -37,1006 +36,1023 @@ import javax.sound.sampled.AudioFormat.E
* This class is used to convert between 8,16,24,32,32+ bit signed/unsigned
* big/litle endian fixed/floating point byte buffers and float buffers.
*
- * @version %I%, %E%
* @author Karl Helgason
*/
-
public abstract class AudioFloatConverter {
- public static final Encoding PCM_FLOAT = new Encoding("PCM_FLOAT");
-
- /***************************************************************************
- *
- * LSB Filter, used filter least significant byte in samples arrays.
- *
- * Is used filter out data in lsb byte
- * when SampleSizeInBits is not dividable by 8.
- *
- **************************************************************************/
-
- private static class AudioFloatLSBFilter extends AudioFloatConverter {
-
- private AudioFloatConverter converter;
- final private int offset;
- final private int stepsize;
- final private byte mask;
- private byte[] mask_buffer;
-
- public AudioFloatLSBFilter(AudioFloatConverter converter, AudioFormat format)
- {
- int bits = format.getSampleSizeInBits();
- boolean bigEndian = format.isBigEndian();
- this.converter = converter;
- stepsize = (bits + 7) / 8;
- offset = bigEndian?(stepsize - 1):0;
- int lsb_bits = bits % 8;
- if(lsb_bits == 0) mask = (byte)0x00;
- else if(lsb_bits == 1) mask = (byte)0x80;
- else if(lsb_bits == 2) mask = (byte)0xC0;
- else if(lsb_bits == 3) mask = (byte)0xE0;
- else if(lsb_bits == 4) mask = (byte)0xF0;
- else if(lsb_bits == 5) mask = (byte)0xF8;
- else if(lsb_bits == 6) mask = (byte)0xFC;
- else if(lsb_bits == 7) mask = (byte)0xFE;
- else mask = (byte)0xFF;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len, byte[] out_buff, int out_offset) {
- byte[] ret = converter.toByteArray(in_buff, in_offset, in_len, out_buff, out_offset);
-
- int out_offset_end = in_len*stepsize;
- for (int i = out_offset+offset; i < out_offset_end; i+=stepsize) {
- out_buff[i] = (byte)(out_buff[i] & mask);
- }
-
- return ret;
- }
-
- public float[] toFloatArray(byte[] in_buff, int in_offset, float[] out_buff, int out_offset, int out_len) {
- if(mask_buffer == null || mask_buffer.length < in_buff.length)
- mask_buffer = new byte[in_buff.length];
- System.arraycopy(in_buff, 0, mask_buffer, 0, in_buff.length);
- int in_offset_end = out_len*stepsize;
- for (int i = in_offset+offset; i < in_offset_end; i+=stepsize) {
- mask_buffer[i] = (byte)(mask_buffer[i] & mask);
- }
- float[] ret = converter.toFloatArray(mask_buffer, in_offset, out_buff, out_offset, out_len);
- return ret;
- }
-
- }
-
- /***************************************************************************
- *
- * 64 bit float, little/big-endian
- *
- **************************************************************************/
-
- // PCM 64 bit float, little-endian
- private static class AudioFloatConversion64L extends AudioFloatConverter {
- ByteBuffer bytebuffer = null;
-
- DoubleBuffer floatbuffer = null;
- double[] double_buff = null;
-
- public float[] toFloatArray(byte[] in_buff, int in_offset,
- float[] out_buff, int out_offset, int out_len) {
- int in_len = out_len * 8;
- if (bytebuffer == null || bytebuffer.capacity() < in_len) {
- bytebuffer = ByteBuffer.allocate(in_len).order(
- ByteOrder.LITTLE_ENDIAN);
- floatbuffer = bytebuffer.asDoubleBuffer();
- }
- bytebuffer.position(0);
- floatbuffer.position(0);
- bytebuffer.put(in_buff, in_offset, in_len);
- if(double_buff == null || double_buff.length < out_len+out_offset)
- double_buff = new double[out_len+out_offset];
- floatbuffer.get(double_buff, out_offset, out_len);
- int out_offset_end = out_offset + out_len;
- for (int i = out_offset; i < out_offset_end; i++) {
- out_buff[i] = (float)double_buff[i];
- }
- return out_buff;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff, int out_offset) {
- int out_len = in_len * 8;
- if (bytebuffer == null || bytebuffer.capacity() < out_len) {
- bytebuffer = ByteBuffer.allocate(out_len).order(
- ByteOrder.LITTLE_ENDIAN);
- floatbuffer = bytebuffer.asDoubleBuffer();
- }
- floatbuffer.position(0);
- bytebuffer.position(0);
- if(double_buff == null || double_buff.length < in_offset+in_len)
- double_buff = new double[in_offset+in_len];
- int in_offset_end = in_offset+in_len;
- for (int i = in_offset; i < in_offset_end; i++) {
- double_buff[i] = in_buff[i];
- }
- floatbuffer.put(double_buff, in_offset, in_len);
- bytebuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
- }
-
- // PCM 64 bit float, big-endian
- private static class AudioFloatConversion64B extends AudioFloatConverter {
- ByteBuffer bytebuffer = null;
-
- DoubleBuffer floatbuffer = null;
- double[] double_buff = null;
-
- public float[] toFloatArray(byte[] in_buff, int in_offset,
- float[] out_buff, int out_offset, int out_len) {
- int in_len = out_len * 8;
- if (bytebuffer == null || bytebuffer.capacity() < in_len) {
- bytebuffer = ByteBuffer.allocate(in_len).order(
- ByteOrder.BIG_ENDIAN);
- floatbuffer = bytebuffer.asDoubleBuffer();
- }
- bytebuffer.position(0);
- floatbuffer.position(0);
- bytebuffer.put(in_buff, in_offset, in_len);
- if(double_buff == null || double_buff.length < out_len+out_offset)
- double_buff = new double[out_len+out_offset];
- floatbuffer.get(double_buff, out_offset, out_len);
- int out_offset_end = out_offset + out_len;
- for (int i = out_offset; i < out_offset_end; i++) {
- out_buff[i] = (float)double_buff[i];
- }
- return out_buff;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff, int out_offset) {
- int out_len = in_len * 8;
- if (bytebuffer == null || bytebuffer.capacity() < out_len) {
- bytebuffer = ByteBuffer.allocate(out_len).order(
- ByteOrder.BIG_ENDIAN);
- floatbuffer = bytebuffer.asDoubleBuffer();
- }
- floatbuffer.position(0);
- bytebuffer.position(0);
- if(double_buff == null || double_buff.length < in_offset+in_len)
- double_buff = new double[in_offset+in_len];
- int in_offset_end = in_offset+in_len;
- for (int i = in_offset; i < in_offset_end; i++) {
- double_buff[i] = in_buff[i];
- }
- floatbuffer.put(double_buff, in_offset, in_len);
- bytebuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
- }
-
- /***************************************************************************
- *
- * 32 bit float, little/big-endian
- *
- **************************************************************************/
-
- // PCM 32 bit float, little-endian
- private static class AudioFloatConversion32L extends AudioFloatConverter {
- ByteBuffer bytebuffer = null;
-
- FloatBuffer floatbuffer = null;
-
- public float[] toFloatArray(byte[] in_buff, int in_offset,
- float[] out_buff, int out_offset, int out_len) {
- int in_len = out_len * 4;
- if (bytebuffer == null || bytebuffer.capacity() < in_len) {
- bytebuffer = ByteBuffer.allocate(in_len).order(
- ByteOrder.LITTLE_ENDIAN);
- floatbuffer = bytebuffer.asFloatBuffer();
- }
- bytebuffer.position(0);
- floatbuffer.position(0);
- bytebuffer.put(in_buff, in_offset, in_len);
- floatbuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff, int out_offset) {
- int out_len = in_len * 4;
- if (bytebuffer == null || bytebuffer.capacity() < out_len) {
- bytebuffer = ByteBuffer.allocate(out_len).order(
- ByteOrder.LITTLE_ENDIAN);
- floatbuffer = bytebuffer.asFloatBuffer();
- }
- floatbuffer.position(0);
- bytebuffer.position(0);
- floatbuffer.put(in_buff, in_offset, in_len);
- bytebuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
- }
-
- // PCM 32 bit float, big-endian
- private static class AudioFloatConversion32B extends AudioFloatConverter {
- ByteBuffer bytebuffer = null;
-
- FloatBuffer floatbuffer = null;
-
- public float[] toFloatArray(byte[] in_buff, int in_offset,
- float[] out_buff, int out_offset, int out_len) {
- int in_len = out_len * 4;
- if (bytebuffer == null || bytebuffer.capacity() < in_len) {
- bytebuffer = ByteBuffer.allocate(in_len).order(
- ByteOrder.BIG_ENDIAN);
- floatbuffer = bytebuffer.asFloatBuffer();
- }
- bytebuffer.position(0);
- floatbuffer.position(0);
- bytebuffer.put(in_buff, in_offset, in_len);
- floatbuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff, int out_offset) {
- int out_len = in_len * 4;
- if (bytebuffer == null || bytebuffer.capacity() < out_len) {
- bytebuffer = ByteBuffer.allocate(out_len).order(
- ByteOrder.BIG_ENDIAN);
- floatbuffer = bytebuffer.asFloatBuffer();
- }
- floatbuffer.position(0);
- bytebuffer.position(0);
- floatbuffer.put(in_buff, in_offset, in_len);
- bytebuffer.get(out_buff, out_offset, out_len);
- return out_buff;
- }
- }
-
- /***************************************************************************
- *
- * 8 bit signed/unsigned
- *
- **************************************************************************/
-
- // PCM 8 bit, signed
- private static class AudioFloatConversion8S extends AudioFloatConverter {
- public float[] toFloatArray(byte[] in_buff, int in_offset,
- float[] out_buff, int out_offset, int out_len) {
- int ix = in_offset;
- int ox = out_offset;
- for (int i = 0; i < out_len; i++)
- out_buff[ox++] = in_buff[ix++] * (1.0f / 127.0f);
- return out_buff;
- }
-
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff, int out_offset) {
- int ix = in_offset;
- int ox = out_offset;
- for (int i = 0; i < in_len; i++)
- out_buff[ox++] = (byte) (in_buff[ix++] * 127.0f);
- return out_buff;
- }
- }
-
- // PCM 8 bit, unsigned
- private static class AudioFloatConversion8U extends AudioFloatConverter {
More information about the distro-pkg-dev
mailing list