build 180113. combined sound support for motor relays, dedicated motor shunt field sound, camera movement speed calculation fix

This commit is contained in:
tmj-fstate
2018-01-13 15:43:20 +01:00
parent 79002a9017
commit 8e5841d0ec
7 changed files with 167 additions and 95 deletions

View File

@@ -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; }