Example #1
0
    def upgrade_5_0_to_6_0(self, tools, address):
        root = tools.root(address)

        root.ensure_node(2, 253, 254).set_long(2)
        root.ensure_node(2, 253, 255.1)
        root.ensure_node(2, 253, 255.3)
        root.ensure_node(2, 253, 255.4).set_string('channel')
        root.ensure_node(2, 253, 255.8).set_string('count')
        root.ensure_node(2, 1, 255, 8).set_string('')

        root.ensure_node(3, 253, 254).set_long(2)
        root.ensure_node(3, 253, 255.1)
        root.ensure_node(3, 253, 255.3)
        root.ensure_node(3, 253, 255.4).set_string('channel')
        root.ensure_node(3, 253, 255.8).set_string('count')
        root.ensure_node(3, 1, 255, 8).set_string('')

        pmap = []
        for p in range(1, 17):
            pnode = root.ensure_node(4, p)
            for n in pnode.iter():
                pbits = n.get_string().split(',')
                pmap.append(logic.make_term('m', p, int(pbits[2]), 1.0))

            pnode.ensure_node(255, 17)

        # replace 0 tail time (meaning, plugin value) with a sensible default
        n = root.ensure_node(10, 254)
        if n.get_data().is_float() and n.get_data().as_float() == 0.0:
            n.set_data(piw.makefloat(30.0, 0))

        root.ensure_node(14, 255.1)
        root.ensure_node(14, 255.3)
        root.ensure_node(14, 255.8).set_string('midi input')

        root.ensure_node(15, 255.1)
        root.ensure_node(15, 255.3)
        root.ensure_node(15, 255.8).set_string('midi output')

        id_bits = root.ensure_node(255, 6).get_string().split('|')
        plug_id = id_bits[0]
        plug_name = id_bits[1] if len(id_bits) > 1 else ''
        au_bits = plug_id[0:4], plug_id[4:8], plug_id[8:12]

        what = ''
        if au_bits[0] == 'aumu': what = 'Synths'
        if au_bits[0] == 'aumf' or au_bits[0] == 'aufx': what = 'Effects'
        if what:
            desc = host_native.plugin_description(
                'AudioUnit:%s/%s' % (what, ','.join(au_bits)), plug_name)
            root.ensure_node(255, 6, 3).set_string(urllib.quote(desc.to_xml()))
            root.ensure_node(255, 6,
                             4).set_data(root.get_node(9, 254).get_data())
            root.ensure_node(255, 6, 5).set_string(
                logic.render_term(logic.make_term('mapping', *tuple(pmap))))

        root.remove(99)

        return True
Example #2
0
    def disconnect(self, srcid, dstid, u, f, c):
        proxy = self.__database.find_item(dstid)

        if proxy:
            if u == 0:
                u = None
            if f == '':
                f = None
            if c == '':
                c = None
            r = proxy.invoke_rpc(
                'disconnect',
                logic.render_term(logic.make_term('conn', u, None, srcid, f,
                                                  c)))
            yield (r)
            if not r.status():
                print 'disconnect failed', srcid, dstid, u, f, c
                self.__frontend.report_error(
                    'eigenD could not disconnect wire ' + srcid + ':' + dstid,
                    r.args()[0])
                yield async .Coroutine.failure('rpc_disconnect failed')

            yield async .Coroutine.success()
        else:
            print 'proxy not found'
Example #3
0
    def mimic_connections(self,fr,to,name,argstocopy=(0,1,3)):
        from_input = self.get_node(*fr)
        if from_input:
            input_name = from_input.get_name()

            input_connections = from_input.get_meta('master')
            if input_connections and input_connections.is_string() and input_connections.as_string():
                input_connections_parsed = logic.parse_termlist(input_connections.as_string())
                output_connections = []

                if input_connections_parsed:
                    for input_conn in input_connections_parsed:
                        upstream_addr,upstream_path = paths.breakid_list(input_conn.args[2])
                        upstream_root = self.tools.get_root(upstream_addr)
                        if upstream_root:
                            upstream_node = upstream_root
                            for n in upstream_path[:-1]:
                                c = upstream_node.get_node(n)
                                if c:
                                    upstream_node = c
                            for c in upstream_node.iter():
                                if name == c.get_name():
                                    conn = logic.make_term('conn',input_conn.args[0] if 0 in argstocopy else None,input_conn.args[1] if 1 in argstocopy else None,c.id(),input_conn.args[3] if 3 in argstocopy else None)
                                    output_connections.append(conn)

                    if len(output_connections):
                        conn_txt = logic.render_termlist(output_connections)
                        c = self.ensure_node(*to)
                        c.set_meta_string('master', conn_txt)
                        print 'connected',name,'for',c.id(),'from',conn_txt
