A long time ago in a galaxy far away, there were microcomputers which ran BASIC and had simple Sound commands which made the machine beep and hiss in all sorts of weird and wonderful ways.
As well as making some great sounds, it was also very useful as a learning tool because you could hear the results of your code.
I'd love to be able to have the sound functionality of machines like the BBC Micro with its "envelope" command, but without having to use an emulator and learn or relearn all the quirks of the various dialects of BASIC.
I'd also like to avoid having to produce a midi or wav file, but would like to make the sounds directly with the code. I've tried winsound.Beep, but after about 4 notes, the time between the notes seems to go random, and also the functionality is nothing compared to even something like a ZX spectrum.
Does anyone know how to do this with Python?
The python-sounddevice and pyaudio libraries provide ways to record audio with Python. python-sounddevice records to NumPy arrays and pyaudio records to bytes objects. Both of these can be stored as WAV files using the scipy and wave libraries, respectively.
JythonMusic is based on Python programming. It is easy to learn for beginners, and powerful enough for experts. JythonMusic is used in computer programming classes combining music and art.
playsound is a Python module by which users can play sound in a single line of code. It is a cross - platform module which is a single function without any dependencies for playing sounds and audios. For example: from playsound import playsound.
I think the audioop package is the closest you are going to get in python to what you had in the good old days. It's pretty low-level but that's the point. You could use this as the building blocks to create your own retro sound library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With