Skip to content

Commit c940991

Browse files
authored
Merge pull request #1160 from peternewell/track_sounds_final_#1
Route Based TTrack Sounds
2 parents 0d2de70 + c64daa0 commit c940991

File tree

8 files changed

+1486
-118
lines changed

8 files changed

+1486
-118
lines changed

Source/Documentation/Manual/sound.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,62 @@ Trigger Function
446446
========= =====================================
447447

448448

449+
Track Based Sounds for Routes
450+
-----------------------------
451+
452+
As track based sounds (such as track joints, curve squeal, etc) are common to all rolling stock these types of sounds can be added at a route level, rather then
453+
at an individual rolling stock level. This has the advantage of ensuring a level of consistency for all individual stock rather then requiring each piece of stock
454+
to have appropriate sounds associated with it. It means that all rolling stock will be "automatically" have track sounds given to it.
455+
456+
This approach relies on use of the Track Region sounds configured in the TType.dat file. A base SMS file is created for the first track region sound which is played
457+
continuously and contains all track related sounds that need to be played despite the region that the train is in. Further track region SMS files can be created for
458+
different track type regions, such as different bridge types (such as wood, concrete or steel).
459+
460+
To enable this approach in OR, the following parameters need to be set accordingly in the route TRK file.
461+
462+
``ORTSPlayTrackSoundsBaseContinuous`` - this causes the first SMS file in the TType file to be played continuously. Set to 1 for continuous play or 0 for legacy operation.
463+
464+
``ORTSDistanceBetweenTrackJoints`` - this defines the distance between the track joints, and the value is any valid distance.
465+
466+
``ORTSConcreteSleepers`` - Allows sounds to be adjusted according to whether track is wood or concrete supported. Set to 1 if concrete sleepers are used throughout the route.
467+
468+
The following control parameters can be used in the relevant track region SMS files to vary a frequency or volume curve for the sound being played:
469+
470+
``AngleofAttackControlled`` - Varies as the Angle of Attack of a car on a curve varies, in Milliradian (mRad).
471+
472+
``CarFrictionControlled`` - Varies as friction of car changes, typically between 0 and 1.
473+
474+
``WheelRPMControlled`` - Varies as RPM of wheel changes, in RPM.
475+
476+
``CarDistanceTrackControlled`` - Distance that the car is from the camera in metres.
477+
478+
``CarTunnelDistanceControlled`` - Varies based upon the distance as a car travels into and out of a tunnel. Typically this value is between 0 and 25 metres.
479+
480+
The following control parameters can be used to trigger, enable or disable different WAV sound files within a SMS file:
481+
482+
``Joint_2Axle_Trigger``, ``Joint_3Axle_Trigger``, ``Joint_4Axle_Trigger``, ``Joint_6Axle_Trigger``, ``Joint_8Axle_Trigger`` - these triggers are operated when the car passes
483+
over a joint, and can be varied in accordance with the number of axles defined in the WAG file.
484+
485+
``Switch_2Axle_Trigger``, ``Switch_3Axle_Trigger``, ``Switch_4Axle_Trigger``, ``Switch_6Axle_Trigger``, ``Switch_8Axle_Trigger`` - these triggers are operated when the car
486+
passes over a switch, and can be varied in accordance with the number of axles defined in the WAG file.
487+
488+
``Xover_2Axle_Trigger``, ``Xover_3Axle_Trigger``, ``Xover_4Axle_Trigger``, ``Xover_6Axle_Trigger``, ``Xover_8Axle_Trigger`` - these triggers are operated when the car passes
489+
over a Cross over, and can be varied in accordance with the number of axles defined in the WAG file. Note that the cross over needs to have been defined within the route editor.
490+
491+
``AngleofAttack_inc_past``, ``Angleofattack_dec_past`` - Varies as the Angle of Attack of a car on a curve varies, in Milliradian (mRad).
492+
493+
``WheelRPM_inc_past``, ``WheelRPM_dec_past`` - Varies as RPM of wheel changes, in RPM.
494+
495+
``ConcreteSleepers_inc_past``, ``ConcreteSleepers_dec_past`` - 0 = wood sleepers, 1 = concrete sleepers
496+
497+
``CarInTunnel_inc_past``, ``CarInTunnel_dec_past`` - 0 = car not in tunnel, 1 = car in tunnel.
498+
499+
``CarCameraDistance_inc_past``, ``CarCameraDistance_dec_past`` - Distance that the car is from the camera, in metres.
500+
501+
Note: If rolling stock already has track sounds set up in tyhe wagon SMS file, then these will be played at the same time as the route based sounds. For best sound outcomes,
502+
the number of axles for each wagon should be correctly set in the WAG file.
503+
504+
449505
Variable Triggers
450506
-----------------
451507

