PySonic - Python wrap of FMOD

Tags:
Original URL:
FMOD supports ASIO, which should be great for fast audio IO. However,
at this point, recording is nor supported. For that, SNACK seems to be
a better choice.


pySonic

What is it?

pySonic is a Python wrapper around the high performance, cross platform FMOD sound library. You get all the benefits of the FMOD library, but in a Pythonic, object oriented package.

How does it work?

pySonic is written almost entirely
in Pyrex. A few raw C functions help support the FMOD callbacks and
memory streams. A suite of unit tests cover most of the functions in
the package. Check the source code out of our SourceForge CVS repository for more details.

What can/can’t it do?

There
isn’t a one-to-one mapping between FMOD functions and pySonic
functions. Many of the FMOD C functions just aren’t needed or don’t fit
in a object oriented Python library. But, roughly speaking, pySonic can
be said to support the following FMOD features.

  • Device and output initialization
  • Runtime updating and information
  • File and memory samples
  • File, memory, and web streams
  • 3D sound
  • EAX global and channel reverb
  • Sample and stream playback (wav, aiff, mp3, ogg, etc.)
  • Music playback (midi, mod, s3m, it, xm, etc.)

pySonic currently does not support the following FMOD features. Look for them in future versions.

  • CD playback
  • Digital signal processing
  • DirectX channel sound effects
  • Sound recording

If you would like to request a new pySonic feature, use our SourceForge feature tracker. If you would like to contribute code to pySonic, email me.



How do I use it?

The best way to start learning how to use pySonic is to read a short tutorial. After that, you can use the API documentation as a reference.

The following example will give you a taste of using pySonic.

      import pySonic      import time
	
      def finished_stream(source):        print ‘Stream finished playing’
	
      # initialize the audio environment      w = pySonic.World()
	
      # create two sources      src1 = pySonic.Source()      src2 = pySonic.Source()
	
      # load a sound entirely from disk, stream another from disk      src1.Sound = pySonic.FileSample(’short.wav’)      src2.Sound = pySonic.FileStream(’long.mp3′)
	
      # position the sources in 3D space      src1.Position = (-0.5, 0.0, 0.5)      src2.Position = (0.5, 0.0, 0.5)
	
      # register a callback for when the stream finishes      src2.SetEndStreamCallback(finished_stream)
	
      # register a callback for when the stream finishes      src1.Play()      src2.Play()
	
      # just block while we’re playing in this example      while src1.IsPlaying() or src2.IsPlaying():        time.sleep(1)

Leave a Reply

If the above Image does not contain text, use this secure code: p49hdRjQ