## IpatchUnit_DLS IpatchUnit_DLS — Unit types and conversions for DLS |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #define             IPATCH_UNIT_DLS_ABS_TIME_0SECS
    int                 ipatch_unit_dls_class_convert       (guint16 src_units,
                                                             const GValue *src_val);
    double              ipatch_unit_dls_percent_to_percent  (int dls_percent);
    int                 ipatch_unit_percent_to_dls_percent  (double percent);
    double              ipatch_unit_dls_gain_to_decibels    (int dls_gain);
    int                 ipatch_unit_decibels_to_dls_gain    (double db);
    double              ipatch_unit_dls_abs_time_to_seconds (int dls_abs_time);
    int                 ipatch_unit_seconds_to_dls_abs_time (double seconds);
    double              ipatch_unit_dls_rel_time_to_time_cents
                                                            (int dls_rel_time);
    int                 ipatch_unit_time_cents_to_dls_rel_time
                                                            (double time_cents);
    double              ipatch_unit_dls_abs_pitch_to_hertz  (int dls_abs_pitch);
    int                 ipatch_unit_hertz_to_dls_abs_pitch  (double hertz);
    double              ipatch_unit_dls_rel_pitch_to_cents  (int dls_rel_pitch);
    int                 ipatch_unit_cents_to_dls_rel_pitch  (double cents);

## Description

## Details

### IPATCH_UNIT_DLS_ABS_TIME_0SECS

    #define IPATCH_UNIT_DLS_ABS_TIME_0SECS 0x80000000L

### ipatch_unit_dls_class_convert ()

    int                 ipatch_unit_dls_class_convert       (guint16 src_units,
                                                             const GValue *src_val);

Converts a value to "DLS" units. DLS units are unit types that are used by DLS (Downloadable Sounds) patches. The IPATCH_UNIT_CLASS_DLS map is used to lookup the corresponding type to convert to. Only some types have an associated DLS type. It is an error to pass a `src_units` type that has no DLS mapping (note that this is contrary to the behavior of `ipatch_unit_user_class_convert()`).

`src_units` : | Source unit type ID
`src_val` : | Source value (type should be compatible with the source unit's value type)
Returns : | The value converted to DLS units.

### ipatch_unit_dls_percent_to_percent ()

    double              ipatch_unit_dls_percent_to_percent  (int dls_percent);

Convert value in DLS percent units to percent.

percent = dls_percent / (10 * 65536)

`dls_percent` : | Value in DLS percent units
Returns : | Value in percent

### ipatch_unit_percent_to_dls_percent ()

    int                 ipatch_unit_percent_to_dls_percent  (double percent);

Convert percent to DLS percent.

dls_percent = percent * 10 * 65536

`percent` : | Value in percent
Returns : | Converted integer in DLS percent

### ipatch_unit_dls_gain_to_decibels ()

    double              ipatch_unit_dls_gain_to_decibels    (int dls_gain);

Converts a value from DLS gain to decibels.

dls_gain = 200 * 65536 * log10 (V / v) decibels = 20 * log10 (V / v)

`dls_gain` : | Value in DLS gain units
Returns : | Value converted to decibels

### ipatch_unit_decibels_to_dls_gain ()

    int                 ipatch_unit_decibels_to_dls_gain    (double db);

Converts a value from decibels to DLS gain. See `ipatch_unit_dls_gain_to_decibel()`

`db` : | Value in decibels
Returns : | Value converted to DLS gain

### ipatch_unit_dls_abs_time_to_seconds ()

    double              ipatch_unit_dls_abs_time_to_seconds (int dls_abs_time);

Converts a value from DLS absolute time to seconds. seconds = 2^(dls_abs_time / (1200 * 65536))

0x80000000 is used as a 0 value.

`dls_abs_time` : | Value in DLS absolute time
Returns : | Value converted to seconds

### ipatch_unit_seconds_to_dls_abs_time ()

    int                 ipatch_unit_seconds_to_dls_abs_time (double seconds);

Converts a value from seconds to DLS absolute time. dls_rel_time = 1200 * log2 (seconds) * 65536

`seconds` : | Value in seconds
Returns : | Value converted to DLS relative time

### ipatch_unit_dls_rel_time_to_time_cents ()

    double              ipatch_unit_dls_rel_time_to_time_cents
                                                            (int dls_rel_time);

Converts a value from DLS relative time to time cents. time_cents = dls_rel_time / 65536

`dls_rel_time` : | Value in DLS relative time
Returns : | Value converted to time cents

### ipatch_unit_time_cents_to_dls_rel_time ()

    int                 ipatch_unit_time_cents_to_dls_rel_time
                                                            (double time_cents);

Converts a value from time_cents to DLS relative time. dls_rel_time = time_cents * 65536

`time_cents` : | Value in time cents
Returns : | Value converted to DLS relative time

### ipatch_unit_dls_abs_pitch_to_hertz ()

    double              ipatch_unit_dls_abs_pitch_to_hertz  (int dls_abs_pitch);

Converts a value from DLS absolute pitch to hertz. hertz = 440 * 2^((dls_abs_pitch / 65536 - 6900) / 1200)

`dls_abs_pitch` : | Value in DLS absolute pitch
Returns : | Value converted to hertz

### ipatch_unit_hertz_to_dls_abs_pitch ()

    int                 ipatch_unit_hertz_to_dls_abs_pitch  (double hertz);

Converts a value from hertz to DLS absolute pitch. dls_abs_pitch = (1200 * log2(hertz/440) + 6900) * 65536

`hertz` : | Value in hertz
Returns : | Value converted to DLS absolute pitch

### ipatch_unit_dls_rel_pitch_to_cents ()

    double              ipatch_unit_dls_rel_pitch_to_cents  (int dls_rel_pitch);

Converts a value from DLS relative pitch to cents. cents = dls_rel_pitch / 65536

`dls_rel_pitch` : | Value in DLS relative pitch
Returns : | Value converted to cents

### ipatch_unit_cents_to_dls_rel_pitch ()

    int                 ipatch_unit_cents_to_dls_rel_pitch  (double cents);

Converts a value from cents to DLS relative pitch. dls_rel_pitch = cents * 65536

`cents` : | Value in cents
Returns : | Value converted to DLS relative pitch