mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Add resonancesound (slightly modified runningnoise calculation)
This commit is contained in:
47
Train.cpp
47
Train.cpp
@@ -8281,6 +8281,20 @@ TTrain::update_sounds( double const Deltatime ) {
|
||||
dsbSlipAlarm->stop();
|
||||
}
|
||||
}
|
||||
|
||||
// dzwiek rezonansu (taki drugi runningnoise w sumie)
|
||||
if (rsResonanceNoise)
|
||||
{
|
||||
if (!FreeFlyModeFlag && !Global.CabWindowOpen && DynamicObject->GetVelocity() > 0.5)
|
||||
{
|
||||
|
||||
update_sounds_resonancenoise(*rsResonanceNoise);
|
||||
}
|
||||
else
|
||||
rsResonanceNoise->stop(FreeFlyModeFlag);
|
||||
}
|
||||
|
||||
|
||||
// szum w czasie jazdy
|
||||
if( rsRunningNoise ) {
|
||||
if( ( false == FreeFlyModeFlag )
|
||||
@@ -8426,6 +8440,25 @@ TTrain::update_sounds( double const Deltatime ) {
|
||||
update_sounds_radio();
|
||||
}
|
||||
|
||||
void TTrain::update_sounds_resonancenoise(sound_source &Sound)
|
||||
{
|
||||
// frequency calculation
|
||||
auto const normalizer{mvOccupied->Vmax * 0.01f};
|
||||
auto const frequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer};
|
||||
|
||||
// volume calculation
|
||||
auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * interpolate(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0
|
||||
|
||||
if (volume > 0.05)
|
||||
{
|
||||
Sound.pitch(frequency).gain(volume).play(sound_flags::exclusive | sound_flags::looping);
|
||||
}
|
||||
else
|
||||
{
|
||||
Sound.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::update_sounds_runningnoise( sound_source &Sound ) {
|
||||
// frequency calculation
|
||||
auto const normalizer { (
|
||||
@@ -8605,6 +8638,8 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
{"brakesound:", {rsBrake, sound_placement::internal, -1, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, 100.0}},
|
||||
{"fadesound:", {rsFadeSound, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, 0, 100.0}},
|
||||
{"runningnoise:", {rsRunningNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax }},
|
||||
{"resonancenoise:", {rsResonanceNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax }},
|
||||
{"windsound:", {rsWindSound, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax }},
|
||||
{"huntingnoise:", {rsHuntingNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax }},
|
||||
{"rainsound:", {m_rainsound, sound_placement::internal, -1, sound_type::single, 0, 100.0}},
|
||||
};
|
||||
@@ -8668,6 +8703,12 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
if (rsBrake) {
|
||||
rsBrake->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
if (rsResonanceNoise) {
|
||||
rsResonanceNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
if (rsWindSound) {
|
||||
rsWindSound->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
if (rsRunningNoise) {
|
||||
rsRunningNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
@@ -8680,7 +8721,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
||||
dsbSwitch, dsbPneumaticSwitch,
|
||||
rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss, rsSBHissU,
|
||||
rsFadeSound, rsRunningNoise, rsHuntingNoise,
|
||||
rsFadeSound, rsRunningNoise, rsResonanceNoise,rsWindSound, rsHuntingNoise,
|
||||
dsbHasler, dsbBuzzer,dsbBuzzerShp, dsbSlipAlarm, m_distancecounterclear, m_rainsound, m_radiostop
|
||||
};
|
||||
for (auto &sound : sounds) {
|
||||
@@ -8703,7 +8744,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
||||
dsbSwitch, dsbPneumaticSwitch,
|
||||
rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss, rsSBHissU,
|
||||
rsFadeSound, rsRunningNoise, rsHuntingNoise,
|
||||
rsFadeSound, rsRunningNoise, rsResonanceNoise, rsWindSound, rsHuntingNoise,
|
||||
dsbHasler, dsbBuzzer, dsbBuzzerShp, dsbSlipAlarm, m_distancecounterclear, m_rainsound, m_radiostop
|
||||
};
|
||||
for( auto &sound : sounds ) {
|
||||
@@ -8994,6 +9035,8 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
{rsSBHissU, ggBrakeCtrl.model_offset()}, // NOTE: fallback if the local brake model can't be located
|
||||
{rsFadeSound, caboffset},
|
||||
{rsRunningNoise, caboffset},
|
||||
{rsResonanceNoise, caboffset},
|
||||
{rsWindSound, caboffset},
|
||||
{rsHuntingNoise, caboffset},
|
||||
{dsbHasler, caboffset},
|
||||
{dsbBuzzer, btLampkaCzuwaka.model_offset()},
|
||||
|
||||
2
Train.h
2
Train.h
@@ -210,6 +210,7 @@ class TTrain {
|
||||
// update function subroutines
|
||||
void update_sounds( double const Deltatime );
|
||||
void update_sounds_runningnoise( sound_source &Sound );
|
||||
void update_sounds_resonancenoise( sound_source &Sound );
|
||||
void update_sounds_radio();
|
||||
inline
|
||||
end cab_to_end( int const End ) const {
|
||||
@@ -802,6 +803,7 @@ public: // reszta może by?publiczna
|
||||
rsBrake,
|
||||
rsFadeSound,
|
||||
rsRunningNoise,
|
||||
rsResonanceNoise,
|
||||
rsHuntingNoise,
|
||||
m_rainsound;
|
||||
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
|
||||
|
||||
Reference in New Issue
Block a user