Two audio_listeners?

Discussion in 'Programming' started by Makkeonmies, Oct 5, 2019.

  1. Makkeonmies

    Makkeonmies Member

    Joined:
    Oct 25, 2017
    Posts:
    124
    In my 2d top-down game I have splitscreen for two players. my game also implements 3d audio so both the player objects are 'listeners.' However if only it were as easy as to put audio_listener_position in the Step event of both player objects...
    I acknowledge there are 'audio masks' (audio_emitter_set_listener_mask) which I should assign to both the player objects to make them listeners, I guess? I have no idea tho where to put the code etc...
    Any help on how I can have two listener objs?
    Thank you in advance.
     
  2. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,743
    What would having two listeners achieve? Audio is still shared between the two player, since you only got one audio output device (which the user controls: side loudspeakers, built-in speaker, headset... you can't tell what they're using, it's just a dumb output channel your audio is routed into). Even if you could activate multiple listeners, sound would be heard from two different directions, which would be even more disorienting than what you have right now.

    What you could do, going for the "play it twice" idea, is to have the listener be absolute, bound to the screen rather than follow the players around, and then when playing a sound, you play it once for each player, with a position based on the player's position relative to the sound (and in turn relative to the absolute listener). E.g. if the sound is to the right of one player and above another, play one instance of it to the right of the absolute listener and the other instance above it, with matching distances to the ABL that they have to the individual players.
     
    Makkeonmies likes this.
  3. Makkeonmies

    Makkeonmies Member

    Joined:
    Oct 25, 2017
    Posts:
    124
    Yes, in my game's case, its relatively dumb as of now since if player 2's character is next to a sound-emitting object, no audio is heared until player 1 arrives to the scene and then the audio can be heard at last. Its just immersion-breaking and somewhat silly when p2's hearing has to depend on p1's position... if both players were on opposite edges of a room, making battle sounds for example, id like the sounds be heared from both of their sides...
    I'll try ur suggestion out !
     
  4. Makkeonmies

    Makkeonmies Member

    Joined:
    Oct 25, 2017
    Posts:
    124
    So, is it even possible, to have two audios playing from one output device: for example if player 1 was moving further away to the left from the sound-emitter and player 2 was standing on the right side of it, could it be made so that the sound fades away on the left side of the output device but stays the same from the right?
    Theoretically speaking ..
     
  5. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,743
    I think you'd need to move the sounds rather than the listener for that effect... which seems to be impossible from what I can tell browsing the function list (there's audio_set_track_position but not audio_set_position...)
     
    Makkeonmies likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice