def _generate_data(self, bytes, offset):
        # XXX TODO consider offset
        if self._bytes_per_sample == 1:
            samples = bytes
            value = 127
            max = 255
            min = 0
            data = (ctypes.c_ubyte * samples)()
        else:
            samples = bytes >> 1
            value = 0
            max = 32767
            min = -32768
            data = (ctypes.c_short * samples)()
        step = (max - min) * 2 * self.frequency / self.audio_format.sample_rate
        for i in range(samples):
            value += step
            if value > max:
                value = (value - max) - max
                step = -step
            if value < min:
                value = min - (value - min)
                step = -step
            data[i] = value
        return data
dataset/ETHPy150Open ardekantur/pyglet/experimental/mt_media/mt_procedural.py/Saw._generate_data/swapped operands of `-`