def common(self, key, modifiers): # exit if(key == '|'): # escape self.cmdcenter.env.exit = True # toggle console elif(key == "`"): self.cmdcenter.cmd("toggle_console()") # reset fb elif(key == "\\"): self.cmdcenter.cmd("reset_fb()") # reset zn elif(key == GLUT_KEY_HOME): default = configmanager.load_dict("state", "default") for i in xrange(len(default.zn)): self.cmdcenter.cmd('radial_2d(zn, %d, 0.4, %s, %s)' % (i, str(r_to_p(self.state.zn[i])), str(r_to_p(default.zn[i])))) # reset par elif(key == GLUT_KEY_END): default = configmanager.load_dict("state", "default") for i in xrange(len(default.par)): self.cmdcenter.cmd('linear_1d(par, %d, 0.4, %f, %f)' % (i, self.state.par[i], default.par[i])) # tap tempo elif(key == GLUT_KEY_F1): self.cmdcenter.cmd("tap_tempo()") # toggle echo elif(key == GLUT_KEY_F11): self.cmdcenter.cmd("toggle_echo()") # toggle fps elif(key == GLUT_KEY_F12): self.cmdcenter.cmd("toggle_fps()") # save state elif(key == "\015"): # enter self.cmdcenter.cmd("save()") # toggle manual iteration elif(key == "\011"): # tab self.cmdcenter.cmd("manual()") # toggle next frame elif(key == "\040"): # space self.cmdcenter.cmd("next()")
def load(self, name): ''' Loads and blends to the given state. ''' if(isinstance(name, int)): name = "state_%d" % name info("Loading state: %s" % name) new_state = configmanager.load_dict("state", name) updates = {} # get update components for name in self.componentmanager.component_list(): if(self.state.components[name] != new_state.components[name]): updates[name] = new_state.components[name] del(new_state.components[name]) if(not self.componentmanager.can_switch_to_components(updates)): error("Failed to load state") return False debug("Loading state, updating components: %s" % str(updates)) # blend to zns for i in xrange(len(new_state.zn)): self.cmd('radial_2d(zn, %d, component_switch_time, %s, %s)' % (i, str(r_to_p(self.state.zn[i])), str(r_to_p(new_state.zn[i])))) # blend to pars for i in xrange(len(new_state.par)): self.cmd('linear_1d(par, %d, component_switch_time, %f, %f)' % (i, self.state.par[i], new_state.par[i])) # print new_state.time, self.state.time, self.t_phase, self.state.component_switch_time # shift t_start # self.cmd('linear_1d(cmd, "t_phase", component_switch_time, %f, %f)' % (0, state.time + self.t_phase - 1.0) / 1.0)) self.cmd("switch_components(%s)" % str(updates))
if val[0] == "$": val = eval(val[1:]) if val == "True": val = True if val == "False": val = False # create vars split = re.compile("\.").split(split[0]) if len(split) == 1: args["app"][split[0]] = val else: args[split[0]][split[1]] = val # create structures app = configmanager.load_dict("app", args["application"], **args["app"]) env = configmanager.load_dict("environment", app.env, **args["env"]) context = configmanager.load_dict("context", app.context, **args["context"]) profile = configmanager.load_dict("profile", app.profile, **args["profile"]) state = configmanager.load_dict("state", app.state, **args["state"]) # encapsulated for asynchronous execution def main(): info("Starting main loop") # initialize & sync modules debug("Initializing modules") global interface, engine, cmdcenter interface = Interface(context) engine = Engine(profile)