DSP Effects in Python

I’ve successfully compiled Panda with FMODEx on OSX and sound output runs fine.

I wanted to test the DSP effects mentioned in the manual but the fmodAudioManager in python doesn’t have any of the DSP functions or constants.

>>> base.sfxManagerList[0].createDsp(base.sfxManagerList[0].DSPEcho)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'libpanda.AudioManager' object has no attribute 'createDsp'
>>> mysound = loader.loadSfx('test1.mp3')
>>> mysound.addDsp(echo)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'libpanda.AudioSound' object has no attribute 'addDsp'

The panda fmodAudioManager.cxx source seems to contain the DSP functionality so I suspect the problem is with the linking to python.

Does anyone have any idea what could be the problem or has someone successfully used the FMODEx effects?

The problem is that the entire DSP interface has been redesigned. There is a new class, FilterProperties, which is documented here:

panda3d.org/apiref.php?page=FilterProperties

To use DSP, you first create a FilterProperties object, then you fill it with filters, then you call:

panda3d.org/apiref.php?page=Audi … ureFilters

Or this:

panda3d.org/apiref.php?page=Audi … ureFilters

I believe that currently, only AudioManager.configureFilters is implemented.

Great! Now I can successfully add DSP filters to AudioManagers.

As you said, AudioSound.configureFilters() always returns False and looking at the fmodAudioSound source, filters aren’t yet implemented.

I never got to use the old system but the manual made the impression that I could attach an effect to a sound and then use the effect object to directly adjust the effect on the sound(s).

With FilterProperties I have to call configureFilters every time I made a change to the effect, i.e.

from pandac.PandaModules import FilterProperites

sound = loader.loadSfx('test.mp3')
sound.play()

filter = FilterProperties()
filter.addDistort(1)
base.sfxManagerList[0].configureFilters(filter)

# I can hear the applied filter now

filter.clear()
filter.addDistort(.5)

# Nothing changes

base.sfxManagerList[0].configureFilters(filter)

# New settings are applied

Is it intended to work like this?

I also notice there is no way to edit filters added to the chain. Excuse my pestering about a not yet implemented feature but I’m just curious. :slight_smile:

That is how it’s supposed to work.

Class FilterProperties is really a trivial class: it’s just a container for configuration parameters. It doesn’t actually do anything with those parameters except store them.

Method configureFilters is responsible for reading those configuration parameters and translating them into some sort of calls to the sound API. It is my intent that configureFilters should compare the old properties to the new properties, and make a list of differences. It should make seamless changes without clicks or popping if at all possible - this will normally be possible if the differences are small (ie, just a parameter change or two). I don’t think that configureFilters is smart like this yet — I just want it to be.

There’s no reason class FilterProperties couldn’t have more convenient accessors to build up or modify a configuration. I just haven’t written any yet. But given the design, it shouldn’t matter how the FilterProperties are created - it should only matter what the final results are. Ie, even if you clear the whole thing and rebuild it from scratch, if the results are the same as before, there should be no clicks or popping when you call configureFilters. Once again, though, this isn’t implemented yet.

The reason none of this is implemented yet is that I’m just more concerned with the free implementation (OpenAL), and that doesn’t support filters at all.

Thanks for the clarification!

It’s just that I got the impression the old system was working by passing the DSP-object as reference and thus reflecting any changes to the DSP object directly on the audio without and additional calls.

I don’t think it’s necessary to work that way, I just wanted to make sure I’m doing it right. It works fine and the way it’s currently implemented lets anyone easily build upon if more control is needed. In fact, I just added effects to my python sound class in a way that I can add and edit effects and the FilterProperties object gets (re-)constructed transparently in the background.

I should also mention that one of my goals was to mimic the design of class WindowProperties and class FrameBufferProperties — those, too, are just containers for configuration parameters. So there’s a bit of a panda tradition here.

I would also like to use the dsp effects of fmod.
I changed audio-library-name to p3fmod_audio so panda should be using fmod (don’t know which version though) but I still get False when I call

base.sfxManagerList[0].configureFilters(filter)

as well as when I call it on an AudioSound object.

Can I use the DSP effects by default or do I need to edit the source and recompile?

I’m busy putting the final wraps on an SDK that is optimized for use with Python and Panda3D. We’re just completing the demo apps and I’m running into some serious confusion regarding DSP capabilities on sounds (pitch shift, echo, distort, etc). I found this post here, and the post below, to be the most useful:

FMOD and Panda : DSP Issues
discourse.panda3d.org/viewtopic.php … hlight=dsp

just thought I’d bridge these discussions :slight_smile:
T