kionell / osu-parsers Goto Github PK
View Code? Open in Web Editor NEWA bundle of decoders/encoders for osu! file formats based on the osu!lazer source code.
License: MIT License
A bundle of decoders/encoders for osu! file formats based on the osu!lazer source code.
License: MIT License
osu! uses additional hit object types (ComboSkip1, ComboSkip2, ComboSkip3) to add offset to combo indexes. At this moment beatmap parser doesn't support it.
Example Map: https://osu.ppy.sh/beatmapsets/653534#osu/1464026
The offending lines look like this:
https://gist.github.com/blueberrymuffin3/fd924a80054a129231f91651d1a42788#file-panda-eyes-ily-m-a-r-v-o-l-l-o-light-insane-osu-L48-L70
M,0,454,,117,104
These commands are correctly parsed by osu!stable and osu!lazer as zero-duration commands, but are ignored by StoryboardParser
.
It's also referenced in the osu!wiki here.
The error occurs here:
osu-parsers/src/Utils/Parsing.ts
Lines 29 to 31 in 788de92
osu-parsers/src/Decoders/StoryboardDecoder.ts
Lines 125 to 131 in 788de92
找不到模块“osu-parsers”或其相应的类型声明
I've noticed that in some rare cases the sampleset is off on some hitobjects after parsing the .osu file.
I've applied the standard ruleset to the beatmap, if that makes any difference.
Beatmap to reproduce:
https://osu.ppy.sh/beatmapsets/2109375#osu/4427449
00:37:399 (5) - Sampleset in hitObject.nodeSamples should be Soft but it's Normal for some reason
There's no Buffer in the browser, hence the reason replays fail to decode.
A workaround is to use the "buffer" module from npm.
Workaround example:
import { Buffer } from "buffer";
async function getReplay(){
const requestResponse = await fetch("/replay.osr")
const arrayBuffer = await requestResponse.arrayBuffer()
await decoder.decodeFromBuffer(Buffer.from(arrayBuffer));
}
It would be way better to have decodeFromBuffer accept ArrayBuffer.
This addition will be useful mainly for Node.js with its Readable/Writable streams, but it will also be good to see if there any alternative for browsers.
Latest change made it impossible to decode most of the storyboard files
Buffers cannot change their size dynamically as arrays. Because of this problem, score encoder crashes the program. Serialization writer needs refactoring.
When parsing a beatmap that happens to have a colon :
in a metadata field results in the colon being replaced with a space:
Original .osu | Parsed String (console.log) | Parsed Object (console.log) |
---|---|---|
Code used to parse the beatmap
const importMetadata = (originBeatmap: string): BeatmapMetadata => {
const decoder = new BeatmapDecoder();
const decodedOriginBeatmap = decoder.decodeFromString(originBeatmap, {
parseStoryboard: true,
});
console.log(decodedOriginBeatmap);
return {
metadata: {
artist: decodedOriginBeatmap.metadata.artistUnicode,
artistRomanized: decodedOriginBeatmap.metadata.artist,
title: decodedOriginBeatmap.metadata.titleUnicode,
titleRomanized: decodedOriginBeatmap.metadata.title,
creator: decodedOriginBeatmap.metadata.creator,
source: decodedOriginBeatmap.metadata.source,
tags: decodedOriginBeatmap.metadata.tags,
},
generalMetadata: {
audioFileName: decodedOriginBeatmap.general.audioFilename,
previewTime: decodedOriginBeatmap.general.previewTime,
epilepsyWarning: decodedOriginBeatmap.general.epilepsyWarning,
samplesMatchPlaybackRate:
decodedOriginBeatmap.general.samplesMatchPlaybackRate,
widescreenStoryboard: decodedOriginBeatmap.general.widescreenStoryboard,
},
beatmapColours: {
sliderBodyColour: decodedOriginBeatmap.colors.sliderBorderColor,
sliderTrackColour: decodedOriginBeatmap.colors.sliderTrackColor,
comboColours: decodedOriginBeatmap.colors.comboColors,
},
};
};
I'm building a cross-platform hitsound copier and i got into some undefined behaviour after encoding a beatmap with video.
Debug info of BeatmapEventSection right before calling encoder.encodeToString() |
Generated content in the .osu |
---|---|
Code used to encode it.
const hitsoundedBeatmap = beatmapsTo.map((beatmap) =>
copyHitsounds(beatmapFrom, beatmap, options)
);
const encoder = new BeatmapEncoder();
const encodedHitsoundedBeatmaps = hitsoundedBeatmap.map((beatmap) =>
encoder.encodeToString(beatmap)
);
安装后提示osu-parsers/lib/browser.mjs 为起点找不到模块 "osu-classes"
There are some parts of the code that don't work in the browser:
If there is an empty line above the osu file format v
line, the parser throws Error: Failed to decode a beatmap: Not a valid beatmap!
.
This only really appeared in 1 map out of the ~2,500 I've parsed (https://osu.ppy.sh/b/1485848), so it's not a very big problem as far as I know.
A quick fix I tried adding was:
this._reset();
this._lines = this._getLines(data);
this._setEnabledSections(typeof options !== 'boolean' ? options : {});
this._sbLines = this._shouldParseStoryboard(options) ? [] : null;
// Remove first line if it's empty
if (this._lines[0] == '') this._lines.shift()
const fileFormatLine = this._lines[0].trim();
if (!fileFormatLine.startsWith('osu file format v')) {
throw new Error('Not a valid beatmap!');
}
inside the decodeFromLines()
function at node.cjs:2700
and node.mjs:2696
.
or at BeatmapDecoder.ts:121.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.