[Papervision3D] 3D Sound Experiment

De'Angelo Richardson dialeoson at yahoo.com
Sat Jan 20 13:26:01 EST 2007


Thanks. Yea, I was wondering where to put it. So far it's 2 separate functions add3DSound( URL, Obj); added to init3D(); and updateSound(Obj); added to the loop3D section.
   
  here's the code.
   
  function add3DSound (soundObj, Obj){
   sound = Obj.sound
   sound = new Sound();
   sound.loadSound(soundObj,true);
   updateSound3D(Obj);
  }
function updateSound3D (Obj){
   newX = int(Obj.x-camera.x);
   newY = int(Obj.y-camera.y);
   newZ = int(Obj.z-camera.z);
   maxSdist = 1050
   Sdist = Math.sqrt(newX*newX+newY*newY+newZ*newZ);
   SndAngle = int(Math.atan(newX/newZ)*180/Math.PI) - camera.rotationY;
  
  
   Sound3D = SndAngle;
   if (Sound3D>359){
    Sound3D = (Sound3D%360);
    
   } else if(Sound3D<=0){
    Sound3D = 360+(Sound3D%360);
   }
   if (newZ<0){
    Sound3D = ((Sound3D)+180)%360;
   } else if(newZ>0){
    Sound3D = Sound3D;
   }//*/
   if(Sdist<=maxSdist){
    Sound3Ddist = Math.abs((Sdist/maxSdist)-1)*100;
   } else {
    Sound3Ddist = 0;
   }
   S3Dang = (Sound3D - 180);
   Panner = (S3Dang - 180)/180;
   if(S3Dang>=-180 and S3Dang<=0){
    S3Dang += 180;
    Panner = int(S3Dang/90*100);
   } else if (S3Dang<179 and S3Dang>0){
    S3Dang -= 179;
    Panner = int(S3Dang/90*100);
   }
   if(Panner<-100){
    Panner = -(Panner%100 + 99)
   }else if(Panner>100){
    Panner = 99 - (Panner%100)
   }else if(Panner == 200 or Panner == -200){
    Panner = 0
   }
   sound.setVolume(int(Sound3Ddist));
   sound.setPan(Panner);
  }
   
  -De'Angelo
  

Carlos Ulloa <c4rl054321 at gmail.com> wrote: 
  This is so cool. Can't stop playing with it!

I haven't thought of 3d sound before, but it's such a nice touch. It makes the whole thing much more immersive.

Maybe we could have a sound:Sound property on each DisplayObject3D so the volume/balance would be adjusted on every render. 

Most per object calculations are affordable performance wise, so there shouldn't be any speed penalty.

It'll be brilliant for PaperWorld.

Excellent work De'Angelo.

C4RL05 
// noventaynueve.com
// papervision3d.org



  On 19/01/07, De'Angelo Richardson < dialeoson at yahoo.com> wrote:     This is my 3D sound experiment. It's not mastered yet but it's pretty close. I could only make it in stereo sound. This was done in AS2. I made it so it would be attached to any object.
   
  http://lab.dlrmedia.net/pv3d/3dsound.html
   
  -De'Angelo 

_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org 
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20070120/33feaecb/attachment.htm


More information about the Papervision3D mailing list