3D sound examples

3DSound.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2
 3newScene()
 4loadGeometry("$VRED_EXAMPLES/geo/sound.osb")
 5updateScene()
 6
 7hideNode(findNode("Environments"))
 8
 9vrLogInfo("On the red objects position you hear a beating sound.")
10vrLogInfo("On the green objects position you hear a diesel engine sound.")
11
12# find node and convert it into transformation node
13rot = findNode("Rotate");
14rot.makeTransform()
15
16# define 360 degree rotation and activate it
17rotInt = vrInterpolator()
18rotSlide = vrRotationSlide(rot, 0,0,0, 0,359,0, 8.0)
19rotInt.add(rotSlide)
20rotInt.setActive(true)
21
22#define key r to toggle rotation
23keyR = vrKey(Key_R)
24keyR.connect(rotInt, SWITCH_TOGGLE)
25vrLogInfo("Press key r to toggle rotation")
3DSound2.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2newScene()
 3
 4sound = vrScenegraphService.createNode(vrScenegraphTypes.SoundNode)
 5sound.setName("Sound")
 6filename = "$VRED_EXAMPLES/audio/motor_b8.wav"
 7sound.setSoundFile(filename)
 8
 9def play(s):
10    sound.setPlay(s)
11
12def pitch(v):
13    sound.setPitch(v)
14
15keyP = vrKey(Key_P)
16keyP.connect(play, true)
17
18keyS = vrKey(Key_S)
19keyS.connect(play, false)
20
21keyH = vrKey(Key_H)
22keyH.connect(pitch, 2.0)
23
24keyL = vrKey(Key_J)
25keyL.connect(pitch, 0.5)
26
27keyR = vrKey(Key_R)
28keyR.connect(pitch, 1.0)
29
30vrLogInfo("Press key 'p' to play")
31vrLogInfo("Press key 's' to stop")
32vrLogInfo("Press key 'h' increase pitch")
33vrLogInfo("Press key 'j' decrease pitch")
34vrLogInfo("Press key 'r' reset pitch")