Example #4
0
    def rpc_dinfo(self, a):
        path = logic.parse_clause(a)
        l = []
        l.append(('dinfo_id', self.__selected or path))

        if self.__selected:
            x = self.read_script(self.__selected)
            if x:
                (n, d, sc, rn) = x

                if rn:
                    l.append(('name', "%s (%s)" % (n, rn)))
                else:
                    l.append(('name', n))

                l.append(('', ''))

                for (i, di) in enumerate(d):
                    l.append(('description' if i == 0 else '', di))

                if self.__status:
                    l.append(('', ''))
                    l.append(('status', self.__status))

        return logic.render_term(logic.make_term('keyval', tuple(l)))
Example #5
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='labeler',
                             ordinal=ordinal)

        self.domain = piw.clockdomain_ctl()

        self[1] = atom.Atom(
            domain=domain.Aniso(hints=(logic.make_term('continuous'), )),
            names='controller output',
            policy=atom.readonly_policy())

        self[2] = atom.Atom(domain=domain.String(),
                            init='Label',
                            names='label category',
                            policy=atom.default_policy(self.__set_category))
        self[3] = atom.Atom(domain=domain.String(),
                            init='',
                            names='label',
                            policy=atom.default_policy(self.__set_label))

        self.ctl_functor = piw.functor_backend(1, True)
        self.ctl_input = bundles.VectorInput(self.ctl_functor.cookie(),
                                             self.domain,
                                             signals=(1, ))
        self[4] = atom.Atom(domain=domain.Aniso(),
                            policy=self.ctl_input.vector_policy(1, False),
                            names='controller input')
        self.ctl_functor.set_functor(
            piw.pathnull(0),
            utils.make_change_nb(
                piw.slowchange(utils.changify(self.__controller_input))))

        self.__ctl = []
Example #6
0
    def attach(self,*args):
        c = []
        for i,a in enumerate(args):
            (id,ch) = a.args
            c.append(logic.make_term('conn',i,self.__key.index,id,ch))

        self[1].set_connections(logic.render_termlist(c))
Example #7
0
 def destroy(self):
     # remove this widget from the targets controllers
     address = self.get_property_string('target-id')
     myrid = paths.to_relative(self.id(), scope=paths.id2scope(address))
     cs = logic.render_term(
         logic.make_term('conn', None, None, myrid, None, 'ctl'))
     if address != '':
         rpc.invoke_rpc(address, 'disconnect', cs)
Example #8
0
 def __init__(self, source, sample_rate, buffer_size, hints=()):
     Domain.__init__(self, hints)
     self.sample_rate = int(sample_rate)
     self.buffer_size = int(buffer_size)
     self.source = source
     self.name = str(
         logic.make_term('iso', self.source, self.sample_rate,
                         self.buffer_size, hints))
Example #9
0
    def upgrade_1_0_1_to_1_0_2(self, tools, address):
        # assign canonical ordinals to agents

        n2 = tools.get_root(address).get_node(2)
        old_plugins = logic.parse_termlist(
            n2.get_data().as_dict_lookup('agents').as_string())
        plugs_by_type = {}

        for old_term in old_plugins:
            (paddress, plugin, pversion, pcversion) = old_term.args
            pmeta = tools.get_root(paddress).get_data()
            pname = pmeta.as_dict_lookup('name')
            pordinal = pmeta.as_dict_lookup('ordinal')

            if not pname.is_string() or not pname.as_string():
                pname = plugin
            else:
                pname = pname.as_string()

            pname = pname.split()
            try:
                pname.remove('agent')
            except:
                pass
            pname = '_'.join(pname)

            if not pordinal.is_long() or not pordinal.as_long():
                pordinal = 0
            else:
                pordinal = pordinal.as_long()

            plugs_by_type.setdefault(plugin, []).append(
                [paddress, plugin, pversion, pcversion, pname, pordinal, 0])

        plugins = []

        for (ptype, plist) in plugs_by_type.iteritems():
            ords_used = set()
            max_ord = 0

            for p in plist:
                if ptype == p[4] and p[5] and p[5] not in ords_used:
                    p[6] = p[5]
                    ords_used.add(p[5])
                    max_ord = max(max_ord, p[5])

            for p in plist:
                if not p[6]:
                    max_ord += 1
                    p[6] = max_ord

                new_term = logic.make_term('a', p[0], p[1], p[2], p[3], p[6])
                plugins.append(new_term)

        n2.set_data(
            piw.dictset(piw.dictnull(0), 'agents',
                        piw.makestring(logic.render_termlist(plugins), 0)))
Example #10
0
 def setup(self,address,name):
     self.set_property_long('ref-count',1)
     self.set_property_string('target-name',name)
     self.set_property_string('target-id',address)
     cs = logic.render_term(logic.make_term('ctl',self.id(),None))
     if address!='':
         return rpc.invoke_rpc(address,'control',cs)
     else:
         return False
