mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge pull request #47 from rakuri255/write_score_to_comment
- Write score as comment
This commit is contained in:
5 files changed
+51
-14
No files matched your search
+11
-5
@@ -277,7 +277,10 @@ def run():
|
||||
ultrastar_note_numbers)
|
||||
|
||||
# Calc Points
|
||||
ultrastar_class = calculate_score_points(isAudio, pitched_data, ultrastar_class, ultrastar_file_output)
|
||||
ultrastar_class, simple_score, accurate_score = calculate_score_points(isAudio, pitched_data, ultrastar_class, ultrastar_file_output)
|
||||
|
||||
# Add calculated score to Ultrastar txt
|
||||
ultrastar_writer.add_score_to_ultrastar_txt(ultrastar_file_output, simple_score)
|
||||
|
||||
# Midi
|
||||
if settings.create_midi:
|
||||
@@ -313,14 +316,17 @@ def separate_vocal_from_audio(basename_without_ext, cache_path, ultrastar_audio_
|
||||
def calculate_score_points(isAudio, pitched_data, ultrastar_class, ultrastar_file_output):
|
||||
if isAudio:
|
||||
ultrastar_class = ultrastar_parser.parse_ultrastar_txt(ultrastar_file_output)
|
||||
ultrastar_score_calculator.print_score_calculation(pitched_data, ultrastar_class)
|
||||
simple_score, accurate_score = ultrastar_score_calculator.calculate_score(pitched_data, ultrastar_class)
|
||||
ultrastar_score_calculator.print_score_calculation(simple_score, accurate_score)
|
||||
else:
|
||||
print(f"{PRINT_ULTRASTAR} {print_blue_highlighted_text('Score of original Ultrastar txt')}")
|
||||
ultrastar_score_calculator.print_score_calculation(pitched_data, ultrastar_class)
|
||||
simple_score, accurate_score = ultrastar_score_calculator.calculate_score(pitched_data, ultrastar_class)
|
||||
ultrastar_score_calculator.print_score_calculation(simple_score, accurate_score)
|
||||
print(f"{PRINT_ULTRASTAR} {print_blue_highlighted_text('Score of re-pitched Ultrastar txt')}")
|
||||
ultrastar_class = ultrastar_parser.parse_ultrastar_txt(ultrastar_file_output)
|
||||
ultrastar_score_calculator.print_score_calculation(pitched_data, ultrastar_class)
|
||||
return ultrastar_class
|
||||
simple_score, accurate_score = ultrastar_score_calculator.calculate_score(pitched_data, ultrastar_class)
|
||||
ultrastar_score_calculator.print_score_calculation(simple_score, accurate_score)
|
||||
return ultrastar_class, simple_score, accurate_score
|
||||
|
||||
|
||||
def create_ultrastar_txt_from_ultrastar_data(song_output, ultrastar_class, ultrastar_note_numbers):
|
||||
|
||||
@@ -26,7 +26,7 @@ def parse_ultrastar_txt(input_file):
|
||||
ultrastar_class.gap = line.split(':')[1].replace('\n', '')
|
||||
elif line.startswith('#BPM'):
|
||||
ultrastar_class.bpm = line.split(':')[1].replace('\n', '')
|
||||
elif line.startswith(('F', ':', '*', 'R', 'G')):
|
||||
elif line.startswith(('F ', ': ', '* ', 'R ', 'G ')):
|
||||
parts = line.split()
|
||||
# [0] F : * R G
|
||||
# [1] start beat
|
||||
|
||||
@@ -29,17 +29,27 @@ def add_point(noteType, points):
|
||||
points.golden_rap += 2
|
||||
return points
|
||||
|
||||
class Score:
|
||||
max_score = 0
|
||||
notes = 0
|
||||
golden = 0
|
||||
line_bonus = 0
|
||||
score = 0
|
||||
|
||||
def print_score(points):
|
||||
# todo: here also a score calculation !?!
|
||||
max_score = MAX_SONG_SCORE if points.line_bonus == 0 else MAX_SONG_SCORE - MAX_SONG_LINE_BONUS
|
||||
notes = max_score * (points.notes + points.rap) / points.parts
|
||||
golden = points.golden_notes + points.golden_rap
|
||||
score = notes + points.line_bonus + golden
|
||||
print(f"{PRINT_ULTRASTAR} Total: {print_cyan_highlighted_text(str(round(score)))}, notes: {print_blue_highlighted_text(str(round(notes)))}, line bonus: {print_light_blue_highlighted_text(str(round(points.line_bonus)))}, golden notes: {print_gold_highlighted_text(str(round(golden)))}")
|
||||
def get_score(points):
|
||||
score = Score()
|
||||
score.max_score = MAX_SONG_SCORE if points.line_bonus == 0 else MAX_SONG_SCORE - MAX_SONG_LINE_BONUS
|
||||
score.notes = round(score.max_score * (points.notes + points.rap) / points.parts)
|
||||
score.golden = round(points.golden_notes + points.golden_rap)
|
||||
score.score = round(score.notes + points.line_bonus + score.golden)
|
||||
score.line_bonus = round(points.line_bonus)
|
||||
return score
|
||||
|
||||
def print_score(score):
|
||||
print(f"{PRINT_ULTRASTAR} Total: {print_cyan_highlighted_text(str(score.score))}, notes: {print_blue_highlighted_text(str(score.notes))}, line bonus: {print_light_blue_highlighted_text(str(score.line_bonus))}, golden notes: {print_gold_highlighted_text(str(score.golden))}")
|
||||
|
||||
|
||||
def print_score_calculation(pitched_data, ultrastar_class):
|
||||
def calculate_score(pitched_data, ultrastar_class):
|
||||
print(PRINT_ULTRASTAR + " Calculating Ultrastar Points")
|
||||
|
||||
simple_points = Points()
|
||||
@@ -91,6 +101,9 @@ def print_score_calculation(pitched_data, ultrastar_class):
|
||||
if simple_part_line_bonus_points >= parts:
|
||||
simple_points.line_bonus += reachable_line_bonus_per_word
|
||||
|
||||
return get_score(simple_points), get_score(accurate_points)
|
||||
|
||||
def print_score_calculation(simple_points, accurate_points):
|
||||
print(f"{PRINT_ULTRASTAR} {print_underlined_text('Simple (octave high ignored)')} points")
|
||||
print_score(simple_points)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ class UltrastarTxt:
|
||||
bpm = ''
|
||||
creator = 'UltraSinger [GitHub]'
|
||||
fixer = 'YOUR NAME'
|
||||
comment = 'UltraSinger [GitHub]'
|
||||
startBeat = []
|
||||
startTimes = []
|
||||
endTimes = []
|
||||
|
||||
@@ -41,6 +41,7 @@ def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrast
|
||||
f.write(f'#VIDEO:{ultrastar_class.video}\n')
|
||||
f.write(f'#BPM:' + str(round(ultrastar_bpm, 2)) + '\n') # not the real BPM!
|
||||
f.write(f'#GAP:' + str(int(gap * 1000)) + '\n')
|
||||
f.write(f'#COMMENT:{ultrastar_class.comment}\n')
|
||||
|
||||
# Write the singing part
|
||||
previous_end_beat = 0
|
||||
@@ -112,6 +113,22 @@ def create_repitched_txt_from_ultrastar_data(input_file, note_numbers, output_re
|
||||
else:
|
||||
f.write(line)
|
||||
|
||||
def add_score_to_ultrastar_txt(ultrastar_file_output, score):
|
||||
with open(ultrastar_file_output, 'r') as f:
|
||||
text = f.read()
|
||||
text = text.split('\n')
|
||||
|
||||
for i in range(len(text)):
|
||||
if text[i].startswith("#COMMENT:"):
|
||||
text[i] = f"{text[i]} | Score: total: {score.score}, notes: {score.notes} line: {score.line_bonus}, golden: {score.golden}"
|
||||
break
|
||||
elif text[i].startswith(('F ', ': ', '* ', 'R ', 'G ')):
|
||||
text.insert(i, f"#COMMENT: UltraSinger [GitHub] | Score: total: {score.score}, notes: {score.notes} line: {score.line_bonus}, golden: {score.golden}")
|
||||
break
|
||||
|
||||
text = '\n'.join(text)
|
||||
|
||||
with open(ultrastar_file_output, 'w') as f:
|
||||
f.write(text)
|
||||
class UltraStarWriter:
|
||||
pass
|
||||
Reference in new issue
Block a user