dsp/banyan_ch_find.py
def banyan_ch_find(mask):
    '''
    mask: 0xa9 = 0b10101001 This means channels 7, 5, 3 and 0 are set
    This means lower is 0b1001 and upper is 0b1010
    '''
    mw = 8
    state = list(map(lambda y: (y, mask >> y & 1), range(mw)))
    ch_count = sum(x[1] for x in state)
    # print("banyan_ch_find", mask, ch_count)
    if ch_count in [1, 2, 4, 8]:
        return banyan_layer_permute(state)
    else:
        return []

    mask: 0xa9 = 0b10101001 This means channels 7, 5, 3 and 0 are set
    This means lower is 0b1001 and upper is 0b1010
    
0xa9 = 0b10101001 This means channels 7, 5, 3 and 0 are set
This means lower is 0b1001 and upper is 0b1010
0xa9 = 0b10101001 This means channels 7 5 3 and 0 are set This means lower is 0b1001 and upper is 0b1010
def banyan_ch_find(mask):
    mw = 8
    state = list(map(lambda y: (y, mask >> y & 1), range(mw)))
    ch_count = sum(x[1] for x in state)
    if ch_count in [1, 2, 4, 8]:
        return banyan_layer_permute(state)
    else:
        return []
def banyan_ch_find ( mask ) : mw = 8 state = list ( map ( lambda y : ( y , mask >> y & 1 ) , range ( mw ) ) ) ch_count = sum ( x [ 1 ] for x in state ) if ch_count in [ 1 , 2 , 4 , 8 ] : return banyan_layer_permute ( state ) else : return [ ]
mask: 0xa9 = 0b10101001 This means channels 7, 5, 3 and 0 are set
This means lower is 0b1001 and upper is 0b1010
mask : 0xa9 = 0b10101001 This means channels 7 5 3 and 0 are set This means lower is 0b1001 and upper is 0b1010
'''
    mask: 0xa9 = 0b10101001 This means channels 7, 5, 3 and 0 are set
    This means lower is 0b1001 and upper is 0b1010
    ''' # print("banyan_ch_find", mask, ch_count)
mask