def load_memon_0_1_0(path: Path, **kwargs: Any) -> jbt.Song: raw_memon = _load_raw_memon(path) schema = Memon_0_1_0() memon = schema.load(raw_memon) metadata = jbt.Metadata( title=memon["metadata"]["title"], artist=memon["metadata"]["artist"], audio=Path(memon["metadata"]["audio"]), cover=Path(memon["metadata"]["cover"]), ) common_timing = jbt.Timing( events=[ jbt.BPMEvent(time=jbt.BeatsTime(0), BPM=memon["metadata"]["BPM"]) ], beat_zero_offset=jbt.SecondsTime(-memon["metadata"]["offset"]), ) charts: MultiDict[jbt.Chart] = MultiDict() for difficulty, memon_chart in memon["data"].items(): charts.add( difficulty, jbt.Chart( level=memon_chart["level"], notes=[ _load_memon_note_v0(note, memon_chart["resolution"]) for note in memon_chart["notes"] ], ), ) return jbt.Song(metadata=metadata, charts=charts, common_timing=common_timing)
def _load_eve(lines: List[str], file_path: Path, *, beat_snap: int = 240) -> song.Song: chart = make_chart_from_events(iter_events(lines), beat_snap=beat_snap) dif = guess_difficulty(file_path.stem) or song.Difficulty.EXTREME return song.Song(metadata=song.Metadata(), charts={dif: chart})
def load_metadata(meta: malody.Metadata, bgm: Optional[malody.Sound]) -> song.Metadata: return song.Metadata( title=meta.song.title, artist=meta.song.artist, audio=none_or(lambda b: Path(b.sound), bgm), cover=none_or(Path, meta.background), )
def test_that_notes_roundtrip( notes: List[Union[song.TapNote, song.LongNote]]) -> None: timing = song.Timing( events=[song.BPMEvent(song.BeatsTime(0), Decimal(120))], beat_zero_offset=song.SecondsTime(0), ) chart = song.Chart( level=Decimal(0), timing=timing, notes=sorted(notes, key=lambda n: (n.time, n.position)), ) metadata = song.Metadata("", "", Path(""), Path("")) string_io = _dump_memo1_chart("", chart, metadata, timing) chart_text = string_io.getvalue() parser = Memo1Parser() for line in chart_text.split("\n"): parser.load_line(line) parser.finish_last_few_notes() actual = set(parser.notes()) assert notes == actual
def eve_compatible_song(draw: DrawFunc) -> song.Song: """eve only keeps notes, timing info and difficulty, the precision you can get out of it is also severly limited""" diff = draw(st.sampled_from(list(song.Difficulty))) chart = draw( jbst.chart( timing_strat=jbst.timing_info( with_bpm_changes=True, bpm_strat=st.decimals(min_value=50, max_value=300, places=2), beat_zero_offset_strat=st.decimals(min_value=0, max_value=20, places=2), time_strat=jbst.beat_time( min_section=1, max_section=10, denominator_strat=st.sampled_from([4, 3]), ), ), notes_strat=jbst.notes( note_strat=st.one_of( jbst.tap_note(time_strat=simple_beat_strat), jbst.long_note( time_strat=simple_beat_strat, duration_strat=jbst.beat_time( min_numerator=1, max_section=3, denominator_strat=st.sampled_from([4, 3]), ), ), ), beat_time_strat=simple_beat_strat, ), level_strat=st.just(Decimal(0)), )) return song.Song( metadata=song.Metadata(), charts={diff: chart}, )