MoonshineSG / OctoPrint-Sound

Play sounds on RaspberryPi on M300
19 stars 4 forks source link

No Sound, keeps defaulting to default.mp3. #6

Closed everon987 closed 2 years ago

everon987 commented 2 years ago

Hi, I've successfully installed 1.0.6 with no errors. However, I am unable to get any sound out of the 3.5mm jack.

I've placed some mp3 files inside .octoprint/data/sound and .octoprint/plugins/sound, all of which have the following mp3 files in 128kbps:

Upon calling m300 @startup , the console shows m300 @STARTUP and plays the default.mp3 file with no sound. I realized that no matter what @keyword is inserted into the console, it becomes uppercase. It also doesn't seem to be able to find the startup.mp3 file inside .octoprint/data/sound.

Things I've tried:

Octoprint Version: 1.7.1 (Correction: It is 1.7.2) OctoPi Version: 0.18.0

PS: Thanks for taking the time out to develop this plugin

MoonshineSG commented 2 years ago

Can you have a look at the logs to see if there's any error or message related to the plugin ?

The capitalisation of the keyword is strange. Is that a "feature" of your OS on the notebook/desktop/tablet you're using ?

everon987 commented 2 years ago

Install logs look good to me: plugin_pluginmanager_console.log

And this is the octoprint.log with the following logging levels enabled: image octoprint.log

I've tried to repeatedly trigger m300 @startup or m300 @default to see if anything will show up in the logs but I don't see anything. Perhaps my logging settings are wrong?

This is what I meant by the capitalization, not sure if this is normal behavior but I've tried it on my phone too and another computer, they all behave similarly: m300 @startup shows up as (@STARTUP)

1

And this is how the folders look like: image

MoonshineSG commented 2 years ago

I see... I have gave up on 3D printing and I don't have any way to test this... But ... My guess is that some change in recent Octoprint version capitalises the parameters of commands... YOU can test my theory by renaming one of the files to capital letters (eg DEFAULT.mp3 or DEFAULT.MP3) If that works you rename them all and you're good. If not, I'll carry on thinking :D

Let me know.

MoonshineSG commented 2 years ago

Whoops.... Notice this in the logs

(ImportError: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory)
  if not pygame.mixer.get_init():

That means your pygame is not properly installed or missing the library...

everon987 commented 2 years ago

Whelp, good catch on that error, totally missed it. I tried doing a sudo apt-get install python-pygame via ssh and rebooted the pi but the error still persists. Currently looking to ways to fix this.

I also did a amixer -q -M sset Headphone 80% and sudo alsactl store to make sure the 3.5mm jack is outputting audible levels of audio which worked so far (installed sox and used play foo.mp3 to test the files and the 3.5mm jack, both are working)

Once the pygame error is fixed and it still doesn't work, I'm going to try renaming the files to capital letters just to give it a shot.

Will update shortly, thanks for the help so far man.

MoonshineSG commented 2 years ago

try apt-get install libsdl2-mixer-2.0-0

everon987 commented 2 years ago

Yep, I've tried that as well (saw it from: https://github.com/cosmologicon/pygame-text/issues/7) Still getting this:

 2022-01-04 14:59:55,353 - py.warnings - WARNING - /home/pi/oprint/lib/python3.7/site-packages/octoprint_sound/__init__.py:27: RuntimeWarning: use mixer: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory
(ImportError: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory)
  if not pygame.mixer.get_init():
MoonshineSG commented 2 years ago

just checking... did you install pygame for python3 ? (pip3 install pygame) ...

everon987 commented 2 years ago

Yep, I did. I had to install pip first though because it wasn't part of OctoPi. Pygame and libsdl2-mixer-2.0-0 are both installed.

image

I ran a sudo apt-update --fix-missing as well. Issue still persist with the same error.

MoonshineSG commented 2 years ago

I'm not sure how I can help. Try to find smth to fix pygame or feel free to change the MP3 player if you're ok with coding in python...

MoonshineSG commented 2 years ago

one more thing.. try to find if "libSDL2_mixer-2.0.so.0" is really on your system... maybe it's a version conflict...

everon987 commented 2 years ago

No worries, I'll mess around a little further and see if I can get it to work and update you if it does (and perhaps post a solution if I found one).

Thanks for your help!

everon987 commented 2 years ago

I managed to fix the dependency error and it is now working.

At first apt-get install libsdl2-mixer-2.0-0 did not work and was constantly giving a 404, which I then ran an sudo apt-update which didn't work either as it required some permissions to be accepted manually.

What fixed it was:

  1. sudo apt update and manually accept all permission prompts (just press "y" all the way)
  2. apt-get install libsdl2-mixer-2.0-0 will work and no longer results in a 404
  3. Reboot and try m300 again

On top of that, to ensure volume isn't defaulted at 40% on boot: amixer -q -M sset Headphone 80% and sudo alsactl store

Edit: I think your plugin already sets the volume at 100 by default, whoops image

The only issue I am trying to fix now is that m300 @"something" keeps calling default.mp3, but there is sound now.

MoonshineSG commented 2 years ago

awesome!

maybe that can be solved by capitalising the file names... 🤞🏻

On 5 Jan 2022, at 15:44, Alvin Lim @.***> wrote:

 I managed to fix the dependency error and it is now working.

At first apt-get install libsdl2-mixer-2.0-0 did not work and was constantly giving a 404, which I then ran an sudo apt-update which didn't work either as it required some permissions to be accepted manually.

What fixed it was:

sudo apt update and manually accept all permission prompts (just press "y" all the way) apt-get install libsdl2-mixer-2.0-0 will work and no longer results in a 404 Reboot and try m300 again On top of that, to ensure volume isn't defaulted at 40% on boot: amixer -q -M sset Headphone 80% and sudo alsactl store

The only issue I am trying to fix now is that m300 @"something" keeps calling default.mp3, but there is sound now.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

everon987 commented 2 years ago

awesome! maybe that can be solved by capitalising the file names... 🤞🏻 On 5 Jan 2022, at 15:44, Alvin Lim @.***> wrote:  I managed to fix the dependency error and it is now working. At first apt-get install libsdl2-mixer-2.0-0 did not work and was constantly giving a 404, which I then ran an sudo apt-update which didn't work either as it required some permissions to be accepted manually. What fixed it was: sudo apt update and manually accept all permission prompts (just press "y" all the way) apt-get install libsdl2-mixer-2.0-0 will work and no longer results in a 404 Reboot and try m300 again On top of that, to ensure volume isn't defaulted at 40% on boot: amixer -q -M sset Headphone 80% and sudo alsactl store The only issue I am trying to fix now is that m300 @"something" keeps calling default.mp3, but there is sound now. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

You are absolutely right. That fixed it: image

image

Thanks again!

MoonshineSG commented 2 years ago

Good to hear that! It must be a change in latest Octoprint...

Happy printing!!!

everon987 commented 2 years ago

Sorry to necro this thread again but:

I realized that if I were to send an m300 @default directly into the terminal, it would work. But placing them in the start GCODE section yields an unknown command error and no sound is played

image

MoonshineSG commented 2 years ago

try capital M ? M300 @WHATEVER