Help needed for real time object movement using sound from microphone

hello guys ,
i have started using upbge from quite some time ,
is it possible to connect mic and use realtime sound in upbge to drive cube on y direction ,

1 Like

Hi @draguu,

The BGE (and I guess UPBGE as well) always came with audaspace integration. According to the docs on github it should also support mic access.

If you look for audio projects on the forum, you’ll find some examples of playing sounds etc.

The question is only, how to deal with Mic input in the gameloop.

What exactly are you trying to achieve?

Audaspace hmmm .

Jimmy gunavan if i remember the name correctly
Jimmy has posted a video for driving animation using pyaudio and animation nodes, i was wondering if we can convert that setup and connect it with logic bricks ,

I am trying to do lipsync here, like drive an empty back and forth according to sound input

Interesting use-case.

Maybe it works to get pyAudio into the BGE’s python distro. Typically you can expand the bundled python by running python -m ensurepip and then run pip install [nameOfModuleYouWantToInstall].

But I personally would try the integrated audio lib first before messing with additional packages.

i tried something , imported pyaudio and tried setting up jimmy’s script to work in upbge,

i installed pyaudio using anaconda now when you open the file and run it for the first time , it works and shows some numbers in the console ,
but its not working for second time , to make it work again we need to restart blender ,

still not getting realtime mic input , but i hope someone will help

lipsync bge1.blend (658.1 KB)

in the file cube should move as we speak in mic


I can’t have a look at the blend right now.

Regarding the “doesn’t work second time issue”, I remember having a similar thing with some other library some time ago (i think it was ZeroMQ).

This might happen when you not properly shut down the libs resources - maybe you can implement some cleanup before quitting (e.g. ESC pressed -> cleanup -> quit game instead of ESC -> quit game).

Second option would be to run the game from the blenderplayer, not from Blenders Editor (at least this existed for 2.79, not sure about UPBGE)

ill check about quit game option , hmm
will wait for someone to look at the file , i am not able to get realtime data out of mic ,

ok so i did some research,
i find some codes, files , and broken lots of other broken file from old blender,

i tried changing codes here and there , and finally i take it tiny little one step further ,
right now i am using pure data, to detect realtime voice from microphone ,

and in blender using that data to drive cube in x direction ,
use this in upbge alpha0.3

game (227.4 KB)