Whenever I run this code, I can't hear the sound play and I even check to see if it plays then go on to the next line but it goes on to the next line and no noise comes out. Here is the code:
import pygame
import time
import sys
pygame.init()
pygame.mixer.init()
binaryHighLow = "010111"
def check():
for x in binaryHighLow:
if x == "0" in binaryHighLow:
lowPitch = pygame.mixer.Sound("440Hz_44100Hz_16bit_05sec.wav")
lowPitch.play()
print("Low")
lowPitch.set_volume(1)
time.sleep(lowPitch.get_length())
elif x == "1" in binaryHighLow:
highPitch = pygame.mixer.Sound("5000hz.wav")
highPitch.play()
print("High")
highPitch.set_volume(1)
time.sleep(highPitch.get_length())
check()
Any suggestions for what I should change to the code?
Putting the
pygame.init()
after thepygame.mixer.init()
.e.g.: