def __init__(self, cv, root): self.damy_mode = 0 #演奏デバイスと通信せずに動かす self.center_adj = 100 #中央寄せ調整用 self.draw_mag = 2.0 #フルスクリーン時、表示するディスプレイに合わせるため self.cv = cv self.root = root self.flag = 0 self.button = gi()#PaspberryPiでの動作確認 # 再帰回数の設定 sys.setrecursionlimit(6000) # sound dataの読み込み_試験用 self.sound_data = self.__read_file() # 受信の準備 if not self.damy_mode: self.udp_data = uc()#PaspberryPiでの動作確認 # 音を出す準備 self.sound = ps() #記録をとる準備 self.write_rec = o_re() self.write_rec_flag = 0
def __init__(self, music_name, cv, p_frame, mode_name): self.cv = cv self.root = p_frame self.music_name = music_name self.mode_name = mode_name #self.button = gi() #RaspberryPiでの動作確認 self.music_deta = [] self.last_time = time.time() self.first_roop = 1 self.draw_point = 0 self.seek_point = 5 self.last_seek_point = 5 #入力描画用 self.end_flag = 0 self.bpm = 0 self.measure = 0 self.music_sound = ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ", "ド", "レ"] self.labals_update = -1 self.labels = [] # 受信の準備 #RaspberryPiでの動作確認 and 演奏デバイスと通信時 # self.udp_data = uc()#PaspberryPiでの動作確認 # 音を出す準備 self.sound = ps() self.rcv_data_s = [] #記録をとる準備 self.write_rec = o_re() self.chan_in = 0 self.chan_in_point = 0 self.score_update = 1 self.d_input = di() #PCでの動作確認 if self.mode_name == "PLAY_RECORDING": l_music_data = rs.read_score(self.music_name) self.bpm = l_music_data[0] self.measure = l_music_data[1] del l_music_data[0:2] self.music_deta = l_music_data for i in self.music_deta: print(i) else: l_music_data = rs.read_score(self.music_name) #, self.mode_name) self.bpm = l_music_data[0] self.measure = l_music_data[1] del l_music_data[0:2] self.music_deta = l_music_data for i in self.music_deta: print(i)
def change_page(button_in): global p_position, c_select, se_file #button_in = int(input('>>'))#PCでの動作確認 button_in = button.gpio_input()#PaspberryPiでの動作確認 if button_in == 0 and chattering_check(button_in):#左 pages[trans_list[p_position][0]].raise_page() pages[trans_list[p_position][0]].draw_select(1) p_position = trans_list[p_position][0] c_select = 1 elif button_in == 1 and p_position != 1 and chattering_check(button_in):#上 if c_select == 1 and pages[p_position].d_positoin > 0: pages[p_position].d_positoin -= 1 pages[p_position].draw_cons() elif c_select != 1: c_select -= 1 pages[p_position].draw_select(c_select) elif button_in == 2 and p_position != 1 and chattering_check(button_in):#下 if len(pages[p_position].contents) >= c_select + 1: c_select += 1 if c_select > 5: c_select = 5 if len(pages[p_position].contents) >= pages[p_position].d_positoin + 6: pages[p_position].d_positoin += 1 pages[p_position].draw_cons() pages[p_position].draw_select(c_select) elif button_in == 3 and chattering_check(button_in):#右 print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") if p_position == 8 and c_select == 2:#記録を消す ope = o_re() ope.del_recording(se_file) pages[trans_list[p_position][0]].raise_page() pages[trans_list[p_position][0]].draw_select(1) p_position = trans_list[p_position][0] c_select = 1 elif p_position == 7:#仮の終了 sd_udp_data = uc()#RaspberryPiでの動作確認 and 演奏デバイスと通信時 sd_udp_data.zero_start(0)#RaspberryPiでの動作確認 and 演奏デバイスと通信時 root.destroy() if c_select == 1: os.system('sudo shutdown -h now') return elif p_position == 6: #設定ファイル書き換え nowDirectoryPath = os.path.dirname(os.path.abspath(__file__)) + "/" with open(nowDirectoryPath + "config.json","r") as config_file: json_obj = json.load(config_file,object_pairs_hook=OrderedDict) if c_select == 1: if json_obj["metronom"] == "ON": json_obj["metronom"] = "OFF" else: json_obj["metronom"] = "ON" if c_select == 2: if json_obj["record_flag"] == "ON": json_obj["record_flag"] = "OFF" else: json_obj["record_flag"] = "ON" if c_select == 3: if json_obj["Mode"] == "A": json_obj["Mode"] = "B" else: json_obj["Mode"] = "A" if c_select == 4: json_obj["Volume"] = str(int(json_obj["Volume"]) + 1) if int(json_obj["Volume"]) == 3: json_obj["Volume"] = "0" print(json_obj["Volume"]) #print(select_volumes[int(json_obj["Volume"])]) with codecs.open(nowDirectoryPath + "config.json","w","utf-8") as writing_config_file: json.dump(json_obj,writing_config_file,ensure_ascii=False) #contents更新 pages[p_position].contents = pages[p_position]._get_list_cons(p_position) pages[p_position].draw_cons() #print(pages[p_position].contents) else: if p_position == 2 or p_position == 4 or p_position == 8: if len(pages[p_position].contents) > 0: se_file = pages[p_position].contents[pages[p_position].d_positoin + c_select - 1]#要改良 #pages[8].set_file_name(se_file) if p_position == 8: se_file = se_file.strip("を再生") se_file = se_file.strip("を消去") pages[trans_list[p_position][1]].set_file_name(se_file) se_file += '.txt' else: se_file = '' if len(trans_list[p_position]) == 2:#移動先が一つだけの時 if len(pages[p_position].contents) > 0: get_con = pages[p_position].contents[pages[p_position].d_positoin + c_select - 1]#要改良 else: get_con = '' print('select : ' + get_con) pages[trans_list[p_position][1]].raise_page() if trans_list[p_position][1] != 1 and trans_list[p_position][1] != 3 and trans_list[p_position][1] != 5: pages[trans_list[p_position][1]].draw_select(1) p_position = trans_list[p_position][1] c_select = 1 # pf.select_func(p_position, get_con)#そのページ専用関数を発動 elif len(trans_list[p_position]) != 1:#??? pages[trans_list[p_position][c_select]].raise_page() #pages[trans_list[p_position][c_select]].draw_select(1) p_position = trans_list[p_position][c_select] # pf.select_func(p_position, 'None')#そのページ専用関数を発動 c_select = 1 if button_in == 7777: root.destroy() else: #root.after(100, change_page, -1)#PCでの動作確認 root.after(100, change_page, button.gpio_input())#PaspberryPiでの動作確認 set_button_buf(button_in)
def __init__(self, music_name, cv, p_frame, mode_name): self.damy_mode = 0 #演奏デバイスと通信せずに動かす self.center_adj = 100 #中央寄せ調整用 self.draw_mag = 2.0 #フルスクリーン時、表示するディスプレイに合わせるため self.cv = cv self.root = p_frame self.music_name = music_name self.mode_name = mode_name self.button = gi() #RaspberryPiでの動作確認 self.music_deta = [] self.last_time = time.time() self.last_input_time = time.time() self.start_time = time.time() self.first_roop = 1 #self.draw_point = 0 self.seek_point = 5 self.last_seek_point = 5 #入力描画用 self.end_flag = 0 self.music_sound = ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ", "ド", "レ"] self.labels = [] self.m_p = [ 127.5, 122.5, 117.5, 112.5, 107.5, 102.5, 97.5, 92.5, 87.5 ] #音階の描画位置 # 受信の準備 #RaspberryPiでの動作確認 and 演奏デバイスと通信時 if not self.damy_mode: self.udp_data = uc() #PaspberryPiでの動作確認 # PCでの動作確認 self.d_input = di() # 音を出す準備 self.sound = ps() self.rcv_data_s = ['0', '00000000'] #記録をとる準備 self.write_rec = o_re() #お手本を読む if self.mode_name == 'JUDGE_PLAY': l_music_data = rs.read_score(self.music_name) else: l_music_data = rs.read_recording(self.music_name) noteLength = l_music_data[0] self.radix = l_music_data[1] self.bpm = 60 / noteLength del l_music_data[0:2] self.exa_music_datas = l_music_data self.exa_counter = 0 #カタカナデータを読む self._read_scale_kana() self.kana_last_write = 0 self.kana_num = 0 self.drawing_kana = self.kana_lines[self.kana_num] #.split(':') self.seek_limit = noteLength * self.radix * 2 #2小説の演奏にかかる時間7 print('self.seek_limit : ', self.seek_limit) self.num_measure_data = self.seek_limit / 0.05 #二小説の描画に必要なデータ数 print('self.num_measure_data : ', self.num_measure_data) #print('self.num_measure_data to int: ', int(self.num_measure_data)) self.draw_min_size = 500 * self.draw_mag / self.num_measure_data #実験用 self.input_counter = 0 self.reflesh = 1 #メトロノームの準備 self.b_metro = bm(self.root, self.bpm)