Is it possible to add 2 sources to the same sound in a vehicle?

Discussion in 'Content Creation' started by Agent_Y, Aug 29, 2021.

  1. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    Like the T-Series has 2 sound sources for the horn, one in each horn on the cab. Except it doesn't work, only one of these horns makes sound when both are equipped. I'm not succesful with trying to make a working setup like this. I have tried:
    • Basically every Jbeam solution that comes to mind, no result, the second source always overrides the first one. Even 2 different sounds at the same time activated by the same electrics value, still happens.
    • Copying the sounds.lua file and renaming everything, using references to the new thing for one of the sources. Still only the new plays and not the old. The rest of the car can use the new LUA without issues, but still playing 2 sounds at the same time with the same electrics value doesn't work, no matter if it's the same or different sound. Even after separating the sound emiters into different slots in Jbeam so they are loaded independently.
    • Copying electrics.lua and renaming everything the same way. Then the second sound doesn't play but the first does. Maybe I did something wrong with renaming there, but there are no errors in the console, so I have no idea.
    Do I have to write a new LUA file specifically to play the sound, and activate it using a custom key binding, or is it possible to do it the way I am trying now to activate it normally with electrics?
     
    • Agree Agree x 1
  2. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    Interesting problem you discovered ! I wanted to reply earlier but could not, what I did do earlier is see what is does with two different sounds on the horns, so I assigned Horns/AU5 to the other horn and still the same problem so far. Have you got it to work with using different electrics on each side ? I'm going to try that first cause this is interesting.
     
    • Agree Agree x 1
  3. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    I did try copying electrics.lua to add a new electrics value activated the same way as the old one. But then the old one plays and new one doesn't. Unless I did something wrong with renaming. Obviously 2 electrics on 2 different inputs work.
     
  4. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    Yep, different electrics work. I assigned "siren" as source on the left horn to test. So if you then select the lightbar button twice you get the horn sound and when pressing the horn at the same time the two horns sound simultaneously.

    It shouldn't be like that obviously and might be worth reporting in Audio Thread.

    To answer your question, yes, as a workaround you can wright a small lua file that just makes a new electrics value.
    You might even want to try it like this :
    Code:
    local M = {}
    
    local function onInit()
     electrics.values['horn2'] = 0
    end
    
    local function updateGFX(dt)
     if electrics.values.horn == 1 then
     electrics.values['horn2'] = 1 else
     electrics.values['horn2'] = 0
     end
    end
    
    -- public interface
    
    M.onInit      = onInit
    M.onReset     = onInit
    M.updateGFX = updateGFX
    
    return M
    
    Then in the jbeam set the second horn source as "horn2".
    I won't test this, I'll leave that up to you.

    Hope this helps :)
     
  5. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    That's a clever solution, I haven't thought of that, seems simple, will try it, thanks!
     
    • Like Like x 1
  6. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    Doesn't work, apparently if you just define new electrics like that, they can't be used for sounds yet and might require a ton of extra code for some reason, idk what to do
     
  7. sebaudio

    sebaudio
    Expand Collapse
    BeamNG Team

    Joined:
    Sep 27, 2018
    Messages:
    30
    Hello! Thanks for bringing this to our attention. We have added the issue to our to-do list and will try to come up with a solution for the next update.
     
    • Like Like x 5
  8. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    Here you go !

    Of course I don't need to tell you to backup original electrics file :)
    Don't forget to set one of the horns to "horn2" source in the horns jbeam !
     

    Attached Files:

  9. SKB

    SKB
    Expand Collapse

    Joined:
    Apr 22, 2017
    Messages:
    1,964
    did the hotfix fix any of this or was it just a "bugfix"?
     
  10. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    Don't guess so, I just made a workaround for the time being.
     
  11. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    Hotfixes don't fix complex issues like this.
    Any way to put it in a mod without overwriting the original file? I mean if there is a way then I will figure it out, but I'm just asking if I should bother trying or if it's impossible
     
    • Like Like x 1
  12. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    Nothing is impossible ! I mean.. I'm talking about real things of course :D
     
    • Like Like x 2
  13. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    Idk what I'm doing wrong but the sound is still not working at all. Still only makes sound after removng the normal horn, after all of the changes I have done. I'm completely clueless.
    Maybe you should test it yourself instead of writing something, assuming it will work and telling me to test. I mean the code itself does work but it doesn't fix the issue.
     
    #13 Agent_Y, Sep 2, 2021
    Last edited: Sep 2, 2021
  14. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,079
    Did you ever think about writing a new lua code and adding a new key binding to the game? Something like this mod I made for you:
     

    Attached Files:

  15. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    I did but I wanted it to be controlled by the normal binding if possible so people don't get confused. But thanks for this, maybe I can use it as a separate button.
    Edit: Wow, you even made the whole Jbeam with selectable horns and the bindings too, that was not needed lol
    Edit 2: This works but when I try to attach it to a slot other than horn, it crashes the game for some reason, will try to find out why
    Edit 3: THIS STILL DOESN'T WORK WITH 2 SOUND SOURCES LIKE I WANTED WHAT THE HECK
    It still plays both sounds from the same location even though I set different nodes for them... I give up. This is a really weird bug we have encountered.
     
    #15 Agent_Y, Sep 2, 2021
    Last edited: Sep 2, 2021
    • Like Like x 1
  16. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    It's not because I stated in another message that I didn't test that you need to take my statement for other messages :)
    The changes in the electrics file works just fine, I don't see the problem :



    If you observe the changes in the electrics file then yes, you can deduct and code a mod out of it.
    I won't say it's easy but it's possible.
     
  17. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,057
    Then there could be something wrong with my PC, it literally doesn't work for me and I didn't change anything in the code. At this point I'd rather wait until this is officially fixed than work on it.
     
  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