Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. A JSON editor (IntelliJ is a good one)
  2. The rFactor 2 SFX JSON schema*
  3. Sounds


rf2-sfxv1.schema.json

...

Code Block
languagejs
titleEngine Example
linenumberstrue
collapsetrue
{
            "multi": {
			  "comment": "multi represents the event type. The name variable below represents the name this event is identified with by the game. The other keys are event properties that affect playback of all children",
              "name": "engine",
              "volume": {
                "key": "engineRPM",
                "value": [[10,0,0],[1850,0.7,0.2],[6000,1,0],[9400,1.5,0.2]]
				"comment": "Here we scale the entire engine volume by RPM to create a ramping effect of a louder engine at higher RPM without having to mess with individual samples.
							Each bracket represents one key, where the first number is the RPM where it applies, the second number is the volume, and the third number is the shape (where 0 is linear, 1 and -1 are a curve).",
              },
              "position": [0,0.3,1.0],
              "effect": "engine",
              "filter": "engine",
			  "commentExtra": "effect and filter apply sound effects and direct filters respectively. They use a name to reference a filter or effect that is defined elsewhere in the file. Position is local to the car.",
              "events": [
                {
                  "multi": {
                    "name": "power",
                    "comment": "The name here is purely for our own knowledge since this event's parent plays back all children anyway. And so does this event! It applies a slightly curved throttle ramp between 10% and 70% throttle, applying to all children, which should be samples used for being on power similar to the old sound system.",
                    "volume": {
                      "key": "throttle",
					  "comment": "The key is a reference to a variable the game will read that correlates to the first value of each key. A list of possible keys, and a visual example, will be provided later"
                      "value": [[0.1,0,0],[0.7,1,0.3]]
                    },
                    "events": [
                      {
                        "loop": {
						  "comment": "Instead of the event type multi, we're looking at the type loop. This type loads a sample and plays it back in a loop whenever the event is fired by its parent. We use the engineRPM key again to define when this particular sample fades in our out, and the same exact system for the sample's pitch. While the volume curve, ideally, is a curve, the pitch should be linearly proportional to RPM. The key used at 1.0 pitch should correspond to the natural RPM the sample was recorded with. This event supports advanced features such as loop points, allowing a sample to loop between specific points so that initial playback won't have to sound as harsh. This can also allow fake engine wobble effects coming on throttle, which adds a lot of immersion! The other loop events below make up part of an engine's Power sound effects.
Note: Samples can be referenced relative to the vehicle's directory now. They no longer have to be in a MAS file in moddev.",
                          "sample": "sounds\\idle_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[10,0,0],[250,1,0.2],[2000,1,0],[2400,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[1850,1,0],[3700,2,0]]
                          }
                        }
                      },
                      {
                        "loop": {
                          "sample": "sounds\\1900_on_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[2000,0,0],[2400,1,0.2],[2500,1,0],[3000,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[1993,1,0],[3986,2,0]]
                          }
                        }
                      },
                      {
                        "loop": {
                          "sample": "sounds\\3800_on_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[2500,0,0],[3000,1,0.2],[3700,1,0],[4500,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[3800,1,0],[7600,2,0]]
                          }
                        }
                      }
                    ]
                  }
                },
                {
                  "multi": {
                    "name": "coast",
					"comment": "This is essentially the Coast equivalent of the previous event group. Same thing, but for coast!",
                    "volume": {
                      "key": "throttle",
                      "value": [[0.1,0.75,0],[0.7,0,0.3]]
                    },
                    "events": [
                      {
                        "loop": {
                          "sample": "sounds\\idle_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[10,0,0],[250,1,0.2],[2000,1,0],[2400,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[1850,1,0],[3700,2,0]]
                          }
                        }
                      },
                      {
                        "loop": {
                          "sample": "sounds\\3400_off_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[2000,0,0],[2400,1,0.2],[3600,1,0],[4800,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[3566,1,0],[7132,2,0]]
                          }
                        }
                      },
                      {
                        "loop": {
                          "sample": "sounds\\5800_off_int.wav",
                          "volume": {
                            "key": "engineRPM",
                            "value": [[3600,0,0],[4800,1,0.2],[5700,1,0],[6400,0,0.2]]
                          },
                          "pitch": {
                            "key": "engineRPM",
                            "value": [[0,0,0],[6083,1,0],[12166,2,0]]
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }

...

The following event types exist:

Type IdentifierPropertyDescriptionInherits from
bank
Base event. All other types inherit all properties from it. If it contains any other events, when fired, it will fire those events passing them the same event name it was fired with. Generally unused.-

eventsAn array containing other events this event can fire and interact with.

volume(optional) Either a fixed number or a curve (see doc "Volume and Pitch Curves"). Special property: Applies to all children ontop of their own volume.

pitch(optional) Same as volume.

position(optional) An array with 3 elements containing the local position of this emitter relative to its parent. If no parent exists or all parents have the offset 0,0,0, this is relative to the car's pivot point.

direction(optional) An array with 3 elements defining the euler angles of the emitter. This is only useful if an event related to this event uses a cone shape (see burst type)

nameIdentifier. Used to fire the event. This only has to exist if this event's parent is a type that fires by name, otherwise it may be used for identification but is not required by the system.
multibank
Contains multiple events and only ever plays one at a time. Commonly used to separate between internal and external sounds, or different types of terrain for road noise. When an event of this type gets fired, the name of the event that gets fired will be passed on to the active child of it.bank

bankKeyString containing the name of the property that will be used to determine which event to play. For example, "camera-in-out" will lead to either "inside" or "outside" being played depending on where the camera is. When the camera changes position, the property will automatically update this event causing it to switch the event it plays back - which could be an event containing the whole spectrum of events needed to represent a full car for one of the camera perspectives in this case.

allowEmpty(optional) If true, when the bankKey refers to an event name that does not exist, it will stop playing until the bankKey refers to an existing event again. Otherwise it will simply continue playing the previously valid event.
crossfade
This event is identical to multibank, except it crossfades between events when it switches, causing a smoother transition.multibank

timeTime in seconds for the crossfade to complete.

exponentShape of the fade. 0 is linear, 1 is exponential. Anything in-between is valid.
multi
Simply plays back every event it contains. If called as part of a loop, all contained events must be loops. If called as a burst, they must be burst.bank




random
Randomly picks a contained event to play it back each time it gets fired. In case of loops, this selection only changes when the loop stops. Contained events may be empty or with invalid samples in order to create an event that only plays sometimes.bank




burst
Plays a single burst sound.bank

cone(optional) Array with 3 elements specifying radius at which to start fading out, radius at which to end fading out, gain when fully faded out. Used in combination with direction to create sounds that can only be heard from certain directions. Very useful for separating exhaust and intake engine samples.

samplePath to sample this event will play back. This path can be local to the vehicle's subdirectory in moddev and the sample does not have to be in a MAS archive. Presently, only 16-bit PCM WAV files are officially supported, but certain other PCM formats might work. Stereo samples will be downmixed to mono, so ideally just use mono mixes. This is necessary for attenuation and panning.

randomSample(optional) If bigger than 0, it determines the random playback offset each time this event gets fired.

refDistance(optional) Distance (in m) where gain will be 1.0. Reasonable defaults have been chosen, so this is not required. If used, try applying it to the whole car for consistency. Automatic inheritance should make that a two line change to the file.

rolloff(optional) Rolloff. Works together with refDistance. Lower numbers mean higher attenuation.

doNotRestart(optional) If true, will prevent the sample from being fired again when it's still in the middle of playing.

effect(optional) String referring to the name of the environment effect used for this event.

filter(optional) String referring to the name of the direct path filter used for this event. Combine with effects to achieve a sensation of depth and a wide sound stage!
loop
Plays a looping soundburst

loopSample(optional) If defined, specifies offset in samples where the sound will loop when it reaches the end. This can be used to add fake transmission wobble or more pleasant back-on-throttle or post-shift effects without hearing them in a loop, and can dramatically reduce the length of a sample used for loops compared to the old system before it inevitably repeats in an immersion-breaking manner.
template
This is a special type. It does not inherit from anything, but is used to create more events from a single input to avoid lots of copy-paste work for easy iteration. Useful for defining only one wheel, but applying the info to all four wheels instead. See Templates section for more info!


List of Events and Variables

...