Answer the question
In order to leave comments, you need to log in
How to write a random sound generator in python?
I recently started getting interested in Python.
You need to write a code that, when run, the speakers will play tonal sounds, peaks, buzz.
So that you can set the playback time of the "track", for example, to 3 minutes or 30.
To be able to set the range from which the key or length of the "note" will be randomly selected.
Without connecting samples.
Where do I begin? Does anyone have any ready made solutions?
Answer the question
In order to leave comments, you need to log in
Something like this
import winsound
from random import randint
from time import sleep
MAX_FREQUENCY = 2500 # Максимальная частота звука 2500Гц
MAX_DURATION = 1000 # Максимальное время для озвучки одного сигнала 1000 ms
def generate_random_beeps(minutes):
for _ in range(minutes * 60):
frequency = randint(1, MAX_FREQUENCY)
duration = randint(1, MAX_FREQUENCY)
winsound.Beep(frequency, duration)
sleep(1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question