Kivy On Android: Other Options for Working Audio

425 views
Skip to first unread message

Horace Johnson

unread,
Mar 24, 2017, 9:51:31 PM3/24/17
to Kivy users support
Using SoundLoader in Kivy is not the way to go since major fps is lost, so I moved to pygame.  It was devastating finding out pygame is not pure python and there for Buildozer will not honor it as a requirement.

Then I tried to work around the audio issue....

          from kivy.core.audio import SoundLoader
          from kivy.core.audio.audio_sdl2 import SoundSDL2

          newsnd = SoundSDL2(source='newsound.ogg')
          newsnd.play()

I was abruptly kicked in the "gonads" again...  SDL2 or auido_pygame was not loaded/found on the android device (like pygame).

Buildozer.spec has a place for pointing to a recipe directory I believe, but there's no working pygame recipes on the net.

So, is there any other options available to me using Kivy 1.9.0 or is that the end of the road Kivy road?   :(

Alexander Taylor

unread,
Mar 25, 2017, 10:35:50 AM3/25/17
to Kivy users support
python-for-android already has a pygame recipe, although the use of pygame is almost deprecated in favour of SDL2. I don't think you can mix them, at least in the current build process, as pygame uses SDL1 which probably conflicts with SDL2. You could try using only pygame, but this is no longer really supported (it should continue to work, just without bugfixes or improvements).

I don't know much about sound management or if there is any Kivy option likely to give better performance, but feel free to open an issue on the Kivy github page about it as it sounds like a bug.

Horace Johnson

unread,
Mar 25, 2017, 2:40:38 PM3/25/17
to Kivy users support
I always thought Kivy came with pygame but what challenged that thought is the fact, import pygame does not work (or pygame.mixer).  Can someone provide the correct way to use pygame sound with Kivy's version of the module?

Alexander Taylor

unread,
Mar 25, 2017, 2:43:11 PM3/25/17
to kivy-...@googlegroups.com
Kivy can use pygame as a backend, and this used to be the default, but
SDL2 has been the new default for quite a long time and the pygame
backend isn't maintained much. Your Kivy probably is not compiled to use
pygame. If Kivy is compiled with pygame, I think pygame.sound would
probably be available as normal (although normally we'd discourage using
it instead of Kivy's own abstractions, as Kivy is designed to be
backend-independent so pygame-specific code may not work on different
platforms).
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/0W1q-SK2o2I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


signature.asc

Horace Johnson

unread,
Mar 25, 2017, 10:43:40 PM3/25/17
to kivy-...@googlegroups.com
That means I'll have to abandon yet another kivy project.  If I'm forced to work with SoundLoader then I must abide by it's limitations.  Sounds such as background music is no issue since it's a longer running sound that starts once and doesn't have to re-start often.  The best way to get multiple sound coming from NPC type actors is to blend a few tracks with multiple sounds randomly and play these tracks (randomly) just like the background music (including evironmental sounds within as well).  The only thing is, you have to create a game now where you can get away with that.  Main character will still be the biggest issue because you'll have to design animation and attack speed to minimize the call to any sound effects that triggers during an event (if you were making an action based game that is.  I was not).

I was actual making a bad a$$ sports title.  I'll just save the project until I move back to using 3D engines for PC/Laptop hardware.  I started using kivy because of the pros but the cons have taken over.
Reply all
Reply to author
Forward
0 new messages