An interesting way to simulate engine sounds...

Discussion in 'Ideas and Suggestions' started by mrwallace888, Feb 4, 2021.

  1. mrwallace888

    mrwallace888
    Expand Collapse

    Joined:
    Jun 17, 2015
    Messages:
    399
    As of recently, I've been getting recommended videos by William Moser on YT, a guy who creates "audiovisual demonstrations of cylinder firing orders".

    The way he did it was seriously impressive, and in most engines he showed, it sounded pretty realistic, too.

    Here's an example of the firing order of certain Ford V8s.

    Here's another of a Subaru's boxer engine. It even has that trademark Subaru rumble.

    So it got me thinking, I know the sounds in this game are synthesized, but what I always figured was that it was just a simple pitch shift, like sounds at multiple RPMs just strung together.

    But what if you guys did it similar to this? What if you simulated sounds of the individual cylinders, increasing in speed/pitch?

    Would this be viable? Would it be pointless? I don't know, I just figured it'd be an interesting experiment to mess with.
     
    • Like Like x 7
  2. stale

    stale
    Expand Collapse

    Joined:
    Jun 14, 2020
    Messages:
    216
    i've been thinking about that too
    in theory, having an appropriately timed bang tied with an engine type's firing order and rpm should produce organic sound, but it'd maybe feel lacking in comparison to the sampled ones, kinda like the really early generic v8-ish sound
    it's definitely worth experimenting with, but it'd potentially mean designing an engine with a simulated firing order and strokes, dunno if that's currently possible
     
  3. mrwallace888

    mrwallace888
    Expand Collapse

    Joined:
    Jun 17, 2015
    Messages:
    399
    Well it's not like it'd simulate it at the physical level, just the auditory level. It's not like you could rip the engine in half and see the cylinders working.
     
  4. stale

    stale
    Expand Collapse

    Joined:
    Jun 14, 2020
    Messages:
    216
    yeah yeah i know that, there'd just probably have to be something like that under the skin, really just the firing order, because that's what gives different engines different tones
    just have some script that accounts for the number of cylinders and the formation (i.e. 1-5-3-6-2-4 for a V6, or 1-3-4-2 for an I4) and make it bang at that rate based on crank rpm or something
    i know next to nothing about how engines work in this game, someone who knows more about jbeam could help out
     
  5. mrwallace888

    mrwallace888
    Expand Collapse

    Joined:
    Jun 17, 2015
    Messages:
    399
    Well if you see that guy's videos, he's got like a bajillion videos for different types of V8 engine firing orders, but they all seem to sound about the same anyways. So I don't think the firing order in itself really changes much?
     
  6. stale

    stale
    Expand Collapse

    Joined:
    Jun 14, 2020
    Messages:
    216
    yeh i noticed that too
    it'd probably just be a matter of trial and error getting it to work organically in beam
    if the goal is to just use a single sample, then it'd need some repeat variable in place of a different sample for higher rpm
    so instead of
    ["art/sound/engine/V8/859.flac", 859],
    ["art/sound/engine/V8/919.flac", 919],
    and so on,
    it'd be something like this
    ["art/sound/engine/V8/revolution.flac", 859],
    ["art/sound/engine/V8/revolution.flac"(something where it'd repeat at maybe 1.4x rate), 919],

    again, i barely know anything about programming in this game, any sound experience i have comes from pissing around in sonic pi and fl studio

     
  7. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    I really like the William Moser videos, and have replicated this inside my modular software synthesizer, Reaktor.

    There's a few issues, but it's a good starting point in some ways. There's a lack of mechanical noise generally... but mainly that pretty much all engine configurations sound the same. It's the exhaust system which really gives a particular model of car it's identity, so that's the main 'issue'.

    All I can say, is the engine sounds we use, which are from a third party, and are samples (but I think a certain amount of granular synthesis has been used in creating those samples), are not ideal for me at all. For sure, for a bog standard 1.8 i4 they're fine, but as you start moving to more esoteric powerful configurations the sounds don't 'cut it' even with the muffled/unmuffled system we are currently using.

    We will be looking at this at some point in the future.... but when... I cannot say as it is not a big priority for the game at this point in time.

    It's certainly an area I'm keen to talk about though :)
     
    • Like Like x 19
  8. atv_123

    atv_123
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    1,590
    To take this a bit a bit more nerdy, to really nail down an engines sound (especially in this manner) not only is it an issue with mechanical sounds like tappets, cams, chains, and the like, but you also have to take into account, not only the piston exhaust strokes, but the header tube lengths as well... if you have equal length headers, then the issue is fairly easy to figure out, but if your header tubes have different lengths, then it will give the engine a completely different sound. Examples:


    vs


    These both have flat plane crank engines, but as you can hear, due to the way their headers are configured, the both have massively different sounds. The Ferrari uses equal length headers while the Mustang uses unequal length due to packaging requirements. Naturally this could be accounted for, but it would require quite a bit of math... something that I am actually working on in my engine simulator that I am building. But without that extra bit, every engine simulated in the way that Mosers videos are presented is that they will all sound like they have equal length headers... which just isn't how most engines are actually constructed, and thus how most engines sound.
     
    • Like Like x 3
  9. SupremeDalek73

    SupremeDalek73
    Expand Collapse

    Joined:
    Sep 13, 2019
    Messages:
    110
    I had a thought, what if Automation used this method and engines were tuned and simulated in Automation but with Beam textures; Automation has presets for different intake and exhaust types, as well as tunable turbos, with superchargers coming later; could this work?
     
  10. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    Yep going point too, was talking about this elsewhere, when the different header pipe lengths, coupled with the different firing order, causes the airwave (thus soundwave) from each header to collide with each other when they reach the end of their pipe thus amplifying the size of the wave when they collide.
     
    • Agree Agree x 2
  11. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    5,046
    I don't think BeamNG will be able to simulate this... So it will probably need some separate samples for that
     
  12. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    Proper synthesis ,such as physical modelling or procedural audio, are two examples of how it could be done.

    For now, procedural audio does not give me the quality I want, and physical modelling is going to be too expensive in terms of CPU... but there is a lot to investigate.

    And again, this is just for the engine... the exhaust is another set of complications.
     
    • Agree Agree x 7
    • Like Like x 1
  13. atv_123

    atv_123
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    1,590
    I think it could be done and done pretty well... its just a matter of figuring out all the processes behind it.

    I also think that while full, real time audio would probably end up with the most dynamic and realistic sounds (eventually) I don't think it is actually necessary to go quite that ham. I feel like sticking with the audio engine in place now and just calculating the sound files on the fly to use each time the vehicle is spawned would be more than enough... as the way that the engine audio functions right now is pretty darn good as is. But not having to record audio for new mods and new vehicles is a nice thing to have as well.

    Like... um... ok... lets say I wanted to make a mod of an inline 7 cylinder engine. I think there are like... 3 different kinds on the planet? and one powers a ship... so that's not gonna fly. The other I think is a diesel, so again... not gonna fly.

    So, how do I make a proper sound for this? Really, I can't record one... but... if I know enough about engines, and what kind of engine I want to make... I could in theory "make" one.... kinda.



    This is an actual inline 7 Cylinder engine... for reference anyways. Its a big ol' diesel truck engine, but we can get all the information we need from this bad boi right here.

    Now, as we know... multi cylinder engines are basically just a bunch of single cylinder engines all slapped together and running in unison. Here is an interesting example to prove my point (unfortunately the camera quality is pretty bad... but still)

    No headers to guide or combine the sound... just open pipes (kinda)


    So... in theory (I haven't actually tried this... but technically it should work) what could be done to "make" a sound like this engine (rather than doing what he did and slapping a bunch of lawn mowers together) is you could find a single cylinder engine that has similar bore and stroke to the engine you would like to make. For gas engines, aiming for a 500cc single cylinder engine will normally get you into the ballpark (unless its a sports bike engine... those are usually much smaller... but even still... it should be easy enough to find similar engines for those sizes)

    Lets say I want to make our inline 7 with similar specs to a Ford 300i6. I picked this because these bad bois are big and the cylinder volume is fairly large. That would be a bore of 3.98in and a stroke of 4in. pi*(3.98in/2)^2 = 12.44in^2 (piston surface area). 12.44in^2 * 4in = 49.76in^3 (cylinder volume). 49.76in^3 = 815.49cc. So an 800cc engine would be what we were aiming for.

    I present you with the Suzuki DR 800 "BIG"


    So, if we were to properly record one of these, we would have a pretty good sound for each independent cylinder in our engine. Naturally, we would need idle, on load, off load, and stuff like that, just like the in game engines have now so they can blend properly and give a dynamic sound in game.

    So, now to set up the sound of the engine.

    So this 7 cylinder will be a 4 stroke, and will have evenly spaced crank pins (an important distinction to make) which means that in 720° of crankshaft rotation, each cylinder will fire once... so 720°/7= roughly 102.85° in between exhaust strokes. So if we use that example of the engine above, it has a time of 0.086s in between exhaust strokes (roughly... I just measured it in audacity) which means that that is our area to work inside. All 7 exhaust strokes need to happen, before the next exhaust stroke occurs in the sound wave. This also means that is your take 60s (for 60 seconds in a minute) and divide that by 0.086s (our time between exhaust pulses) you get the idle RPM... which is roughly 700RPM's. To get our time offset, we just need to divide our single pulse time by 7 as we will have 7 cylinders. This leaves us with a time between pulses of 0.012286s

    So if we were to simulate racing headers, or just... no headers at all... zoomies I suppose as well... our job hear is done. Take a sound here with 2 thumps, offset it evenly 7 times between those 2 thumps... then repeat it (and probably have to edit it a bit to make it sound half way decent... no clipping at the start and end of the sound file for instance) and your done.

    Adding UEL headers or stock exhaust manifolds in, things get a bit more tricky... as you now have to individually offset each cylinder by the length they are away from the collector. In the case of our engine we pictured up above (the original diesel i7) we can see that it has cast log style exhaust manifolds that connect to a turbo half way up the engine. This can all be figured out fairly easily still for distance calculations... but for simplicity, I will basically take the entire length of a Ford 300i6 engine block as my manifold length... as an i7 will be longer than the entire block of one, but the exhausts come out at the center of the cylinders anyways thus chopping the length of an entire cylinder off from each end. So our length will be 725 mm or 28.56". On the cast log, it looks like the collector is between cylinders 3 and 4? So that's what I am going to roll with. That gives us tube lengths of:

    Cylinder 1 = 258.93mm = 0.25893m
    Cylinder 2 = 155.36mm = 0.15536m
    Cylinder 3 = 51.79mm = 0.05979m
    Cylinder 4 = 51.79mm = 0.05979m
    Cylinder 5 = 155.36mm = 0.15536m
    Cylinder 6 = 258.93mm = 0.25893m
    Cylinder 7 = 362.50mm = 0.36250m

    Now we can calculate the time that each cylinders pulse would take to reach the collector... naturally the exhaust gas's will flow faster or slower depending on throttle input, boost, this, that, and the other thing... but right now I am going to use an average of 500m/s attained from here as at velocity's that fast, its not going to make tooooo much of a difference.

    After dividing each distance by 500m/s we get time delay for each cylinder of:

    Cylinder 1 = 0.000518s
    Cylinder 2 = 0.000311s
    Cylinder 3 = 0.000104s
    Cylinder 4 = 0.000104s
    Cylinder 5 = 0.000311s
    Cylinder 6 = 0.000518s
    Cylinder 7 = 0.000725s

    Now for the interesting part... to get the delays correct along with when they will get to the collector, we need to know the firing order of the engine. The firing order for the engine pictured above appears to be (or at least what I can find) 1-3-5-7-2-4-6.

    Knowing ALL of this, we could finally construct our engine sound and actually have it roughly correct (for open headers anyways.)

    Cylinder 1 = 0.000518s
    Cylinder 3 = 0.012389s
    Cylinder 5 = 0.024882s
    Cylinder 7 = 0.037582s
    Cylinder 2 = 0.049454s
    Cylinder 4 = 0.061532s
    Cylinder 6 = 0.074232s

    And then there you are... basically take your sound, copy it across the tracks, and then offset the waveforms by the equivalent amount as you see there... I do recommend using at minimum one full cycle offset per piston beat as to make sure the wave forms don't overlap too closely or else you get static. So you end up with something more like this...

    Cylinder 1 = 0.086518s
    Cylinder 3 = 0.184389s
    Cylinder 5 = 0.282882s
    Cylinder 7 = 0.381582s
    Cylinder 2 = 0.479454s
    Cylinder 4 = 0.577532s
    Cylinder 6 = 0.676232s

    Using these offsets in Audacity with that motorcycle above, I managed to make an inline 7 cylinder engine "sound" which.... kinda sounds like you would expect. I am sure much more talented people could make something that sounds much better, but at least this gives everyone the idea.



    As you can hear... its not actually that far off... granted if I knew sound editing better, I could probably get it bang on.

    Then after this, the built in muffling engine in beam probably would actually take care of the rest on its own as it does seem to be set up very well. It might need some parameters tweaked per engine... but we do that now anyways, so that's not much different.
     

    Attached Files:

    • Like Like x 20
    • Staff Pick Staff Pick x 1
    • Agree Agree x 1
  14. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    Good grief - that's a very impressive post!
     
    • Agree Agree x 13
    • Like Like x 1
  15. Sir-Tanks-Alot

    Sir-Tanks-Alot
    Expand Collapse

    Joined:
    Feb 9, 2021
    Messages:
    18
    Great points. Even the configuration of the exhaust tips can change the overall sound of a vehicle. My IRL '69 Firebird has the exhaust tips pointed down at the ground, and that gives it a deeper, more throaty note. Big rumble for a small block.

    Tips straight out the back gives a "cleaner" engine note; a more direct from the engine sound.
     
  16. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    Yep, what you're hearing is effectively muffling right at the tip. The sound is directed downwards, hitting the surface, which absorbs some of the high frequencies, and most of the really high frequencies. Since we have control over the orientation, direction etc of the emitter - we use this sort of thing already to EQ the exhaust, you can hear it when you rotate the chase camera around the car. Same with the semi - the exhausts are pointing upwards. What we can't do, is replicate how the surface may be cutting and amplifying certain frequencies as they reflect off that surface - as per what your exhaust is doing.
     
    #16 TDK, Feb 10, 2021
    Last edited: Feb 11, 2021
    • Like Like x 3
  17. Sir-Tanks-Alot

    Sir-Tanks-Alot
    Expand Collapse

    Joined:
    Feb 9, 2021
    Messages:
    18
    Thanks for the info, and keep up the great work. Sound is an oft-overlooked part of video game production.
     
    • Like Like x 2
  18. mrwallace888

    mrwallace888
    Expand Collapse

    Joined:
    Jun 17, 2015
    Messages:
    399
    Weren't you guys planning on doing ray-traced audio or whatever the hell it's called? I heard something once about it.
     
  19. IonicOwl

    IonicOwl
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    166
    We managed to get a 1.0l Nissan Micra to sound like a boxer just by swapping the factory manifold out with one that had the runners for cylinders 1 and 2 lengthened.



    (video by the chap that made the manifold)
     
    • Like Like x 5
  20. TDK

    TDK
    Expand Collapse
    BeamNG Team

    Joined:
    Dec 17, 2017
    Messages:
    355
    Yeah, we want to use ray tracing to determine whether a vehicle has a roof and windows, and determine the size of an enclosed cabin.
    --- Post updated ---
    Fabulous!
     
    • Like Like x 5
  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