## IpatchUnit_SF2

IpatchUnit_SF2 — Unit types and conversions for SoundFont

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    int                 ipatch_unit_sf2_abs_pitch_to_dls_abs_pitch
                                                            (int sf2_abs_pitch);
    int                 ipatch_unit_dls_abs_pitch_to_sf2_abs_pitch
                                                            (int dls_abs_pitch);
    double              ipatch_unit_sf2_abs_pitch_to_hertz  (int sf2_abs_pitch);
    int                 ipatch_unit_hertz_to_sf2_abs_pitch  (double hz);
    double              ipatch_unit_sf2_ofs_pitch_to_multiplier
                                                            (int sf2_ofs_pitch);
    int                 ipatch_unit_multiplier_to_sf2_ofs_pitch
                                                            (double multiplier);
    int                 ipatch_unit_sf2_abs_time_to_dls_abs_time
                                                            (int sf2_abs_time);
    int                 ipatch_unit_dls_abs_time_to_sf2_abs_time
                                                            (int dls_abs_time);
    double              ipatch_unit_sf2_abs_time_to_seconds (int sf2_abs_time);
    int                 ipatch_unit_seconds_to_sf2_abs_time (double sec);
    double              ipatch_unit_sf2_ofs_time_to_multiplier
                                                            (int sf2_ofs_time);
    int                 ipatch_unit_multiplier_to_sf2_ofs_time
                                                            (double multiplier);
    int                 ipatch_unit_centibels_to_dls_gain   (int centibel);
    int                 ipatch_unit_dls_gain_to_centibels   (int dls_gain);
    double              ipatch_unit_centibels_to_decibels   (int cb);
    int                 ipatch_unit_decibels_to_centibels   (double db);
    double              ipatch_unit_tenth_percent_to_percent
                                                            (int tenth_percent);
    int                 ipatch_unit_percent_to_tenth_percent
                                                            (double percent);

## Description

## Details

### ipatch_unit_sf2_abs_pitch_to_dls_abs_pitch ()

    int                 ipatch_unit_sf2_abs_pitch_to_dls_abs_pitch
                                                            (int sf2_abs_pitch);

Converts a value from SF2 absolute pitch to DLS absolute pitch.

sf2_abs_pitch = 1200 * log2(f/8.176) f = 8.176 * 2^(sf2_abs_pitch/1200)

dls_abs_pitch = (1200 * log2(f/440) + 6900) * 65536 f = 440 * 2^((dls_abs_pitch / 65536 - 6900) / 1200)

`sf2_abs_pitch` : | Value in SF2 absolute pitch
Returns : | Value converted to DLS absolute pitch

### ipatch_unit_dls_abs_pitch_to_sf2_abs_pitch ()

    int                 ipatch_unit_dls_abs_pitch_to_sf2_abs_pitch
                                                            (int dls_abs_pitch);

Converts a value from DLS absolute pitch to SF2 absolute pitch. See `ipatch_unit_sf2_abs_pitch_to_dls_abs_pitch()`

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

### ipatch_unit_sf2_abs_pitch_to_hertz ()

    double              ipatch_unit_sf2_abs_pitch_to_hertz  (int sf2_abs_pitch);

Convert SoundFont absolute pitch to frequency in Hertz.

`sf2_abs_pitch` : | Value in SoundFont absolute pitch
Returns : | Value in Hertz (cycles per second)

### ipatch_unit_hertz_to_sf2_abs_pitch ()

    int                 ipatch_unit_hertz_to_sf2_abs_pitch  (double hz);

Convert frequency in Hertz to SoundFont absolute pitch.

`hz` : | Hertz (cycles per second) value
Returns : | Converted value in SoundFont absolute pitch.

### ipatch_unit_sf2_ofs_pitch_to_multiplier ()

    double              ipatch_unit_sf2_ofs_pitch_to_multiplier
                                                            (int sf2_ofs_pitch);

Convert SoundFont offset pitch (cents) to multiplier factor.

`sf2_ofs_pitch` : | Value in SoundFont offset pitch
Returns : | Multiplier factor

### ipatch_unit_multiplier_to_sf2_ofs_pitch ()

    int                 ipatch_unit_multiplier_to_sf2_ofs_pitch
                                                            (double multiplier);

