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

pa_cvolume* pa_cvolume_set_fade ( pa_cvolume v,
const pa_channel_map map,
float  new_fade 
)

Adjust the 'fade' value (i.e. 'balance' between front and rear) for the specified volume with the specified channel map. v will be modified in place and returned. The balance is a value between -1.0f and +1.0f. This operation might not be reversible! Also, after this call pa_cvolume_get_fade() is not guaranteed to actually return the requested fade value (e.g. when the input volume was zero anyway for all channels). If no fade value is applicable to this channel map the volume will not be modified. See pa_channel_map_can_fade().

Since:
0.9.15

Definition at line 780 of file volume.c.

References pa_channel_map::channels, pa_channel_map::map, pa_volume_t, and pa_cvolume::values.

                                                                                          {
    pa_volume_t front, nfront, rear, nrear, m;
    unsigned c;

    pa_assert(map);
    pa_assert(v);

    pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(v, map), NULL);
    pa_return_val_if_fail(new_fade >= -1.0f, NULL);
    pa_return_val_if_fail(new_fade <= 1.0f, NULL);

    if (!pa_channel_map_can_fade(map))
        return v;

    get_avg_fr(map, v, &front, &rear);

    m = PA_MAX(front, rear);

    if (new_fade <= 0) {
        nfront  = (new_fade + 1.0f) * m;
        nrear = m;
    } else  {
        nrear = (1.0f - new_fade) * m;
        nfront = m;
    }

    for (c = 0; c < map->channels; c++) {
        if (on_front(map->map[c])) {
            if (front == 0)
                v->values[c] = nfront;
            else
                v->values[c] = (pa_volume_t) (((uint64_t) v->values[c] * (uint64_t) nfront) / (uint64_t) front);
        } else if (on_rear(map->map[c])) {
            if (rear == 0)
                v->values[c] = nrear;
            else
                v->values[c] = (pa_volume_t) (((uint64_t) v->values[c] * (uint64_t) nrear) / (uint64_t) rear);
        }
    }

    return v;
}

Generated by  Doxygen 1.6.0   Back to index