Code Monkey home page Code Monkey logo

osu-parsers's People

Contributors

blueberrymuffin3 avatar kionell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

osu-parsers's Issues

Add combo offset to the parsed objects

osu! uses additional hit object types (ComboSkip1, ComboSkip2, ComboSkip3) to add offset to combo indexes. At this moment beatmap parser doesn't support it.

Storyboard parser fails on commands with an empty end time

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:

if (Number.isNaN(value)) {
throw new Error('Not a number');
}

It's caused by this line:
command.endTime = Parsing.parseInt(data[3]);

And is caught here:
try {
// Storyboard data.
this._parseStoryboardData(line, storyboard, depth);
}
catch {
return;
}

ScoreDecoder is not working in Browser environiment

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.

Score encoder is not working

Buffers cannot change their size dynamically as arrays. Because of this problem, score encoder crashes the program. Serialization writer needs refactoring.

Beatmaps with `:` in a metadata field gets the `:` replaced with a space

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)
image image image

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,
    },
  };
};

related .osu

Encoding a beatmap with video does not write the video to the encoded string/file.

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
image image

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)
  );

use error

安装后提示osu-parsers/lib/browser.mjs 为起点找不到模块 "osu-classes"

Add support for browser environment

There are some parts of the code that don't work in the browser:

  1. All decodeFromPath and encodeToPath methods - fs module problem.
  2. Both score decoder and encoder - buffer methods.

Empty first line in a map throws "Not a valid beatmap!" error

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.

image

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.