clangen / musikcube

a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++
https://musikcube.com
BSD 3-Clause "New" or "Revised" License
4.08k stars 295 forks source link

Windows does not save system volume settings between sessions #644

Open i-d-lytvynenko opened 7 months ago

i-d-lytvynenko commented 7 months ago

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

Additional Information

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 ") 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).