Skip to content

Commit

Permalink
Add ability to increase pitch range of diesel engine sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 14, 2023
1 parent 8a64259 commit 1303274
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected void effects(LocomotiveDiesel stock) {
if (idle != null) {
if (stock.isRunning()) {
float volume = Math.max(0.1f, stock.getSoundThrottle());
float pitch = 0.7f + stock.getSoundThrottle() / 4;
float pitchRange = stock.getDefinition().getEnginePitchRange();
float pitch = (1-pitchRange) + stock.getSoundThrottle() * pitchRange;
if (running == null) {
// Simple
idle.effects(stock, volume, pitch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class LocomotiveDieselDefinition extends LocomotiveDefinition {
private int fuelEfficiency;
private boolean hornSus;
private int notches;
private float enginePitchRange;

public LocomotiveDieselDefinition(String defID, DataBlock data) throws Exception {
super(LocomotiveDiesel.class, defID, data);
Expand Down Expand Up @@ -49,6 +50,7 @@ public void loadData(DataBlock data) throws Exception {
DataBlock sounds = data.getBlock("sounds");
idle = SoundDefinition.getOrDefault(sounds, "idle");
running = SoundDefinition.getOrDefault(sounds, "running");
enginePitchRange = sounds.getValue("engine_pitch_range").asFloat();
horn = SoundDefinition.getOrDefault(sounds, "horn");
bell = SoundDefinition.getOrDefault(sounds, "bell");
}
Expand Down Expand Up @@ -91,4 +93,8 @@ public ValveGearConfig getValveGear() {
public int getThrottleNotches() {
return notches;
}

public float getEnginePitchRange() {
return enginePitchRange;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ properties =

sounds =
idle = "immersiverailroading:sounds/diesel/default/idle.ogg" # Optional: See sound_definition.caml for details
running = null # Optional: See sound_definition.caml for details
running = null # Optional: See sound_definition.caml for details
engine_pitch_range = 0.25 # Optional: Percent of the pitch range to map the throttle to. Ex: 0.25 means start at 75% pitch and move to 100% as the engine throttles up
horn = "immersiverailroading:sounds/diesel/default/horn.ogg" # Optional: See sound_definition.caml for details
bell = "immersiverailroading:sounds/diesel/default/bell.ogg" # Optional: See sound_definition.caml for details
controls =
Expand Down

0 comments on commit 1303274

Please sign in to comment.