Exemple #1
0
 def list_markers(self):
     """
     cat: info
     desc: list the markers in this controller
     """
     info_title("Controller for {0}".format(self.reltype))
     info_list(list(self.markers.values()))
Exemple #2
0
    def init_mode(self):
        """
        fill in initialization via input
        get recording by mode
        call get_help/playback if asked
        returns rec array
        """
        valid_modes = (
            "live Record (R)", 
            "read from File (F)", 
            "relativism project or sampler Object (O)", 
            "Help (H)"
        )
        info_title("Available modes:")
        info_list(valid_modes)
        p("Enter desired mode's letter")
        mode = inpt('letter', allowed='rfh')

        # Record Mode
        if mode == "r":
            self.record_live()
        # File Mode
        elif mode == "f":
            self.read_file()
        elif mode == "o":
            raise NotImplementedError
        # Help
        elif mode == "h":
            raise NotImplementedError
Exemple #3
0
def sd_select_device(device_type='in'):
    """
    type: in or out
    returns [index, name] of device
    """
    info_title("Devices by index ({0} found):".format(len(sd.query_devices())))
    for i in str(sd.query_devices()).split('\n'):
        info_line(i)
    while True:
        p("Enter desired device index")
        device_ind = inpt('int')
        try:
            device = sd.query_devices()[device_ind]
        except IndexError:
            err_mess("No device with index {0}".format(device_ind))
            continue
        if device_type in ('in', 'input'):
            if device['max_input_channels'] < 1:
                err_mess("Device cannot be used as an input")
                continue
        elif device_type in ('out', 'output'):
            if device['max_output_channels'] < 1:
                err_mess("Device cannot be used as an output")
        device_name = device['name']
        info_block("'{0}' selected".format(device_name))
        return [device_ind, device_name]
Exemple #4
0
 def list_projects(self):
     info_title("Existing projects:")
     for k, v in self.projects.items():
         if v == "None":
             info_list(k + " (Not found)")
         else:
             info_list(k)
Exemple #5
0
 def show_settings():
     info_title("Settings:")
     attrs = [attr for attr in dir(_SettingsContainer) if "__" not in attr and attr != "_defaults"]
     maxlen = max(len(i) for i in attrs)
     for name in attrs:
         value = getattr(_SettingsContainer, name)
         if value == True:
             value = "On"
         if value == False:
             value = "Off"
         info_list(name + ": " + (" " * abs(maxlen - len(name))) + str(value))
Exemple #6
0
 def see_proj(self, proj_name, proj_path):
     info_block("Previewing Project '{0}'".format(proj_name))
     fullpath = join_path(
         proj_path,
         proj_name + ".Project." + RelSavedObj.datafile_extension)
     with open(fullpath, "r") as f:
         data = json.load(f)
     info_title("Path: " + data["path"])
     info_line("Audio file: " + str(data["file"]))
     info_line("Children:")
     children = [
         re.sub(r"<.*>", "", i).split(".") for i in data["children"]
     ]
     children = ["{0} '{1}'".format(i[1], i[0]) for i in children]
     info_list(children)
Exemple #7
0
 def list_active(self):
     """
     desc: list active pairs in this sampler
     cat: info
     dev:
         returns bool, false if nothing to list
     """
     info_title("Active pairs in '{0}':".format(self.name))
     empty = True
     for a in self.active:
         info_list(str(a))
         empty = False
     if empty:
         info_list("No active pairs created")
         return False
Exemple #8
0
 def process():
     section_head("Editing User Settings")
     method_strs = [func for func in dir(Settings) if "__" not in func and 
         is_public_process(getattr(Settings, func))]
     while True:
         info_title("Available processes:")
         info_list(method_strs)
         p("What process to run?")
         proc = inpt("alphanum")
         try:
             proc = autofill(proc, method_strs)
             method = getattr(Settings, proc)
             if is_public_process(method):
                 method()
             else:
                 raise AttributeError
         except AutofillError as e:
             err_mess("No process matches '{0}'!".format(e.word))
         except AttributeError:
             err_mess("No process matches '{0}'!".format(proc))
Exemple #9
0
def complete_args(e, method_name, args, obj):
    """
    handle wrong number of args
    """
    if method_name not in str(e):
        show_error(e)
    err_mess("Wrong number of arguments: {0}".format(str(e)))
    info_title("Arguments for {0}: ".format(method_name), indent=4)
    obj.get_process(method_name)._rel_data.display_args()
    # too many
    command_str = "\n      " + method_name + " "
    if "were given" in str(e):
        p("Enter intended arguments", start=command_str)
        new_args = inpt('split', 'arg')
        return [method_name] + new_args
    # not enough
    else:
        if len(args) > 0:
            command_str += " ".join(args) + " "
        p("Complete arguments", start=command_str)
        new_args = inpt('split', 'arg')
        return [method_name] + args + new_args
Exemple #10
0
 def list_samples(self):
     info_title("Samples in Sample Group '{0}':".format(self.name))
     info_list(list(self.samples.keys()))