equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
27 */ |
27 */ |
28 |
28 |
29 import java.io.ByteArrayOutputStream; |
29 import java.io.ByteArrayOutputStream; |
30 import java.io.File; |
30 import java.io.File; |
31 import java.io.FileOutputStream; |
31 import java.io.FileOutputStream; |
32 import java.io.IOException; |
32 import java.io.InputStream; |
|
33 import java.nio.file.Files; |
|
34 import java.nio.file.Paths; |
33 |
35 |
34 import javax.sound.sampled.*; |
36 import javax.sound.sampled.*; |
35 |
37 |
36 import com.sun.media.sound.*; |
38 import com.sun.media.sound.*; |
37 |
39 |
53 testarray[i] *= 0.3; |
55 testarray[i] *= 0.3; |
54 } |
56 } |
55 test_byte_array = new byte[testarray.length*2]; |
57 test_byte_array = new byte[testarray.length*2]; |
56 AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); |
58 AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); |
57 test_file = File.createTempFile("test", ".raw"); |
59 test_file = File.createTempFile("test", ".raw"); |
58 FileOutputStream fos = new FileOutputStream(test_file); |
60 try (FileOutputStream fos = new FileOutputStream(test_file)) { |
59 fos.write(test_byte_array); |
61 fos.write(test_byte_array); |
|
62 } |
60 } |
63 } |
61 |
64 |
62 static void tearDown() throws Exception { |
65 static void tearDown() throws Exception { |
63 if(!test_file.delete()) |
66 Files.delete(Paths.get(test_file.getAbsolutePath())); |
64 test_file.deleteOnExit(); |
|
65 } |
67 } |
66 |
68 |
67 public static void main(String[] args) throws Exception { |
69 public static void main(String[] args) throws Exception { |
68 try |
70 try |
69 { |
71 { |