WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Creating the sound effect (https://forum.worldviz.com/showthread.php?t=2776)

llqqff 06-08-2010 12:04 PM

Creating the sound effect
 
Hi,
I am working on how to play the sound in vizard that can change the volume when the distance of two objects changes which means: I have a target in some position and I move my right hand, when my hand is moving closer to the target, the volume of the sound increases, otherwise decreases.

I know the target.playsound() function, which can calculate the distance between the target and the two LEDs, then play the spatialized sound automatically.

And now I know how to calculate the distance between the target and the hand, but I don't know how the change the volume when the distance changes.

Jeff 06-08-2010 12:28 PM

Are you saying you want to use the .playsound command but also manipulate the sound volume yourself? If so, look at the following:

Code:

import viz
viz.go()

ball = viz.add('ball.wrl',pos = [0,1.8,2])

slider = viz.addSlider()
slider.setPosition(0.5,0.2)
slider.set(1)

sound = ball.playsound( 'boing!.wav', viz.LOOP )

def changeVolume(value):
        sound.volume(value)
       
vizact.onslider(slider,changeVolume)


llqqff 06-08-2010 12:52 PM

Actually, I don't want a slider, I want the volume changes automatically when the distance of the hand and the target changes, is there anyway to do that?


All times are GMT -7. The time now is 06:31 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC