Xsound
Attributes
-
ENGLISH NAME : X-ParticleSoundShader
-
NAME : Xsound
-
INCLUDE : Mpreview
-
INCLUDE : Xbase
-
PATH : res/description/xsound.res
-
PLUGIN : X-Particles
-
MAXON online help (may not exist): XSOUND
Elements
Example Code
The following code does not use the correct values when setting the data. You should check directly in C4D for the correct values that you should use in place of the ones that are shown.
This code is just to show you how to access the values for getting and setting the parameters.
Python
import c4d
from c4d import gui
def main():
shader = c4d.BaseShader(c4d.Xsound)
#You can set parameters two different ways.
#First way
shader[c4d.XSOUND_MODE] = c4d.XSOUND_MODE_SINGLE
shader[c4d.XSOUND_LOG] = True
shader[c4d.XSOUND_LOG_SCALE] = 1
shader[c4d.XSOUND_FILE] = "c:\\SomeFile.txt"
shader[c4d.XSOUND_AUTO] = True
shader[c4d.XSOUND_SCALE] = 0.1
shader[c4d.XSOUND_LOOP] = True
shader[c4d.XSOUND_COLOR_MODE] = c4d.XSOUND_COLOR_MODE_AMP
shader[c4d.XSOUND_FFT] = 1
shader[c4d.XSOUND_DB_RANGE] = 0.1
shader[c4d.XSOUND_FREQUENCY_MIN] = 0.1
shader[c4d.XSOUND_FREQUENCY_MAX] = 0.1
#Second way, using the base container.
bc = shader.GetDataInstance()
bc.SetInt32(c4d.XSOUND_MODE,c4d.XSOUND_MODE_SINGLE)
bc.SetBool(c4d.XSOUND_LOG,True)
bc.SetInt32(c4d.XSOUND_LOG_SCALE,1)
bc.SetFileName(c4d.XSOUND_FILE,"c:\\SomeFile.txt")
bc.SetBool(c4d.XSOUND_AUTO,True)
bc.SetFloat(c4d.XSOUND_SCALE,0.1)
bc.SetBool(c4d.XSOUND_LOOP,True)
bc.SetInt32(c4d.XSOUND_COLOR_MODE,c4d.XSOUND_COLOR_MODE_AMP)
bc.SetInt32(c4d.XSOUND_FFT,1)
bc.SetFloat(c4d.XSOUND_DB_RANGE,0.1)
bc.SetFloat(c4d.XSOUND_FREQUENCY_MIN,0.1)
bc.SetFloat(c4d.XSOUND_FREQUENCY_MAX,0.1)
if __name__=='__main__':
main()
C++
#include "c4d.h"
#include "../res/description/xsound.h"
void SampleFunction()
{
BaseDocument *pDoc = GetActiveDocument();
BaseShader *pShader = BaseShader::Alloc(Xsound);
//You can set parameters two different ways.
//First way
//Some objects do not store all their data in the container. You need to use GetParameter()/SetParameter() instead.
DESCFLAGS_SET flags = DESCFLAGS_SET_PARAM_SET;
pShader->SetParameter(DescID(XSOUND_MODE),GeData(XSOUND_MODE_SINGLE),flags);
pShader->SetParameter(DescID(XSOUND_LOG),GeData(true),flags);
pShader->SetParameter(DescID(XSOUND_LOG_SCALE),GeData(1),flags);
pShader->SetParameter(DescID(XSOUND_FILE),GeData(Filename("c:\\SomeFile.txt"),flags);
pShader->SetParameter(DescID(XSOUND_AUTO),GeData(true),flags);
pShader->SetParameter(DescID(XSOUND_SCALE),GeData(0.1),flags);
pShader->SetParameter(DescID(XSOUND_LOOP),GeData(true),flags);
pShader->SetParameter(DescID(XSOUND_COLOR_MODE),GeData(XSOUND_COLOR_MODE_AMP),flags);
pShader->SetParameter(DescID(XSOUND_FFT),GeData(1),flags);
pShader->SetParameter(DescID(XSOUND_DB_RANGE),GeData(0.1),flags);
pShader->SetParameter(DescID(XSOUND_FREQUENCY_MIN),GeData(0.1),flags);
pShader->SetParameter(DescID(XSOUND_FREQUENCY_MAX),GeData(0.1),flags);
pShader->Message(MSG_UPDATE);
//Second way, using the base container.
BaseContainer *bc = pShader->GetDataInstance();
bc->SetInt32(XSOUND_MODE,XSOUND_MODE_SINGLE);
bc->SetBool(XSOUND_LOG,true);
bc->SetInt32(XSOUND_LOG_SCALE,1);
bc->SetFileName(XSOUND_FILE,"c:\\SomeFile.txt");
bc->SetBool(XSOUND_AUTO,true);
bc->SetFloat(XSOUND_SCALE,0.1);
bc->SetBool(XSOUND_LOOP,true);
bc->SetInt32(XSOUND_COLOR_MODE,XSOUND_COLOR_MODE_AMP);
bc->SetInt32(XSOUND_FFT,1);
bc->SetFloat(XSOUND_DB_RANGE,0.1);
bc->SetFloat(XSOUND_FREQUENCY_MIN,0.1);
bc->SetFloat(XSOUND_FREQUENCY_MAX,0.1);
pShader->Message(MSG_UPDATE);
}
Buttons
This node has buttons. Buttons can manually be executed by calling the following code
Python
c4d.CallButton(shader,c4d.XSOUND_GRAPH)
C++
DescriptionCommand dc;
dc.id = DescID(XSOUND_GRAPH);
pShader->Message(MSG_DESCRIPTION_COMMAND, &dc);
Gradients
This node has gradients. Gradients can manually be edited by calling the following code
Python
C++
#include "customgui_gradient.h"
XSOUND_FREQUENCYOUT_COLOR
GeData data;
pShader->GetParameter(DescID(XSOUND_FREQUENCYOUT_COLOR),data,DESCFLAGS_GET_PARAM_GET));
Gradient *pGradient = (Gradient*)data.GetCustomDataType(CUSTOMDATATYPE_GRADIENT);
if(pGradient)
{
//must be set before any knot is set
pGradient->SetData(GRADIENT_MODE, GeData(GRADIENTMODE_ALPHA));
GradientKnot k1, k2;
k1.col = Vector(0.0, 0.0, 1.0);
k1.pos = 0.0;
k2.col = 1.0;
k2.pos = 1.0;
pGradient->InsertKnot(k1);
pGradient->InsertKnot(k2);
}
pShader->SetParameter(DescID(XSOUND_FREQUENCYOUT_COLOR),data,DESCFLAGS_SET_PARAM_SET));
XSOUND_FREQUENCY_COLOR
pShader->GetParameter(DescID(XSOUND_FREQUENCY_COLOR),data,DESCFLAGS_GET_PARAM_GET));