JOAL v2.6.0-rc-20250712
JOAL, OpenAL® API Binding for Java™ (public API).
ALutWAVLoaderTest.java
Go to the documentation of this file.
1package com.jogamp.openal.test.junit;
2
3import static org.junit.Assert.*;
4
5import java.io.IOException;
6import java.nio.ByteBuffer;
7import java.nio.ByteOrder;
8
9import org.junit.FixMethodOrder;
10import org.junit.Test;
11import org.junit.Assert;
12import org.junit.runners.MethodSorters;
13
14import com.jogamp.openal.test.resources.ResourceLocation;
15import com.jogamp.openal.test.util.UITestCase;
16import com.jogamp.openal.util.ALut;
17import com.jogamp.openal.util.WAVData;
18import com.jogamp.openal.util.WAVLoader;
19
20@FixMethodOrder(MethodSorters.NAME_ASCENDING)
21public class ALutWAVLoaderTest extends UITestCase {
22
23 @Test
24 public void testALutLoadWAVFileStream() throws IOException {
25 // variables to load into
26 final int[] format = new int[1];
27 final int[] size = new int[1];
28 final ByteBuffer[] data = new ByteBuffer[1];
29 final int[] freq = new int[1];
30 final int[] loop = new int[1];
31
32 ALut.alutLoadWAVFile(ResourceLocation.getTestStream0(), format, data, size, freq, loop);
33 System.out.println("*** ALut.alutLoadWAV Stream0 size "+size[0]);
34 Assert.assertTrue("Stream0 size "+ResourceLocation.getTestStream0Size()+" < "+size[0], size[0] <= ResourceLocation.getTestStream0Size());
35
36 ALut.alutLoadWAVFile(ResourceLocation.getTestStream3(), format, data, size, freq, loop);
37 System.out.println("*** ALut.alutLoadWAV Stream3 size "+size[0]);
38 Assert.assertTrue("Stream3 size "+ResourceLocation.getTestStream3Size()+" < "+size[0], size[0] <= ResourceLocation.getTestStream3Size());
39
40 }
41
42 @Test
43 public void testWAVDataLoadStream() throws IOException {
44 final WAVData wd0 = WAVData.loadFromStream(ResourceLocation.getTestStream0(), ResourceLocation.getTestStream0Size(), 1, 8, 22050, ByteOrder.LITTLE_ENDIAN, true);
45 System.out.println("*** WAVData.loadFrom Stream0 size "+wd0.data.limit());
46 assertEquals(wd0.data.limit(), ResourceLocation.getTestStream0Size());
47
48 final WAVData wd1 = WAVData.loadFromStream(ResourceLocation.getTestStream1(), ResourceLocation.getTestStream1Size(), 2, 16, 44100, ByteOrder.BIG_ENDIAN, true);
49 System.out.println("*** WAVData.loadFrom Stream1 size "+wd1.data.limit());
50 assertEquals(wd1.data.limit(), ResourceLocation.getTestStream1Size());
51
52 final WAVData wd2 = WAVData.loadFromStream(ResourceLocation.getTestStream2(), ResourceLocation.getTestStream2Size(), 2, 16, 44100, ByteOrder.LITTLE_ENDIAN, true);
53 System.out.println("*** WAVData.loadFrom Stream2 size "+wd2.data.limit());
54 assertEquals(wd2.data.limit(), ResourceLocation.getTestStream2Size());
55
56 final WAVData wd3 = WAVData.loadFromStream(ResourceLocation.getTestStream3(), ResourceLocation.getTestStream3Size(), 2, 16, 44100, ByteOrder.LITTLE_ENDIAN, true);
57 System.out.println("*** WAVData.loadFrom Stream3 size "+wd3.data.limit());
58 assertEquals(wd3.data.limit(), ResourceLocation.getTestStream3Size());
59
60 }
61
62 @Test
63 public void testWAVLoaderLoadStream() throws IOException {
65 System.out.println("*** WAVLoader.loadFrom Stream0 size "+wd0.data.limit());
66 Assert.assertTrue("Stream0 size "+ResourceLocation.getTestStream0Size()+" < "+wd0.data.limit(), wd0.data.limit() <= ResourceLocation.getTestStream0Size());
67
69 System.out.println("*** WAVLoader.loadFrom Stream3 size "+wd3.data.limit());
70 Assert.assertTrue("Stream3 size "+ResourceLocation.getTestStream3Size()+" < "+wd3.data.limit()+" .. "+wd3.data, wd3.data.limit() <= ResourceLocation.getTestStream3Size());
71 }
72
73 // TODO test * LoadFile
74
75 public static void main(final String args[]) throws IOException {
76 org.junit.runner.JUnitCore.main(ALutWAVLoaderTest.class.getName());
77 }
78}
static InputStream getTestStream3()
WAV 44100Hz, 2 channels, S16_LE.
static InputStream getTestStream2()
CDR 44100Hz, 2 channels, S16_LE.
static InputStream getTestStream0()
WAV 22050Hz, 1 channel, S8_LE.
static InputStream getTestStream1()
CDR 44100Hz, 2 channels, S16_BE.
static void alutLoadWAVFile(final String fileName, final int[] format, final ByteBuffer[] data, final int[] size, final int[] freq, final int[] loop)
Definition: ALut.java:106
This class is a holder for WAV (.wav ) file Data returned from the WavLoader, or directly via loadFro...
Definition: WAVData.java:53
final ByteBuffer data
The audio data.
Definition: WAVData.java:55
static WAVData loadFromStream(InputStream aIn, final int byteCount, final int numChannels, final int bits, final int sampleRate, final ByteOrder byteOrder, final boolean loop)
This method loads a (.wav) file into a WAVData object.
Definition: WAVData.java:100
A Loader utility for (.wav) files.
Definition: WAVLoader.java:51
static WAVData loadFromStream(final InputStream stream)
This method loads a (.wav) file into a WAVData object.
Definition: WAVLoader.java:81