Source Code Cross Referenced for ReverberateSound.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3d » examples » sound » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » org.jdesktop.j3d.examples.sound 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ReverberateSound.java,v $
003:         *
004:         * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * - Redistribution of source code must retain the above copyright
011:         *   notice, this list of conditions and the following disclaimer.
012:         *
013:         * - Redistribution in binary form must reproduce the above copyright
014:         *   notice, this list of conditions and the following disclaimer in
015:         *   the documentation and/or other materials provided with the
016:         *   distribution.
017:         *
018:         * Neither the name of Sun Microsystems, Inc. or the names of
019:         * contributors may be used to endorse or promote products derived
020:         * from this software without specific prior written permission.
021:         *
022:         * This software is provided "AS IS," without a warranty of any
023:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026:         * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027:         * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028:         * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029:         * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030:         * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033:         * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034:         * POSSIBILITY OF SUCH DAMAGES.
035:         *
036:         * You acknowledge that this software is not designed, licensed or
037:         * intended for use in the design, construction, operation or
038:         * maintenance of any nuclear facility.
039:         *
040:         * $Revision: 1.3 $
041:         * $Date: 2007/02/09 17:21:51 $
042:         * $State: Exp $
043:         */
044:
045:        package org.jdesktop.j3d.examples.sound;
046:
047:        /*
048:         * ReverberateSound
049:         *
050:         * Same as MoveSound except this calls UniverseBuilderJS to use the
051:         * JavaSoundMixer AudioDevice rather than the HolosketchMixer device.
052:         *
053:         * NOTE: To run this anywhere but the Solaris Eng Menlo Park network
054:         * the URL path must be set to the java3d/javaone directory.
055:         */
056:
057:        import java.applet.Applet;
058:        import java.awt.*;
059:        import com.sun.j3d.utils.applet.MainFrame;
060:        import com.sun.j3d.utils.geometry.ColorCube;
061:        import com.sun.j3d.utils.universe.*;
062:        import java.net.URL;
063:        import javax.media.j3d.*;
064:        import javax.swing.JOptionPane;
065:        import javax.vecmath.*;
066:        import org.jdesktop.j3d.examples.Resources;
067:
068:        public class ReverberateSound extends Applet {
069:
070:            // File name of sound sample
071:            private static URL url = null;
072:            private SimpleUniverse u = null;
073:
074:            public BranchGroup createSceneGraph() {
075:                // Create the root of the subgraph
076:                BranchGroup objRoot = new BranchGroup();
077:
078:                // Create the transform group node and initialize it to the identity.
079:                // Enable the TRANSFORM_WRITE capability so that our behavior code
080:                // can modify it at runtime.  Add it to the root of the subgraph.
081:                TransformGroup objTrans = new TransformGroup();
082:                objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
083:                objRoot.addChild(objTrans);
084:
085:                // Create a simple shape leaf node and add it into the scene graph.
086:                objTrans.addChild(new ColorCube(0.4));
087:
088:                // Create a new Behavior object that will perform the desired
089:                // operation on the specified transform object and add it into the
090:                // scene graph.
091:                Transform3D yAxis = new Transform3D();
092:                Alpha rotation = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0,
093:                        20000, 0, 0, 0, 0, 0);
094:                RotationInterpolator rotator = new RotationInterpolator(
095:                        rotation, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f);
096:                BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,
097:                        0.0, 0.0), 100.0);
098:                rotator.setSchedulingBounds(bounds);
099:                objTrans.addChild(rotator);
100:
101:                //
102:                // Create an AuralAttribute with reverb params set
103:                //
104:                Soundscape soundScape2 = new Soundscape();
105:                AuralAttributes attributes2 = new AuralAttributes();
106:                attributes2.setReverbOrder(6);
107:                attributes2
108:                        .setCapability(AuralAttributes.ALLOW_REVERB_ORDER_WRITE);
109:                attributes2
110:                        .setCapability(AuralAttributes.ALLOW_REVERB_DELAY_WRITE);
111:                attributes2
112:                        .setCapability(AuralAttributes.ALLOW_REFLECTION_COEFFICIENT_WRITE);
113:                soundScape2.setApplicationBounds(bounds);
114:                soundScape2.setAuralAttributes(attributes2);
115:                objRoot.addChild(soundScape2);
116:
117:                //
118:                // Create a sound node and add it to the scene graph
119:                //
120:                PointSound sound = new PointSound();
121:                sound.setCapability(PointSound.ALLOW_ENABLE_WRITE);
122:                sound.setCapability(PointSound.ALLOW_INITIAL_GAIN_WRITE);
123:                sound.setCapability(PointSound.ALLOW_SOUND_DATA_WRITE);
124:                sound.setCapability(PointSound.ALLOW_DURATION_READ);
125:                sound.setCapability(PointSound.ALLOW_POSITION_WRITE);
126:                sound.setCapability(PointSound.ALLOW_LOOP_WRITE);
127:                sound.setSchedulingBounds(bounds);
128:
129:                objTrans.addChild(sound);
130:                //
131:                // Create a new Behavior object that will play the sound
132:                //
133:                AudioReverberate player = new AudioReverberate(sound, url,
134:                        attributes2);
135:                player.setSchedulingBounds(bounds);
136:                objTrans.addChild(player);
137:
138:                return objRoot;
139:            }
140:
141:            public ReverberateSound() {
142:            }
143:
144:            public void init() {
145:                url = Resources
146:                        .getResource("resources/audio/hello_universe.au");
147:                if (url == null) {
148:                    System.err
149:                            .println("resources/audio/hello_universe.au not found");
150:                    System.exit(1);
151:                }
152:
153:                setLayout(new BorderLayout());
154:                GraphicsConfiguration config = SimpleUniverse
155:                        .getPreferredConfiguration();
156:
157:                Canvas3D c = new Canvas3D(config);
158:                add("Center", c);
159:
160:                /*
161:                 * Create a simple scene and attach it to the virtual universe
162:                 */
163:                u = new SimpleUniverse(c);
164:                AudioDevice audioDev = u.getViewer().createAudioDevice();
165:                BranchGroup scene = createSceneGraph();
166:
167:                // This will move the ViewPlatform back a bit so the
168:                // objects in the scene can be viewed.
169:                u.getViewingPlatform().setNominalViewingTransform();
170:
171:                u.addBranchGraph(scene);
172:
173:                JOptionPane.showMessageDialog(this ,
174:                        ("This program is still a work in progress.\n"
175:                                + "Please check back in Java 3D 1.5.\n"),
176:                        "Incomplete Work", JOptionPane.INFORMATION_MESSAGE);
177:            }
178:
179:            public void destroy() {
180:                u.cleanup();
181:            }
182:
183:            //
184:            // The following allows ReverberateSound to be run as an application
185:            // as well as an applet
186:            //
187:            public static void main(String[] args) {
188:                new MainFrame(new ReverberateSound(), 256, 256);
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.