0
import winsound
# ok1 = oktav 1
# ok2 = oktav 2

ok2C = winsound.Beep(65,500)
ok2c0 = winsound.Beep(69,500)
ok2D = winsound.Beep(73,500)
ok2d0 = winsound.Beep(77,500)
ok2E = winsound.Beep(82,500)
ok2F = winsound.Beep(87,500)
ok2f0 = winsound.Beep(92,500)
ok2G = winsound.Beep(98,500)
ok2g0 = winsound.Beep(103,500)
ok2A = winsound.Beep(110,500)
ok2a0 = winsound.Beep(116,500)
ok2B = winsound.Beep(123,500)

I was trying to make a piano-like program with the hz frequencys. When I ran the code it started to give me every hz frequency written. What I was aiming for was only using the frequencys I want with using the variables. I tried using the while loop to cancel the program from giving all values but it won't work. Can anyone help me?

  • `winsound.Beep` is the function, that actually triggers the sound playback. Thus, your variables don't contain the frequency, but a reference to the function call. IMHO what you want is the variables to only contain the frequencies, like `ok2C = 65`. And then, whenever you need this note to be played, you would call `winsound.Beep(ok2C, 500)`. – ahuemmer May 30 '23 at 05:48

0 Answers0