JOAL v2.6.0-rc-20250712
JOAL, OpenAL® API Binding for Java™ (public API).
ResourceLocation.java
Go to the documentation of this file.
1
2package com.jogamp.openal.test.resources;
3
4import java.io.IOException;
5import java.io.InputStream;
6import java.io.BufferedInputStream;
7import java.net.URLConnection;
8
9import com.jogamp.common.util.IOUtil;
10
11/** just a tag to locate the resources */
12public class ResourceLocation {
13 /** WAV 22050Hz, 1 channel, S8_LE */
14 public static final String lewiscarrol_wav = "lewiscarroll.wav";
15 public static final int lewiscarrol_wav_size = 1025476;
16 /** CDR 44100Hz, 2 channels, S16_BE */
17 public static final String aa_cdr = "aa.cdr";
18 public static final int aa_cdr_size = 846704;
19 /** CDR 44100Hz, 2 channels, S16_LE */
20 public static final String aa_cd = "aa.cd";
21 public static final int aa_cd_size = 846704;
22 /** CDR 44100Hz, 2 channels, S16_LE */
23 public static final String aa_wav = "aa.wav";
24 public static final int aa_wav_size = 846748;
25
26 static final ResourceLocation rl;
27
28 static {
29 rl = new ResourceLocation();
30
31 }
32
33 /** WAV 22050Hz, 1 channel, S8_LE */
34 public static InputStream getTestStream0() {
35 return getInputStream(lewiscarrol_wav, true);
36 }
37 public static int getTestStream0Size() {
39 }
40 /** CDR 44100Hz, 2 channels, S16_BE */
41 public static InputStream getTestStream1() {
42 return getInputStream(aa_cdr, true);
43 }
44 public static int getTestStream1Size() {
45 return aa_cdr_size;
46 }
47 /** CDR 44100Hz, 2 channels, S16_LE */
48 public static InputStream getTestStream2() {
49 return getInputStream(aa_cd, true);
50 }
51 public static int getTestStream2Size() {
52 return aa_cd_size;
53 }
54 /** WAV 44100Hz, 2 channels, S16_LE */
55 public static InputStream getTestStream3() {
56 return getInputStream(aa_wav, true);
57 }
58 public static int getTestStream3Size() {
59 return aa_wav_size;
60 }
61
62 public static InputStream getInputStream(final String fileName) {
63 return getInputStream(fileName, false);
64 }
65
66 public static InputStream getInputStream(final String fileName, final boolean throwException) {
67 final URLConnection conn = IOUtil.getResource(fileName, rl.getClass().getClassLoader(), rl.getClass());
68 if (conn == null) {
69 return null;
70 }
71 InputStream stream = null;
72 try {
73 stream = new BufferedInputStream(conn.getInputStream());
74 } catch (final IOException e) {
75 if(throwException && null == stream) {
76 throw new RuntimeException("File '"+fileName+"' not found: "+e.getMessage());
77 } else {
78 System.err.println("File '"+fileName+"' not found");
79 e.printStackTrace();
80 }
81 }
82 return stream;
83 }
84}
static InputStream getInputStream(final String fileName)
static InputStream getInputStream(final String fileName, final boolean throwException)
static final String aa_cd
CDR 44100Hz, 2 channels, S16_LE.
static final String aa_cdr
CDR 44100Hz, 2 channels, S16_BE.
static InputStream getTestStream3()
WAV 44100Hz, 2 channels, S16_LE.
static final String aa_wav
CDR 44100Hz, 2 channels, S16_LE.
static InputStream getTestStream2()
CDR 44100Hz, 2 channels, S16_LE.
static final String lewiscarrol_wav
WAV 22050Hz, 1 channel, S8_LE.
static InputStream getTestStream0()
WAV 22050Hz, 1 channel, S8_LE.
static InputStream getTestStream1()
CDR 44100Hz, 2 channels, S16_BE.