1 |
5068fa06
|
Leszek Koltunski
|
package org.distorted.examples.interpolator;
|
2 |
427ab7bf
|
Leszek Koltunski
|
|
3 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.library.Distorted;
|
4 |
|
|
import org.distorted.library.Interpolator1D;
|
5 |
|
|
import org.distorted.examples.R;
|
6 |
427ab7bf
|
Leszek Koltunski
|
|
7 |
|
|
import android.app.Activity;
|
8 |
|
|
import android.opengl.GLSurfaceView;
|
9 |
|
|
import android.os.Bundle;
|
10 |
|
|
import android.view.View;
|
11 |
|
|
import android.widget.SeekBar;
|
12 |
|
|
import android.widget.TextView;
|
13 |
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
14 |
|
|
|
15 |
|
|
///////////////////////////////////////////////////////////////////
|
16 |
|
|
|
17 |
|
|
public class InterpolatorActivity extends Activity implements OnSeekBarChangeListener
|
18 |
|
|
{
|
19 |
|
|
private SeekBar barD, barN;
|
20 |
|
|
private TextView textD, textN;
|
21 |
|
|
|
22 |
|
|
///////////////////////////////////////////////////////////////////
|
23 |
|
|
@Override
|
24 |
|
|
protected void onCreate(Bundle savedInstanceState)
|
25 |
|
|
{
|
26 |
|
|
super.onCreate(savedInstanceState);
|
27 |
|
|
setContentView(R.layout.interpolatorlayout);
|
28 |
|
|
|
29 |
|
|
barD = (SeekBar)findViewById(R.id.interpolatorSeekDuration);
|
30 |
|
|
barD.setOnSeekBarChangeListener(this);
|
31 |
|
|
textD = (TextView)findViewById(R.id.interpolatorTextDuration);
|
32 |
|
|
|
33 |
|
|
barN = (SeekBar)findViewById(R.id.interpolatorSeekNoise);
|
34 |
|
|
barN.setOnSeekBarChangeListener(this);
|
35 |
|
|
textN = (TextView)findViewById(R.id.interpolatorTextNoise);
|
36 |
|
|
|
37 |
|
|
barD.setProgress(50);
|
38 |
|
|
textD.setText("Duration: 10 s");
|
39 |
|
|
|
40 |
|
|
barN.setProgress(0);
|
41 |
|
|
textN.setText("Noise: 0.0");
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
///////////////////////////////////////////////////////////////////
|
45 |
|
|
@Override
|
46 |
|
|
protected void onResume()
|
47 |
|
|
{
|
48 |
|
|
super.onResume();
|
49 |
|
|
|
50 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
|
51 |
|
|
mView.onResume();
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////
|
55 |
|
|
@Override
|
56 |
|
|
protected void onPause()
|
57 |
|
|
{
|
58 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
|
59 |
|
|
mView.onPause();
|
60 |
|
|
|
61 |
|
|
super.onPause();
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////
|
65 |
|
|
@Override
|
66 |
|
|
public void onStop()
|
67 |
|
|
{
|
68 |
|
|
super.onStop();
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
///////////////////////////////////////////////////////////////////
|
72 |
|
|
@Override
|
73 |
|
|
public void onDestroy()
|
74 |
|
|
{
|
75 |
|
|
Distorted.onDestroy();
|
76 |
|
|
super.onDestroy();
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
///////////////////////////////////////////////////////////////////
|
80 |
|
|
|
81 |
|
|
public void Loop(View v)
|
82 |
|
|
{
|
83 |
|
|
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_LOOP);
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
///////////////////////////////////////////////////////////////////
|
87 |
|
|
|
88 |
|
|
public void Path(View v)
|
89 |
|
|
{
|
90 |
|
|
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_PATH);
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
///////////////////////////////////////////////////////////////////
|
94 |
|
|
|
95 |
|
|
public void Jump(View v)
|
96 |
|
|
{
|
97 |
|
|
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_JUMP);
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
///////////////////////////////////////////////////////////////////
|
101 |
|
|
|
102 |
|
|
public void Dim1D(View v)
|
103 |
|
|
{
|
104 |
|
|
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_1D);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
///////////////////////////////////////////////////////////////////
|
108 |
|
|
|
109 |
|
|
public void Dim2D(View v)
|
110 |
|
|
{
|
111 |
|
|
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_2D);
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
///////////////////////////////////////////////////////////////////
|
115 |
|
|
|
116 |
|
|
public void Dim3DXY(View v)
|
117 |
|
|
{
|
118 |
|
|
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_3DXY);
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
///////////////////////////////////////////////////////////////////
|
122 |
|
|
|
123 |
|
|
public void Dim3DXZ(View v)
|
124 |
|
|
{
|
125 |
|
|
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_3DXZ);
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
///////////////////////////////////////////////////////////////////
|
129 |
|
|
|
130 |
|
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
131 |
|
|
{
|
132 |
|
|
float v, t;
|
133 |
|
|
int i;
|
134 |
|
|
|
135 |
|
|
switch (bar.getId())
|
136 |
|
|
{
|
137 |
|
|
case R.id.interpolatorSeekDuration: v = progress*200;
|
138 |
|
|
i = (int)(v/100);
|
139 |
|
|
t = i/10.0f;
|
140 |
|
|
InterpolatorSurfaceView.setDuration((int)v);
|
141 |
|
|
textD.setText("Duration: "+(int)t+" s");
|
142 |
|
|
break;
|
143 |
|
|
case R.id.interpolatorSeekNoise : InterpolatorSurfaceView.setNoise(progress/100.0f);
|
144 |
|
|
textN.setText("Noise: "+(progress/100.f));
|
145 |
|
|
break;
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
///////////////////////////////////////////////////////////////////
|
150 |
|
|
|
151 |
|
|
public void onStartTrackingTouch(SeekBar bar) { }
|
152 |
|
|
|
153 |
|
|
///////////////////////////////////////////////////////////////////
|
154 |
|
|
|
155 |
|
|
public void onStopTrackingTouch(SeekBar bar) { }
|
156 |
|
|
|
157 |
|
|
///////////////////////////////////////////////////////////////////
|
158 |
|
|
// end of file
|
159 |
|
|
}
|