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

Windows does not save system volume settings between sessions #644

Open
i-d-lytvynenko opened this issue Nov 25, 2023 · 0 comments
Open

Comments

@i-d-lytvynenko
Copy link

Issue Description

Musikcube does not retain the system volume settings between sessions. Whenever the program is relaunched, the volume in the system volume mixer resets to the default value.

Expected Behavior

Ideally, musikcube should save and restore the system volume settings from the previous session, ensuring that the volume level remains consistent across relaunches.

Steps to Reproduce

  1. Launch musikcube.
  2. Play something.
  3. Adjust the musikcube volume using the Windows volume mixer.
  4. Close musikcube.
  5. Relaunch musikcube.

Current Behavior

Upon relaunching musikcube, the system volume in the volume mixer is reset to the default value, disregarding any previous adjustments made by the user.

Environment

  • Version: 3.0.2
  • Operating System: Windows 10, 64-bit

Additional Information

  • No error messages or warnings are displayed when encountering this issue.
  • The program is not recognized as an audio source by Windows (i.e. not shown in volume mixer) until a track is played. This makes it problematic to change the volume manually or using a script. A semi-working solution is to run something like the following after launching musikcube:
import sys
import pycaw.pycaw as pycaw

def set_volume(program_name, volume_percent):
    sessions = pycaw.AudioUtilities.GetAllSessions()
    for session in sessions:
        volume = session.SimpleAudioVolume
        if session.Process and session.Process.name() == program_name:
            volume.SetMasterVolume(volume_percent / 100, None)

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("Usage: python set_volume.py <program_name> <volume_percent>")
        sys.exit(1)

    program_name = sys.argv[1]
    volume_percent = int(sys.argv[2])

    set_volume(program_name, volume_percent)

python set_volume.py "musikcube-cmd.exe" 25. This works, but only if the program has already produced some sounds, which could help if you set ResumePlaybackOnStartup option to true and run this script after musikcube with a small delay (for example, using a batch script).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant