'Iterator that returns the whole sound array of the clip by chunks'

@requires_duration
def iter_chunks(self, chunksize=None, chunk_duration=None, fps=None, quantize=False, nbytes=2, progress_bar=False):

    if (fps is None):
        fps = self.fps
    if (chunk_duration is not None):
        chunksize = int((chunk_duration * fps))
    totalsize = int((fps * self.duration))
    if ((totalsize % chunksize) == 0):
        nchunks = (totalsize // chunksize)
    else:
        nchunks = ((totalsize // chunksize) + 1)
    pospos = (list(range(0, totalsize, chunksize)) + [totalsize])
    def generator():
        for i in range(nchunks):
            tt = ((1.0 / fps) * np.arange(pospos[i], pospos[(i + 1)]))
            (yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize, fps=fps, buffersize=chunksize))
    if progress_bar:
        return tqdm(generator(), total=nchunks)
    else:
        return generator()
