ImpactMaterialData

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.

Static Fields

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() { { ImpactMaterialUnsized.ceramic, 2180 }, { ImpactMaterialUnsized.glass, 2500 }, { ImpactMaterialUnsized.stone, 2000 }, { ImpactMaterialUnsized.metal, 8450 }, { ImpactMaterialUnsized.wood_hard, 1200 }, { ImpactMaterialUnsized.wood_medium, 700 }, { ImpactMaterialUnsized.wood_soft, 400 }, { ImpactMaterialUnsized.fabric, 1540 }, { ImpactMaterialUnsized.leather, 860 }, { ImpactMaterialUnsized.plastic_hard, 1150 }, { ImpactMaterialUnsized.plastic_soft_foam, 285 }, { ImpactMaterialUnsized.rubber, 1522 }, { ImpactMaterialUnsized.paper, 1200 }, { ImpactMaterialUnsized.cardboard, 698 } }

Fields

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.

Static Methods

Load

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.

GetImpactMaterial

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).

GetSize

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.

GetSize

public static int GetSize(double volume)

Returns the object's "size bucket" given its volume.

Name Type Description
volume double The object's volume.

GetImpactMaterialUnsized

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.

Code Examples

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;
    }
}