mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 17:09:19 +02:00
Merge pull request #74 from Unofficial-MaSzyna-Developement/cab-resonance-sound
Cab resonance & wind sound
This commit is contained in:
@@ -1421,7 +1421,7 @@ public:
|
|||||||
double AccSVBased {}; // tangential acceleration calculated from velocity change
|
double AccSVBased {}; // tangential acceleration calculated from velocity change
|
||||||
double AccN = 0.0; // przyspieszenie normalne w [m/s^2]
|
double AccN = 0.0; // przyspieszenie normalne w [m/s^2]
|
||||||
double AccVert = 0.0; // vertical acceleration
|
double AccVert = 0.0; // vertical acceleration
|
||||||
double nrot = 0.0;
|
double nrot = 0.0; // predkosc obrotowa kol (obrotow na sekunde)
|
||||||
double nrot_eps = 0.0; //przyspieszenie kątowe kół (bez kierunku)
|
double nrot_eps = 0.0; //przyspieszenie kątowe kół (bez kierunku)
|
||||||
double WheelFlat = 0.0;
|
double WheelFlat = 0.0;
|
||||||
bool TruckHunting { true }; // enable/disable truck hunting calculation
|
bool TruckHunting { true }; // enable/disable truck hunting calculation
|
||||||
|
|||||||
57
Train.cpp
57
Train.cpp
@@ -8311,6 +8311,30 @@ TTrain::update_sounds( double const Deltatime ) {
|
|||||||
dsbSlipAlarm->stop();
|
dsbSlipAlarm->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dzwiek wiatru rozbijajacego sie o szyby w kabinie
|
||||||
|
if (rsWindSound)
|
||||||
|
{
|
||||||
|
if (!FreeFlyModeFlag && !Global.CabWindowOpen && DynamicObject->GetVelocity() > 0.5)
|
||||||
|
update_sounds_resonancenoise(*rsWindSound);
|
||||||
|
else
|
||||||
|
rsWindSound->stop(FreeFlyModeFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
// szum w czasie jazdy
|
||||||
if( rsRunningNoise ) {
|
if( rsRunningNoise ) {
|
||||||
if( ( false == FreeFlyModeFlag )
|
if( ( false == FreeFlyModeFlag )
|
||||||
@@ -8456,6 +8480,25 @@ TTrain::update_sounds( double const Deltatime ) {
|
|||||||
update_sounds_radio();
|
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 ) {
|
void TTrain::update_sounds_runningnoise( sound_source &Sound ) {
|
||||||
// frequency calculation
|
// frequency calculation
|
||||||
auto const normalizer { (
|
auto const normalizer { (
|
||||||
@@ -8635,6 +8678,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}},
|
{"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}},
|
{"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 }},
|
{"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 }},
|
{"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}},
|
{"rainsound:", {m_rainsound, sound_placement::internal, -1, sound_type::single, 0, 100.0}},
|
||||||
};
|
};
|
||||||
@@ -8698,6 +8743,12 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
if (rsBrake) {
|
if (rsBrake) {
|
||||||
rsBrake->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
rsBrake->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
|
if (rsResonanceNoise) {
|
||||||
|
rsResonanceNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||||
|
}
|
||||||
|
if (rsWindSound) {
|
||||||
|
rsWindSound->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||||
|
}
|
||||||
if (rsRunningNoise) {
|
if (rsRunningNoise) {
|
||||||
rsRunningNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
rsRunningNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
@@ -8710,7 +8761,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
||||||
dsbSwitch, dsbPneumaticSwitch,
|
dsbSwitch, dsbPneumaticSwitch,
|
||||||
rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss, rsSBHissU,
|
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
|
dsbHasler, dsbBuzzer,dsbBuzzerShp, dsbSlipAlarm, m_distancecounterclear, m_rainsound, m_radiostop
|
||||||
};
|
};
|
||||||
for (auto &sound : sounds) {
|
for (auto &sound : sounds) {
|
||||||
@@ -8733,7 +8784,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
||||||
dsbSwitch, dsbPneumaticSwitch,
|
dsbSwitch, dsbPneumaticSwitch,
|
||||||
rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss, rsSBHissU,
|
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
|
dsbHasler, dsbBuzzer, dsbBuzzerShp, dsbSlipAlarm, m_distancecounterclear, m_rainsound, m_radiostop
|
||||||
};
|
};
|
||||||
for( auto &sound : sounds ) {
|
for( auto &sound : sounds ) {
|
||||||
@@ -9025,6 +9076,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
|
{rsSBHissU, ggBrakeCtrl.model_offset()}, // NOTE: fallback if the local brake model can't be located
|
||||||
{rsFadeSound, caboffset},
|
{rsFadeSound, caboffset},
|
||||||
{rsRunningNoise, caboffset},
|
{rsRunningNoise, caboffset},
|
||||||
|
{rsResonanceNoise, caboffset},
|
||||||
|
{rsWindSound, caboffset},
|
||||||
{rsHuntingNoise, caboffset},
|
{rsHuntingNoise, caboffset},
|
||||||
{dsbHasler, caboffset},
|
{dsbHasler, caboffset},
|
||||||
{dsbBuzzer, btLampkaCzuwaka.model_offset()},
|
{dsbBuzzer, btLampkaCzuwaka.model_offset()},
|
||||||
|
|||||||
3
Train.h
3
Train.h
@@ -210,6 +210,7 @@ class TTrain {
|
|||||||
// update function subroutines
|
// update function subroutines
|
||||||
void update_sounds( double const Deltatime );
|
void update_sounds( double const Deltatime );
|
||||||
void update_sounds_runningnoise( sound_source &Sound );
|
void update_sounds_runningnoise( sound_source &Sound );
|
||||||
|
void update_sounds_resonancenoise( sound_source &Sound );
|
||||||
void update_sounds_radio();
|
void update_sounds_radio();
|
||||||
inline
|
inline
|
||||||
end cab_to_end( int const End ) const {
|
end cab_to_end( int const End ) const {
|
||||||
@@ -804,6 +805,8 @@ public: // reszta może by?publiczna
|
|||||||
rsBrake,
|
rsBrake,
|
||||||
rsFadeSound,
|
rsFadeSound,
|
||||||
rsRunningNoise,
|
rsRunningNoise,
|
||||||
|
rsResonanceNoise,
|
||||||
|
rsWindSound,
|
||||||
rsHuntingNoise,
|
rsHuntingNoise,
|
||||||
m_rainsound;
|
m_rainsound;
|
||||||
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
|
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
|
||||||
|
|||||||
Reference in New Issue
Block a user