Zulko / pianoputer

Use your computer keyboard as a "piano".
http://zulko.github.io/blog/2014/03/29/soundstretching-and-pitch-shifting-in-python/
Other
324 stars 92 forks source link

Running in background #18

Open kosirm opened 3 years ago

kosirm commented 3 years ago

Hi, thank you for this app, it is extremely useful, I like it very much! I would like to use it in "background" so I can create/use sounds(my piano) also when I'm typing in other windows (i.e. when pygame window is not focused...) Do you have idea if this is possible maybe? I'm really not much into python, that's why I ask. Thanks for any reply! BR, Milan

kosirm commented 3 years ago

Oh sorry... I just found line 328 in pianoputer_stereo.py # todo if the window lost focus cant hear the SOUND So it's on your todo list already 👍 , hopefully you will implement solution soon. Thanks!

kosirm commented 3 years ago

I've found WINDOWEVENT_FOCUS_LOST event attribute on pygame.display.set_mode but I have no idea how to use it or if it is usable at all...

yoyoberenguer commented 3 years ago

Hi Kosirm,

Yes you could do a fix with WINDOWEVENT_FOCUS_LOST, therefore there is an easier way. Use pygame.event.set_grab(True) just before the WHILE loop in the code.

The focus event allow pygame to control the keyboard and mouse directly, meaning that pygame will be the first to collect your keyboard/mouse inputs while the program is running

To switch between your windows, use ALT-TAB or exit pianocumputer. Kind Regards

kosirm commented 3 years ago

Thank you so much! I will do this now... BR