Added osu parser, not fully implemented. Very much hardcoded to only play p names

This commit is contained in:
Valerio
2026-01-05 14:29:55 -05:00
parent e0b7f0a863
commit 976f5683b2
6 changed files with 2728 additions and 24 deletions

2623
PNames.osu Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1,2 @@
61506649d1a0f78c7759ffd83b010e58ab0e167bdeb06b11584933d7a7409f35|Dogbite|t+pazolite
74ee9547980a5a16d7de54004b8422fd1655e079d51cfe7fa554787604ecb654|TRIPLE HELIX|Yonokid
61506649d1a0f78c7759ffd83b010e58ab0e167bdeb06b11584933d7a7409f35|Dogbite|t+pazolite

View File

@@ -12,38 +12,38 @@ practice_mode_bar_delay = 1
score_method = "shinuchi"
[nameplate_1p]
name = 'どんちゃん'
title = 'ドンだーデビュー!'
name = "どんちゃん"
title = "ドンだーデビュー!"
title_bg = 0
dan = -1
gold = false
rainbow = false
[nameplate_2p]
name = 'かつちゃん'
title = 'ドンだーデビュー!'
name = "かつちゃん"
title = "ドンだーデビュー!"
title_bg = 1
dan = -1
gold = false
rainbow = false
[paths]
tja_path = ['Songs']
skin = 'PyTaikoGreen'
tja_path = ["Songs"]
skin = "PyTaikoGreen"
[keys]
exit_key = 'Q'
borderless_key = 'F10'
fullscreen_key = 'F11'
pause_key = "SPACE"
back_key = 'ESCAPE'
restart_key = 'F1'
exit_key = "Q"
borderless_key = "f10"
fullscreen_key = "f11"
pause_key = "space"
back_key = "escape"
restart_key = "f1"
[keys_1p]
left_kat = ['D']
left_don = ['F']
right_don = ['J']
right_kat = ['K']
left_kat = ["D"]
left_don = ["F"]
right_don = ["J"]
right_kat = ["K"]
[keys_2p]
left_kat = ["Z"]
@@ -58,17 +58,13 @@ right_don = [17]
right_kat = [12]
[audio]
# device_type: 0 = default, this will be set on first launch to the recommended setting
# Windows users should generally pick 4 (WDM-KS) and Linux users should pick 0 (ALSA)
device_type = 0
sample_rate = 44100
# buffer_size: Size in samples per audio buffer
# - 0 = let driver choose (may result in very small buffers with ASIO, typically 64)
buffer_size = 32
[volume]
sound = 1.0
music = 1.0
music = 0.0
voice = 1.0
hitsound = 1.0
attract_mode = 1.0

1
libs/osz.py Symbolic link
View File

@@ -0,0 +1 @@
../osz.py

79
osz.py Normal file
View File

@@ -0,0 +1,79 @@
import hashlib
import logging
import math
import random
from collections import deque
from dataclasses import dataclass, field, fields
from enum import IntEnum
from functools import lru_cache
from pathlib import Path
from typing import Optional
from libs.global_data import Modifiers
from libs.utils import strip_comments
from libs.tja import TimelineObject, Note, NoteType, Drumroll, Balloon, NoteList, CourseData, ParserState
osu_file = Path("./PNames.osu")
contents = osu_file.open(mode='r', encoding='utf-8').read()
import re
def read_osu_note_data(file_path, target_header="HitObjects"):
note_data = []
current_header = None
with file_path.open(mode='r', encoding='utf-8') as f:
for line in f:
line = line.rstrip("\n")
if re.match(r"\[\w*\]", line): # header pattern
current_header = line[1:-1]
if current_header == target_header:
if re.match(r"[-+]?\d*\.?\d+" , line):
string_array = re.findall(r"[-+]?\d*\.?\d+" , line) # search for floats
int_array = [int(num_str) for num_str in string_array]
note_data.append(int_array)
else:
continue
return note_data
note_data = read_osu_note_data(osu_file)
def note_data_to_NoteList(note_data):
osu_NoteList = NoteList()
counter = 0
for line in note_data:
if line[3] == 1 and line[4] == 0: # DON
don = Note()
don.type = NoteType(1)
don.hit_ms = line[2]
don.bpm = 207
don.scroll_x = 1
don.scroll_y = 0
don.display = True
don.index = counter
counter = counter + 1
don.moji = 0
osu_NoteList.play_notes.append(don)
if line[3] == 1 and line[4] == 2: # KAT
kat = Note()
kat.type = NoteType(2)
kat.hit_ms = line[2]
kat.bpm = 207
kat.scroll_x = 1
kat.scroll_y = 0
kat.display = True
kat.index = counter
counter = counter + 1
kat.moji = 1
osu_NoteList.play_notes.append(kat)
osu_NoteList.draw_notes = osu_NoteList.play_notes.copy()
return osu_NoteList

View File

@@ -50,6 +50,8 @@ from libs.utils import (
)
from libs.video import VideoPlayer
from libs.osz import read_osu_note_data, note_data_to_NoteList
logger = logging.getLogger(__name__)
class DrumType(IntEnum):
@@ -414,9 +416,11 @@ class Player:
unload_offset = travel_distance / sudden_pixels_per_ms
note.unload_ms = note.hit_ms + unload_offset
###from libs.osz import read_osu_note_data, note_data_to_NoteList
def reset_chart(self):
notes, self.branch_m, self.branch_e, self.branch_n = self.tja.notes_to_position(self.difficulty)
#notes, self.branch_m, self.branch_e, self.branch_n = self.tja.notes_to_position(self.difficulty)
notes = note_data_to_NoteList(read_osu_note_data(Path("./PNames.osu")))
self.branch_m, self.branch_e, self.branch_n = [], [], []
self.play_notes, self.draw_note_list, self.draw_bar_list = deque(apply_modifiers(notes, self.modifiers)[0]), deque(apply_modifiers(notes, self.modifiers)[1]), deque(apply_modifiers(notes, self.modifiers)[2])
self.don_notes = deque([note for note in self.play_notes if note.type in {NoteType.DON, NoteType.DON_L}])