Example #11
0
 def setup(self, address, name):
     myrid = paths.to_relative(self.id(), scope=paths.id2scope(address))
     self.set_property_long('ref-count', 1)
     self.set_property_string('target-name', name)
     self.set_property_string('target-id', address)
     cs = logic.render_term(
         logic.make_term('conn', None, None, myrid, None, 'ctl'))
     if address != '':
         return rpc.invoke_rpc(address, 'connect', cs)
     else:
         return False
Example #12
0
    def rpc_lexicon(self,arg):
        l = self.database.get_lexicon()
        t = l.get_timestamp()
        d = [ x for x in l.lexicon_iter() ]
        nd = len(d)
        i = int(arg)

        if i<0 or i>=nd:
            return async.success('%s:%d:' % (t,nd))

        d = d[i:i+100]
        ds = logic.render_termlist([logic.make_term(e,m,c) for (e,(m,c)) in d])
        return '%s:%d:%s' % (t,nd,ds)
Example #13
0
 def move_connection(self,old_id,new_id):
     print self.id(),'replacing',old_id,'with',new_id
     conn = self.get_meta('master')
     if conn and conn.is_string() and conn.as_string():
         conn_parsed = logic.parse_termlist(conn.as_string())
         conn_replaced = []
         for c in conn_parsed:
             if c.args[2] == old_id:
                 conn_replaced.append(logic.make_term(c.pred,c.args[0],c.args[1],new_id,c.args[3]))
             else:
                 conn_replaced.append(c)
         conn_new = logic.render_termlist(conn_replaced)
         self.set_meta_string('master',conn_new)
         print self.id(),'replaced',conn,'with',conn_new
Example #14
0
def upgrade_plugins_v0(tools, address):
    n2 = tools.root(address).get_node(2)
    for n in n2.iter(extension=253):
        n3 = n.get_node(255, 6)
        old_term = logic.parse_term(n3.get_string())
        (address, plugin, version, cversion) = old_term.args
        map = tools.mapping.get(address)
        if map:
            (nplugin, nversion, ncversion) = map[1].split(':')
            new_term = logic.make_term(old_term.pred, address, plugin,
                                       nversion, ncversion)
            n3.set_string(str(new_term))

    return True
Example #15
0
    def __init__(self, signal, iso, continuous=False, **kwds):
        assert 'domain' not in kwds
        self.signal = signal
        self.iso = iso

        if continuous:
            self.hints = (logic.make_term('continuous'),)
        else:
            self.hints = ()

        if iso:
            dom = domain.Null(hints=self.hints)
        else:
            dom = domain.Aniso(hints=self.hints)

        atom.Atom.__init__(self, policy=BundleOutputPolicy(), domain=dom, **kwds)
Example #16
0
    def create_agent(self, agent, ordinal):
        print 'backend create agent', agent, ordinal
        plugin_def = logic.make_term('module', agent, ordinal)
        r = rpc.invoke_rpc(self.__database.to_usable_id('<eigend1>'),
                           'addmodule', logic.render_term(plugin_def))

        yield (r)
        if not r.status():

            print 'addmodule failed', agent, ordinal, r.args()[0]

            self.__frontend.report_error(
                'eigenD could not create agent ' + agent + ' ' + str(ordinal),
                r.args()[0])
            yield async .Coroutine.failure('rpc_addmodule failed')

        yield async .Coroutine.success()
Example #17
0
    def upgrade_1_0_0_to_1_0_1(self, tools, address):
        plugins = []
        n2 = tools.get_root(address).get_node(2)
        for n in n2.iter(extension=253, exclude=[254, 255]):
            n3 = n.get_node(255)
            old_term = logic.parse_term(n3.get_data().as_string())
            (address, plugin, version, cversion) = old_term.args
            ncversion = tools.newcversion(address)
            nversion = tools.newrversion(address)
            nplugin = tools.canonical_name(address)
            new_term = logic.make_term('a', address, nplugin, nversion,
                                       ncversion)
            plugins.append(new_term)

        n2.erase_children()
        n2.set_data(
            piw.dictset(piw.dictnull(0), 'agents',
                        piw.makestring(logic.render_termlist(plugins), 0)))
Example #18
0
def upgrade_plugins_v1(tools, address):
    n2 = tools.get_root(address).get_node(2)
    old_plugins = logic.parse_termlist(
        n2.get_data().as_dict_lookup('agents').as_string())
    new_plugins = []

    for old_term in old_plugins:
        (address, plugin, version, cversion, ordinal) = old_term.args
        ncversion = tools.newcversion(address)
        nversion = tools.newrversion(address)
        nplugin = tools.canonical_name(address)
        new_term = logic.make_term(old_term.pred, address, nplugin, nversion,
                                   ncversion, ordinal)
        new_plugins.append(new_term)

    n2.set_data(
        piw.dictset(piw.dictnull(0), 'agents',
                    piw.makestring(logic.render_termlist(new_plugins), 0)))
