I just received my pHAT DAC and am playing around a bit with it. What I’m currently trying to do is playing multiple sounds via a python script at once. This works flawlessly with my internal RPi 2 sound system for up to 8 streams. But as soon as I’m using the pHAT DAC there is only one sound coming out at once.
For reference: A small script that I used for the RPi with maximal 8 sounds playing simultaneously. Assume that there is a directory sounds with the soundfiles 1.wav, 2.wav, …
#!/usr/bin/python3 import time from subprocess import Popen from queue import Queue sounds = Queue(maxsize = 8) def play(number): if sounds.qsize() >= 8: sounds.get().kill() process = Popen(['aplay', './sounds/' + str(number) + '.wav']) sounds.put(process) for i in range(1, 10): play(i) time.sleep(0.5)
What I would expect is to get 9 sounds (8 at a time maximal) to play in parallel, each started half a second before the preceding one. What happens in reality is that the first sound seems to block the output. Let’s assume it is 3 seconds long, then only 7.wav will be heard, the rest simply doesn’t play.
Is there anything I missed? Isn’t it possible to mix multiple sounds?
Thanks in advance for your help!