Engine Audio


I've been researching techniques for engine audio and I have narrowed it down to a few options:

1. Pitch Shift Engine Loop

A simple engine loop which is pitch shifted to simulate RPM and some added distortion effect when you get up in the high RPMs. This is the simplest of all techniques, and the one that takes up the least amount of disk space and processing power, but it also has some drawbacks. The main drawback is the sound itself - it sounds quite artificial and fake. 

Pitch shifting was the first method I implemented during prototyping since it's so simple. The video above uses this method and for an arcade style racer I suppose it's fine, maybe even suitable since it's not a simulator, but I still want to explore the different options that are available.

2. Custom engine cycle implementation in C#

I started to play with the idea of using an acceleration ramp audio file and chopping that up into many small cycles down to a piston stroke level and then having the audio skip forwards/backwards in the audio clip based on the current RPM of the car. It takes a lot of time and effort to get this to work and I have only gotten to a point where it sounds decent but there are many things to do to improve the sound.


In iZotope RX5 I loaded an acceleration recording of my own BMW 530 (6 cylinder engine) and viewed the Spectrogram. I identified the cylinders firing and put markers into the audio file after the engine ran through its cycle firing all 6 cylinders. I exported the markers into a text file which I used to define an array in a C# script, e.g.:

int[] Markers = new int[] { 829, 2251, 4384, 6280, 8413, 10309, 12205, 14101, 15760, 17656, 19789, 21448, 23107, 25003, 26899, 28558, 30217, 31876, 33535, 35194, 36853, 38749, 40645, 42304, 43726, 45385, 47281, 48940, 50599, 52495, 53917, 55576, 56998, 58894, 60316, 61975, 63871, 65293, 66715, 68374, 69796, 70981, 72640, 74062, 75484, 77143, 78565, 80461, 81883, 83305, 84727, 86386, 87808, 89467, 90885, 92445, 93970, 95392, 96577, 97999, 99438, 100920, 102288, 103656, 105024, 106506, 107988, 109584, 111066, 112662, 114030, 115398, 116697, 118032, 119412, 120792, 121988, 123368, 124656, 125973, 127293, 128481, 129867, 131187, 132309, 133431, 134685, 136203, 137391, 138843, 140031, 141219, 142605, 143859, 144915, 146235, 147357, 149073, 150195, 151419, 152274, 153320, 154460, 155694, 156645, 157974, 159399, 160539, 161679, 162994, 164226, 165402, 166578, 167754, 168986, 170050, 170946, 171954, 173074, 174418, 175679, 176967, 178031, 179207, 179934, 181055, 182118, 183126, 184302, 185367, 186599, 187662, 188727, 189959, 191022, 192087, 193151, 194271, 195335, 196511, 197519, 198639, 199758, 200711, 201887, 202895, 203958, 204911, 205863, 207150, 208158, 209111, 210231, 211182, 212247, 213255, 214319, 215382, 216222, 217343, 218463, 219582, 220422, 221375, 222383, 223614, 224567, 225630, 226638, 227591, 228561, 229621, 230599, 231659, 232555, 233615, 234511, 235489, 236541, 237348 };

Then I created a script that basically skips to the sample location based on the RPM of the engine at any given time. I have done this in a very quick and dirty way so I get some audio click artifacts since I'm not doing any crossfading and simply just brutally forcing the audio source to skip to a particular location. I do, however, have a window size so when there is not a lot of RPM change it cycles through 6 of these cycles in a loop whereas when you are accelerating or decelerating it shrinks the window to a single cycle.

This is what the original sound file sounds like: https://www.imphenzia.com/remote-content/mp3/engine-ramp.mp3

And this is what it sounds like when implemented in it's most basic form in the game:


I think I could greatly improve this implementation by using the Native Audio SDK by Unity where I can manipulate in the same way but by using a more powerful C++ DLL which would also allow me to shrink/expand the window better and crossfade between the grains. Basically it would be granular synthesis. Unfortunately my C++ skills are non-existent so it will take some tinkering to get it working but at the same time it would be a great opportunity to learn.

3. Third party cycle-based engine Rev engine by CrankCaseAudio

The final solution, and probably the best sounding one, would be by using the third party "Rev" engine by CrankCaseAudio. It comes with an editor which basically does what I did manually in my custom implementation above, but it does a much better and precise job along with doing it in a few seconds rather than half an hour for the manual task.

Also, the engine itself is much more sophisticated. It uses the individual cycles, similar to what I do in my approach above, but it applies layering, crossfading and models the engine sound to mimic how the engine behaves when clutching and shifting gears. Using the available Unity3D demo project, I implemented the Rev engine as a test in That's Racing with the demo engine (Camaro SS) that came with the demo:

I can only think of two drawbacks with using the Rev engine at the moment and those are:

1. Price - it costs a fair amount even when indie-friendly pricing is applied. The engine itself costs $1500 (for the first platform) and the editor to create sound ramp files costs another $1500. On top of that is any additional platform (e.g. Mac / Linux / Console, or even mobile) is another $750 per platform. This is also the pricing for a single title.

2. Limitations - I ran in to some issues where I can't alter the audio source that the Unity plugin for the Rev engine uses so I can't switch from stereo to spatial 3D sound which is a must for me since I will be having multiple cars and rely on the 3D position from the isometric viewpoint. I have e-mailed the CrankCaseAudio to ask - maybe I'm just missing how to do it =)

I think that the price will be a showstopper for using the engine so I may further develop my own one. Saying this, if I end up kickstarting this game along the line I want to push to fund the use of this very engine provided I can iron out any implementation issues.

Conclusion

I'm still deciding on the best approach and I haven't ruled out any of the above. If I get the funding I will likely go for the Rev engine (option 3) but I will still investigate and test my own  implementation (option 2) and I'll use option 1 as a fallback.

Regardless of which I'd like to advertise in my local car racers forum here in Sweden to get people with interesting cars to participate and having their car recorded with an acceleration and deceleration audio ramp.

What do you think??

Comments

Log in with itch.io to leave a comment.

I don´t know if you are still with this but its fantastic. Im starting something like that and i just need a really good hand for this. Any example?

Cool! Check out this video series that I am making right now: 

I've got 4 episodes available so far.

Nice im following now. Any idea when you will make new episodes, or specially for the sounds?