28package com.jogamp.openal.test.manual;
30import java.io.BufferedReader;
31import java.io.IOException;
32import java.io.InputStreamReader;
33import java.util.concurrent.TimeUnit;
35import com.jogamp.common.os.Clock;
36import com.jogamp.openal.ALFactory;
37import com.jogamp.openal.JoalVersion;
38import com.jogamp.openal.util.SimpleSineSynth;
55 public static float atof(
final String str,
final float def) {
57 return Float.parseFloat(str);
58 }
catch (
final Exception ex) {
65 final BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
66 System.err.println(message);
68 final String s = stdin.readLine();
69 System.err.println(s);
71 }
catch (
final IOException e) { e.printStackTrace(); }
75 public static void main(
final String[] args) {
77 for(
int i=0; i<args.length; i++) {
78 if(args[i].equals(
"-f")) {
80 freq =
atof(args[i], freq);
88 System.err.println(
"0: "+o);
90 System.err.println(
"1: "+o);
93 final float min = 100, max = 10000, step = 30;
94 final long t0 = Clock.currentNanos();
95 for(
float f=min; f<max; f+=step) {
99 }
catch (
final InterruptedException e) { }
101 final long t1 = Clock.currentNanos();
102 final int exp = (int)( (max - min) / step ) * o.
getLatency();
103 final int has = (int)TimeUnit.NANOSECONDS.toMillis(t1-t0);
104 final int diff = has - exp;
105 System.err.println(
"Loop "+has+
" / "+exp+
" [ms], diff "+diff+
" [ms], "+((
float)diff/(float)exp) * 100f+
"%");
108 System.err.println(
"c: "+o);
109 boolean quit =
false;
111 final String in =
enterValue(
"Enter new frequency or just enter to exit");
112 if( 0 == in.length() ) {
115 freq =
atof(in, freq);
117 System.err.println(
"n: "+o);
This class provides factory methods for generating AL and ALC objects.
static ALC getALC()
Get the default ALC object.
static JoalVersion getInstance()
StringBuilder toString(final ALC alc, StringBuilder sb)
Return JogampVersion package information and AL informal strings.
A continuous simple off-thread mutable sine wave synthesizer.
static float atof(final String str, final float def)
static void main(final String[] args)
static String enterValue(final String message)
A continuous simple off-thread mutable sine wave synthesizer.
int getLatency()
Returns latency or frame-duration in milliseconds.
void setFreq(final float f)
void setAmplitude(final float a)
static final float MIDDLE_C