struct in Clatter.Core
Audio synthesis data for an impact material. Every ImpactMaterialData has a corresponding ImpactMaterial (see: ImpactMaterialData.impactMaterials).
This class contains useful helper methods for converting ImpactMaterialUnsized values to ImpactMaterial values, as well as means of deriving density and "size bucket" values.
Name | Type | Description | Default Value |
---|---|---|---|
impactMaterials | ImpactMaterial |
A dictionary of impact data. Key = An ImpactMaterial value. Value = An ImpactMaterialData. | new Dictionary |
Density | ImpactMaterialUnsized |
A dictionary of density values per impact material. Key = An ImpactMaterialUnsized. Value = Density in kg/m^3. Readonly. | new Dictionary |
Name | Type | Description | Default Value |
---|---|---|---|
cf | double[] | The frequency of the sinusoid used to create the mode in Hz. | |
op | double[] | The power of the mode at the onset, in dB relative to the amplitude of the "onset click". | |
rt | double[] | RT60 values. The time it takes a mode power to decay 60dB (i.e. 10^-6) from its onset power in seconds. |
public static void Load(ImpactMaterial impactMaterial)
Load impact material data from a file relative to this assembly.
Name | Type | Description |
---|---|---|
impactMaterial | ImpactMaterial |
The impact material. |
public static void GetImpactMaterial(ImpactMaterialUnsized impactMaterialUnsized, int size)
Parse a size bucket value and an ImpactMaterialUnsized value to get an ImpactMaterial value.
Name | Type | Description |
---|---|---|
impactMaterialUnsized | ImpactMaterialUnsized |
The unsized impact material. |
size | int | The size bucket value (0-5). |
public static int GetSize(Vector3d extents)
Returns the object's "size bucket" given the bounding box extents.
Name | Type | Description |
---|---|---|
extents | Vector3d |
The object's bounding box extents. |
public static int GetSize(double volume)
Returns the object's "size bucket" given its volume.
Name | Type | Description |
---|---|---|
volume | double | The object's volume. |
public static void GetImpactMaterialUnsized(ImpactMaterial impactMaterial)
Parse a sized impact material to get an un-sized impact material.
Name | Type | Description |
---|---|---|
impactMaterial | ImpactMaterial |
The sized impact material. |
To derive the "size bucket" and mass from an ImpactMaterialUnsized value and volume:
using Clatter.Core;
public class SizeBucket
{
private uint nextId;
public ClatterObjectData Get(ImpactMaterialUnsized impactMaterialUnsized, double amp, double resonance, double volume, ScrapeMaterial? scrapeMaterial)
{
// Get the "size bucket".
int size = ImpactMaterialData.GetSize(volume);
// Get the impact material.
ImpactMaterial impactMaterial = ImpactMaterialData.GetImpactMaterial(impactMaterialUnsized, size);
// Get the density of the material.
double density = ImpactMaterialData.Density[impactMaterialUnsized];
// Derive the mass.
double mass = density * volume;
// Create the object.
ClatterObjectData a = new ClatterObjectData(nextId, impactMaterial, amp, resonance, mass, scrapeMaterial);
// Increment the ID for the next object.
nextId++;
return a;
}
}