mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 13:29:18 +02:00
build 191212. bogie sound tweak, minor bug fixes
This commit is contained in:
59
DynObj.cpp
59
DynObj.cpp
@@ -4052,11 +4052,13 @@ void TDynamicObject::RenderSounds() {
|
||||
}
|
||||
}
|
||||
if( door.step_folding ) {
|
||||
for( auto &doorsounds : m_doorsounds ) {
|
||||
if( doorsounds.placement == side ) {
|
||||
// determine left side doors from their offset
|
||||
doorsounds.step_close.play( sound_flags::exclusive );
|
||||
doorsounds.step_open.stop();
|
||||
if( door.step_position < 1.0f ) { // sanity check, the vehicles may keep the doorstep unfolded until the door close
|
||||
for( auto &doorsounds : m_doorsounds ) {
|
||||
if( doorsounds.placement == side ) {
|
||||
// determine left side doors from their offset
|
||||
doorsounds.step_close.play( sound_flags::exclusive );
|
||||
doorsounds.step_open.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4097,7 +4099,9 @@ void TDynamicObject::RenderSounds() {
|
||||
}
|
||||
// szum w czasie jazdy
|
||||
if( ( GetVelocity() > 0.5 )
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
&& ( false == m_bogiesounds.empty() )
|
||||
#endif
|
||||
&& ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view)
|
||||
FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise
|
||||
// Global.pWorld->train() == nullptr ? true : // (can skip this check, with no player train the external view is a given)
|
||||
@@ -4105,8 +4109,11 @@ void TDynamicObject::RenderSounds() {
|
||||
ctOwner != simulation::Train->Dynamic()->ctOwner ? true : // confirmed isn't a part of the user-driven train
|
||||
Global.CabWindowOpen ? true : // sticking head out we get to hear outer noise
|
||||
false ) ) {
|
||||
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
auto const &bogiesound { m_bogiesounds.front() };
|
||||
#else
|
||||
auto const &bogiesound { m_outernoise };
|
||||
#endif
|
||||
// frequency calculation
|
||||
auto const normalizer { (
|
||||
true == bogiesound.is_combined() ?
|
||||
@@ -4144,25 +4151,40 @@ void TDynamicObject::RenderSounds() {
|
||||
|
||||
if( volume > 0.05 ) {
|
||||
// apply calculated parameters to all motor instances
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
for( auto &bogiesound : m_bogiesounds ) {
|
||||
bogiesound
|
||||
.pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack
|
||||
.gain( volume )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
#else
|
||||
m_outernoise
|
||||
.pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack
|
||||
.gain( volume )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// stop all noise instances
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
for( auto &bogiesound : m_bogiesounds ) {
|
||||
bogiesound.stop();
|
||||
}
|
||||
#else
|
||||
m_outernoise.stop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
// don't play the optional ending sound if the listener switches views
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
for( auto &bogiesound : m_bogiesounds ) {
|
||||
bogiesound.stop( false == FreeFlyModeFlag );
|
||||
}
|
||||
#else
|
||||
m_outernoise.stop( false == FreeFlyModeFlag );
|
||||
#endif
|
||||
}
|
||||
// flat spot sound
|
||||
if( MoverParameters->CategoryFlag == 1 ) {
|
||||
@@ -5407,6 +5429,9 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
||||
noisetemplate.m_amplitudefactor /= ( 1 + MoverParameters->Vmax );
|
||||
noisetemplate.m_frequencyfactor /= ( 1 + MoverParameters->Vmax );
|
||||
|
||||
m_outernoise = noisetemplate;
|
||||
/*
|
||||
// disabled until we can resolve sound interferences
|
||||
if( true == m_bogiesounds.empty() ) {
|
||||
// fallback for cases without specified noise locations, convert sound template to a single sound source
|
||||
m_bogiesounds.emplace_back( noisetemplate );
|
||||
@@ -5421,6 +5446,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
||||
bogie.offset( bogieoffset );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
else if( token == "wheelflat:" ) {
|
||||
@@ -5512,7 +5538,9 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
||||
// add entry to the list
|
||||
auto const location { glm::vec3 { 0.f, 0.f, offset } };
|
||||
bogienoise.offset( location );
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
m_bogiesounds.emplace_back( bogienoise );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6814,8 +6842,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
|
||||
// motor sounds
|
||||
volume = 0.0;
|
||||
if( ( true == Vehicle.Mains )
|
||||
&& ( false == motors.empty() ) ) {
|
||||
if( false == motors.empty() ) {
|
||||
|
||||
if( std::abs( Vehicle.enrot ) > 0.01 ) {
|
||||
|
||||
@@ -6879,7 +6906,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
+ std::abs( Vehicle.Mm ) / 60.0 * Deltatime,
|
||||
0.0, 1.25 );
|
||||
volume *= std::max( 0.25f, motor_momentum );
|
||||
|
||||
motor_volume = interpolate( motor_volume, volume, 0.25 );
|
||||
if( motor_volume >= 0.05 ) {
|
||||
// apply calculated parameters to all motor instances
|
||||
for( auto &motor : motors ) {
|
||||
@@ -6889,21 +6916,21 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// stop all motor instances
|
||||
for( auto &motor : motors ) {
|
||||
motor.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// stop all motor instances
|
||||
motor_volume = 0.0;
|
||||
for( auto &motor : motors ) {
|
||||
motor.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
motor_volume = interpolate( motor_volume, volume, 0.25 );
|
||||
if( motor_volume < 0.05 ) {
|
||||
// stop all motor instances
|
||||
for( auto &motor : motors ) {
|
||||
motor.stop();
|
||||
}
|
||||
}
|
||||
// motor blowers
|
||||
if( false == motorblowers.empty() ) {
|
||||
for( auto &blowersound : motorblowers ) {
|
||||
|
||||
4
DynObj.h
4
DynObj.h
@@ -456,7 +456,11 @@ private:
|
||||
sound_source sHorn1 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||
sound_source sHorn2 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||
sound_source sHorn3 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||
#ifdef EU07_SOUND_BOGIESOUNDS
|
||||
std::vector<sound_source> m_bogiesounds; // TBD, TODO: wrapper for all bogie-related sounds (noise, brakes, squeal etc)
|
||||
#else
|
||||
sound_source m_outernoise { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||
#endif
|
||||
sound_source m_wheelflat { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||
sound_source rscurve { sound_placement::external, 2 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; // youBy
|
||||
sound_source rsDerailment { sound_placement::external, 2 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; // McZapkie-051202
|
||||
|
||||
@@ -283,6 +283,12 @@ eu07_application::get_cursor_pos( double &Horizontal, double &Vertical ) const {
|
||||
glfwGetCursorPos( m_windows.front(), &Horizontal, &Vertical );
|
||||
}
|
||||
|
||||
int
|
||||
eu07_application::get_mouse_button( int const Button ) const {
|
||||
|
||||
return glfwGetMouseButton( m_windows.front(), Button );
|
||||
}
|
||||
|
||||
void
|
||||
eu07_application::on_key( int const Key, int const Scancode, int const Action, int const Mods ) {
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
get_cursor_pos() const;
|
||||
void
|
||||
get_cursor_pos( double &Horizontal, double &Vertical ) const;
|
||||
int
|
||||
get_mouse_button( int const Button ) const;
|
||||
// input handlers
|
||||
void
|
||||
on_key( int const Key, int const Scancode, int const Action, int const Mods );
|
||||
|
||||
@@ -459,16 +459,28 @@ drivermouse_input::poll() {
|
||||
while( m_updateaccumulator > updaterate ) {
|
||||
|
||||
if( m_mousecommandleft != user_command::none ) {
|
||||
// NOTE: basic keyboard controls don't have any parameters
|
||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
m_relay.post( m_mousecommandleft, 0, 0, GLFW_REPEAT, 0 );
|
||||
if( Application.get_mouse_button( GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS ) {
|
||||
// sanity check, as our button callback can trigger after button release leaving us with desync
|
||||
// NOTE: basic keyboard controls don't have any parameters
|
||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
m_relay.post( m_mousecommandleft, 0, 0, GLFW_REPEAT, 0 );
|
||||
}
|
||||
else {
|
||||
m_mousecommandleft = user_command::none;
|
||||
}
|
||||
}
|
||||
if( m_mousecommandright != user_command::none ) {
|
||||
if( Application.get_mouse_button( GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS ) {
|
||||
// sanity check, as our button callback can trigger after button release leaving us with desync
|
||||
// NOTE: basic keyboard controls don't have any parameters
|
||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
m_relay.post( m_mousecommandright, 0, 0, GLFW_REPEAT, 0 );
|
||||
m_relay.post( m_mousecommandright, 0, 0, GLFW_REPEAT, 0 );
|
||||
}
|
||||
else {
|
||||
m_mousecommandright = user_command::none;
|
||||
}
|
||||
}
|
||||
m_updateaccumulator -= updaterate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user