mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-30 22:59:51 +02:00
volume correction for 8, 16 and 32 bit
This commit is contained in:
parent
2275466d09
commit
8588488f8f
2 changed files with 23 additions and 8 deletions
|
@ -31,7 +31,8 @@ Player::Player(const PcmDevice& pcmDevice, Stream* stream) :
|
|||
stream_(stream),
|
||||
pcmDevice_(pcmDevice),
|
||||
volume_(1.0),
|
||||
muted_(false)
|
||||
muted_(false),
|
||||
volCorrection_(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -69,13 +70,14 @@ void Player::adjustVolume(char* buffer, size_t frames)
|
|||
|
||||
const SampleFormat& sampleFormat = stream_->getFormat();
|
||||
|
||||
if (volume < 1.0)
|
||||
if ((volume < 1.0) || (volCorrection_ != 1.))
|
||||
{
|
||||
if (sampleFormat.bits == 8)
|
||||
volume *= volCorrection_;
|
||||
if (sampleFormat.sampleSize == 1)
|
||||
adjustVolume<int8_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
else if (sampleFormat.bits == 16)
|
||||
else if (sampleFormat.sampleSize == 2)
|
||||
adjustVolume<int16_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
else if (sampleFormat.bits == 32)
|
||||
else if (sampleFormat.sampleSize == 4)
|
||||
adjustVolume<int32_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue