Esempio n. 1
0
def print_module(fn_pch2: str, mod_id: int, loc: Location):
    if not fn_pch2.lower().endswith('.pch2'):
        print("error: patch file should have extension '.pch2'")
        exit(-1)
    data = ProjectData()
    path = os.path.abspath(os.path.expanduser(fn_pch2))
    p = parse_pch2(data, path)

    m = p.find_module(mod_id, loc)
    if m is None:
        print('error: cannot find module with id {} in the {} location'.format(
            mod_id, loc.short_str()))
        exit(-1)

    udo = Udo(p, m)
    params_midi = p.find_mod_params(loc, mod_id)
    params_mapped = udo.get_params()
    assert params_midi.num_params == len(params_mapped)

    tbl = [['Type', 'Raw', 'Mapped']]
    for raw, mapped in zip(params_midi.values, params_mapped):
        tbl.append(['Parameter', str(raw), str(mapped)])
    for mode in m.modes:
        tbl.append(['Mode', str(mode), ''])

    print('Patch: {}'.format(fn_pch2))
    print('Details of the module:\n{}'.format(m))
    print()
    print(tabulate(tbl, headers='firstrow', tablefmt='simple'))
Esempio n. 2
0
 def _gen_instr(self, loc: Location) -> str:
     s = StringIO()
     s.write('; --------------------\n')
     s.write('; {} AREA\n'.format(loc.short_str()))
     s.write('instr {}\n'.format(2 - loc.value))
     statements = [udo.get_statement_parts() for udo in self.udos
                   if udo.mod.location == loc]
     table_head = ('; Module', 'Parameters', 'Modes', 'Inlets', 'Outlets')
     table_str = tabulate(statements, table_head, tablefmt='plain')
     s.write(table_str)
     s.write('\nendin\n')
     return s.getvalue()