Example #19
0
    def __substitute_connection(self, tgt, old_id, new_id):
        (s, p) = paths.breakid_list(tgt)
        root = self.root(s)
        atom = root.get_node(*p)
        if atom is None: return
        conn = atom.get_node(255, 2)
        if conn is None: return
        old_conn = logic.parse_clauselist(conn.get_string_default(''))
        new_conn = []

        for c in old_conn:
            if c.args[2] == old_id:
                new_conn.append(
                    logic.make_term(c.pred, c.args[0], c.args[1], new_id,
                                    c.args[3]))
            else:
                new_conn.append(c)

        conn.set_string(logic.render_termlist(new_conn))
Example #20
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='audio unit',
                             container=100,
                             ordinal=ordinal)

        self.__state = PluginState(self.__plugin_state_loaded)
        self.set_private(self.__state)

        self.__browser = PluginBrowser(self)
        self.__domain = piw.clockdomain_ctl()
        self.__audio_output = audio.AudioOutput(bundles.Splitter(
            self.__domain),
                                                1,
                                                2,
                                                names='channels')
        self.__audio_output_channels = audio.AudioChannels(self.__audio_output)
        self.__midi_output = bundles.Splitter(self.__domain)
        self.__observer = PluginObserver(self.__state, self)
        self.host = host_native.plugin_instance(
            self.__observer, self.__domain, self.__audio_output.cookie(),
            self.__midi_output.cookie(),
            utils.statusify(self.__window_state_changed))
        self.parameter_list = inputparameter.List(self.host,
                                                  self.host.clock_domain(),
                                                  self.verb_container())
        self.__audio_input = audio.AudioInput(bundles.ScalarInput(
            self.host.audio_input_cookie(),
            self.__domain,
            signals=range(1, 65)),
                                              1,
                                              2,
                                              names='channels')
        self.__audio_input_channels = audio.AudioChannels(self.__audio_input)
        self.__key_input = bundles.VectorInput(
            self.host.midi_from_belcanto_cookie(),
            self.__domain,
            signals=(1, 2))
        self.__midi_input = bundles.ScalarInput(
            self.host.midi_aggregator_cookie(), self.__domain, signals=(1, ))
        self.__metronome_input = bundles.ScalarInput(
            self.host.metronome_input_cookie(),
            self.__domain,
            signals=(1, 2, 3, 4))
        self.host.set_bypassed(True)

        # plugin browser
        self[1] = self.__browser

        # audio output
        self[2] = atom.Atom(names='audio outputs')
        self[2][1] = self.__audio_output
        self[2][2] = self.__audio_output_channels

        # audio input
        self[3] = atom.Atom(names='audio inputs')
        self[3][1] = self.__audio_input
        self[3][2] = self.__audio_input_channels

        # parameter mapping
        self[4] = self.parameter_list

        # metronome input
        self[5] = atom.Atom(names='metronome inputs')
        self[5][1] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__metronome_input.nodefault_policy(
                                   1, False),
                               names='song beat input')
        self[5][2] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__metronome_input.nodefault_policy(
                                   2, False),
                               names='running input')
        self[5][3] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__metronome_input.nodefault_policy(
                                   3, False),
                               names='tempo input')
        self[5][4] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__metronome_input.nodefault_policy(
                                   4, False),
                               names='bar beat input')

        # kbd/controller inputs
        self[6] = atom.Atom(names='musical inputs')
        self[6][1] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__key_input.vector_policy(1, False),
                               names='pressure input')
        self[6][2] = atom.Atom(domain=domain.Aniso(),
                               policy=self.__key_input.merge_nodefault_policy(
                                   2, False),
                               names='frequency input')

        # midi channel
        self[7] = atom.Atom(domain=domain.BoundedInt(0, 20),
                            init=0,
                            names='midi channel',
                            policy=atom.default_policy(self.set_midi_channel))

        # velocity curve control
        vel = (T('stageinc', 0.1), T('inc', 0.1), T('biginc',
                                                    1), T('control', 'updown'))
        self[8] = atom.Atom(names='velocity curve controls')
        self[8][1] = atom.Atom(domain=domain.BoundedInt(1, 1000),
                               init=4,
                               names='velocity sample',
                               policy=atom.default_policy(
                                   self.__set_velocity_samples))
        self[8][2] = atom.Atom(domain=domain.BoundedFloat(0.1, 10, hints=vel),
                               init=4,
                               names='velocity curve',
                               policy=atom.default_policy(
                                   self.__set_velocity_curve))
        self[8][3] = atom.Atom(domain=domain.BoundedFloat(0.1, 10, hints=vel),
                               init=4,
                               names='velocity scale',
                               policy=atom.default_policy(
                                   self.__set_velocity_scale))

        self[9] = atom.Atom(domain=domain.Bool(),
                            init=True,
                            names='tail time enable',
                            policy=atom.default_policy(
                                self.__set_tail_time_enabled))
        self[10] = atom.Atom(domain=domain.BoundedFloatOrNull(0, 100000),
                             init=10,
                             names='tail time',
                             policy=atom.default_policy(self.__set_tail_time))
        self[11] = atom.Atom(domain=domain.BoundedInt(1, 16),
                             init=1,
                             names='minimum channel',
                             policy=atom.default_policy(self.set_min_channel))
        self[12] = atom.Atom(domain=domain.BoundedInt(1, 16),
                             init=16,
                             names='maximum channel',
                             policy=atom.default_policy(self.set_max_channel))

        # other global settings inputs
        self[20] = atom.Atom(domain=domain.BoundedInt(0, 100),
                             init=0,
                             names="minimum decimation",
                             policy=atom.default_policy(
                                 self.set_min_decimation))
        self[21] = atom.Atom(domain=domain.Bool(),
                             init=True,
                             names="notes enable",
                             policy=atom.default_policy(self.set_midi_notes))
        self[22] = atom.Atom(domain=domain.Bool(),
                             init=True,
                             names="pitch bend enable",
                             policy=atom.default_policy(
                                 self.set_midi_pitchbend))
        self[23] = atom.Atom(domain=domain.Bool(),
                             init=False,
                             names="high resolution velocity enable",
                             policy=atom.default_policy(
                                 self.set_midi_hires_velocity))
        self[24] = atom.Atom(domain=domain.BoundedInt(0, 96),
                             init=1,
                             names="pitch bend range upper",
                             policy=atom.default_policy(self.set_pitchbend_up))
        self[25] = atom.Atom(domain=domain.BoundedInt(0, 96),
                             init=1,
                             names="pitch bend range lower",
                             policy=atom.default_policy(
                                 self.set_pitchbend_down))

        # status output to drive the talker lights
        self[13] = bundles.Output(1, False, names='status output')
        self.light_output = bundles.Splitter(self.__domain, self[13])
        self.lights = piw.lightsource(piw.change_nb(), 0,
                                      self.light_output.cookie())
        self.lights.set_size(2)
        self.set_light(1, True)
        self.set_light(2, False)

        # midi I/O
        # midi input
        self[14] = atom.Atom(domain=domain.Aniso(),
                             policy=self.__midi_input.nodefault_policy(
                                 1, False),
                             names='midi input')
        # midi output
        self[15] = self.__midi_output.add_output(
            bundles.Output(1, False, names='midi output'))

        # controller input/output to add labels
        self[16] = atom.Atom(
            domain=domain.Aniso(hints=(logic.make_term('continuous'), )),
            names='controller output',
            policy=atom.readonly_policy())

        self[17] = atom.Atom(domain=domain.String(),
                             init='Plugin',
                             names='label category',
                             policy=atom.default_policy(self.__set_category))
        self[18] = atom.Atom(domain=domain.String(),
                             init='',
                             names='label',
                             policy=atom.default_policy(self.__set_label))

        self.ctl_functor = piw.functor_backend(1, True)
        self.ctl_input = bundles.VectorInput(self.ctl_functor.cookie(),
                                             self.__domain,
                                             signals=(1, ))
        self[19] = atom.Atom(domain=domain.Aniso(),
                             policy=self.ctl_input.vector_policy(1, False),
                             names='controller input')
        self.ctl_functor.set_functor(
            piw.pathnull(0),
            utils.make_change_nb(
                piw.slowchange(utils.changify(self.__controller_input))))

        self.__ctl = []

        # verbs
        self.add_verb2(1, 'show([],None)', callback=self.__show)
        self.add_verb2(2, 'show([un],None)', callback=self.__unshow)
        self.add_verb2(3, 'close([],None)', callback=self.__close)
        self.add_verb2(4,
                       'bypass([toggle],None)',
                       callback=self.__tog_bypass,
                       status_action=self.__status_bypass)
        self.add_verb2(5,
                       'show([toggle],None)',
                       callback=self.__tog_show,
                       status_action=self.__status_show)
        self.add_verb2(6,
                       'open([],None,role(None,[abstract]))',
                       callback=self.__open)
        self.add_verb2(7,
                       'scan([],None)',
                       callback=self.__browser.refresh_plugin_list)
        self.add_verb2(8, 'bypass([],None)', callback=self.__bypass)
        self.add_verb2(9, 'bypass([un],None)', callback=self.__unbypass)

        # control change
        self.add_verb2(
            10,
            'set([],~a,role(None,[matches([midi,program])]),role(to,[numeric]))',
            create_action=self.__set_program_change)
        self.add_verb2(
            11,
            'set([],~a,role(None,[matches([midi,bank])]),role(to,[numeric]))',
            create_action=self.__set_bank_change)
        self.add_verb2(
            12,
            'set([],~a,role(None,[mass([midi,controller])]),role(to,[numeric]))',
            create_action=self.__set_midi_control)

        self.set_ordinal(ordinal)
