com.sun.media.sound.AudioFloatConverter Java Examples
The following examples show how to use
com.sun.media.sound.AudioFloatConverter.
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: TGMixer.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public TGMixer() { super(new Line.Info(Mixer.class)); this.lines = new HashMap<Class<?>, Line>(); this.sourceLineInfo = new ArrayList<DataLine.Info>(); this.targetLineInfo = new ArrayList<DataLine.Info>(); List<AudioFormat> formats = new ArrayList<AudioFormat>(); for (int channels = 1; channels <= 2; channels++) { formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); 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) { 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_UNSIGNED, 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)); formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } this.sourceLineInfo.add(new DataLine.Info(SourceDataLine.class, formats.toArray(new AudioFormat[formats.size()]), AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED)); }
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
Source File: TestPreciseTimestampRendering.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #8
Source File: TestPreciseTimestampRendering.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #9
Source File: TestPreciseTimestampRendering.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #10
Source File: TestPreciseTimestampRendering.java From hottub with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #11
Source File: TestPreciseTimestampRendering.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #12
Source File: TestPreciseTimestampRendering.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #13
Source File: TestPreciseTimestampRendering.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #14
Source File: TestPreciseTimestampRendering.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #15
Source File: TestPreciseTimestampRendering.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #16
Source File: TestPreciseTimestampRendering.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #17
Source File: TestPreciseTimestampRendering.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #18
Source File: TestPreciseTimestampRendering.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #19
Source File: TestPreciseTimestampRendering.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static SF2Soundbank createTestSoundbank() { // Create impulse instrument // used to measure timing of note-on playback SF2Soundbank soundbank = new SF2Soundbank(); float[] data = new float[100]; Arrays.fill(data, 0); data[0] = 1.0f; byte[] bdata = new byte[data.length * format.getFrameSize()]; AudioFloatConverter.getConverter(format).toByteArray(data, bdata); SF2Sample sample = new SF2Sample(soundbank); sample.setName("Test Sample"); sample.setData(bdata); sample.setSampleRate((long) format.getSampleRate()); sample.setOriginalPitch(69); soundbank.addResource(sample); SF2Layer layer = new SF2Layer(soundbank); layer.setName("Test Layer"); soundbank.addResource(layer); SF2LayerRegion region = new SF2LayerRegion(); region.setSample(sample); layer.getRegions().add(region); SF2Instrument ins = new SF2Instrument(soundbank); ins.setName("Test Instrument"); soundbank.addInstrument(ins); SF2InstrumentRegion insregion = new SF2InstrumentRegion(); insregion.setLayer(layer); ins.getRegions().add(insregion); return soundbank; }
Example #20
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); }
Example #21
Source File: TestPreciseTimestampRendering.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #22
Source File: TestPreciseTimestampRendering.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #23
Source File: TestPreciseTimestampRendering.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #24
Source File: TestPreciseTimestampRendering.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #25
Source File: TestPreciseTimestampRendering.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #26
Source File: TestPreciseTimestampRendering.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #27
Source File: TestPreciseTimestampRendering.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #28
Source File: TestPreciseTimestampRendering.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #29
Source File: TestPreciseTimestampRendering.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }
Example #30
Source File: TestPreciseTimestampRendering.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void test(Soundbank soundbank) throws Exception { // Create instance of synthesizer using the testing soundbank above AudioSynthesizer synth = new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, null); synth.unloadAllInstruments(synth.getDefaultSoundbank()); synth.loadAllInstruments(soundbank); Receiver recv = synth.getReceiver(); // Set volume to max and turn reverb off ShortMessage reverb_off = new ShortMessage(); reverb_off.setMessage(ShortMessage.CONTROL_CHANGE, 91, 0); recv.send(reverb_off, -1); ShortMessage full_volume = new ShortMessage(); full_volume.setMessage(ShortMessage.CONTROL_CHANGE, 7, 127); recv.send(full_volume, -1); Random random = new Random(3485934583945l); // Create random timestamps long[] test_timestamps = new long[30]; for (int i = 1; i < test_timestamps.length; i++) { test_timestamps[i] = i * 44100 + (int) (random.nextDouble() * 22050.0); } // Send midi note on message to synthesizer for (int i = 0; i < test_timestamps.length; i++) { ShortMessage midi_on = new ShortMessage(); midi_on.setMessage(ShortMessage.NOTE_ON, 69, 127); recv.send(midi_on, (long) ((test_timestamps[i] / 44100.0) * 1000000.0)); } // Measure timing from rendered audio float[] fbuffer = new float[100]; byte[] buffer = new byte[fbuffer.length * format.getFrameSize()]; long firsts = -1; int counter = 0; long s = 0; long max_jitter = 0; outerloop: for (int k = 0; k < 10000000; k++) { stream.read(buffer); AudioFloatConverter.getConverter(format).toFloatArray(buffer, fbuffer); for (int i = 0; i < fbuffer.length; i++) { if (fbuffer[i] != 0) { if (firsts == -1) firsts = s; long measure_time = (s - firsts); long predicted_time = test_timestamps[counter]; long jitter = Math.abs(measure_time - predicted_time); if (jitter > 10) max_jitter = jitter; counter++; if (counter == test_timestamps.length) break outerloop; } s++; } } synth.close(); if (counter == 0) throw new Exception("Nothing was measured!"); if (max_jitter != 0) { throw new Exception("Jitter has occurred! " + "(max jitter = " + max_jitter + ")"); } }