From 8020c15967609613ac8c9e079818a3143f228a85 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Thu, 5 Dec 2019 17:21:04 +0100 Subject: [PATCH] build 191205. sound pitch variation parameter --- sound.cpp | 13 ++++++++++++- version.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sound.cpp b/sound.cpp index eabd867e..1d7418cc 100644 --- a/sound.cpp +++ b/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( false, "\n\r\t ,;" ), + 0.0f, 1.0f ) + * 100.0f / 2.0f }; + m_pitchvariation = ( + variation == 0.0f ? + 1.0f : + 0.01f * static_cast( Random( 100.0 - variation, 100.0 + variation ) ) ); + } else if( key.compare( 0, std::min( 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( Random( 97.5, 102.5 ) ); + m_pitchvariation = 0.01f * static_cast( Random( 97.5, 102.5 ) ); } /* if( ( ( m_flags & sound_flags::exclusive ) != 0 ) diff --git a/version.h b/version.h index 3609970e..47f9ef04 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 19 -#define VERSION_MINOR 1117 +#define VERSION_MINOR 1205 #define VERSION_REVISION 0