About
The SoundEffectorData stores multiple sound probes that are used to sample a given sound file (defined by a sound track). The class also allows to sample the sound file using the defined probes.
The SoundEffectorData class is defined in the customgui_soundeffector.h
header file. The data type ID is CUSTOMDATATYPE_SOUNDEFFECTOR. Sub-channel IDs are defined in dsoundprobe.h
.
BaseObject*
const moGraphCloner =
doc->GetActiveObject();
if (moGraphCloner == nullptr)
if (moGraphCloner->IsInstanceOf(1018544) == false)
Filename soundFile;
BaseObject* const soundEffector = BaseObject::Alloc(440000255);
if (soundEffector == nullptr)
doc->InsertObject(soundEffector,
nullptr,
nullptr);
GeData clonerData;
{
InExcludeData* const ieData = clonerData.GetCustomDataTypeWritable<InExcludeData>();
if (ieData == nullptr)
ieData->InsertObject(soundEffector, 1 << 0);
}
CTrack* const soundTrack = CTrack::Alloc(soundEffector, soundTrackID);
if (soundTrack == nullptr)
soundTrack->SetName("New Sound Track"_s);
soundEffector->InsertTrackSorted(soundTrack);
GeData data;
{
SoundEffectorData* const soundData = data.GetCustomDataTypeWritable<SoundEffectorData>();
if (soundData == nullptr)
soundData->SetActiveSoundTrack(soundTrack,
doc);
}
NONE
Definition: asset_browser.h:1
LOAD
Load.
Definition: c4d_filterdata.h:1
@ CID_SOUND_NAME
Definition: ctsound.h:7
ANYTHING
Any file.
Definition: ge_prepass.h:0
#define MAXON_SCOPE
Definition: apibase.h:2891
return OK
Definition: apibase.h:2740
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define CTsound
Sound.
Definition: ge_prepass.h:1553
#define ConstDescID(...)
Definition: lib_description.h:592
@ ID_MG_MOTIONGENERATOR_EFFECTORLIST
Definition: obasemogen.h:16
@ MGSOUNDEFFECTOR_GADGET
Definition: oesound.h:6
const char * doc
Definition: pyerrors.h:226
Access
The SoundEffectorData is typically used with the "Sound" MoGraph effector. An instance of this class is obtained from this object. The parameter ID is defined in oesound.h
.
BaseObject*
const soundEffector =
doc->GetActiveObject();
if (soundEffector == nullptr)
if (soundEffector->IsInstanceOf(440000255) == false)
GeData data;
const SoundEffectorData* const soundData = data.GetCustomDataType<SoundEffectorData>();
if (soundData == nullptr)
const Int probeCnt = soundData->GetProbeCount();
ApplicationOutput(
"Sound Effector uses " + String::IntToString(probeCnt) +
" probes.");
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Int Int
Definition: ge_sys_math.h:55
Allocation/Deallocation
A SoundEffectorData object can be created with the usual tools, see Entity Creation and Destruction Manual (Cinema API).
- SoundEffectorData::Alloc(): Creates a new SoundEffectorData object.
- SoundEffectorData::Free(): Deletes the given SoundEffectorData object.
Sound
A SoundEffectorData is referencing a CTrack of the type CTsound. The sound file used in that CTrack is the sound file used by a SoundEffectorData, which is sampled and displayed in the Attribute Manager.
- SoundEffectorData::GetActiveSoundTrack(): Returns the active CTrack.
- SoundEffectorData::SetActiveSoundTrack(): Sets the active CTrack.
See also CTrack Manual.
CTrack*
const track = soundData->GetActiveSoundTrack(
doc);
if (track)
{
const DescID id = track->GetDescriptionID();
{
GeData parameterData;
const Filename soundFile = parameterData.GetFilename();
const String soundFileStr = soundFile.GetString();
}
}
Probes
One or many probes can be used to sample the sound file. Such probes are edited with these functions:
- SoundEffectorData::CreateProbe(): Creates a new probe and returns its index.
- SoundEffectorData::CreateDefaultProbe(): Creates the default probe.
- SoundEffectorData::GetProbeCount(): Returns the number of probes.
- SoundEffectorData::GetProbe(): Returns the Probe of the given index.
- SoundEffectorData::DeleteProbe(): Deletes the probe of the given index.
- SoundEffectorData::UpdateProbeOrder(): Updates the probe order. Must be called after any change to a probe position.
A probe is represented with the Probe class. The "left" and "right" position is defined in Hz, the top and bottom values as a normalized scalar defined between 0.0 and 1.0.
- Probe::GetRight(): Returns the right value.
- Probe::SetRight(): Sets the right value.
- Probe::GetLeft(): Returns the left value.
- Probe::SetLeft(): Sets the left value.
- Probe::GetBottom(): Returns the bottom value.
- Probe::SetBottom(): Sets the bottom value.
- Probe::GetTop(): Returns the top value.
- Probe::SetTop(): Sets the top value.
- Probe::ValidateDimensions(): Swaps the left/right and top/bottom values if they are inverted.
The Probe class also has these public attributes:
- Probe::_clamp: Clamps the output from 0.0 to 1.0.
- Probe::_colorMode: The color mode (Default, Custom Color, Custom Gradient).
- Probe::_samplingMode: The sampling mode (Peak, Average, Step).
- Probe::_strength: Overall strength multiplier.
- Probe::_color: Color for the "Custom Color" mode.
- Probe::_gradient: Gradient for the "Custom Gradient" mode.
- Probe::_fadePercentage: Fade percentage for decay.
- Probe::_freeze: Freeze state of the output.
- Probe::_freezeArray: Freeze value of the output.
const Int probeIndex = soundData->CreateProbe();
Probe* const probe = soundData->GetProbe(probeIndex);
if (probe == nullptr)
probe->SetLeft(300.0);
probe->SetRight(2000.0);
probe->SetTop(0.8);
probe->SetBottom(0.2);
probe->_samplingMode = 1;
probe->_colorMode = 1;
probe->_color =
Vector { 0.5, 0.5, 1.0 };
soundData->UpdateProbeOrder();
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
Data
Additional settings allow to define the range of the frequency spectrum that is currently displayed in the Attribute Manager. These range functions are only valid if the sound data is displayed using the SoundDataCustomGui (e.g. in the Attribute Manager).
- SoundEffectorData::GetRange(): Returns the currently displayed range.
- SoundEffectorData::SetRange(): Sets the currently displayed range.
Further functions are:
- SoundEffectorData::GetLinLog(): Returns the blend value of the linear/logarithmic slider.
- SoundEffectorData::SetLinLog(): Sets the blend value of the linear/logarithmic slider.
- SoundEffectorData::GetFreeze(): Returns the freeze state.
- SoundEffectorData::SetFreeze(): Sets the freeze state.
The color used to colorize the sound is defined by a Gradient:
- SoundEffectorData::GetGradient(): Returns the global Gradient.
- SoundEffectorData::GetGradientDirection(): Returns the gradient direction.
- SoundEffectorData::SetGradientDirection(): Sets the gradient direction.
soundData->SetRange(1000.0, 2000.0, 0.0, 1.0);
soundData->SetLinLog(0.5);
soundData->SetGradientDirection(0);
Gradient* gradient = MAXON_REMOVE_CONST(soundData->GetGradient());
if (gradient == nullptr)
gradient->FlushKnots();
gradient->InsertKnot(red);
gradient->InsertKnot(green);
Represents a knot in a gradient.
Definition: gradient.h:40
Float pos
Position.
Definition: gradient.h:43
Color col
Color.
Definition: gradient.h:41
Sampling
The SoundEffectorData class can be used to sample a sound file. The sound file that is sampled is defined with the active CTrack (see Sound).
- SoundEffectorData::IsFFTSamplingCacheDirty(): Returns true if the cache is up-to-date.
- SoundEffectorData::InitSampling(): Initializes the sampling functionality.
- SoundEffectorData::Sample(): Samples the sound file at the current frame.
- SoundEffectorData::SampleArray(): Samples whole array of elements simultaneously.
- SoundEffectorData::FreeSampling(): Frees the memory used for sampling.
- Note
- The sound data is sampled using the existing probes and their settings.
if (!soundData->InitSampling(
doc))
const Int32 sampleCount = 100;
{
soundData->Sample(
i, sampleCount,
value, color);
}
soundData->FreeSampling();
Py_ssize_t i
Definition: abstract.h:645
PyObject * value
Definition: abstract.h:715
maxon::Int32 Int32
Definition: ge_sys_math.h:51
maxon::Float Float
Definition: ge_sys_math.h:57
Copy
The settings of a given SoundEffectorData object can be copied with:
- SoundEffectorData::CopyTo(): Copies the sound data into the given SoundEffectorData.
Further Reading