Re: Lightweight OpenAL Python Wrapper

@14
Heh, nothing wrong with good questions! So...

1: The rolloff factor is how much the volume drops relative to the distance a player is from the listener. If you have a high rolloff factor, then if a player moves, say, 10 units away from the listener the volume will drop dramatically between that distance. Whereas if you have a very low rolloff factor, you might have to move the player 100 units or more away from the listener to get the same amount of volume drop.

2: When a sound plays, there are always two things, a player for creating the sound, and a listener for hearing it. If there is no listener, nothing can hear the sound, and if there is no player, there is nothing to hear. So, if you move the listener, the adjacent sounds appear to move, but only because the object that hears them is moving, not the sounds themselves. Now if the listener stands still and the sounds appear to move, that would be because the players playing them are moving, not the listener.

3: With OpenAL there are various objects, the Listener, Sources, Players, Effects, Filters, and EFX Slots. Sources are the sounds themselves that are loaded into memory, like loading a file, there is no limit other than your systems resources on the number of Sources you can load and have in memory. Players are the objects used to play them, generally speaking there's a limit of about 32 players that can play simultaneously, usually 31 to help prevent playback errors when starting or stopping them. There can be only one Listener at any given time, a particular limitation of OpenAL. There is no limitation on the number of Effects, Filters or EFX Slots you can load, but there is a limit on the number you can assign to a given player, though what that is exactly may be system specific.

4: You can do this by moving the desired player object, or the listener, more in the given direction. So instead of moving them by 10 units, move them by 100, and you should get a more dramatic panning effect.

5: Being more specific, different platforms have different limits on the number of sounds they can play simultaneously, Windows Phone for example has a limit of 16 sounds. Generally 32 is considered a safe number for most platforms, if you try playing more than that it may throw an error, not play, or potentially crash if you don't catch it.

6: Directly? No. OpenAL can play sounds loaded into OpenAL buffers, but it has no encoding or decoding of its own, the WAV loader I currently have built in uses Pythons native wave function to load a file into an OpenAL buffer, for example. This isn't to say that other libraries aren't available that can't help with that however, such as PyOgg as i've previously mentioned. Another one i've come across recently is [PySoundFile], which can handle a variety of formats, including mp3 and ogg. Note that PyOgg and PySoundFile can't play sounds on their own, their encoder/decoders, but OpenAL can't load sounds on its own either, so their best used together.

You can find additional information on a number of OpenAL functions and descriptions in the developer and Effects Extenions guides.


@12
As I've mentioned, I've been digging a bit more into a few libraries and come across PySoundFile, a wrapper for libsndfile. It also seems capable of decoding a BytesIO ogg file into a format that can be passed to an OpenAL buffer, much like how pygame does:

from io import BytesIO
from pysoundfile import SoundFile
fObj = BytesIO(open('filename.flac', 'rb').read())
flac = SoundFile(fObj, virtual_io=True)

So instead of using PyOgg you could use this to load data that can then be fed into a custom BufferSound() OpenAL object for playback, although this may not totally address things like streaming as yet. There's also potentially [librosa] for decoding, which is used for audio analysis.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector

Reply via email to