Beispiel #1
0
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)
Beispiel #2
0
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