Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

3D Sound Removing the Doppler Effect

Discussion in 'Audio & Video' started by showmeskeletons, Apr 4, 2013.

  1. showmeskeletons

    showmeskeletons

    Joined:
    Mar 15, 2013
    Posts:
    15
    Hello!
    I'm currently creating a project that involves a 3D environment that the player is able to walk around explore, with music that changes as they traverse around the environment.
    So far I have been adding layers of music as Audio Source components in various 3D objects in the space, things like rocks, lanterns etc. I need to remove the Doppler effect as I'm using music rather than sound effects the music raises or lowers in pitch as the player moves about, something that I don't want!
    So far I've been removing the Doppler effect by lowering the level down to 0 this has worked really well. Unfortunately the latest piece of music/audio file seems to still have a Doppler effect, even after lowering the level down. Any idea why this is? Any way I can combat this? Is there a better, more efficient way of creating a dynamic, 3D soundscape?

    Thanks in advance!
     
  2. Emre

    Emre

    Joined:
    Jul 8, 2012
    Posts:
    21
    I believe that the Doppler effect can be simulated in Unity, but I don't think it is there by default.
     
  3. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    757
    Is it definitely still varying the pitch with Doppler on 0, or could it be just the panning? I'd try putting panning on 0 as well, if it's not important to your 3D positioning of the music.
     
  4. Niki.j

    Niki.j

    Joined:
    Oct 17, 2012
    Posts:
    157
    Hello...


    if i am getting you right,then you want to get the continuous sound with the same volume whatever will be the sound.
    then you just need to place your audio sources need to your audio listener also disable your 3d sound effect for you audio clips..

    hope it will help you...

    Thanks
    Niki.j
     
  5. showmeskeletons

    showmeskeletons

    Joined:
    Mar 15, 2013
    Posts:
    15
    it seems that the pitch is going up when moving forward/closer to the audio source and down when moving back/away from the audio source. i've noticed that if i put panning at 0, the audio will almost become 2D constantly loud (or 'on') rather than be positioned in a 3D space.
     
  6. showmeskeletons

    showmeskeletons

    Joined:
    Mar 15, 2013
    Posts:
    15
    the opposite in fact, i need things to become louder when you approach them quieter when you walk away from them. think of a standard sound effect, like the crackling of a fire, but using music instead. each track (bass, lead melody etc.) of the music needs to be positioned in the 3D space, getting louder when you approach and quieter when you back away.
    thanks for the help though! :)
     
  7. element_wsc

    element_wsc

    Joined:
    Jul 27, 2012
    Posts:
    522
    Cant you just use a 2d sound and change its volume based on the distance between the camera and the audio source?
     
  8. showmeskeletons

    showmeskeletons

    Joined:
    Mar 15, 2013
    Posts:
    15
    probably! haha, is that scripting? forgive my naivety but i'm a musician first and a programmer second (if not third, fourth or fifth! :p ).
     
  9. element_wsc

    element_wsc

    Joined:
    Jul 27, 2012
    Posts:
    522
    example on its way! :p

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class VolumeInterpolate : MonoBehaviour {
    6.    
    7.     public Transform player = null;
    8.     public float maxDistance = 0f;
    9.    
    10.     private AudioSource _aSource = null;
    11.     private Transform _myTr = null;
    12.  
    13.     void Start () {
    14.         _myTr = transform;
    15.         _aSource = (AudioSource)GetComponent<AudioSource>();
    16.         _aSource.volume = 0f;
    17.     }
    18.    
    19.     // Update is called once per frame
    20.     void Update (){
    21.         float distance = Vector3.Distance(_myTr.position, player.position);
    22.         if(distance <= maxDistance)
    23.         {
    24.             _aSource.volume = Mathf.Abs((distance / maxDistance) - 1f);
    25.         }
    26.     }
    27. }
    28.  
    You need to attach this to your AudioSources and change them to 2D in your import settings.
     
  10. akarsh

    akarsh

    Joined:
    Aug 26, 2014
    Posts:
    11
    hi,
    I want to remove unwanted noise from output audio .So please help me out?
     
    Priyanka-Rajwanshi likes this.
  11. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    434
    guys this is utterly wrong

    TO REMOVE THE STUPID DOPPLER EFFECT, JUST SET TO ZERO

    it's that simple.

    do NOT use a script to affect the volume with distance!!! that's what audio source does for you!

    just select "3D sound" and it will do that. BUT be sure to set Doppler effect to zero.

    (you only use doppler effect in very unusual situations .. just forget about it)
     
unityunity