def get_dft_bin_num(freq, sample_rate, dft_size):
    
    """
    Gets the DFT bin number for a specified frequency.
    
    The bin number is in [0, `dft_size`).
    """
    
    bin_size = sample_rate / dft_size
    
    # Modulo operation puts any frequency into the appropriate bin
    # with number in [0, dft_size).
    return int(round(freq / bin_size)) % dft_size