def cnt_evnt_typ(ptrn, typ):
    """
    Args:
        ptrn   - midi.Pattern
        typ    - midi.events Type
    Returns:
        n_evnt - int, number of typ evnts in ptrn
    """
    n_evnt = 0
    for trck in ptrn:
        for evnt in trck:
            if isinstance(evnt, typ):
                n_evnt += 1
    return n_evnt