Example #21
0
    def phase2_1_0_1(self,tools,address):
        print 'upgrading plugin host',address
        root = tools.get_root(address)
        freq_input = root.ensure_node(6,2)
        scaler_conn = freq_input.get_master()
        if not scaler_conn: return
        scaler_addr = paths.id2server(scaler_conn[0])
        scaler_root = tools.get_root(scaler_addr)
        if not scaler_root: return
        scaler_type = scaler_root.get_meta_string('plugin')
        if scaler_type != 'scaler': return
        print 'scaler is',scaler_addr
        scaler_pressure_input = scaler_root.get_node(4,2)
        recorder_conn = scaler_pressure_input.get_master()
        if not recorder_conn: return
        recorder_addr = paths.id2server(recorder_conn[0])
        recorder_root = tools.get_root(recorder_addr)
        if not recorder_root: return
        recorder_type = recorder_root.get_meta_string('plugin')
        if recorder_type != 'recorder': return
        print 'recorder is',recorder_addr

        canonical_names = {}
        available_sources = {}
        blocked_sources = []

        available_sources['pressure'] = paths.makeid_list(scaler_addr,1,2)
        available_sources['roll'] = paths.makeid_list(scaler_addr,1,3)
        available_sources['yaw'] = paths.makeid_list(scaler_addr,1,4)

        for (k,v) in available_sources.items():
            canonical_names[v] = k

        for i in range(5,15):
            recorder_input = recorder_root.get_node(1,i)
            if recorder_input:
                input_name = recorder_input.get_name()
                input_conn = recorder_input.get_master()
                output_id = paths.makeid_list(recorder_addr,2,i)
                if not input_conn:
                    blocked_sources.append(output_id)
                    print 'unavailable input',output_id
                    continue
                upstream_addr,upstream_path = paths.breakid_list(input_conn[0])
                upstream_root = tools.get_root(upstream_addr)
                if not upstream_root: continue
                upstream = upstream_root.get_node(*upstream_path)
                if not upstream: continue
                upstream_name = upstream.get_name().split()
                if 'output' in upstream_name: upstream_name.remove('output')
                upstream_name = ' '.join(upstream_name)
                if upstream_name == 'controller': continue
                print 'recorder output',i,'at',output_id,'called',input_name,'connected to',upstream_name
                available_sources[upstream_name] = output_id
                canonical_names[output_id] = upstream_name

        for n,id in available_sources.items():
            print 'source',n,'at',id

        current_parms = {}
        unused_parms = range(1,16)
        existing_names = []

        for k in range(1,16):
            parm_node = root.get_node(4,k)
            parm_name = parm_node.get_name()
            if not parm_node: continue
            parm_conn = parm_node.get_master()
            if not parm_conn: continue
            parm_master = parm_conn[0]

            if parm_master in canonical_names:
                parm_name = canonical_names[parm_master]
            else:
                split_name = parm_name.split()
                kstr = str(k)
                if split_name and split_name[-1]==kstr:
                    parm_name = ' '.join(split_name[:-1])

            if parm_master not in current_parms:
                current_parms[parm_master] = (k,parm_name)
                existing_names.append(parm_name)
                print 'existing source',k,'called',parm_name,'connected to',parm_master
                unused_parms.remove(k)

        for pname,pmaster in available_sources.items():
            if pmaster not in current_parms and pname not in existing_names:
                if unused_parms:
                    k = unused_parms[0]
                    unused_parms = unused_parms[1:]
                    current_parms[pmaster] = (k,pname)
                    print 'adding available source',k,pname,'from',pmaster


        print 'parameter map:'
        for pmaster,(k,pname) in current_parms.items():
            print 'parameter',k,'called',pname,'connected to',pmaster

        for k in range(1,17):
            parm_node = root.ensure_node(4,k)
            parm_node.set_meta('master',piw.data())
            parm_node.set_name('parameter %d' % k)
            
        for pmaster,(k,pname) in current_parms.items():
            if pmaster in blocked_sources:
                continue
            conn = logic.make_term('conn',None,None,pmaster,None)
            conn_txt = logic.render_term(conn)
            parm_node = root.ensure_node(4,k)
            parm_node.set_meta_string('master',conn_txt)
            parm_node.set_name(pname)
            print 'connected',parm_node.id(),'to',conn_txt,'called',pname,'parameter',k

        conn = logic.make_term('conn',None,None,paths.makeid_list(scaler_addr,1,2),None)
        conn_txt = logic.render_term(conn)
        parm_node = root.ensure_node(4,16)
        parm_node.set_meta_string('master',conn_txt)
        parm_node.set_name('key position')

        local_map = {}

        self.check_midi_controller(root,(6,4),7,current_parms,local_map) # volume
        self.check_midi_controller(root,(6,5),1,current_parms,local_map) # modwheel
        self.check_midi_controller(root,(6,6),10,current_parms,local_map) # pan
        self.check_midi_controller(root,(6,7),4,current_parms,local_map) # foot pedal
        self.check_midi_controller(root,(6,8),11,current_parms,local_map) # expression
        self.check_midi_controller(root,(6,9),130,current_parms,local_map) # channel pressure
        self.check_midi_controller(root,(6,10),128,current_parms,local_map) # poly pressure
        self.check_midi_controller(root,(6,11),131,current_parms,local_map) # pitch bend
        self.check_midi_controller(root,(6,12),64,current_parms,local_map) # sustain pedal

        print 'local map',local_map

        map_node = root.ensure_node(255,5)
        map_data = map_node.get_data()
        map_list = []

        if map_data.is_string() and map_data.as_string() and map_data.as_string() != '[]':
            print 'map data',map_data.as_string()
            map_term = logic.parse_term(map_data.as_string())
            map_list = map_term.args

        bits_14 = set([0x07,0x01,0x0a,0x04,0x0b])

        for cc,p in local_map.items():
            ccl = (cc+32) if cc<32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list=list(map_list)
            map_list.append(logic.make_term('c',p,cc,1.0,0,0,1.0,True,const.scope_pernote,res,ccl))

        map_term = logic.make_term('mapping',*map_list)
        map_node.set_data(piw.makestring(logic.render_term(map_term),0))
