Cinema 4D – Accessing Sound Effector probes with Python

The Sound effector has been a part of Cinema 4D for quite a while. Recently we had a need to use the effector to drive other parts of the scene, but not through other effectors (we needed numeric values etc.). Python to the rescue!

A sample scene using the Sound effector with Python tag

Simply add a Python tag to the Sound effector and use the following script (or rather, use this as you base and play with it):

# simple example of how to access sound effector probes
# Michael Auerswald - (

import c4d

def main():
    o = op.GetObject()
    #for i in range(data.GetProbeCount()):
    #    print(data.GetProbe(i))

    userDataProbes = 10
    samplesPerProbe = 1  # just use one here, should suffice in 99% of cases
    sampleCount = data.GetProbeCount() * samplesPerProbe

    samples = [0 for x in range(userDataProbes)]

    for i in range(sampleCount):
        sample, vec = data.Sample(i, sampleCount)
        samples[int(i / samplesPerProbe)] += sample
        #print("{0} {1}".format(int(i / samplesPerProbe), sample))

    for i in range(userDataProbes):
            op[c4d.ID_USERDATA,(i+1)] = samples[i] / samplesPerProbe
        except AttributeError:
            # just to prevent trouble if the userdata field does not exist

Make sure to drop the Sound effector onto some dummy object (for example a Box with size 0,0,0), otherwise it will not run. It needs to be a “real” object, not a Null.

Add a bunch of UserData fields to the tag (or wherever you want ) and feed the probe data into them. Then you can pick these UserData fields up in e.g. Xpresso and go from there.

Here’s the sample scene file: (R20)

Leave a Reply

Your email address will not be published. Required fields are marked *