Starting User Interface
[tu-mathvis-ws13:luisvera-tu-mathvis-ws13.git] / src / experiments / audio / AudioExample.java
1 package experiments.audio;
2
3
4 import java.io.InputStream;
5
6 import de.jreality.audio.javasound.CachedAudioInputStreamSource;
7 import de.jreality.geometry.Primitives;
8 import de.jreality.math.MatrixBuilder;
9 import de.jreality.plugin.JRViewer;
10 import de.jreality.plugin.JRViewer.ContentType;
11 import de.jreality.scene.AudioSource;
12 import de.jreality.scene.SceneGraphComponent;
13 import de.jreality.tools.DraggingTool;
14 import de.jreality.util.Input;
15
16
17 public class AudioExample {
18
19         public static SceneGraphComponent getAudioComponent() throws Exception {
20                 InputStream wavFile = AudioExample.class.getResourceAsStream("zarathustra.wav");
21                 final AudioSource source = new CachedAudioInputStreamSource("zarathustra", Input.getInput("zarathustra", wavFile), true);
22                 SceneGraphComponent audioComponent = new SceneGraphComponent("monolith");
23                 audioComponent.setAudioSource(source);
24                 audioComponent.setGeometry(Primitives.cube());
25                 MatrixBuilder.euclidean().translate(0, 5, 0).scale(2, 4.5, .5).assignTo(audioComponent);
26                 audioComponent.addTool(new DraggingTool());
27                 source.start();
28                 return audioComponent;
29         }
30
31         
32         public static void main(String[] args) throws Exception {
33                 JRViewer v = new JRViewer();
34                 v.addBasicUI();
35                 v.addAudioSupport();
36                 v.addVRSupport();
37                 v.addContentSupport(ContentType.TerrainAligned);
38                 v.setContent(getAudioComponent());
39                 v.startup();
40         }
41         
42 }