While, "strong_beat.play()" is in the while loop, it stops running
*import simpleaudio, time, math
temp = 0
strong_beat = simpleaudio.WaveObject.from_wave_file('metronome2.wav')
while temp<20:
strong_beat.play()
time.sleep(0.5)
temp = temp + 1
print (temp)*
however if I remove it it continues to run properly
With:With the function
Without:Without the function
I don't know if there's a fundamental thing I don't understand, but the internet was not helping and I don't really know what to do.
I have limited knowledge of python, but I don't remember this being a problem in the past.
The reason for the failure is the combination of the python version and the latest version of the simpleaudio package.
Using python version 3.12.8 or 3.13.1 and simpleaudio 1.0.4 the following code fails with an "access violation" at line "play_obj.wait_done()".
The very same code (below) will work correctly if instead of using the simpleaudio package, use simpleaudio-312compat version 1.0.4. Note that the import line for simpleaudio stays the same.
import simpleaudio
strong_beat = simpleaudio.WaveObject.from_wave_file('hal2.wav')
temp = 0
while temp < 20:
temp += 1
play_obj = strong_beat.play()
play_obj.wait_done()
print("temp:", temp)