Convert multiplier factor to SoundFont offset pitch (cents).

`multiplier` : | Multiplier factor
Returns : | Converted value in SoundFont offset pitch (cents).

### ipatch_unit_sf2_abs_time_to_dls_abs_time ()

    int                 ipatch_unit_sf2_abs_time_to_dls_abs_time
                                                            (int sf2_abs_time);

Convert a value from SF2 absolute time to DLS absolute time.

sf2_abs_time = 1200 * log2 (seconds) seconds = 2^(sf2_abs_time / 1200)

dls_abs_time = 1200 * log2 (seconds) * 65536 seconds = 2^(dls_abs_time / (1200 * 65536))

`sf2_abs_time` : | Value in SF2 absolute time (timecents)
Returns : | Value converted to DLS absolute time.

### ipatch_unit_dls_abs_time_to_sf2_abs_time ()

    int                 ipatch_unit_dls_abs_time_to_sf2_abs_time
                                                            (int dls_abs_time);

Convert a value from DLS absolute time to SF2 absolute time. See `ipatch_unit_sf2_abs_time_to_dls_abs_time()`

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

### ipatch_unit_sf2_abs_time_to_seconds ()

    double              ipatch_unit_sf2_abs_time_to_seconds (int sf2_abs_time);

Convert a value from SoundFont absolute time (timecents) to seconds.

`sf2_abs_time` : | Value in SoundFont absolute time
Returns : | Value in seconds

### ipatch_unit_seconds_to_sf2_abs_time ()

    int                 ipatch_unit_seconds_to_sf2_abs_time (double sec);

Convert value from seconds to SoundFont absolute time (timecents).

`sec` : | Value in seconds
Returns : | Value in SoundFont absolute time

### ipatch_unit_sf2_ofs_time_to_multiplier ()

    double              ipatch_unit_sf2_ofs_time_to_multiplier
                                                            (int sf2_ofs_time);

Convert a value from SoundFont offset time (timecents) to a multiplier.

`sf2_ofs_time` : | Value in SoundFont offset time (timecents)
Returns : | Multiplier factor

### ipatch_unit_multiplier_to_sf2_ofs_time ()

    int                 ipatch_unit_multiplier_to_sf2_ofs_time
                                                            (double multiplier);

Convert value from a multiplier to SoundFont offset time (timecents).

`multiplier` : | Multiplier factor
Returns : | Value in SoundFont offset time (timecents)

### ipatch_unit_centibels_to_dls_gain ()

    int                 ipatch_unit_centibels_to_dls_gain   (int centibel);

Convert a value from centibels to DLS gain (1/655360th of a dB).

V = target amplitude, v = original amplitude centibel = 200 * log10 (v / V) dls_gain = 200 * 65536 * log10 (V / v)

`centibel` : | Value in centibels (10th of a Decibel)
Returns : | Value converted to DLS gain

### ipatch_unit_dls_gain_to_centibels ()

    int                 ipatch_unit_dls_gain_to_centibels   (int dls_gain);

Convert a value from DLS gain to centibels.

`dls_gain` : | Value in DLS gain (1/655360th of a dB)
Returns : | Value converted to centibels.

### ipatch_unit_centibels_to_decibels ()

    double              ipatch_unit_centibels_to_decibels   (int cb);

Convert a value from Centibels to Decibels.

`cb` : | Value in Centibels (10th of a Decibel)
Returns : | Value in Decibels

### ipatch_unit_decibels_to_centibels ()

    int                 ipatch_unit_decibels_to_centibels   (double db);

Convert Decibels to Centibels (10ths of a dB)

`db` : | Value in Decibels
Returns : | Converted value in Centibels (10ths of a Decibel)

### ipatch_unit_tenth_percent_to_percent ()

    double              ipatch_unit_tenth_percent_to_percent
                                                            (int tenth_percent);

Convert a value from 10ths of a Percent to Percent.

`tenth_percent` : | Value in 10ths of a Percent (Percent * 10)
Returns : | Value in Percent

### ipatch_unit_percent_to_tenth_percent ()

    int                 ipatch_unit_percent_to_tenth_percent
                                                            (double percent);

Convert Percent to 10ths of a Percent (Percent * 10)

`percent` : | Value in Percent
Returns : | Converted value in 10ths of a Percent