Beispiel #1
0
 def get_mixer_value(self, desc, handler=None):
     addr = Capture.get_addr(desc)
     size = Capture.get_size(desc)
     message = Roland.receive_data(addr, size)
     if handler is not None:
         self.listener.register_addr(addr, handler)
     return self.send(message)
Beispiel #2
0
def reverb_page():
    reverb = Capture.get_subtree('reverb').keys()
    params = Capture.get_subtree('reverb.echo')

    tmpl = env.from_string("""
Reverb is organized so that the timing parameters for each type of reverb are independent.

Base address: {{ hex(base) }} H

Reverb types:

{% for value, verb in types %}
{% set offset = get_addr('reverb.'+verb) %}
{{ "%02x" % value }}: {{ verb.ljust(10) }}  {{ "memory offset: " + hex(offset) if offset else "" }}
{% endfor %}

Parameters:

{% for param, offset in params %}
{% if param != 0 %}
{{ "%02x" % offset }}: {{ str(param).ljust(10) }}
{% endif %}
{% endfor %}
	""")
    return tmpl.render(hex=render_bytes,
                       types=enumerate(ReverbType().values()),
                       params=params.items(),
                       str=str,
                       get_addr=get_addr,
                       base=Capture.get_addr('reverb'))
Beispiel #3
0
def print_addr_description(desc, mask):
    addr = Capture.get_addr(desc)
    b = render_bytes(addr)
    s = desc.split('.')
    title = desc  #s[-1]
    indent = ""  # "  " * (len(s)-1)
    print("%s\t%s%s" % (b, indent, title))
Beispiel #4
0
    def notify_control(self, control):
        widget = self.window.get_control(control)
        if not widget: return

        addr = Capture.get_addr(control)
        value = self.mixer.memory.get_value(addr)

        self.debug("notify_control " + control + " to " + value.format())
        widget.block()
        widget.set_value(value)
        widget.unblock()
        widget.update_label(value.format())
Beispiel #5
0
    def wait_for_value(self, control):
        timeout = 10
        waited = 0
        delay = 0.05

        addr = Capture.get_addr(control)
        while waited < timeout:
            value = self.mixer.memory.get_value(addr)
            if value.value is not None:
                break
            time.sleep(delay)
            waited += delay
        return value
Beispiel #6
0
def print_memory_table(elements):
    masks = [0, 0, 0, 0, 0]
    mask = None

    for a in elements:
        dots = a.count('.')
        mask = get_mask(Capture.get_subtree(a))
        if mask:
            masks[dots] = mask
        else:
            mask = (masks[dots - 1] ^ 0xffffffff)  #or (pmask ^ 0xffffffff)
            #mask = None
        print("%08x" % mask if mask is not None else "-\t", end=" ")
        print_addr_description(a, mask)
Beispiel #7
0
    def set(self, control, new_value):
        self.setup_interface()
        self.setup_midi()

        addr = Capture.get_addr(control)
        value = self.interface.parse_value(control, new_value)
        if value is None:
            print("Unrecognized value for %s: %s" %
                  (control.split('.')[-1], new_value))
        else:
            self.set_mixer_value(addr, value.pack())
            value = self.interface.wait_for_value(control)
            print(value.format())
        self.cleanup()
Beispiel #8
0
    def render(self):
        ret = ""
        selected_control = ""
        spacing = self.page.spacing
        max_width = max(len(row) for row in self.controls)
        ret += "\033[2K"
        ret += "%s\033[0m" % TerminalMixer.highlight(
            self.legend(), self.get_highlight_for_page())
        ret += " \033[4m %s \033[0m" % self.page_name
        ret += "\n\033[2K\n\033[2K"
        ret += '\033[1;30m'
        ret += ''.join(h[0:spacing].center(spacing) if i < max_width else h
                       for i, h in enumerate(self.header))
        ret += '\033[0m'
        ret += "\n\033[2K"
        labels = self.page.get_labels()
        for r, row in enumerate(self.controls):
            w = spacing * int(max_width / len(row))
            for c, control in enumerate(row):
                active = False
                if control is None:
                    formatted = ' '
                else:
                    addr = Capture.get_addr(control)
                    value = self.memory.get_value(addr)
                    if isinstance(value, Bool) and value.value:
                        active = True
                    formatted = self.memory.get_formatted(addr)
                if self.cursor.x == c and self.cursor.y == r:
                    ret += "\033[7m"
                    selected_control = control
                else:
                    ret += "\033[0m"
                if active:
                    ret += "\033[1m"
                ret += formatted.center(w)
            ret += "\033[0m"
            if labels is not None and r < len(labels):
                label = labels[r]
                if label is not None:
                    if len(label) > 0 and label[0] == "*":
                        ret += " \033[0;4m%s\033[24m" % label[1:]
                    else:
                        ret += " \033[1;30m%s\033[0m" % label
            ret += "\n\033[2K"

        ret += "\n\033[2K%s\n" % (selected_control or '')
        return ret
Beispiel #9
0
 def get_selected_addr(self):
     control = self.get_selected_control()
     if control is None:
         return None
     return Capture.get_addr(control)
Beispiel #10
0
	def test_memory_lookup(self):
		self.assertEqual(0x00061208, Capture.get_addr("input_monitor.b.channel.3.volume"))
		self.assertEqual(0x0006230e, Capture.get_addr("input_monitor.c.channel.4.reverb"))
		with self.assertRaises(Exception) as ctx:
			Capture.get_addr("daw_monitor.c.channel.4.reverb")
		self.assertEqual(0x00050b07, Capture.get_addr("preamp.channel.12.gate"))
		self.assertEqual(0x00050003, Capture.get_addr("preamp.channel.1.hi-z"))
		self.assertEqual(0x00050103, Capture.get_addr("preamp.channel.2.hi-z"))
		with self.assertRaises(Exception) as ctx:
			Capture.get_addr("preamp.channel.3.hi-z")

		self.assertEqual(0x00030001, Capture.get_addr("patchbay.3-4"))
		self.assertEqual(0x00040000, Capture.get_addr("reverb.type"))
		self.assertEqual(0x00040101, Capture.get_addr("reverb.echo.pre_delay"))
Beispiel #11
0
	def test_all_memory(self):
		names = Capture.memory_names()
		self.assertIsInstance(names, list)
		{ name:Capture.get_addr(name) for name in names }
Beispiel #12
0
 def list_controls(self):
     for control in Capture.memory_names():
         if control.count('.') < 1: continue
         print(control)
Beispiel #13
0
def get_addr(control):
    try:
        return Capture.get_addr(control)
    except:
        return None
Beispiel #14
0
def prefixed(desc):
    return [
        '%s.%s' % (desc, x) for x in nonzero(Capture.get_subtree(desc).keys())
    ]
Beispiel #15
0
def print_memory_table(elements):
    masks = [0, 0, 0, 0, 0]
    mask = None

    for a in elements:
        dots = a.count('.')
        mask = get_mask(Capture.get_subtree(a))
        if mask:
            masks[dots] = mask
        else:
            mask = (masks[dots - 1] ^ 0xffffffff)  #or (pmask ^ 0xffffffff)
            #mask = None
        print("%08x" % mask if mask is not None else "-\t", end=" ")
        print_addr_description(a, mask)


#elements = ['reverb'] + prefixed('reverb') + prefixed('reverb.echo')
#elements = ['input_monitor'] + prefixed('input_monitor') + prefixed('input_monitor.a.channel') + prefixed('input_monitor.a.channel.1')
#elements = ['daw_monitor'] + prefixed('daw_monitor') + prefixed('daw_monitor.a.channel') + prefixed('daw_monitor.a.channel.1')
#elements = ['preamp'] + prefixed('preamp') + prefixed('preamp.channel') + prefixed('preamp.channel.1') + ['line'] + prefixed('line.channel') + prefixed('line.channel.13')
#elements = ['master.direct_monitor'] + prefixed('master.direct_monitor') + prefixed('master.direct_monitor.a') + prefixed('master.direct_monitor.a.left')
#print_memory_table(elements)

mem = [
    "%s\t%s" % (render_bytes(Capture.get_addr(a)), a)
    for a in Capture.memory_names()
]
mem.sort()
for m in mem:
    print(m)
Beispiel #16
0
 def get_memory_value(self, control):
     addr = Capture.get_addr(control)
     return self.memory.get_value(addr)
Beispiel #17
0
 def set_memory_value(self, name, value):
     addr = Capture.get_addr(name)
     data = self.memory.set_value(addr, value)
     return addr, data
Beispiel #18
0
 def memory_names(self):
     return Capture.memory_names()