MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / getAudioLoudness

Function getAudioLoudness

source/frontend/StarVoice.cpp:51–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51float getAudioLoudness(int16_t* data, size_t samples, float volume = 1.0f) {
52 constexpr size_t CHUNK_SIZE = 50;
53
54 float highest = -127.f;
55 for (size_t i = 0; i < samples; i += CHUNK_SIZE) {
56 float level = getAudioChunkLoudness(data + i, std::min<size_t>(i + CHUNK_SIZE, samples) - i, volume);
57 if (level > highest)
58 highest = level;
59 }
60
61 return highest;
62}
63
64class VoiceAudioStream {
65public:

Callers 2

readAudioDataMethod · 0.85
mixMethod · 0.85

Calls 1

getAudioChunkLoudnessFunction · 0.85

Tested by

no test coverage detected