Re: Lightweight OpenAL Python Wrapper
Thats seems like a bit more of a complex question. PyOgg is able to stream files, but it seems to expect the file itself rather than a BytesIO stream, and OpenAL streaming is one of those things i've generally avoided because of the required buffer management. There was a rather interesting stackoverflow topic [here] though that successfully loads and plays an mp3 file from a BytesIO stream, it also works with Vorbis though is limited to only one stream at a time. Its likely possible to do it with OpenAL, but i'd have to dig a lot more into BytesIO and Vorbis decoding, along with OpenAL streaming. Here's an example with pygame though:
import pygame
from pygame import mixer
import sys
import io
def Example():
with open("Example.ogg",'rb') as in_file:
buffer = io.BytesIO(in_file.read())
#initialize pygame pygame.init() #initialize sound mixer mixer.init() #create display window = pygame.display.set_mode([640,480]) #load sound, can only stream one at a time pygame.mixer.music.load(buffer) #main update loop while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: #if space is pressed, play sound if event.key == pygame.K_SPACE: pygame.mixer.music.play() #if escape is pressed, quit if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit(0) #update window pygame.display.update() Example()
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector