import sys, os sys.path.insert(0, os.path.abspath('..')) from common.core import BaseWidget, run, lookup from common.screen import ScreenManager, Screen from kivy.core.window import Window import photo_editor from settings import Settings from home import Homepage # Makes window open full screen Window.fullscreen = 'auto' sm = ScreenManager() sm.add_screen(Homepage(name='home')) sm.add_screen(photo_editor.PhotoEditor(name='photo_editor', sm=sm )) sm.add_screen(Settings(name='settings')) if __name__ == "__main__": if (len(sys.argv) >= 2): # ['main.py', 'filepath', '...'] _, filepath = sys.argv[:2] photo_editor.filepath = filepath sm.switch_to('photo_editor') else: sm.switch_to('home') run(sm)
tempo = 120 multiplier = 1 / 60 * tempo * 480 converted_midi_duration = [[(i * multiplier, j) for i, j in k] for k in duration_midi] for i in converted_midi_duration: self.seq.append( NoteSequencer(self.sched, self.synth, 1, (0, 0), i, True)) def play_recording(self): print("hello") for i in self.seq: i.start() if self.live_wave: self.mixer.add(self.live_wave) def on_key_down(self, keycode, modifiers): t = lookup(keycode[1], ['up', 'down'], [.001, -.001]) if t is not None: self.onset_detector.onset_thresh += t if keycode[1] == "w": self.init_recording() if keycode[1] == "s" and self.seq: self.play_recording() if __name__ == "__main__": run(MainWidget())
self.sched.set_generator(self.synth) # create the metronome: self.metro = Metronome(self.sched, self.synth) # and text to display our status self.label = topleft_label() self.add_widget(self.label) def on_key_down(self, keycode, modifiers): if keycode[1] == 'm': self.metro.toggle() bpm_adj = lookup(keycode[1], ('up', 'down'), (10, -10)) if bpm_adj: new_tempo = self.tempo_map.get_tempo() + bpm_adj self.tempo_map.set_tempo(new_tempo, self.sched.get_time()) def on_update(self): self.audio.on_update() bpm = self.tempo_map.get_tempo() self.label.text = self.sched.now_str() + '\n' self.label.text += 'tempo:{}\n'.format(bpm) self.label.text += 'm: toggle Metronome\n' self.label.text += 'up/down: change speed\n' # pass in which MainWidget to run as a command-line arg run(eval('MainWidget' + sys.argv[1]))
self.set_buffer(self.sw, self.dim) if keycode[1] == 'q': center = self.sw + self.dim / 2.0 self.dim /= 0.9 self.sw = center - (self.dim / 2.0) self.set_buffer(self.sw, self.dim) if keycode[1] == 'a': center = self.sw + self.dim / 2.0 - (np.array([-0.05, 0.0]) * self.dim) self.sw = center - (self.dim / 2.0) self.set_buffer(self.sw, self.dim) if keycode[1] == 'd': center = self.sw + self.dim / 2.0 - (np.array([0.05, 0.0]) * self.dim) self.sw = center - (self.dim / 2.0) self.set_buffer(self.sw, self.dim) if keycode[1] == 's': center = self.sw + self.dim / 2.0 - (np.array([0.0, -0.05]) * self.dim) self.sw = center - (self.dim / 2.0) self.set_buffer(self.sw, self.dim) if keycode[1] == 'w': center = self.sw + self.dim / 2.0 - (np.array([0.0, 0.05]) * self.dim) self.sw = center - (self.dim / 2.0) self.set_buffer(self.sw, self.dim) run(MainWidget3)
def on_key_down(self, keycode, modifiers): self.active_screen.on_key_down(keycode, modifiers) if keycode[1] == 'r': self.writer.toggle() def on_layout(self, winsize): if self.style_selection != None: self.style_selection.on_layout(winsize) if self.key_selection != None: self.key_selection.on_layout(winsize) if self.chord_selection != None: self.chord_selection.on_layout(winsize) if self.perc_selection != None: self.perc_selection.on_layout(winsize) if self.melody_selection != None: self.melody_selection.on_layout(winsize) def on_update(self): self.audio.on_update() self.active_screen.on_update() if __name__ == "__main__": # pass in which MainWidget to run as a command-line arg run(eval("MainWidget"))
print("INVALID CONTROL TYPE") return # Init game self.game = Game() self.canvas.add(self.game) def on_update(self): if self.control_type == "controller": button = UserInput.on_controller_input(self.joystick) if button: self.game.on_player_input(button) self.game.on_update() def on_key_down(self, keycode, modifiers): if self.control_type == "keyboard": button = UserInput.on_keyboard_input(keycode, modifiers) if button == Button.ESC: App.get_running_app().stop() elif button: self.game.on_player_input(button) # will get called when the window size changes def on_layout(self, win_size): self.game.on_layout(win_size) if __name__ == "__main__": run(MainWidget, fullscreen=True)
global received received = eval(msg) else: send(DISCONNECT_MESSAGE) run = False # run = False thread = threading.Thread(target=update_state, args=(client, ADDR)) thread.start() def send(msg): print(msg) message = msg.encode(FORMAT) msg_length = len(message) send_length = str(msg_length).encode(FORMAT) send_length += b' ' * (HEADER - len(send_length)) client.send(send_length) client.send(message) run(ExerciseWidget()) # thread.exit() # send("Hello World!") # input() # send("Hello Everyone!") # input() # send("Hello Tim!") send(DISCONNECT_MESSAGE)
kYesterday, False) self.seq2 = NoteSequencer(self.sched, self.synth, 2, (0, 52), kSomewhere, True) # and text to display our status self.label = topleft_label() self.add_widget(self.label) def on_key_down(self, keycode, modifiers): obj = lookup(keycode[1], 'mas', (self.metro, self.seq1, self.seq2)) if obj is not None: obj.toggle() bpm_adj = lookup(keycode[1], ('up', 'down'), (10, -10)) if bpm_adj: new_tempo = self.tempo_map.get_tempo() + bpm_adj self.tempo_map.set_tempo(new_tempo, self.sched.get_time()) def on_update(self): self.audio.on_update() self.label.text = self.sched.now_str() + '\n' self.label.text += 'tempo:%d\n' % self.tempo_map.get_tempo() self.label.text += 'm: toggle Metronome\n' self.label.text += 'a: toggle Sequence 1\n' self.label.text += 's: toggle Sequence 2\n' self.label.text += 'up/down: change speed\n' run(MainWidget)
class Scene(BaseWidget): def __init__(self): super(Scene, self).__init__() self.background = BackgroundWidget() self.add_widget(self.background) self.foreground = ForegroundWidget() self.add_widget(self.foreground) # Flying music notes self.anim_group = AnimGroup() self.canvas.add(self.anim_group) self.anim_group.add(FadingMusicNote()) def on_layout(self, win_size): self.background.on_layout(win_size) self.foreground.on_layout(win_size) def on_update(self): self.anim_group.on_update() def add_note_sprite(self): self.anim_group.add(FadingMusicNote((320, 80))) if __name__ == "__main__": run(Scene())