Exemple #1
0
def get_cosine_test_vector():
    '''Get a max amplitude cosine test vector to try saturate the pipeline
    with.'''
    t = np.linspace(0, 1, 16000)
    f = 20  # Hz
    A = 2**15 - 1  # max 16b signed amplitude
    x = A * np.cos(2 * np.pi * f * t)
    x = aco.pdm_model(x, 'fast')
    sigs = aco.aco(x)
    return x, sigs
Exemple #2
0
def get_multi_cosine_test_vector():
    '''Get a max amplitude cosine test vector to try saturate the pipeline
    with.'''
    t = np.linspace(0, 1, 16000)
    n_freqs = 100
    freqs = np.logspace(0, np.log10(16000), 10)
    A = (2**15 - 1) / n_freqs  # max 16b signed amplitude
    x = np.zeros(16000)
    for f in freqs:
        x += A * np.cos(2 * np.pi * f * t)
    x = aco.pdm_model(x, 'fast')
    sigs = aco.aco(x)
    return x, sigs
Exemple #3
0
def get_random_sample_test_vector(test_num):
    top_dir = '../../../py/'
    categories = ['yes/', 'noise/', 'no/', 'unknown/']
    category = categories[test_num % 4]
    sample_dir = top_dir + category
    fnames = os.listdir(sample_dir)
    idx = np.random.randint(len(fnames))
    fname = sample_dir + fnames[idx]
    print('Running test with', fname)

    x = pdm.read_sample_file(fname)
    x = aco.pdm_model(x, 'fast')
    sigs = aco.aco(x)
    return x, sigs
Exemple #4
0
def get_random_test_vector():
    x = np.random.randint(-2**15, 2**15 - 1, size=16000)
    x = aco.pdm_model(x, 'fast')
    sigs = aco.aco(x)
    return x, sigs
Exemple #5
0
def get_sample_test_vector():
    '''Get a real audio sample for input and calculate the expected outputs.'''
    x = pdm.read_sample_file(pdm.SAMPLE_FNAME)
    x_distorted = aco.pdm_model(x, 'fast')
    sigs = aco.aco(x_distorted)
    return x_distorted, sigs