Logo Search packages:      
Sourcecode: pulseaudio version File versions

pa_cvolume* pa_cvolume_remap ( pa_cvolume v,
pa_channel_map from,
pa_channel_map to 
)

Remap a volume from one channel mapping to a different channel mapping.

Since:
0.9.12

Definition at line 307 of file volume.c.

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

                                                                                      {
    int a, b;
    pa_cvolume result;

    pa_assert(v);
    pa_assert(from);
    pa_assert(to);
    pa_assert(v->channels == from->channels);

    if (pa_channel_map_equal(from, to))
        return v;

    result.channels = to->channels;

    for (b = 0; b < to->channels; b++) {
        pa_volume_t k = 0;
        int n = 0;

        for (a = 0; a < from->channels; a++)
            if (from->map[a] == to->map[b]) {
                k += v->values[a];
                n ++;
            }

        if (n <= 0) {
            for (a = 0; a < from->channels; a++)
                if ((on_left(from->map[a]) && on_left(to->map[b])) ||
                    (on_right(from->map[a]) && on_right(to->map[b])) ||
                    (on_center(from->map[a]) && on_center(to->map[b])) ||
                    (on_lfe(from->map[a]) && on_lfe(to->map[b]))) {

                    k += v->values[a];
                    n ++;
                }
        }

        if (n <= 0)
            k = pa_cvolume_avg(v);
        else
            k /= n;

        result.values[b] = k;
    }

    *v = result;
    return v;
}


Generated by  Doxygen 1.6.0   Back to index