Exemple #1
0
def run():
    # map output ports
    ports = dict(enumerate(scheme['send'], 1))

    for band in scheme.get_bands():
        selected_port = None
        while True:
            if selected_port:
                print 'using [%s]' % selected_port
                break

            current_value = band.get('jackport')
            print 'which jack port to use for channel [%s]? %s' % \
                (band['name'],
                 current_value and 'default is "%s"' % current_value or '')

            show_possible(ports)

            selected_port = select_port(ports, current_value)

        band['jackport'] = selected_port

    # map measure ports
    ports = dict(enumerate(scheme['receive'], 1))
    show_possible(ports)

    for channel_name, current_value in scheme['measure'].items():
        selected_port = None
        while True:
            if selected_port:
                print 'using [%s]' % selected_port
                break

            print 'which jack port to use for [%s]? %s' % \
                (channel_name, current_value and 'current: "%s"' % current_value or '')

            show_possible(ports)

            selected_port = select_port(ports, current_value)

        scheme['measure'][channel_name] = selected_port

    scheme.save()
Exemple #2
0
def compile():

    config = BF_HEAD % {
        'sampling_rate': scheme['sample_rate'],
        'filter_length': '%s,%s' % (scheme['filter_size'] / PARTS_COUNT, PARTS_COUNT)}

    # coeffs
    coeffs = [
        ((band['lower'], band['upper']), band['range'], band['file'])
        for channel in scheme['channels']
        for band in channel['bands']
        if band['file']
    ] + [
        (0, '%s_correction' % channel['name'], channel['correction'])
        for channel in scheme['channels']
        if channel.get('correction')
    ]

    coeffs = sorted(set(coeffs))

    config += """\n\n## COEFFS ##\n"""

    for order, coeff, file_path in coeffs:
        config += BF_COEFF % {
            'name': coeff,
            'file': file_path,
            }

    # inputs
    inputs = [channel['name'] for channel in scheme['channels']] + \
             ['%s_correction' % channel['name'] 
              for channel in scheme['channels']
              if channel.get('correction')]

    config += BF_INPUT % {
        'names': ', '.join(map(quote, inputs)),
        'channels': '%s/%s' % (len(inputs), ', '.join(map(str, range(len(inputs))))),
        'delays': ','.join('0' * len(inputs)),
        'mutes': ','.join(['false'] * len(inputs)),
        }

    # outputs
    outputs = scheme.get_bands()
    config += BF_OUTPUT % {
        'names': ', '.join([quote(band['name']) for band in outputs]),
        # 'ports': ', '.join([quote(band['jack_port']) for band in outputs]),
        'channels': '%s/%s' % (len(outputs), ','.join(map(str, range(len(outputs))))),
        'delays': ','.join([str(int(band.get('delay', 0)))
                            for band in outputs]),
        'mutes': ','.join(['false'] * len(outputs)),
        }

    # scheme
    for j, input in enumerate(scheme['channels']):
        input['brutenum'] = j

    for j, out in enumerate(outputs):
        out['brutenum'] = j

    scheme.save()

    # filters
    config += """\n\n## FILTERS ##\n"""
    for channel in scheme['channels']:
        for band in channel['bands']:

            if channel.get('correction'):
                from_filters_line = 'from_filters: "%s";' % ('%s_correction' % channel['name'])
            else:
                from_filters_line = ''

            config += BF_FILTER % {
                'name': band['name'],
                'input_line': 'inputs: "%s";' % channel['name'],
                'from_filters_line': from_filters_line,
                'output_line': 'outputs: "%s";' % band['name'],
                'coeff': band['file'] and '"%s"' % band['range'] or '-1',
                }

    for channel in scheme['channels']:
        if channel.get('correction'):
            config += BF_FILTER % {
                'name': '%s_correction' % channel['name'],
                'input_line': 'inputs: "%s_correction";' % channel['name'],
                'from_filters_line': '',
                'output_line': 'to_filters: %s;' % \
                    ','.join(('"%s"' % b['name'] for b in channel['bands'])),
                'coeff': '"%s_correction"' % channel['name'],
                }

    return config
Exemple #3
0
    brute.start()
    time.sleep(1)

    plum = Plum()

    plum[(scheme['measure']['microphone'], 'jack.record-[0-9]+:in_1')] = True
    plum[('jack.play.sweep:out_1', 'jack.record-[0-9]+:in_2')] = True
         
    for channel in scheme['channels']:

        for ch in scheme.channels:
            plum[('jack.play.sweep:out_1', Channel(ch).bruteport)] = False

        plum[('jack.play.sweep:out_1', Channel(channel).bruteport)] = True

        for b in scheme.get_bands():
            plum[Band(b).pair] = False

        for b in channel['bands']:
            plum[Band(b).pair] = True

        plum.apply()
        print plum.config

        sweep = measure.Sweep(
                scheme['sample_rate'],
                duration=44,
                hzstart=10,
                hzend=scheme['sample_rate'] / 2.1)

        channel['measurement'] = sweep.measure(
Exemple #4
0
from scheme import scheme
import measure
import brute
import bruteconf
import plumbing
from plumbing import Plum, Channel, Band


if __name__ == '__main__':

    plumbing.stop_plumbing()
    brute.stop()
    time.sleep(1)

    # сформировать конфигурацию brutefir без задержек и коррекции
    for band in scheme.get_bands():
        band['delay'] = 0

    for channel in scheme.channels:
        if 'correction' in channel:
            del channel['correction']

    scheme.save()
    time.sleep(1)

    bruteconf.configure()

    brute.start()
    time.sleep(1)

    plum = Plum()