WIP Beta released Soundbank Vehicle Sound System - V0.3 Released

Discussion in 'Utilities and programming' started by Dummiesman, Dec 31, 2014.

  1. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Hello guys! :) I'd like to introduce the soundbank system for engine sounds . This is a LUA mod that allows any number of sound files to be used for engine sounds, created by a 'bank' method. The details are below, as well as a video and download.

    A video.
    In this video I demonstrate a bank consisting of 4 sounds.


    How does it work? [v0.3]
    In soundbank_system.lua a series of bank entries are defined , then a table of bank entries ( the "bank" of sounds) is created . The sound bank includes several parameters, the parameters for each type of bank entry are listed below

    All entries : required: type optional: Node (default is cameraNode)
    Engine bank entry : required: SFXProfile,MinVolume,MaxVolume,FadeInStartRPM,Fade InEndRPM,FadeOutStartRPM,FadeOutEndRPM,MinPitch,MaxPitch,PitchShiftStartRPM,PitchShiftEndRPM optional: SFXProfileOff
    KeyPress bank entry : required: SFXProfile,Volume,Pitch,KeyName
    Wind entry : required: SFXProfile, VolumeFactor, PitchFactor, MaxVolume

    Every update tick the sounds are updated by entry type with the parameters. This can be used to create custom sounds for a vehicle with a higher complexity than just one sound :)

    Who is this aimed at?
    This is aimed at mod developers for the most part. It's also aimed at people wanting to create mods for existing mods.


    Examples!

    Example of a list of bank entries in soundbank_system.lua:
    Code:
    --The sound profiles. Warning : LOONG CODE :)
    --Type enumeration
    --Type 0 : Uses engine 
    --Type 1 : Activated on key hold
    --Type 2 : Wind sound
    local RANGEHORN = {
        Type    =    1,
        SFXProfile = "RANGEHORN",
        Pitch    =    1,
        Volume    =    1,
        KeyName    =    "H",
        Node     =    6,
    }
    
    local generic_wind = {
        Type = 2,
        SFXProfile = "WindTestSound",
        VolumeFactor = 0.001,
        PitchFactor = 60,
        MaxVolume = 1,
    }
    
    local mclaren_idle = {
        Type    =    0,
        SFXProfile    =    "mclaren_idle",
        MinVolume    =    0.719000,
        MaxVolume    =    0.940000,
        FadeInStartRPM    =    1.000000,
        FadeInEndRPM    =    800.000000,
        FadeOutStartRPM    =    2500.000000,
        FadeOutEndRPM    =    9500.000000,
        MinPitch    =    1.000000,
        MaxPitch    =    1.250000,
        PitchShiftStartRPM    =    1.000000,
        PitchShiftEndRPM    =    4000.000000,
    }
    local mclaren_low = {
        Type    =    0,
        SFXProfile    =    "mclaren_low_on",
        SFXProfileOff = "mclaren_low_off",
        MinVolume    =    0.679000,
        MaxVolume    =    0.950600,
        FadeInStartRPM    =    500.000000,
        FadeInEndRPM    =    2500.000000,
        FadeOutStartRPM    =    4500.000000,
        FadeOutEndRPM    =    11000.000000,
        MinPitch    =    0.850000,
        MaxPitch    =    2.500000,
        PitchShiftStartRPM    =    500.000000,
        PitchShiftEndRPM    =    13000.000000,
    }
    local mclaren_mid = {
        Type    =    0,
        SFXProfile    =    "mclaren_mid_on",
        SFXProfileOff = "mclaren_mid_off",
        MinVolume    =    0.630500,
        MaxVolume    =    0.940900,
        FadeInStartRPM    =    1500.000000,
        FadeInEndRPM    =    4500.000000,
        FadeOutStartRPM    =    9000.000000,
        FadeOutEndRPM    =    13500.000000,
        MinPitch    =    0.850000,
        MaxPitch    =    2.500000,
        PitchShiftStartRPM    =    3000.000000,
        PitchShiftEndRPM    =    20000.000000,
    }
    local mclaren_high = {
        Type    =    0,
        SFXProfile    =    "mclaren_high_on",
        SFXProfileOff = "mclaren_high_off",
        MinVolume    =    0.620800,
        MaxVolume    =    0.940900,
        FadeInStartRPM    =    4500.000000,
        FadeInEndRPM    =    9000.000000,
        FadeOutStartRPM    =    12000.000000,
        FadeOutEndRPM    =    15000.000000,
        MinPitch    =    0.850000,
        MaxPitch    =    3.000000,
        PitchShiftStartRPM    =    4500.000000,
        PitchShiftEndRPM    =    22000.000000,
    }
    
    Example of the required name.cs for those profiles:
    [xcode=c]
    %vehicleName = "Civetta Bolide";


    singleton SFXProfile(RANGEHORN)
    {

    filename = "vehicles/super/horn/horntest.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_idle)
    {
    fileName = "vehicles/super/engine/mclaren_idle.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_low_on)
    {
    fileName = "vehicles/super/engine/mclaren_onlow.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_low_off)
    {
    fileName = "vehicles/super/engine/mclaren_offlow.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_mid_on)
    {
    fileName = "vehicles/super/engine/mclaren_onmid.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_mid_off)
    {
    fileName = "vehicles/super/engine/mclaren_offmid.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_high_off)
    {
    fileName = "vehicles/super/engine/mclaren_offhigh.ogg";
    description = "AudioDefaultLoop3D";
    };

    singleton SFXProfile(mclaren_high_on)
    {
    fileName = "vehicles/super/engine/mclaren_onhigh.ogg";
    description = "AudioDefaultLoop3D";
    };
    [/xcode]

    Premade audio banks (submit by PM if you have a good one)

    Basic idle/low/med/high bank with horn - by Dummiesman
    Also included in download of v0.2. Audio files not included.

    Basic idle/low/med/high with on/off with horn - by Dummiesman
    Also included in download of v0.3. Audio files not included

    Download
    The download for the lua file is attached to the post, it by default contains the name.cs and the custom lua file. This way it can be added to a vehicle with minimal manual editing.

    Ejoy! :) Ask any questions if needed
     

    Attached Files:

    #1 Dummiesman, Dec 31, 2014
    Last edited by a moderator: Oct 21, 2015
  2. Richard

    Richard
    Expand Collapse

    Joined:
    Aug 20, 2013
    Messages:
    53
    Re: Soundbank Vehicle Sound System - V0.1 Released

    Very nice script. Beamng does need better sounds after all!
     
  3. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    Re: Soundbank Vehicle Sound System - V0.1 Released

    Silly of me to already be asking for more, but just wondering if it's possible to use engine load/throttle to choose between sounds? Then we could have a bank for low/no throttle decel and throttle+accel. Allows for backfires and burblyness off throttle then intake roar under accel.
     
  4. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Re: Soundbank Vehicle Sound System - V0.1 Released

    Once I feel like coding it, I plan an EngineConditional type of sound entry that will fit that need :)

    Updated first post with a KeyPress sound, example added for a horn sound (note : previous sound bank entries are not compatible with this version unless you add Type = 0, to the entries)

    More plans : Adding a callback sound type. This way you would do the following
    Code:
    function updateMYSOUND(entry)
      entry["clip"]:setPitch(0.5)
    end
    
    local MYSOUND = {
        Type    =    2,
        SFXProfile = "MY SFX PROFILE",
        Node     =    60,
        UpdateFunc = "updateMYSOUND",
    }
    
     
    #4 Dummiesman, Dec 31, 2014
    Last edited by a moderator: Dec 31, 2014
  5. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    Re: Soundbank Vehicle Sound System - V0.2 Released

    Very cool, just got it working in my ke17 mod. Now to find some appropriate sound bank files!

    Edit: It won't load RANGEMID and RANGEHIGH. I tried my own sounds as well as your default ones, and copy pasted your entries in name.cs and changed the paths from volksfagen to ke17 (my car). Was working in 0.1 :/

    soundbankv02error.png

    Edit 2: I guess it really doesn't like .wav? Strange that it loads the horn, idle and low sounds, then chokes
     
    #5 Goosah, Dec 31, 2014
    Last edited: Dec 31, 2014
  6. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Re: Soundbank Vehicle Sound System - V0.2 Released


    If you haven't already, a game restart is required to load the new name.cs if you have edited it .
     
  7. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    Re: Soundbank Vehicle Sound System - V0.2 Released

    OK, it works with your sound files, but not with mine.

    Somewhere there is a problem, it wont load RANGEMID or RANGEHIGH.

    Mine are wavs, and about 4 seconds long, whereas your .ogg are 2 seconds. But it loads RANGEIDLE and RANGELOW just fine.

    I double checked the naming and it seems fine, and am doing the restarts between changes.
     
  8. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Re: Soundbank Vehicle Sound System - V0.2 Released

    It could be possible that the engine requires an OGG file. I use Audacity to create mine.
     
  9. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    Re: Soundbank Vehicle Sound System - V0.2 Released

    Sorry to clog up the thread with support questions, I tried some different .wavs and it worked fine. I just didn't expect it since the first 2 wavs from the same source (an LFS sound mod) worked fine.
     
  10. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Re: Soundbank Vehicle Sound System - V0.2 Released

    No problem, wavs were probably an unsupported bitrate/format.

    - - - Updated - - -

    V0.3 Released!

    What's different? : Wind sounds must be defined in the sound bank (added to example post), on/off engine sounds (added to example post)

    In v0.3, You can specify SFXProfileOff in your engine bank entries for this effect ;) (Smoothed since video made, sounds much better now)

     
    #10 Dummiesman, Dec 31, 2014
    Last edited by a moderator: Oct 21, 2015
  11. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    Re: Soundbank Vehicle Sound System - V0.2 Released

    Oh that's a very nice feature!

    I spent a bunch of time last night trying to make a good sound for the Corolla Sprinter. Even to the point of finding a youtube of somebody starting up one and running it at various speeds. Unfortunately it was just too noisy and the rpm wasnt steady. I couldnt seem to make nice loops, and the sound was all wooshy/whistley :/

    It's also tough to match the pitches up! The main pulses of the sound from cylinder firing should have a frequency matching the engine speed. Something like f=n*RPM/120, where n=# of cyl. I need to find a way to discover the main frequency of the loop in Audacity. But my samples were so noisy I couldn't pick anything out visually.
     
  12. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Re: Soundbank Vehicle Sound System - V0.2 Released

    Yeah sound creation can be tough. A lot of times you have to shorten the recorded sample, delete part of it, copy the first part, then add it to the end and reverse it.
     
  13. Pyroxyde

    Pyroxyde
    Expand Collapse

    Joined:
    Nov 13, 2012
    Messages:
    58
    Re: Soundbank Vehicle Sound System - V0.2 Released

    This is a very interesting thing !

    It is simple to create and tweak thoses files. Sadly, sound creation is very difficult.

    Drive need better sounds. It will be much more immersive with better sounds.

    Thanks for this Dummiesman !
     
  14. mtslittow

    mtslittow
    Expand Collapse

    Joined:
    Sep 28, 2012
    Messages:
    142
    This is exactly what I've been wanting! I have some nice recordings i've taken from our cars at various rpms. I Should start tinkering with them and see what i can come up with.
    I already implemented the sound of an old diesel seat hatchback @3000 rpm to BeamNG, which already sounds acceptable:
    https://soundcloud.com/rtf54/beamng-engine-samples (captured from the game)
     
  15. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    That sounds great! It would probably be a perfect fit for the Covet ;)
     
  16. Kreunz

    Kreunz
    Expand Collapse

    Joined:
    Mar 13, 2014
    Messages:
    157
    How do i use it? Sence there is no instructions.
     
  17. chevy65

    chevy65
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    155
    real noob here... i cant figure out how to install it
     
  18. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    This is intended for mod developers only. To add it to vehicles you need to copy all the "singleton SFXProfile" from name.cs to the name.cs in the vehicle you are adding it to. Then install the .lua to the Lua folder of the vehicle you are adding it to.
     
  19. chevy65

    chevy65
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    155
    sweet thanks. i'm working on a ratrod for my fist mod and figured id use this to make my supercharged 454 sound file sound better.
     
  20. inotalas

    inotalas
    Expand Collapse

    Joined:
    Nov 13, 2013
    Messages:
    15
    Hi Dummiesman, I spent some hours messing with your mod and everything works fine but I have some questions.

    It is possible to add transmission sound according to driveshaft speed? I'm not so good programming but I'm good editing and adapting sound :rolleyes:


    Thanks for your job mate and sorry if my English is not the best.
     
    #20 inotalas, Jan 24, 2015
    Last edited: Jan 25, 2015
  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