Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

float pa_cvolume_get_balance ( const pa_cvolume v,
const pa_channel_map map 
)

Calculate a 'balance' value for the specified volume with the specified channel map. The return value will range from -1.0f (left) to +1.0f (right). If no balance value is applicable to this channel map the return value will always be 0.0f. See pa_channel_map_can_balance().

Since:
0.9.15

Definition at line 608 of file volume.c.

References pa_volume_t.

                                                                             {
    pa_volume_t left, right;

    pa_assert(v);
    pa_assert(map);

    pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(v, map), 0.0f);

    if (!pa_channel_map_can_balance(map))
        return 0.0f;

    get_avg_lr(map, v, &left, &right);

    if (left == right)
        return 0.0f;

    /*   1.0,  0.0  =>  -1.0
         0.0,  1.0  =>   1.0
         0.0,  0.0  =>   0.0
         0.5,  0.5  =>   0.0
         1.0,  0.5  =>  -0.5
         1.0,  0.25 => -0.75
         0.75, 0.25 => -0.66
         0.5,  0.25 => -0.5   */

    if (left > right)
        return -1.0f + ((float) right / (float) left);
    else
        return 1.0f - ((float) left / (float) right);
}

Generated by  Doxygen 1.6.0   Back to index