I want to make a small program that changes the volume levels of programs based on what programs are open and possibly given audio detection, for example if im running a game window, and I have music in the background, I'd want it to lower the music volume if it detects audio being sent from the game window.
I usually play with game volumes turned off, but I usually watch cutscenes, so my goal is to have the music playing and mute if a cutscene comes up.
I dont know how doable it is with python, but I have the most knowledge of python thus Im asking for that if possible, I could do it in another language if anyone has suggestion.
So more or less, I just need some direction on what libraries of languages would be useful for making this program.
OS involved - Windows 10
Related
TL;DR- Python listens to live audio and reacts accordingly on the go.
I am a complete beginner to Python, this is my first idea i'd love to work on. So it all began with me "hacking" my LED strips i have connected to WiFi. I can easily switch their color by launching a file and make them do certain pattern one time (haven't tried repeated/infinite patterns). My goal is to make it listen to music played on computer (essentially listen to system sounds one could say) and analyze the low bands and depending on the intensity of them, change the LED colors. As example music plays and lights switch color on each beat.
I haven't tried anything so far.
Lights work completely fine as i enter custom RGB and brightness values.
I was planning on making clones of simple 8-bit era games to start my 'career' in using pygame. I've almost finished my clone of snake. I was planning on putting these games on my laptop so I could play them on the go, but honestly, I don't know if the laptop could handle it.
While developing my snake clone, I noticed that the game would experience increasing lag as the game progressed. I was surprised at this, seeing as I'm running this on a high-end gaming computer. I determined the problem was that my algorithm for recording the snake's path (which I use for drawing the tail) was filling up insanely fast with coordinates. I fixed this by having the game only allow the list of coordinates to be as long as the snake's current length. This did a lot to fix the lag, but I still experience some slow down if I get the snake really long.
I don't understand why the game would lag on my computer just from a (relatively) small list of variables. This machine can run Skyrim on full graphics, yet it can't handle a game that uses over a few dozen variables? This has made me worried for my laptop, since, obviously that is NOT a gaming machine.
However, I have no clue how to determine if my laptop could run my game or not. Normally I just go to 'can you run it?' if I need to figure this out, but obviously I can't do that for my game. I don't know how to determine what kind of system a person would need to run any game I make. I wasn't expecting such primitive games to cause performance issues on my machine. I mean, if I can run Skyrim at full graphics, then why does my Snake game slow down as it progresses? It makes no sense. And I'm using pygame.draw for graphics, so I'm not having to load and draw proper sprites either. Honestly, the only game out there that's less graphics intensive than mine is pong. How could something so basic have issues on a modern gaming computer of all things?
I am searching for a way/framework to play at least 3 music files at one in a python application. It should run at least under ubuntu and mac as well as on the raspberry pi.
I need per channel/music file/"deck" that is played:
Control of the Volume of the Playback
Control of the start position of the playback
Play and Pause/Resume functionality
Should support mp3 (Not a must but would be great!)
Great would be built in repeat functionality really great would be a fade to the next iteration when the song is over.
If I can also play at least two video files with audio over the same framework, this would be great, but is not a must.
Has anyone an Idea? I already tried pygame but their player can play just one music file at once or has no control over the playback position.
I need that for a theatre where a background sound should be played (and started simultaneosly with the light) and when it is over, a next file fades over. while that is happening there are some effects (e.g. a bell) at a third audio layer.
I finally got an answer/workaround.
I am using pythons multiprocessing class/functionality to run multiple pygame instances.
So i can play more than one music file at a time with fully control over playmode and playback position.
I began learning Python a few days ago, and i was wondering about a practical use for a program.
Then i came up with the following: if my brother is in his room recording himself playing guitar, a led plugged to the usb and wired so it's outside his door lights up, and then i'll know he's recording and i'll take care not to make any noises.
The main questions are:
How Python can detect any recording going on in the system?
How would i interface with the usb so i can actually turn the led on?
to interact with USB, you can read this related question.
to detect recording, you will have to tell us on which operating system your program is intented to run (but i am not sure it is possible to detect that another application is recording)
How can I tell Windows not to do unhelpful pre-processing on tablet pen events?
I am programming in Python 2.6, targetting tablet PCs running Windows 7 (though I would like my program to work with little modification on XP with a SMART interactive whiteboard, and for mouse users on Linux/Mac). I've written a program which hooks into the normal Windows mouse events, WM_MOUSEMOVE etc., and writes on a canvas.
The problem is that the mouse messages are being fiddled with before they reach my application. I found that if I make long strokes and pause between strokes then the mouse messages are sent properly. But if I make several rapid short strokes, then something is doing unhelpful pre-processing. Specifically, if I make a down-stroke about 10 pixels long, and then make another downstroke about five pixels to the right of the first, then the second WM_MOUSEDOWN reports that it comes from exactly the same place as the first.
This looks like some sort of pre-processing, perhaps so that naive applications don't get confused about double-clicks. But for my application, where I want very faithful response to rapid gestures, it's unhelpful.
I found a reference to the MicrosoftTabletPenServiceProperty atom, and to CS_DBLCLKS window style, and I turned them both off with the following piece of Python code:
hwnd = self.GetHandle()
tablet_atom = "MicrosoftTabletPenServiceProperty"
atom_ID = windll.kernel32.GlobalAddAtomA(tablet_atom)
windll.user32.SetPropA(hwnd,tablet_atom,1)
currentstyle = windll.user32.GetClassLongA(hwnd, win32con.GCL_STYLE)
windll.user32.SetClassLongA(hwnd, win32con.GCL_STYLE, currentstyle & ~win32con.CS_DBLCLKS)
But it has no effect.
I tried writing a low-level hook for the mouse driver, with SetWindowsHookEx, but it doesn't work -- obviously the mouse messages are being pre-processed even before they are sent to my low-level Windows hook.
I would be very grateful for advice about how to turn off this pre-processing. I do not want to switch to RealTimeStylus -- first because it won't work on Windows XP plus SMART interactive whiteboard, second because I can't see how to use RealTimeStylus in CPython, so I would need to switch to IronPython, and then my code would no longer run on Linux/Mac.
Damon.
For raw mouse messages, you can use WM_INPUT on XP and later. Seven added some touch specific stuff: WM_GESTURE and WM_TOUCH