Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume sounds best when using a logarithmic scale #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from console_callbacks import audio_arg_parser, mixer, error_callback, connection_callbacks, debug_callbacks, playback_callbacks, playback_setup
from lastfm import lastfm_arg_parser
from utils import print_zeroconf_vars
import math

class Connect:
def __init__(self, error_cb = error_callback, web_arg_parser = None):
Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(self, error_cb = error_callback, web_arg_parser = None):
lib.SpRegisterConnectionCallbacks(connection_callbacks, userdata)
lib.SpRegisterPlaybackCallbacks(playback_callbacks, userdata)

mixer_volume = int(mixer.getvolume()[0] * 655.35)
mixer_volume = int(math.pow(mixer.getvolume()[0] / 100.0, 3) * 65535)
lib.SpPlaybackUpdateVolume(mixer_volume)

bitrates = {
Expand Down
2 changes: 2 additions & 0 deletions console_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import threading
from connect_ffi import ffi, lib
from lastfm import lastfm
import math


RATE = 44100
Expand Down Expand Up @@ -257,6 +258,7 @@ def playback_volume(self, volume):
mixer.setmute(0)
print "Mute deactivated"
corected_playback_volume = int(min_volume_range + ((volume / 655.35) * (100 - min_volume_range) / 100))
corected_playback_volume = int(100 * math.pow(corected_playback_volume / 100.0, 1.0 / 3.0))
print "corected_playback_volume: {}".format(corected_playback_volume)
mixer.setvolume(corected_playback_volume)

Expand Down