PySolFC icon indicating copy to clipboard operation
PySolFC copied to clipboard

Question: What is needed for music to play?

Open MorsMortium opened this issue 1 year ago • 14 comments

Hi! I have created this AUR package, for Arch Linux, as they do not include the music files with the package: https://aur.archlinux.org/packages/pysolfc-music

When installed, it contains the following files (next to the other data files):

pysolfc-music /usr/
pysolfc-music /usr/share/
pysolfc-music /usr/share/PySolFC/
pysolfc-music /usr/share/PySolFC/music/
pysolfc-music /usr/share/PySolFC/music/Astral_Dreams.COPYRIGHT
pysolfc-music /usr/share/PySolFC/music/Astral_Dreams.it
pysolfc-music /usr/share/PySolFC/music/Bye_For_Now.COPYRIGHT
pysolfc-music /usr/share/PySolFC/music/Bye_For_Now.s3m
pysolfc-music /usr/share/PySolFC/music/Past_and_Future.COPYRIGHT
pysolfc-music /usr/share/PySolFC/music/Past_and_Future.it
pysolfc-music /usr/share/PySolFC/music/Ranger_Song.COPYRIGHT
pysolfc-music /usr/share/PySolFC/music/Ranger_Song.s3m
pysolfc-music /usr/share/PySolFC/music/Subsequential.COPYRIGHT
pysolfc-music /usr/share/PySolFC/music/Subsequential.mod

It depends on the pysolfc package, so the following dependencies are installed:

[pysolfc-cardsets](https://archlinux.org/packages/extra/any/pysolfc-cardsets/)
[python-attrs](https://archlinux.org/packages/extra/any/python-attrs/)
[python-configobj](https://archlinux.org/packages/extra/any/python-configobj/)
[python-pillow](https://archlinux.org/packages/extra/x86_64/python-pillow/)
[python-pygame](https://archlinux.org/packages/extra/x86_64/python-pygame/)
[python-pysol_cards](https://archlinux.org/packages/extra/any/python-pysol_cards/)
[python-random2](https://archlinux.org/packages/extra/any/python-random2/)
[python-six](https://archlinux.org/packages/extra/any/python-six/)
[tk](https://archlinux.org/packages/extra/x86_64/tk/)
[python-setuptools](https://archlinux.org/packages/extra/any/python-setuptools/) (make)

The music however no longer plays. At one point it worked, and the regular sound effects still play. This is under wayland, with pipewire and pipewire-pulse

Not sure if I miss some dependency, or their location changed recently or if there is something else going wrong.

MorsMortium avatar Oct 11 '24 10:10 MorsMortium

Nothing's changed with the music playing logic lately.

For playing sounds in PySol, it depends on which Python libraries are installed. Sound effects are supported in most builds, but for the music to play, a Python package that supports the music playback is needed. In current builds, this is usually pygame. A couple months back, I had an issue with the music in my local dev environment, and got it fixed by simply reinstalling pygame, and I do see pygame among the installed packages. Older versions may use pysol-sound-server, but this doesn't work as well as pygame. My advice would be to check the version of pygame you're using, and update/refresh it to see if that works.

Another note - if you go to Options > Sound, the options that are displayed depend on which libraries are installed and which sound options your current build supports. If the options to enable music and set the volume are missing, then your build does not support music playback, and you might want to check pygame. If the options are present, the music is supported, and the issue is most likely with the music files themselves.

Does that info help?

joeraz avatar Oct 12 '24 01:10 joeraz

The current pygame version is 2.6.0-1, I reinstalled that with removing it from cache too. I installed the -git version 2.6.0.r26.g79807da84-1, which was built on my system. The options are there for music too. The music files play correctly with Audacious and VLC

MorsMortium avatar Oct 12 '24 06:10 MorsMortium

More things I tried: replace pipewire with pulseaudio, run it with a completely new user, run it on x11 instead of wayland. All of these resulted in effects working but music not

MorsMortium avatar Oct 12 '24 06:10 MorsMortium

One more thing I tried: with the downgrade utility installed pygame 2.5.2-1, 2.5.2-2 and 2.4.0-1 versions, none worked and one version broke sound too, but reinstalling 2.6.0-1 fixed it

MorsMortium avatar Oct 12 '24 07:10 MorsMortium

Confirming the music files are located in \PySolFC\data\music, correct?

If the music options are showing, it might be something off with the files themselves.

joeraz avatar Oct 13 '24 22:10 joeraz

They are located in /usr/share/PySolFC/music. Now I relocated them to /usr/share/PySolFC/data/music, without any results. On Arch this folder contains these other folders/files as well:

cardset*
html
images
info.txt
pysolfc.glade
sound
tcl
themes
tiles

And in this folder they played, previously. This is also the folder written in the repo, but I have now also tested putting them into the automatically created ~/.PySolFC/music folder, without results. I have compared md5 checksums for all music files, and they match with the manually downloaded and extracted files from here: https://github.com/shlomif/pysol-music/archive/refs/tags/4.50.tar.gz

MorsMortium avatar Oct 14 '24 03:10 MorsMortium

Getting somewhere. I have put a .wav file in /usr/share/PySolFC/music, it plays. I've put it in ~/.PySolFC/music, it plays again. It might be some codec issue, as the files themselves play correctly in multiple players

MorsMortium avatar Oct 14 '24 04:10 MorsMortium

Wrote a very simple music player based on how PySolFC plays music:

import pygame.mixer
import pygame.mixer_music
import time

pygame.mixer.pre_init(44100, -16, 2, 1024*1)
pygame.mixer.init()

pygame.mixer_music.load("./Astral_Dreams.it")
pygame.mixer_music.set_volume(1)
pygame.mixer_music.play()
while pygame.mixer_music and pygame.mixer_music.get_busy():
    time.sleep(0.2)

While the .wav file just plays, the .it, .mod and .s3m files result in an error: pygame.error: Unrecognized audio format

MorsMortium avatar Oct 14 '24 05:10 MorsMortium

I have reported it here: https://github.com/pygame/pygame/issues/4365

MorsMortium avatar Oct 14 '24 05:10 MorsMortium

Hello @MorsMortium , I'm a pygame-ce member, could you try with pygame-ce and tell me if it works ? If not, could you as well open an issue in https://github.com/pygame-community/pygame-ce please ? In pygame-ce we're much more active, with good maintainance, and all the team comes from pygame original repos. So If you want an answer to your problem rapidly, I suggest you to check pygame-ce. You can also visit the pygame discord before if you want a faster answer.

bilhox avatar Oct 14 '24 17:10 bilhox

@bilhox Indeed, installing with pip in a venv, and then running the script in it plays all the sounds files (the extra ones too, mentioned in the pygame issue)

MorsMortium avatar Oct 14 '24 18:10 MorsMortium

But after checking, in a venv just installing regular pygame also plays it

MorsMortium avatar Oct 14 '24 18:10 MorsMortium

Wanted to make a comparison, between the system and the venv version, but the venv version from pypi contains files like /home/morsmortium/ce/lib/python3.12/site-packages/pygame.libs/libsystemd-7fd64813.so.0.6.0, which I'm not sure that it exists on my openrc system

MorsMortium avatar Oct 14 '24 18:10 MorsMortium

So an environmental issue, then? Given the symptoms, that does add up.

joeraz avatar Oct 15 '24 03:10 joeraz

@MorsMortium If this issue is environmental, is there anything else you need from me here?

joeraz avatar Oct 22 '24 22:10 joeraz

No, this is only related to pygame, and I'm waiting on some insights from there. Thanks for the help!

MorsMortium avatar Oct 23 '24 18:10 MorsMortium