Exemplo n.º 1
0
def run():
    channels = parse(sys.argv[1:])

    freqs = set([freq for channel in channels for freq in channel['freqs']])

    scheme['filter_duration'] = FILTER_DURATION

    filter_size = int(np.power(2, int(np.log2(scheme['sample_rate'] - 1)) + 1) *
                      scheme['filter_duration'])

    scheme['filter_size'] = filter_size

    fir = Fir(filter_size)

    for channel in channels:
        channel['bands'] = []

        if len(channel['freqs']) < 2:
            channel['freqs'] = [0, HIGHEST_FREQENCY]

        for lower, upper in pairwise(channel['freqs']):
            band = {
                'lower': lower,
                'upper': upper,
                'range': '%s_%s' % (lower, upper),
                'name': '%s_%s_%s' % (channel['name'], lower, upper),
            }
            if lower > 0 or upper != HIGHEST_FREQENCY:
                filename = fir_coeffs_filename('bandpass', scheme['sample_rate'],
                                               filter_size, lower, upper)
                band['file'] = scheme.path('coeffs', filename)
                fir.save(band['file'], fir.bandpass(upper, lower))
            else:
                band['file'] = ''

            channel['bands'].append(band)

        channel['bands'].reverse()
        del channel['freqs']

    scheme['channels'] = channels

    scheme.save()
Exemplo n.º 2
0
def configure():
    open(scheme.path('brutefir.conf'), 'w').write(compile())
Exemplo n.º 3
0
        print 'Impulses peak positions too far from each other: %s' % \
            ' '.join(map(str, sorted(peaks)))
        sys.exit(-1)

    trim_start = max(0, earlier_peak - 1)
    trim_end = later_peak + 3

    # trim impulse responses
    for channel in scheme['channels']:
        sox_trim(scheme['sample_rate'], channel['measurement'].impulse_file,
                 trim_start, trim_end)

    # todo make DRC
    for channel in scheme['channels']:
        filename = '_'.join([channel['name'], 'correction'])
        channel['correction'] = scheme.path('coeffs', filename)

        drc_calculate(sample_rate=scheme['sample_rate'],
                      impulse_file=channel['measurement'].impulse_file,
                      target_file=channel['correction'])

        del channel['measurement']

    scheme.save()

    # сформировать полную конфигурацию brutefir
    bruteconf.configure()
    time.sleep(1)

    brute.start()