mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 180113. combined sound support for motor relays, dedicated motor shunt field sound, camera movement speed calculation fix
This commit is contained in:
21
sound.cpp
21
sound.cpp
@@ -57,14 +57,30 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons
|
||||
// on the far end the crossfade section extends to the threshold point of the next chunk...
|
||||
for( std::size_t idx = 0; idx < m_soundchunks.size() - 1; ++idx ) {
|
||||
m_soundchunks[ idx ].second.fadeout = m_soundchunks[ idx + 1 ].second.threshold;
|
||||
/*
|
||||
m_soundchunks[ idx ].second.fadeout =
|
||||
interpolate<float>(
|
||||
m_soundchunks[ idx ].second.threshold,
|
||||
m_soundchunks[ idx + 1 ].second.threshold,
|
||||
m_crossfaderange * 0.01f );
|
||||
*/
|
||||
}
|
||||
// ...and on the other end from the threshold point back into the range of previous chunk
|
||||
m_soundchunks.front().second.fadein = std::max( 0, m_soundchunks.front().second.threshold );
|
||||
// m_soundchunks.front().second.fadein = m_soundchunks.front().second.threshold;
|
||||
for( std::size_t idx = 1; idx < m_soundchunks.size(); ++idx ) {
|
||||
auto const previouschunkwidth { m_soundchunks[ idx ].second.threshold - m_soundchunks[ idx - 1 ].second.threshold };
|
||||
m_soundchunks[ idx ].second.fadein = m_soundchunks[ idx ].second.threshold - 0.01f * m_crossfaderange * previouschunkwidth;
|
||||
/*
|
||||
m_soundchunks[ idx ].second.fadein =
|
||||
interpolate<float>(
|
||||
m_soundchunks[ idx ].second.threshold,
|
||||
m_soundchunks[ idx - 1 ].second.threshold,
|
||||
m_crossfaderange * 0.01f );
|
||||
*/
|
||||
}
|
||||
m_soundchunks.back().second.fadeout = std::max( 100, m_soundchunks.back().second.threshold );
|
||||
// m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold;
|
||||
// test if the chunk table contains any actual samples while at it
|
||||
for( auto &soundchunk : m_soundchunks ) {
|
||||
if( soundchunk.first.buffer != null_handle ) {
|
||||
@@ -353,7 +369,7 @@ sound_source::play_combined() {
|
||||
// a chunk covers range from fade in point, where it starts rising in volume over crossfade distance,
|
||||
// lasts until fadeout - crossfade distance point, past which it grows quiet until fade out point where it ends
|
||||
if( soundpoint < soundchunk.second.fadein ) { break; }
|
||||
if( soundpoint > soundchunk.second.fadeout ) { continue; }
|
||||
if( soundpoint >= soundchunk.second.fadeout ) { continue; }
|
||||
|
||||
if( ( soundchunk.first.playing > 0 )
|
||||
|| ( soundchunk.first.buffer == null_handle ) ) {
|
||||
@@ -564,7 +580,7 @@ sound_source::update_combined( audio::openal_source &Source ) {
|
||||
auto const soundpoint { compute_combined_point() };
|
||||
auto const &soundchunk { m_soundchunks[ soundhandle ^ sound_id::chunk ] };
|
||||
if( ( soundpoint < soundchunk.second.fadein )
|
||||
|| ( soundpoint > soundchunk.second.fadeout ) ) {
|
||||
|| ( soundpoint >= soundchunk.second.fadeout ) ) {
|
||||
Source.stop();
|
||||
update_counter( soundhandle, -1 );
|
||||
return;
|
||||
@@ -681,7 +697,6 @@ sound_source::update_crossfade( sound_handle const Chunk ) {
|
||||
m_properties.pitch = 1.f;
|
||||
}
|
||||
}
|
||||
|
||||
// if there's no crossfade sections, our work is done
|
||||
if( m_crossfaderange == 0 ) { return; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user