Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Old School Sound Programming in Python

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?

like image 848
Robin Andrews Avatar asked Aug 28 '15 08:08

Robin Andrews


People also ask

Can you make sound effects in 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.

Can Python be used for music?

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.

Is there a sound module in Python?

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.


1 Answers

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.

like image 107
ThatAintWorking Avatar answered Sep 24 '22 01:09

ThatAintWorking