16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

Added sounds for EP brake made by EP-Compact

This commit is contained in:
Królik Uszasty
2021-10-10 21:28:51 +02:00
parent 99c7b2e0ad
commit 62d5bbe627
2 changed files with 50 additions and 0 deletions

View File

@@ -4189,6 +4189,40 @@ void TDynamicObject::RenderSounds() {
}
}
// epbrake - epcompact
if (( MoverParameters->BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( MoverParameters->LocHandle )) {
auto const epbrakepressureratio{ std::max( 0.0, MoverParameters->LocHandle->GetCP() ) / std::max(1.0, MoverParameters->MaxBrakePress[0] ) };
if ( m_lastepbrakepressure != -1.f ) {
// HACK: potentially reset playback of opening bookend sounds
if ( false == m_epbrakepressureincrease.is_playing() ) {
m_epbrakepressureincrease.stop();
}
if ( false == m_epbrakepressuredecrease.is_playing() ) {
m_epbrakepressuredecrease.stop();
}
// actual sound playback
auto const epquantizedratio{ static_cast<int>( 50 * epbrakepressureratio) };
auto const lastepbrakepressureratio { std::max( 0.f, m_lastepbrakepressure ) / std::max( 1.0, MoverParameters->MaxBrakePress[0] ) };
auto const epquantizedratiochange { epquantizedratio - static_cast<int>( 50 * lastepbrakepressureratio ) };
if ( epquantizedratiochange > 0 ) {
m_epbrakepressureincrease
.pitch(
true == m_epbrakepressureincrease.is_combined() ?
epquantizedratio * 0.01f :
m_epbrakepressureincrease.m_frequencyoffset + m_epbrakepressureincrease.m_frequencyfactor * 1.f )
.play();
}
else if ( epquantizedratiochange < 0 ) {
m_epbrakepressuredecrease
.pitch(true == m_epbrakepressuredecrease.is_combined() ?
epquantizedratio * 0.01f :
m_epbrakepressuredecrease.m_frequencyoffset + m_epbrakepressuredecrease.m_frequencyfactor * 1.f )
.play();
}
}
m_lastepbrakepressure = MoverParameters->LocHandle->GetCP();
}
// emergency brake
if( MoverParameters->EmergencyValveFlow > 0.025 ) {
// smooth out air flow rate
@@ -5719,6 +5753,18 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
m_brakecylinderpistonrecede.owner( this );
}
else if (token == "epbrakeinc:") {
// brake cylinder pressure increase sounds
m_epbrakepressureincrease.deserialize(parser, sound_type::single);
m_epbrakepressureincrease.owner(this);
}
else if (token == "epbrakedec:") {
// brake cylinder pressure decrease sounds
m_epbrakepressuredecrease.deserialize(parser, sound_type::single);
m_epbrakepressuredecrease.owner(this);
}
else if( token == "emergencybrake:" ) {
// emergency brake sound
m_emergencybrake.deserialize( parser, sound_type::single );

View File

@@ -499,6 +499,10 @@ private:
sound_source m_brakecylinderpistonrecede { sound_placement::external };
float m_lastbrakepressure { -1.f }; // helper, cached level of pressure in the brake cylinder
float m_brakepressurechange { 0.f }; // recent change of pressure in the brake cylinder
sound_source m_epbrakepressureincrease{ sound_placement::external };
sound_source m_epbrakepressuredecrease{ sound_placement::external };
float m_lastepbrakepressure{ -1.f }; // helper, cached level of pressure in the brake cylinder
float m_epbrakepressurechange{ 0.f }; // recent change of pressure in the brake cylinder
sound_source m_emergencybrake { sound_placement::engine };
double m_emergencybrakeflow{ 0.f };
sound_source sReleaser { sound_placement::external };