Source/Orts.Formats.Msts/RouteFile.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public Tr_RouteFile(STFReader stf)
8686
new STFReader.TokenProcessor("routestart", ()=>{ if (RouteStart == null) RouteStart = new RouteStart(stf); }),
8787
new STFReader.TokenProcessor("environment", ()=>{ Environment = new TRKEnvironment(stf); }),
8888
new STFReader.TokenProcessor("milepostunitskilometers", ()=>{ MilepostUnitsMetric = true; }),
89-
new STFReader.TokenProcessor("electrified", ()=>{ Electrified = stf.ReadBoolBlock(false); }),
89+
new STFReader.TokenProcessor("electrified", ()=>{ Electrified = stf.ReadBoolBlock(false); }),
9090
new STFReader.TokenProcessor("overheadwireheight", ()=>{ OverheadWireHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, 6.0f);}),
91-
new STFReader.TokenProcessor("speedlimit", ()=>{ SpeedLimit = stf.ReadFloatBlock(STFReader.UNITS.Speed, 500.0f); }),
91+
new STFReader.TokenProcessor("speedlimit", ()=>{ SpeedLimit = stf.ReadFloatBlock(STFReader.UNITS.Speed, 500.0f); }),
9292
new STFReader.TokenProcessor("defaultcrossingsms", ()=>{ DefaultCrossingSMS = stf.ReadStringBlock(null); }),
9393
new STFReader.TokenProcessor("defaultcoaltowersms", ()=>{ DefaultCoalTowerSMS = stf.ReadStringBlock(null); }),
9494
new STFReader.TokenProcessor("defaultdieseltowersms", ()=>{ DefaultDieselTowerSMS = stf.ReadStringBlock(null); }),
@@ -127,6 +127,9 @@ public Tr_RouteFile(STFReader stf)
127127
new STFReader.TokenProcessor("ortscurveswitchsmsnumber", ()=>{ CurveSwitchSMSNumber = stf.ReadIntBlock(null); }),
128128
new STFReader.TokenProcessor("ortsopendoorsinaitrains", ()=>{ OpenDoorsInAITrains = stf.ReadBoolBlock(false); }),
129129

130+
new STFReader.TokenProcessor("ortsplaytracksoundsbasecontinuous", ()=>{ TrackSoundDefaultContinuousPlay = stf.ReadBoolBlock(false); }),
131+
new STFReader.TokenProcessor("ortsdistancebetweentrackjoints", ()=>{ DistanceBetweenTrackJointsM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
132+
new STFReader.TokenProcessor("ortsconcretesleepers", ()=>{ ConcreteSleepers = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
130133
});
131134
//TODO This should be changed to STFException.TraceError() with defaults values created
132135
if (RouteID == null) throw new STFException(stf, "Missing RouteID");
@@ -175,6 +178,11 @@ public Tr_RouteFile(STFReader stf)
175178
public float ForestClearDistance = 0;
176179
public bool RemoveForestTreesFromRoads = false;
177180

181+
// Track based sounds
182+
public bool TrackSoundDefaultContinuousPlay = false;
183+
public float DistanceBetweenTrackJointsM;
184+
public float ConcreteSleepers;
185+
178186
// images
179187
public string Thumbnail;
180188
public string LoadingScreen;

0 commit comments

Comments
 (0)