WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Overiding spatial sound algorithm (https://forum.worldviz.com/showthread.php?t=1989)

DrMothra 04-28-2009 03:38 AM

Overiding spatial sound algorithm
 
Hi, I'm quite new to Vizard and have been using the spatialized 3D sound component. I'd like to replace the default algorithm of determining 3D sound level with my own formula, which takes a number of other factors into account, such as reflections, barriers between user and source, etc, but still keep the spatialization effects. Is there a way to do this? Any info appreciated.

Thanks.

Gladsomebeast 04-29-2009 10:55 PM

Seems the simplest method would be to call your own functions that play a sound with your algorithm. You can create a Python plugin to connect to your 3D sound code if it has a C API. This means you could not use the .playsound method.

Vizard has a plugin architecture to change the 3D sound "algorithm" for the .playsound method. Vizard supports the AuSim 3D sound system by replacing the DirectX 3D sound plugin with the AuSim plugin. The vizausim.py file in the Vizard30/python directory loads the sound3d_ausim1.dll file and adds some additional methods at the python level.

I don't know how to make a sound3d DLL/plugin. Perhaps WorldViz will release the source code for their current sound3d plugins :D

DrMothra 04-30-2009 08:14 AM

Hi, thanks for the info. I'll check out the AuSim plugin and see what I can derive from that.

Cheers.

Gladsomebeast 05-01-2009 12:27 PM

What 3D sound system are you looking to integrate?

DrMothra 05-06-2009 03:33 AM

I'm not really looking to integrate another sound system, I just want to override the default attenuation properties with my own formula, but I still want to keep all the spatialization effects. For instance, when I move around my virtual room I need the sound to diminish if I walk behind a wall or door, etc. I have a formula that works perfectly well, I just need to be able to implement it.

Thanks.

Gladsomebeast 05-06-2009 11:42 AM

Ah. In that case you can just set the volume of the DirectX 3D sound.

Code:

asdfSound = noisyThing.playsound('asdf.wav')
...

#every frame
newVolume = soundVolumn(noisyThing, viewPosition)
asdfSound.volume(newVolume)


DrMothra 05-07-2009 06:19 AM

Yes, I've tried this, but the default attenuation doesn't seem to get overridden, it still seems like the default (linear?) relationship, whereas my algorithm is slightly different. I'll check it out again next week and just double check that is what I'm getting.

Thanks.

Gladsomebeast 05-07-2009 01:15 PM

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. :cool:

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

DrMothra 05-07-2009 02:15 PM

Thanks for the info. I'll go back and try it out again, it would appear that there is something obvious that I am missing or failing to do. I'll let you know the outcome.

Thanks again.

DrMothra 06-17-2009 07:46 AM

Apologies for taking so long to get back to you, I've only just started looking at this again today after being swamped with other work. I can get the volume to alter accordingly with the example that you posted, but I still have the same query, but I think that I can explain it a little more coherently now. Essentially if I set the volume of an object to 1 (max) and move away from the object the sound is still attenuated, this sort of makes sense - the object is playing at its maximum volume but I'm too far away to hear it. I would really like greater control over the sound than this, hence why I referred to overriding the sound level previously. So I still have some level of attenuation regardless of what calculated volume level I arrive at. I can compensate for this to a degree by adjusting my formula to take the attenuation into account, but I can't get rid of it completely. In actual fact I can still get the kind of effect I was after so it's OK, but would be good if I could stop the default attenuation completely. Thanks for all your help thus far.

Gladsomebeast 06-17-2009 01:22 PM

OK, I see.

If the DirectSound API allows you to control attenuation, then you could email farshizzo and request that he expose that feature in the next release or something.

You could also play the sounds with some other, more open library. Seems OpenAL is popular.

DrMothra 06-17-2009 04:19 PM

Hi, I normally write my own VR software and have used OpenAL before, it's just that for the current project I'm having to use Vizard; not that this is a bad thing but I find it quite constraining at first as I don't have the same level of control that I normally do (not that I'm a control freak or anything!). Therefore I may never come back to Vizard after this work is completed. I think I can just about achieve the effect that I want. If I decide to alter it later I may well look at the OpenAL route, or e-mail farshizzo.

Thanks for your time again.

Gladsomebeast 06-18-2009 12:26 AM

True, Vizard is targeting/marketed as the simpler tool, thus exposing less functionality than an open engine. However, there is nothing to stop folks from integrating other sub-systems, like OpenAL. Something you may have had to do in the other engine's you have worked with perhaps? What rendering engein's did you use to construct your other VR systems Mothra?

DrMothra 06-18-2009 02:19 AM

Hi, at the moment I'm integrating a number of third party components together to build our VR system. So I'm using Ogre for the graphics, Raknet for the networking, ffmpeg for the video, OpenAL for the audio, etc. I'm generally a graphics programmer by trade and I've used all sorts of things from raw OpenGL to OpenSceneGraph with some in-house networking thrown in. I'm trying to get away from in-house software as much as possible as they suffer from lack of documentation and support (as I'm sure that you know!), and I'd like the latest system to be easy to use, well supported/documented so that it's flexible for others to use. I live in hope...

Cheers.

Gladsomebeast 06-18-2009 12:52 PM

“Where there is life, there is hope.” :)


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

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