Ah
Well there's not much to it. The audio input class just inherits from sf::SoundRecorder and uses the buffer to create a VU meter:
bool AudioIn::onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
{
//sum and average the value of the current set of samples
sf::Int64 sum = 0;
for(std::size_t i = 0; i < sampleCount; i++)
{
sum += std::abs(samples[i]);
}
float avg = static_cast<float>(sum / sampleCount);
//10 * log() == power, 20 * log() == amplitude
//See: http://www.sengpielaudio.com/calculator-db.htm
m_dB = (avg > 0) ? 20.f * log10(avg / m_reference) : -1000000.f; //in theory could go to -inf so we cut off somewhere
sf::Lock lock(m_mutex);
Signal = (m_dB > m_threshold);
return true;
}
Signal is an atomic bool (because the audio input runs in its own thread) which is set to true if the input level is above a designated value. In this case that value is set by the calibration mode you see at the beginning of the video where I check the input volume of the record. That way you ultimately get a boolean value which you can test much in the same ways as sf::Keyboard::isKeyPressed(), eg:
if(AudioIn.Signal) fire();