def sonorities(notes, tolerance=1e-6):
    """
    Break notes into groups that sound together.
    """
    notes = list(sorted(notes, key=lambda n: n.time))
    result = []
    sonority = []
    while notes:
        time = notes[0].time
        for note in sonority[:]:
            if note.off_time < time + tolerance:
                sonority.remove(note)
        while notes and abs(notes[0].time - time) < tolerance:
            sonority.append(notes.pop(0))
        result.append((time, sonority[:]))
    if sonority:
        off_time = max(note.off_time for note in sonority)
        result.append((off_time, []))
    return result