I am running the Pythonista 3 beta.
I am using the "wave" module to create a dynamically create a wave audio file. The file has the file extension ".wav".
The code creates a wave file, plays it, and then deletes the file. The delete code loops until the file is deleted to prevent any issues if the file is locked while playing.
If I play the audio with the "play_effect" method shown below, the first wave file is played completely, and deleted. However, when the code generates a different audio file after that with the same name as the first audio file, when "play_effect" is called, I hear the first audio that played before play again.
from sound import play_effect
play_effect(audio_file_name)
All subsequent calls to the "play_effect" method play the same audio. The only way I can change the sound when playing a new wave file with the same name is to exit Pythonista and run it again.
Using the code below to try to play the file, I get silence.
import sound
player = sound.Player(audio_file_name)
player.play()
Is there a way to dynamically generate audio and play it and reuse the same audio file name and get different audio? I could keep changing the audio file name, but if the sounds are being cached somewhere, that would soon fill up memory.