-
Notifications
You must be signed in to change notification settings - Fork 2
/
play_sheet.py
49 lines (39 loc) · 1.34 KB
/
play_sheet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from pathlib import Path
import json
import time
import pygame
from library import reverse_utilities as ru
from library import logger_generate
from config import base
reverse_config = base.reverse_config()
rc = reverse_config
logger = logger_generate.generate(base.logger_config())
sounds = ru.get_sounds()
# sounds[0].play()
# 讀取譜面
aims_folder_path = Path(rc['aims_folder_path'])
output_sheet_path = (aims_folder_path /
Path(rc['output_sheet_path'])).resolve()
_temp = output_sheet_path / './native_sheet.json'
with open(_temp, mode='r', encoding='utf-8') as f:
_original_sheet = f.read()
original_sheet = json.loads(_original_sheet)['original_sheet']
# 先生出時間差
for j in range(0, len(original_sheet)):
if j == len(original_sheet) - 1:
original_sheet[j]['time_area'] = 0
break
original_sheet[j]['time_area'] =\
original_sheet[j + 1]['time'] - original_sheet[j]['time']
# 來播放
for note in original_sheet:
# k = 0
sleep_time = note['time_area']
sound_number = note['keyboard']
# print(f"channels = {pygame.mixer.get_num_channels()}")
points_channel = sounds[sound_number].play()
logger.debug(f"find_channel = {pygame.mixer.find_channel()}")
logger.debug(f"points_channel = {points_channel}")
logger.debug(sound_number + 1)
time.sleep(sleep_time)
#