def btn5_action(): if state == 0: TTTruck.undo() elif state == 1: TTTruck.loop_rate(random.random() * 4) elif state == 2: pass elif state == 3: pass
def btn4_action(): if state == 0: TTTruck.undo() elif state == 1: # TTTruck.stretch pass elif state == 2: pass elif state == 3: TTTruck.publish_global_changes()
def process_loops(): completed = [] for k, v in loops.items(): if not v.__contains__(None): logging.debug(f'Received complete loop {k}') completed.append((k, v)) while completed: c = completed.pop() loops.pop(c[0]) TTTruck._write_wav(c)
def btn3_action(): if state == 0: TTTruck.loop_add() elif state == 1: # TTTruck.stretch pass elif state == 2: # TTTruck.set_tempo() pass elif state == 3: TTTruck.publish_all_changes()
def btn4_action(): if state == 0: TTTruck.delete_loop() elif state == 1: # TTTruck.delay() pass elif state == 2: # TTTruck.delete() pass elif state == 3: TTTruck.publish_global_changes()
def process_incoming(): while PeerClient.receive_queue: incoming_bytes, peer = PeerClient.receive_queue.pop() import json msg = json.loads(incoming_bytes) try: if msg['action']: action = msg['action'] if action == 'ping': state = msg['state'] peer.sending_status = state #resend_queue[peer] = state logging.debug( f'Received ping from: {peer.get_address()}. Current state: {state}' ) if action == 'loop_add': message = msg['message'] loop_name = message['loop_name'] current_chunk = message['current_chunk'] if loops.get(loop_name, None) is None: loops[message['loop_name']] = [ None for i in range(message['number_of_chunks']) ] loops[loop_name].pop(current_chunk - 1) loops[loop_name].insert( current_chunk - 1, message['chunk_body'].encode('latin1')) logging.debug( f'Received chunk: {current_chunk} for {loop_name} from: {peer.get_address()}.' ) else: loops[loop_name].pop(current_chunk - 1) loops[loop_name].insert( current_chunk - 1, message['chunk_body'].encode('latin1')) logging.debug( f'Received chunk {current_chunk} from: {peer.get_address()}. ' ) if action == 'loop_modify': message = msg['message'] logging.debug( f'Modifying : {message} from: {peer.get_address()}.') # {'action': 'loop_add', 'message': {'loop_name': name, {'param': value}, loop_name = message['loop_name'] for param, value in message.items(): if param == 'loop_name': continue TTTruck.set_parameter(loop_name, param, value) except Exception as e: logging.warning( f'Unable to receive data {msg} from: {peer.get_address()}')
def btn6_action(): if state == 0: TTTruck.redo() elif state == 1: TTTruck.solo() elif state == 2: TTTruck.select_next_loop() elif state == 3: TTTruck.select_prev_loop()
def btn2_action(): if state == 0: TTTruck.loop_overdub() elif state == 1: TTTruck.loop_multiply() elif state == 2: TTTruck.set_quantize() elif state == 3: TTTruck.publish_selected_changes()
def btn1_action(): if state == 0: indicator1() TTTruck.loop_record() elif state == 1: TTTruck.loop_reverse() elif state == 2: TTTruck.set_sync_source() elif state == 3: TTTruck.publish_loop()
def _(event): TTTruck.set_sync_source()
def test_loop_index(self): OSCServer.start(port=9952) t = threading.Thread(target=OSCClient.start(client_name='test'), daemon=True) t.start() SLClient.ping() #time.sleep(0.3) TTTruck._delete_all_loops() self.assertEqual(0, SLClient.loops) self.assertFalse(TTTruck.loop_index) # one loop TTTruck.loop_add() #time.sleep(1) self.assertEqual(0, TTTruck.get_number_of_loops()) self.assertTrue(TTTruck.loop_index) first_loop = TTTruck.loop_index[0] #print(first_loop) # second loop TTTruck.loop_add() second_loop = TTTruck.loop_index[1] #print(second_loop) #time.sleep(1) self.assertEqual(1, TTTruck.get_number_of_loops()) # third loop TTTruck.loop_add() #time.sleep(1) self.assertEqual(2, TTTruck.get_number_of_loops()) third_loop = TTTruck.loop_index[2] TTTruck.select_loop(1) #time.sleep(1) TTTruck.loop_reverse() #time.sleep(1) self.assertEqual(1, TTTruck.changes[second_loop]['reverse']) #time.sleep(1) TTTruck.loop_reverse() #time.sleep(1) self.assertEqual(0, TTTruck.changes[second_loop]['reverse']) TTTruck.delete_loop() #time.sleep(1) #print(OSCServer.selected_loop, 's') # third loop should now be the second of two loops self.assertEqual(1, TTTruck.get_number_of_loops()) self.assertEqual(third_loop, TTTruck.loop_index[1]) # delete second loop again and ensure first loop is all that's left TTTruck.delete_loop() #time.sleep(1) self.assertEqual(0, TTTruck.get_number_of_loops()) self.assertEqual(first_loop, TTTruck.loop_index[0])
def _(event): TTTruck.loop_record()
def _(event): TTTruck.loop_rate(random.random() * 4)
def _(event): #/tmp/tmpho4iedf1/tq21alez3ne04s1oago7.wav TTTruck.loop_load('tq21alez3ne04s1oago7')
def _(event): TTTruck.select_next_loop()
def next_loop(): TTTruck.select_next_loop()
def _(event): TTTruck.publish_all_changes()
def _(event): TTTruck.publish_loop()
def _(event): TTTruck.loop_add()
def _(event): TTTruck.delete_loop()
def publish(): TTTruck.publish_loop()
def _(event): TTTruck.publish_selected_changes()
def solo(): solo_indicator() TTTruck.solo()
def _(event): TTTruck.loop_reverse()