Example #22
0
    def phase2_1_0_2(self, tools, address):
        print 'upgrading converter', address
        root = tools.get_root(address)
        freq_input = root.ensure_node(2, 2)
        scaler_conn = freq_input.get_master()
        if not scaler_conn: return
        scaler_addr = paths.id2server(scaler_conn[0])
        scaler_root = tools.get_root(scaler_addr)
        if not scaler_root: return
        scaler_type = scaler_root.get_meta_string('plugin')
        if scaler_type != 'scaler': return
        print 'scaler is', scaler_addr
        scaler_pressure_input = scaler_root.get_node(4, 2)
        recorder_conn = scaler_pressure_input.get_master()
        if not recorder_conn: return
        recorder_addr = paths.id2server(recorder_conn[0])
        recorder_root = tools.get_root(recorder_addr)
        if not recorder_root: return
        recorder_type = recorder_root.get_meta_string('plugin')
        if recorder_type != 'recorder': return
        print 'recorder is', recorder_addr

        available_sources = {}
        available_sources['pressure'] = paths.makeid_list(scaler_addr, 1, 2)
        available_sources['roll'] = paths.makeid_list(scaler_addr, 1, 3)
        available_sources['yaw'] = paths.makeid_list(scaler_addr, 1, 4)
        available_sources['key position'] = paths.makeid_list(
            scaler_addr, 1, 2)

        for i in range(5, 15):
            recorder_input = recorder_root.get_node(1, i)
            if recorder_input:
                input_name = recorder_input.get_name()
                input_conn = recorder_input.get_master()
                if not input_conn: continue
                upstream_addr, upstream_path = paths.breakid_list(
                    input_conn[0])
                upstream_root = tools.get_root(upstream_addr)
                if not upstream_root: continue
                upstream = upstream_root.get_node(*upstream_path)
                if not upstream: continue
                upstream_name = upstream.get_name().split()
                if 'output' in upstream_name: upstream_name.remove('output')
                upstream_name = ' '.join(upstream_name)
                if upstream_name == 'controller': continue
                output_id = paths.makeid_list(recorder_addr, 2, i)
                print 'recorder output', i, 'at', output_id, 'called', input_name, 'connected to', upstream_name
                available_sources[upstream_name] = output_id

        for n, id in available_sources.items():
            print 'source', n, 'at', id

        desired_sources = {
            'pressure': 1,
            'roll': 2,
            'yaw': 3,
            'breath': 4,
            'strip position 1': 5,
            'absolute strip 1': 6,
            'strip position 2': 7,
            'absolute strip 2': 8,
            'pedal 1': 9,
            'pedal 2': 10,
            'pedal 3': 11,
            'pedal 4': 12,
            'key position': 16,
        }

        active_sources = {}

        for k in range(1, 17):
            parm_node = root.ensure_node(12, k)
            parm_node.set_meta('master', piw.data())
            parm_node.set_name('parameter %d' % k)

        for k, v in desired_sources.items():
            if k in available_sources:
                conn = logic.make_term('conn', None, None,
                                       available_sources[k], None)
                conn_txt = logic.render_term(conn)
                parm_node = root.ensure_node(12, v)
                parm_node.set_meta_string('master', conn_txt)
                parm_node.set_name(k)
                if v < 16:  # dont map anything to key position
                    active_sources[available_sources[k]] = v
                print 'connected', parm_node.id(), 'to', conn_txt, 'called', k

        print 'checking for midi output', active_sources

        my_controller = None

        all_agents = tools.get_agents()
        for agent in all_agents:
            agent_root = tools.get_root(agent)
            if not agent_root: continue
            agent_type = agent_root.get_meta_string('plugin')
            if agent_type != 'midi_output': continue
            agent_midi_input = agent_root.get_node(2)
            if not agent_midi_input: continue
            agent_conn = [
                paths.id2server(i) for i in agent_midi_input.get_master()
            ]
            print agent, 'is midi output', agent_conn, root.id()
            if root.id() not in agent_conn: continue
            print 'my midi output', agent
            for i in agent_conn:
                controller_root = tools.get_root(i)
                controller_type = controller_root.get_meta_string('plugin')
                if controller_type != 'midi_controller': continue
                my_controller = controller_root
                break
            if my_controller: break

        if not my_controller: return

        cc1 = self.get_midi_cc(my_controller, 1)
        cc2 = self.get_midi_cc(my_controller, 2)
        cc3 = self.get_midi_cc(my_controller, 3)
        cc4 = self.get_midi_cc(my_controller, 4)

        print 'midi controller', my_controller.id(), cc1, cc2, cc3, cc4

        global_map = {}

        self.check_midi_controller(my_controller, (2, 1), 7, active_sources,
                                   global_map)  # volume
        self.check_midi_controller(my_controller, (2, 2), 1, active_sources,
                                   global_map)  # modwheel
        self.check_midi_controller(my_controller, (2, 3), 10, active_sources,
                                   global_map)  # pan
        self.check_midi_controller(my_controller, (2, 4), 4, active_sources,
                                   global_map)  # foot pedal
        self.check_midi_controller(my_controller, (2, 5), 11, active_sources,
                                   global_map)  # EXPRESSION
        self.check_midi_controller(my_controller, (2, 6), 130, active_sources,
                                   global_map)  # channel pressure
        self.check_midi_controller(my_controller, (2, 7), 131, active_sources,
                                   global_map)  # pitch bend
        self.check_midi_controller(my_controller, (2, 8), 64, active_sources,
                                   global_map)  # sustain pedal
        self.check_midi_controller(my_controller, (2, 9), cc1, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 10), cc2, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 11), cc3, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 12), cc4, active_sources,
                                   global_map)

        local_map = {}

        self.check_midi_controller(root, (2, 4), 7, active_sources,
                                   local_map)  # volume
        self.check_midi_controller(root, (2, 5), 1, active_sources,
                                   local_map)  # modwheel
        self.check_midi_controller(root, (2, 6), 10, active_sources,
                                   local_map)  # pan
        self.check_midi_controller(root, (2, 7), 4, active_sources,
                                   local_map)  # foot pedal
        self.check_midi_controller(root, (2, 8), 11, active_sources,
                                   local_map)  # expression
        self.check_midi_controller(root, (2, 9), 130, active_sources,
                                   local_map)  # channel pressure
        self.check_midi_controller(root, (2, 10), 128, active_sources,
                                   local_map)  # poly pressure
        self.check_midi_controller(root, (2, 11), 131, active_sources,
                                   local_map)  # pitch bend
        self.check_midi_controller(root, (2, 12), 64, active_sources,
                                   local_map)  # sustain pedal

        print 'per key mappings', local_map
        print 'global mappings', global_map

        map_node = root.ensure_node(255, 1)
        map_data = map_node.get_data()
        map_list = []

        if map_data.is_string() and map_data.as_string(
        ) and map_data.as_string() != '[]':
            print 'map data', map_data.as_string()
            map_term = logic.parse_term(map_data.as_string())
            map_list = map_term.args

        bits_14 = set([0x07, 0x01, 0x0a, 0x04, 0x0b])

        for cc, p in local_map.items():
            ccl = (cc + 32) if cc < 32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list = list(map_list)
            map_list.append(
                logic.make_term('c', p, cc, 1.0, 0, 0, 1.0, True,
                                const.scope_pernote, ccl, ccl))

        for cc, p in global_map.items():
            ccl = (cc + 32) if cc < 32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list.append(
                logic.make_term('c', p, cc, 1.0, 0, 0, 1.0, True,
                                const.scope_global, ccl, ccl))

        map_term = logic.make_term('mapping', *map_list)
        map_node.set_data(piw.makestring(logic.render_term(map_term), 0))
Example #23
0
 def create_echo(self,trigger,text):
     print 'create echo for',text,'trigger',trigger
     self.verb_defer(30,trigger,trigger,None,(logic.make_term('abstract',tuple(text.split(' '))),))
Example #24
0
 def destroy(self):
     # remove this widget from the targets controllers
     cs = logic.render_term(logic.make_term('ctl',self.id(),None))
     address = self.get_property_string('target-id')
     if address!='':
         rpc.invoke_rpc(address,'uncontrol',cs)