'Computes the track or album gain of a list of items, returns
a list of TrackGain objects.
When computing album gain, the last TrackGain object returned is
the album gain'

def compute_gain(self, items, is_album):

    if (len(items) == 0):
        return []
    albumgaintot = 0.0
    albumpeaktot = 0.0
    returnchunks = []
    if (len(items) > self.chunk_at):
        i = 0
        for chunk in self.isplitter(items, self.chunk_at):
            i += 1
            returnchunk = self.compute_chunk_gain(chunk, is_album)
            albumgaintot += returnchunk[(-1)].gain
            albumpeaktot += returnchunk[(-1)].peak
            returnchunks = (returnchunks + returnchunk[0:(-1)])
        returnchunks.append(Gain((albumgaintot / i), (albumpeaktot / i)))
        return returnchunks
    else:
        return self.compute_chunk_gain(items, is_album)
