mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
build 191205. sound pitch variation parameter
This commit is contained in:
13
sound.cpp
13
sound.cpp
@@ -182,6 +182,17 @@ sound_source::deserialize_mapping( cParser &Input ) {
|
||||
{ std::stoi( key.substr( indexstart, indexend - indexstart ) ), 0, 0, 1.f } } );
|
||||
}
|
||||
}
|
||||
else if( key == "pitchvariation:" ) {
|
||||
auto const variation {
|
||||
clamp(
|
||||
Input.getToken<float>( false, "\n\r\t ,;" ),
|
||||
0.0f, 1.0f )
|
||||
* 100.0f / 2.0f };
|
||||
m_pitchvariation = (
|
||||
variation == 0.0f ?
|
||||
1.0f :
|
||||
0.01f * static_cast<float>( Random( 100.0 - variation, 100.0 + variation ) ) );
|
||||
}
|
||||
else if( key.compare( 0, std::min<std::size_t>( key.size(), 5 ), "pitch" ) == 0 ) {
|
||||
// sound chunk pitch, defined with key pitchX where X = activation threshold
|
||||
auto const indexstart { key.find_first_of( "1234567890" ) };
|
||||
@@ -333,7 +344,7 @@ sound_source::play( int const Flags ) {
|
||||
|
||||
// initialize emitter-specific pitch variation if it wasn't yet set
|
||||
if( m_pitchvariation == 0.f ) {
|
||||
m_pitchvariation = 1.f; // 0.01f * static_cast<float>( Random( 97.5, 102.5 ) );
|
||||
m_pitchvariation = 0.01f * static_cast<float>( Random( 97.5, 102.5 ) );
|
||||
}
|
||||
/*
|
||||
if( ( ( m_flags & sound_flags::exclusive ) != 0 )
|
||||
|
||||
Reference in New Issue
Block a user