I want to create MIDI tracks in a Python program and be able to play them instantly (preferably without writing to disk). I have recently discovered the package python-midi which looks great. However I haven't figured out how to play the tracks created with this package. Do I need an additional package? Help would be appreciated.
My solution if anyone is interested:
I ended up using mido for my Python MIDI API, with Pygame as the backend.
Works like a charm :)
Related
I want to find out which programs are playing sound with a python code, I researched it a lot, even though I tried libraries like winsdk pycaw, I couldn't get any results
The simplest way is to use standard winsound module. Please, refer to documentation
If you are now under Windows, there are:
the bell character on the terminal
AppKit to play MacOS system sounds
pygame to play custom sound files
simpleaudio to play custom sound files
the beepy package
I have to make relaxing music using pyo package in python. I am not very experienced with audio processing . Any advice for that?
There are a few examples on the GitHub and potentially other sources on the internet. I recommend checking it out and trying a few different experiments with the program to get an understanding to move forward. It might and probably will help https://github.com/belangeo/pyo
I working in python on computers in a lab where I do not have root privileges and can't get any libraries installed. Someone I am helping is writing a game and wants to add audio. We can play sounds with something like this
subprocess.call(["afplay","gun_battle_sound-ReamProductions-1158375208.wav"])
but everything stops until the sound is done playing. Is there a way to keep things moving while the audio is playing? Is there a library that we can just copy? We are using the graphics module from Zelle, so I am looking for something like that - simple to use and install.
Thank you!
Pyglet
is completely copyable and easy to download.
Otherwise you will probably need to create a thread from threading just for the sound to play on.
I've searched for this around, and every answer seems to include an external Python library, such as Pygame, Snack, etc, for playing sounds.
Is there not a simple pure pythonic way from the built in modules to play, say, a .wav file without the use for external modules? I know that Python doesn't natively support .mp3 files.
The most I've found in that regard is winsound. Nothing extra to install; just import it. However, as you might have guessed, it only works on Windows. I use Pygame's mixer when I want sound. Its support for mp3 files is limited, and it requires an installation (unless you package your application), but it's the most straightforward of the third-party audio modules I've looked into.
I recently finished up a small game I wrote in python, using pygame, at the request of some of my friends. Currently, I have the .pyw game file, and an assets folder containing all files used in the program. I used py2exe to distribute the game, which worked fine, although it still does not seem very user friendly to people downloading the game. One of my friends requested a mac version of it, and although I know about py2app, I am unsure of how to use it, and whether or not it is the best way to package my game.
Basically, I want a single file that I can send to any mac user, so they can easily use the program I have made, while preferably not seeing the source code.
I have googled around for a simple solution, but have not found one. If anyone could give a very simple explanation of how to easily do this, that would be great. Please keep in mind I am fairly new to programming, and may not understand all the programming lingo, so if you could keep it simple, I would appreciate it.
Thanks in advance.
The answer to How can I distribute python programs? suggests Pyinstaller which looks promising, although I have not tried it myself.
See this tutorial by Irwin Kwan to see how Pyinstaller can actually be used with Pygame. He describes a procedure for preparing a Windows executable as well as one for OS X.