|
|
@ -36,8 +36,11 @@ void Sound::update() { |
|
|
|
if (sm.updated("microphone")) { |
|
|
|
if (sm.updated("microphone")) { |
|
|
|
float volume = util::map_val(sm["microphone"].getMicrophone().getFilteredSoundPressureWeightedDb(), 30.f, 60.f, 0.f, 1.f); |
|
|
|
float volume = util::map_val(sm["microphone"].getMicrophone().getFilteredSoundPressureWeightedDb(), 30.f, 60.f, 0.f, 1.f); |
|
|
|
volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale); |
|
|
|
volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale); |
|
|
|
|
|
|
|
// set volume on changes
|
|
|
|
|
|
|
|
if (std::exchange(current_volume, std::nearbyint(volume * 10)) != current_volume) { |
|
|
|
Hardware::set_volume(volume); |
|
|
|
Hardware::set_volume(volume); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setAlert(Alert::get(sm, 0)); |
|
|
|
setAlert(Alert::get(sm, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|