MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / getVehicleAudioAttributes

Function getVehicleAudioAttributes

src/OpenLoco/src/Audio/VehicleAudio.cpp:125–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123 }
124
125 static AudioAttributes getVehicleAudioAttributes(const Vehicles::VehicleBase& base, const Vehicles::VehicleSound& soundParams, const Viewport& viewport)
126 {
127 auto vpPos = World::gameToScreen(base.position, WindowManager::getCurrentRotation());
128 const auto uiPoint = viewport.viewportToScreen(vpPos);
129
130 const auto zoomVolumeModifier = getZoomVolumeModifier(viewport.zoom);
131
132 const auto panX = calculatePan(uiPoint.x, Ui::width());
133 const auto panY = calculatePan(uiPoint.y, Ui::height());
134
135 const auto undergroundModifier = isUnderground(base.position) ? kVolumeModifierUnderground : 0;
136
137 const auto xFalloffModifier = getFalloffModifier(panX);
138 const auto yFalloffModifier = getFalloffModifier(panY);
139
140 const auto falloffVolumeModifier = std::min(xFalloffModifier, yFalloffModifier);
141
142 const auto overallVolumeModifier = std::max(falloffVolumeModifier + undergroundModifier + zoomVolumeModifier, 0);
143
144 const auto volume = std::max(((soundParams.drivingSoundVolume * overallVolumeModifier) / 8) + kVehicleVolumeCalcMin, kVolumeMin);
145
146 AudioAttributes attribs{};
147 attribs.volume = volume;
148 attribs.pan = panX;
149 attribs.frequency = soundParams.drivingSoundFrequency;
150 return attribs;
151 }
152
153 static void stopVehicleSound(Vehicles::VehicleSound& sound)
154 {

Callers 1

updateSingleVehicleSoundFunction · 0.85

Calls 9

gameToScreenFunction · 0.85
getCurrentRotationFunction · 0.85
getZoomVolumeModifierFunction · 0.85
calculatePanFunction · 0.85
widthFunction · 0.85
heightFunction · 0.85
isUndergroundFunction · 0.85
getFalloffModifierFunction · 0.85
viewportToScreenMethod · 0.80

Tested by

no test coverage detected