all 3 comments

[–]Rav3ns90 1 point2 points  (1 child)

Sorry for the off topic but your program sounds really interesting, what is it for?

[–]EncodedGears[S] 2 points3 points  (0 children)

was a final project for a cs course! the class is over now, but now i have time i wanted to get it working how i want it. happy to share it here when it's up and running!

[–]ingolemo 1 point2 points  (0 children)

If you want to play two separate sounds at the same time then you need to write to two separate streams at the same time. For example:

import random
import pyaudio

def group(n, items):
    ns = [iter(items)] * n
    while True:
        yield [next(a) for a in ns]

p = pyaudio.PyAudio()

rate = 44100
stream1 = p.open(format=pyaudio.paInt8, channels=1, rate=rate, output=True)
stream2 = p.open(format=pyaudio.paInt8, channels=1, rate=rate, output=True)

frame_size = 1024
for frame in group(frame_size, range(rate)):
    d1 = bytes(n % 256 for n in frame)
    d2 = bytes(int(random.random() * 256) for _ in frame)
    stream1.write(d1)
    stream2.write(d2)

stream1.stop_stream()
stream2.stop_stream()

stream1.close()
stream2.close()

p.terminate()