View Single Post
  #8  
Old 05-07-2009, 01:15 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
So changing the sound volume every frame with the volume computed by your algorithm won't work? I guess I'm missing something. But thats ok.

Just for fun I added a slider controlling volume to the Vizard 3D sound example
Code:
# WorldViz Copyright 2002====================================================
# This script demonstrates the use of 3D sound, otherwise known as spatialized
# sound.  To mimic the sound changes that occur in real environments with
# real sounds, the computer will change the sound being played between the
# two speakers (or 4 speakers for fancy cards) to create the sense of spatialized
# sound.  Vizard uses Microsoft Direct Sound as it's interface to this procedure,
# which in turn will use any 3D sound acceleration that is available on your
# sound card.  As such, you'll have to turn to either Microsoft or your sound
# card manufacturer to try and figure out what is really going on.  Good luck.
#
# In this demo, two objects are create by issuing the 'add' command.  To
# attach a sound to an object, the child method command 'playsound' is called.
# Pressing the 'z' key in this demo causes one of the object to start orbiting
# around the origin.
#
#===========================================================================


import viz
import math

viz.go()

import vizinfo
info = vizinfo.add('This script demonstrates how to use 3D sound.\nA sound is being played from each object.\nUse the checkbox to toggle between spinning the object.\nMove closer to an object to hear each sound louder.')
SpinCheck = info.add(viz.CHECKBOX,'Spin Object')
SpinCheck.set(1)
SpinAction = vizact.spin(0,1,0,90)
volumeSlider = info.add(viz.SLIDER, 'volume')

viz.add('tut_ground.wrl')

m1 = viz.add('tut_hedra.wrl')
m2 = viz.add('tut_hedra.wrl')

m1Sound = m1.playsound('buzzer.wav', viz.LOOP)
m1.translate(-15, 0,15)

m2Sound = m2.playsound('boing!.wav', viz.LOOP)
m2.translate(-5, 0, 0)
m2.center(5,0,0)
m2.addAction(SpinAction)

vizact.onbuttondown(SpinCheck,m2.addAction,SpinAction)
vizact.onbuttonup(SpinCheck,m2.clearActions)

vizact.onslider(volumeSlider, m1Sound.volume)
vizact.onslider(volumeSlider, m2Sound.volume)
Also here is a link to the Direct Sound API. Good background info for sound newbs like me:
http://msdn.microsoft.com/en-us/libr...23(VS.85).aspx
__________________
Paul Elliott
WorldViz LLC
Reply With Quote