mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-06 10:09:33 +02:00
volume ... should be moved to server
This commit is contained in:
parent
3acab0c9d2
commit
36cd60169d
2 changed files with 21 additions and 3 deletions
|
@ -86,13 +86,28 @@ void Player::adjustVolume(char* buffer, size_t frames)
|
||||||
//https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/pulse/volume.c#n260
|
//https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/pulse/volume.c#n260
|
||||||
//http://www.robotplanet.dk/audio/audio_gui_design/
|
//http://www.robotplanet.dk/audio/audio_gui_design/
|
||||||
//https://lists.linuxaudio.org/pipermail/linux-audio-dev/2009-May/thread.html#22198
|
//https://lists.linuxaudio.org/pipermail/linux-audio-dev/2009-May/thread.html#22198
|
||||||
void Player::setVolume(double volume)
|
void Player::setVolume_poly(double volume, double exp)
|
||||||
{
|
{
|
||||||
volume_ = volume*volume*volume;
|
volume_ = std::pow(volume, exp);
|
||||||
LOG(DEBUG) << "setVolume: " << volume << " => " << volume_ << "\n";
|
LOG(DEBUG) << "setVolume poly: " << volume << " => " << volume_ << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//http://stackoverflow.com/questions/1165026/what-algorithms-could-i-use-for-audio-volume-level
|
||||||
|
void Player::setVolume_exp(double volume, double base)
|
||||||
|
{
|
||||||
|
// double base = M_E;
|
||||||
|
// double base = 10.;
|
||||||
|
volume_ = (pow(base, volume)-1) / (base-1);
|
||||||
|
LOG(DEBUG) << "setVolume exp: " << volume << " => " << volume_ << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Player::setVolume(double volume)
|
||||||
|
{
|
||||||
|
setVolume_exp(volume, 10.);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Player::setMute(bool mute)
|
void Player::setMute(bool mute)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void worker() = 0;
|
virtual void worker() = 0;
|
||||||
|
|
||||||
|
void setVolume_poly(double volume, double exp);
|
||||||
|
void setVolume_exp(double volume, double base);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void adjustVolume(char *buffer, size_t count, double volume)
|
void adjustVolume(char *buffer, size_t count, double volume)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue