guess I can't have atomic for an array in Clang. ok
also the indenting was mixed so I had to fix it which is why the diff here is so wacky
This commit is contained in:
parent
c0fd5c0a60
commit
c14a99a7c3
@ -387,7 +387,11 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) {
|
||||
mix = true;
|
||||
|
||||
float volume = speaker->volume;
|
||||
std::array<float, 2> levels = speaker->channelVolumes;
|
||||
std::array<float, 2> levels;
|
||||
{
|
||||
MutexLocker locker(speaker->mutex);
|
||||
levels = speaker->channelVolumes;
|
||||
}
|
||||
for (size_t i = 0; i != samples; ++i)
|
||||
sharedBuffer[i] += (int32_t)(speakerBuffer[i]) * levels[i % 2] * volume;
|
||||
//Blends the weaker channel into the stronger one,
|
||||
@ -438,13 +442,14 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) {
|
||||
void Voice::update(float, PositionalAttenuationFunction positionalAttenuationFunction) {
|
||||
for (auto& entry : m_speakers) {
|
||||
if (SpeakerPtr& speaker = entry.second) {
|
||||
if (positionalAttenuationFunction) {
|
||||
speaker->channelVolumes = {
|
||||
Vec2F newChannelVolumes = positionalAttenuationFunction ? Vec2F{
|
||||
1.0f - positionalAttenuationFunction(0, speaker->position, 1.0f),
|
||||
1.0f - positionalAttenuationFunction(1, speaker->position, 1.0f)};
|
||||
} else
|
||||
speaker->channelVolumes = {1.0f, 1.0f};
|
||||
|
||||
1.0f - positionalAttenuationFunction(1, speaker->position, 1.0f)
|
||||
} : Vec2F{1.0f, 1.0f};
|
||||
{
|
||||
MutexLocker locker(speaker->mutex);
|
||||
speaker->channelVolumes = newChannelVolumes;
|
||||
}
|
||||
auto& dbHistory = speaker->dbHistory;
|
||||
memmove(&dbHistory[1], &dbHistory[0], (dbHistory.size() - 1) * sizeof(float));
|
||||
dbHistory[0] = speaker->decibelLevel;
|
||||
@ -704,7 +709,7 @@ void Voice::thread() {
|
||||
encoded.resize(encodedSize);
|
||||
|
||||
{
|
||||
MutexLocker lock(m_encodeMutex);
|
||||
MutexLocker locker(m_encodeMutex);
|
||||
m_encodedChunks.emplace_back(std::move(encoded));
|
||||
m_encodedChunksLength += encodedSize;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
atomic<bool> playing = 0;
|
||||
atomic<float> decibelLevel = -96.0f;
|
||||
atomic<float> volume = 1.0f;
|
||||
atomic<std::array<float, 2>> channelVolumes = std::array<float, 2>{1.0f, 1.0f};
|
||||
Vec2F channelVolumes = Vec2F::filled(1.f);
|
||||
|
||||
unsigned int minimumPlaySamples = 4096;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user