I created a simple text output from the game into a room in Python with the intention of introducing a Pure Data patch (via libPd) in order to play another sound file (this will later be replaced by an algorithm for generative music) for each of my rooms.
The python code I'm currently working with was taken from one of the examples in libput github. It looks like this:
import pyaudio import wave import sys from pylibpd import * p = pyaudio.PyAudio() ch = 2 sr = 48000 tpb = 16 bs = 64 stream = p.open(format = pyaudio.paInt16, channels = ch, rate = sr, input = True, output = True, frames_per_buffer = bs * tpb) m = PdManager(ch, ch, sr, 1) libpd_open_patch('wavfile.pd') while 1: data = stream.read(bs) outp = m.process(data) stream.write(outp) stream.close() p.terminate() libpd_release()
A clean data patch simply reproduces a pre-rendered wav file, however the result sounds almost as if it had been corrupted. I assume the problem is with the block size, but I'm not sure.
If anyone has experience implementing lidPD in Python, I would be very grateful because I am sure that what I am trying to achieve is confusing simply.
Thanks in advance, Cap
source share