Java Code Examples for com.sun.media.sound.AudioFloatConverter#getConverter()
The following examples show how to use
com.sun.media.sound.AudioFloatConverter#getConverter() .
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: Bits32ToFromFloatArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final Encoding enc, final byte[] expected, boolean end) { AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100, end); byte[] bytes = new byte[FLOATS.length * af.getFrameSize()]; AudioFloatConverter conv = AudioFloatConverter.getConverter(af); conv.toByteArray(FLOATS, bytes); if (!Arrays.equals(bytes, expected)) { System.err.println("Actual: " + Arrays.toString(bytes)); System.err.println("Expected: " + Arrays.toString(expected)); throw new RuntimeException(); } float[] floats = new float[bytes.length / af.getFrameSize()]; conv.toFloatArray(bytes, floats); if (!Arrays.equals(floats, FLOATS)) { System.err.println("Actual: " + Arrays.toString(floats)); System.err.println("Expected: " + Arrays.toString(FLOATS)); throw new RuntimeException(); } }
Example 2
Source File: Bits64ToFromFloatArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final Encoding enc, final byte[] expected, boolean end) { System.err.println(enc); AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100, end); byte[] bytes = new byte[FLOATS.length * af.getFrameSize()]; AudioFloatConverter conv = AudioFloatConverter.getConverter(af); conv.toByteArray(FLOATS, bytes); if (!Arrays.equals(bytes, expected)) { System.err.println("Actual: " + Arrays.toString(bytes)); System.err.println("Expected: " + Arrays.toString(expected)); throw new RuntimeException(); } float[] floats = new float[bytes.length / af.getFrameSize()]; conv.toFloatArray(bytes, floats); if (!Arrays.equals(floats, FLOATS)) { System.err.println("Actual: " + Arrays.toString(floats)); System.err.println("Expected: " + Arrays.toString(FLOATS)); throw new RuntimeException(); } }
Example 3
Source File: Bits24ToFromFloatArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final Encoding enc, final byte[] expected, boolean end) { System.err.println(enc); AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100, end); byte[] bytes = new byte[FLOATS.length * af.getFrameSize()]; AudioFloatConverter conv = AudioFloatConverter.getConverter(af); conv.toByteArray(FLOATS, bytes); if (!Arrays.equals(bytes, expected)) { System.err.println("Actual: " + Arrays.toString(bytes)); System.err.println("Expected: " + Arrays.toString(expected)); throw new RuntimeException(); } float[] floats = new float[bytes.length / af.getFrameSize()]; conv.toFloatArray(bytes, floats); if (!Arrays.equals(floats, FLOATS)) { System.err.println("Actual: " + Arrays.toString(floats)); System.err.println("Expected: " + Arrays.toString(FLOATS)); throw new RuntimeException(); } }
Example 4
Source File: Bits16ToFromFloatArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final Encoding enc, final byte[] expected, boolean end) { System.err.println("enc = " + enc); AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100, end); byte[] bytes = new byte[FLOATS.length * af.getFrameSize()]; AudioFloatConverter conv = AudioFloatConverter.getConverter(af); conv.toByteArray(FLOATS, bytes); if (!Arrays.equals(bytes, expected)) { System.err.println("Actual: " + Arrays.toString(bytes)); System.err.println("Expected: " + Arrays.toString(expected)); throw new RuntimeException(); } float[] floats = new float[bytes.length / af.getFrameSize()]; conv.toFloatArray(bytes, floats); if (!Arrays.equals(floats, FLOATS)) { System.err.println("Actual: " + Arrays.toString(floats)); System.err.println("Expected: " + Arrays.toString(FLOATS)); throw new RuntimeException(); } }
Example 5
Source File: Bits8ToFromFloatArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final Encoding enc, final byte[] expected) { AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100, true); byte[] bytes = new byte[FLOATS.length * af.getFrameSize()]; AudioFloatConverter conv = AudioFloatConverter.getConverter(af); conv.toByteArray(FLOATS, bytes); if (!Arrays.equals(bytes, expected)) { System.err.println("Actual: " + Arrays.toString(bytes)); System.err.println("Expected: " + Arrays.toString(expected)); throw new RuntimeException(); } float[] floats = new float[bytes.length / af.getFrameSize()]; conv.toFloatArray(bytes, floats); if (!Arrays.equals(floats, FLOATS)) { System.err.println("Actual: " + Arrays.toString(floats)); System.err.println("Expected: " + Arrays.toString(FLOATS)); throw new RuntimeException(); } }
Example 6
Source File: SoftAudioBuffer.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
public SoftAudioBuffer(int size, AudioFormat format) { this.size = size; this.format = format; converter = AudioFloatConverter.getConverter(format); }