I've created a simple text-based game in Python which I'm using in conjunction with libPd (wrapper for Pure Data). All the game code was written before the audio was implemented and works as intended; similarly the libPd script itself also works perfectly on its own. However getting them to play nice together is proving to be tricky.
I assume it's to do with while loops and my usage of them.
Below is an extract from the game code -
while True:
command = raw_input().lower()
if command == "commands":
print '"look around"'
print '"explore"'
print '"inventory"'
print '"examine"'
print '"take"'
print '"combine"'
print '"quit"'
elif command == "look" or command == "look around":
char.look()
...etc... ...etc...
While the libPd script on its own is as follows -
while True:
if not ch.get_queue():
for x in range(BUFFERSIZE):
if x % BLOCKSIZE == 0:
outbuf = m.process(inbuf)
samples[selector][x][0] = outbuf[(x % BLOCKSIZE) * 2]
samples[selector][x][1] = outbuf[(x % BLOCKSIZE) * 2 + 1]
ch.queue(sounds[selector])
selector = int(not selector)
libpd_release()
I originally tried indenting the entire game code within the libPd section but that caused the audio to only play once a command was typed, stopping once the print messages had been returned.
How do I go about combining the two so that the music is constant whilst the player is free to run through the rest of the commands/game?