Coder Social home page Coder Social logo

francesco149 / oppai Goto Github PK

View Code? Open in Web Editor NEW
102.0 15.0 11.0 768 KB

legacy version of my osu! pp calculator. the newer, better version can be found here https://github.com/Francesco149/oppai-ng

License: GNU General Public License v3.0

C++ 94.26% Shell 0.41% Batchfile 0.16% Roff 0.42% Python 1.39% JavaScript 0.45% Java 2.91%

oppai's Introduction

Build Status

NOTE

oppai has been rewritten from scratch in pure C89 here: here. it's much smaller and faster than legacy oppai.

this is now deprecated and not actively developed anymore.

Index

osu! pp advanced inspector (oppai) is a difficulty and pp calculator for osu! standard beatmaps. It works on any map, even unsubmitted ones and all you have to do is supply it with the map's .osu file.

Getting started

Demonstration usage video on windows and linux: here.

  • If you are on arch linux, you can use the AUR packages oppai or oppai-git maintained by ammongit. Otherwise, download the latest binaries for your OS from here, extract the archive and place the executable anywhere you like. Advanced users are free to add oppai to their PATH to use it anywhere.
  • Open cmd (or your favorite terminal emulator if you're on linux) and cd /path/to/your/oppai/folder (forward slashes might be backwards on windows)
  • Type ./oppai for a list of possible parameters.

UPDATE: You can now pipe beatmaps to oppai from stdin, which means that you can download a map on the fly and call oppai on it in one simple command.

Some linux examples of piping:

curl https://osu.ppy.sh/osu/37658 | ./oppai -
curl https://osu.ppy.sh/osu/37658 | ./oppai - +HDHR
curl https://osu.ppy.sh/osu/37658 | ./oppai - +HDHR 99% 600x 1m

Windows examples of piping (using powershell):

(New-Object System.Net.WebClient).DownloadString("https://osu.ppy.sh/osu/37658") | ./oppai -
(New-Object System.Net.WebClient).DownloadString("https://osu.ppy.sh/osu/37658") | ./oppai - +HDHR
(New-Object System.Net.WebClient).DownloadString("https://osu.ppy.sh/osu/37658") | ./oppai - +HDHR 99% 600x 1m

NOTE: to obtain the beatmap url, just open the desired map's page in your browser, click on the desired difficulty and copy the url, then replace /b/ with /osu/.

If you don't feel like using the command line, you can hop on the shigetora chat and type !oppai url_to_beatmap followed by the parameters. But remember, you won't get the full output which contains much more useful info than just pp! So I recommend spending 1 minute downloading the tool and learning to use it from the command line.

Examples:

!oppai https://osu.ppy.sh/osu/37658
!oppai https://osu.ppy.sh/osu/37658 +HDHR
!oppai https://osu.ppy.sh/osu/37658 +HDHR 500x 1m

Caching beatmaps

oppai automatically caches pre-parsed beatmaps in binary format in the "oppai_cache" folder in the same directory as the oppai executable.

This speeds up subsequent calculations for that same map by up to 25%, especially on slow CPU's. The cache filesize is about 65kb per map on average.

If you have a machine with really slow I/O (networked filesystem, old HDD) or a cpu with really good single core performance, you might want to try passing -no-cache to disable caching and see if that makes it faster (it usually makes it SLOWER though).

NOTE: cache files are not guaranteed to be compatible across architecture, so you can't copy your beatmap cache from a 64-bit machine to a 32-bit machine or use 32-bit and 64-bit oppai on the same cache folder. delete it or move it in such cases.

Compiling from source (Linux)

git clone https://github.com/Francesco149/oppai.git
cd oppai
./build.sh

To cross compile, you can edit the build.sh and add, for example, -m32 after g++ in CXX.

OpenSSL is required to build oppai on Linux. The library and header files are bundled in the package libssl-dev on most distributions. On Debian it can be obtained as follows:

sudo apt-get install libssl-dev

Compiling from source (Windows)

You need to have git bash installed. The easiest way to get it is to install GitHub desktop.

You will also need visual studio. Any version should do. You don't even need the IDE, you can even get the stand-alone compiler without all the bloat.

Open git bash and type:

git clone https://github.com/Francesco149/oppai.git

Now open a visual studio command prompt:

cd \path\to\oppai\win
build.bat

The executable will be found in the build directory.

Compiling from source (OSX)

Via homebrew:

brew install --HEAD pmrowla/homebrew-tap/oppai

Note that installing with --HEAD is not required, but it is recommended since the tap may not always be up to date with the current oppai release tarball. Installing from homebrew will place the executable in your homebrew path.

Compiling from source in OSX will still require the use of homebrew since Apple no longer bundles OpenSSL headers with OSX. Also note that homebrew may give warnings about not symlinking OpenSSL, this is intended behavior and you should not brew link --force openssl due to potential conflicts with the Apple bundled OpenSSL.

brew install openssl
git clone https://github.com/Francesco149/oppai.git
cd oppai
./build.sh

Library mode and bindings

oppai can now be compiled in library mode by defining OPPAI_LIB=1. this allows you to #include /path/to/oppai/code/main.cc in any C++ program and call oppai functions to parse beatmaps, calculate pp and difficulty in your own software. The API is thread safe, so you can process beatmaps in parallel if you wish so.

This also makes it simple to create bindings to use oppai in pretty much any programming language.

Currently available bindings:

The library mode API is still new and nothing is set in stone, but I don't see it changing in the future.

Here's a minimal example of using oppai in lib mode (no error checking):

#include "../main.cc"

// don't forget to define OPPAI_LIB=1 in your build script!

#define BUFSIZE 2000000
static char buf[BUFSIZE];

int main(int argc, char* argv[])
{
    if (argc != 2) {
        fprintf(stderr, "Usage: %s file.osu\n", argv[0]);
        return 1;
    }

    // if you need to multithread, create one ctx and buffer for each thread
    oppai_ctx ctx;

    beatmap b(&ctx);
    beatmap::parse(argv[1], b, buf, BUFSIZE, true);

    // b.apply_mods(mods::...)

    f64 stars, aim = 0, speed = 0;

    d_calc_ctx dctx(&ctx);
    stars = d_calc(&dctx, b, &aim, &speed);

    printf(
        "%.17g stars, %.17g aim stars, %.17g speed stars\n",
        stars, aim, speed
    );

    pp_calc_result result = pp_calc(&ctx, aim, speed, b /* mods ... */);
    printf("%.17g pp\n", result.pp);

    return 0;
}

Recommended compiler flags for linux:

${CXX:-g++}              \
    -std=c++98           \
    -pedantic            \
    -O2                  \
    -Wno-variadic-macros \
    -Wall -Werror        \
    main.cc              \
    -lm -lstdc++         \
    -lcrypto             \
    -DOPPAI_LIB=1        \
    -o test

... and windows:

cl  -D_CRT_SECURE_NO_WARNINGS=1 ^
    -DNOMINMAX=1 ^
    -DOPPAI_LIB=1 ^
    -O2 ^
    -nologo -MT -Gm- -GR- -EHsc -W4 -WX ^
    -wd4201 ^
    -wd4100 ^
    -wd4458 ^
    -F8000000 ^
    main.cc ^
    -Fetest.exe ^
    Advapi32.lib

See lib_example/main.cc for a more complete example with error checking.

oppai's People

Contributors

christopher-dg avatar dpisdaniel avatar francesco149 avatar oamaok avatar omkelderman avatar pmrowla avatar thehowl avatar tillerino avatar zlima12 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

oppai's Issues

liboppai

Do you think it's worthwhile to create some externally-linkable functions and make an API that others could link to for use in their applications?

test

testing if old commit issue references affect new issues

TouchDevice MOD(TD) should be included now

Recently, TouchDevice(TD) replace previous NoVideo in enable_mods, some nerfed algorithm apply to this MOD when calculate pp (ACC). I hope when I pass +TD to oppai, it could give me correct answer. Waiting for your updates :)

syntax error when counting PP with SD or PF

C:\Users\QHS>"C:\CoolQ Pro\data\image\resource\oppai.exe" "C:\CoolQ Pro\data\image\resource\osu\1059390.osu" -ojson +sd 97.12% 0m 228x

+SD
{"oppai_version":"1.1.18","code":-2,"errstr":"syntax error"}

C:\Users\QHS>"C:\CoolQ Pro\data\image\resource\oppai.exe" "C:\CoolQ Pro\data\image\resource\osu\1059390.osu" -ojson 97.12% 0m 228x
{"oppai_version":"1.1.18","code":200,"errstr":"no error","artist":"Drop","title":"Granat","creator":"Left","version":"Insane","mods_str":"","mods":0,"od":7.5,"ar":9,"cs":4.3,"hp":6,"combo":228,"max_combo":229,"num_circles":61,"num_sliders":78,"num_spinners":0,"misses":0,"score_version":1,"stars":4.0024787806542204,"speed_stars":1.8782654451297689,"aim_stars":2.0422307053928908,"nsingles":117,"nsingles_threshold":138,"aim_pp":30.755210021571642,"speed_pp":23.756500317173852,"acc_pp":5.5947907430272652,"pp":61.919390076092263}

Is it a feature or a bug..?

buggy perfect slider logic

https://osu.ppy.sh/s/359890

6755-7032: Slider [Type P, Length 112, 1 Repetitions] (272, 192) (301, 151) (369, 141) 

-- TEST SLIDER SIMULATION --
0ms (272.208 191.283)
50ms (291.018 159.471)
100ms (322.644 140.353)
150ms (358.82 138.34)
200ms (358.82 138.34) <-- ????
250ms (358.82 138.34) <-- ????
277ms (0 0) <-- ????

this is probably what was causing slider diff calc issues on some maps.

tolower/toupper was not declared

$ make
Compiling pp_calc.cc...
Compiling diff_calc.cc...
Compiling main.cc...
main.cc: In function ‘int main(int, char**)’:
main.cc:87:39: error: ‘tolower’ was not declared in this scope
   std::transform(a, a + strlen(a), a, tolower);
                                       ^~~~~~~
main.cc:127:6: error: ‘toupper’ was not declared in this scope
      toupper);
      ^~~~~~~
Makefile:41: recipe for target 'obj/main.o' failed
make: *** [obj/main.o] Error 1

running arch linux on latest source

overhaul code structure

pp calc, and diff calc should be entirely separated and the pp calc module should not be aware of the beatmap object, so that they can be used by themselves as separate modules.

might also want to separate beatmap from diff calc so it can be used by itself to extract metadata and such

java-oppai: is ${env_var:PATH} required?

It makes the command line invokation longer and uglier.

are you sure it's actually required? when I tested with jamvm, all I needed was

javac -1.5 -cp src/oppai.jar Example.java
java -Djava.library.path=. -cp .:src/oppai.jar Example /path/to/song.osu

compilation command is also cleaner in my example

note that I also took off package test in Example as it was unnecessary and you can run it without a package name

@dpisdaniel

pyoppai error: Unable to find vcvarsall.bat

I have been able to install pyoppai on linux, but the windows installation with git bash throws this error.

Full output:

$ python setup.py install
running install
running build
running build_ext
building 'pyoppai' extension
error: Unable to find vcvarsall.bat

PP calculation formulas

Sorry if post here, i dont know how to PM in github,
Can you make code of pp calculation in JS/Java version?
I need the formulas, anyway thanks.

Missing artist

I am getting a Missing artist in metadata error for this map:

Thing is: it's true, this map doesn't have an artist. However it's freakin ranked (Kappa), so what do we do now?

Add man page

A man page for usage of the program, giving available options, usage examples, and other notes.

inf pp

map: https://osu.ppy.sh/b/1258033&m=0

for some reason (I havent played the map, if I will it'll probably be obvious) this thing has a shitton of stars:
(interesting sidenote: website/osu-api displays it as zero stars)

stars: 5.62916e+94
aim stars: 3.75277e+94
speed stars: 4.39004e+59

aim: 2.71601e+284
speed: 4.34789e+179

which results in a pp value of infinite: infpp

Which in itself isnt that bad honestly, but it is a problem when doing json output:

{"oppai_version":"0.9.6","artist":"Helblinde","title":"The Solace of Oblivion","version":"Aspire","creator":"MinG3012","mods_str": "","od":8.68,"ar":9.35,"cs":3.99,"hp":2.55,"combo": 16727,"max_combo": 16727,"num_circles": 737,"num_sliders": 767,"num_spinners": 4,"misses": 0,"score_version": 1,"stars": 5.6291586263016401e+94,"speed_stars": 4.3900365064717424e+59,"aim_stars": 3.7527724175344267e+94,"rhythm_awkwardness": nan,"nsingles": 959,"nsingles_timing": 1415,"nsingles_threshold": 1038,"pp":inf}

Since because of the inf value of pp and the nan value of "rhythm_awkwardness" it is not valid json anymore 😞

Replace inf and nan with null or something since that is valid json? Idk, probably stupid idea, but I have no idea how to handle such cases in a "true json" way....

singletap percent above 100

wat

o p p a i | v0.9.7
s     d n | 
u     v s | (looking for
!     a p | cool ascii
      n e | to put here)
      c c | 
      e t | 
      d o | 
        r |


TrySail - High Free Spirits -TV.Ver- [Skystar's Extra] (Rizia) 
od9 ar9.19 cs3.79 hp7
506/506 combo
292 circles, 100 sliders 2 spinners
0xmiss
100%
scorev1

5.96 stars
aim stars: 3.21, speed stars: 2.3

aim: 132.61
speed: 47.87
accuracy: 85.54

rhythm awkwardness (beta): 0.780026
awkwardness acc pp bonus (beta): 1
326 spacing singletaps (83.1633%)
393 timing singletaps (100.255%)
345 notes within singletap threshold (88.0102%)

271.73pp

java-oppai: better code arrangement

Beatmap.cpp including every other cpp is even more unintuitive than my main.cpp including everything else.

either squash everything into one file and get rid of the .h's making sure to preserve all function attributes that were in the headers (I realize they are automatically generated, but I usually copy the prototype by hand from the generated JNI header), or just compile cpp's separately normally.

also, Beatmap continaining the diff/pp calculation results is a bit weird, maybe put them in separate objects like other bindings do?

@dpisdaniel

Replay support?

plz support replays! i can't play and see my misses at the same time

annoying "fopen: No such file or directory" output when running oppai

fopen: No such file or directory
{"oppai_version":"0.9.5","artist":"Komiya Mao","title":"(can you) understand me?","version":"uhh?","creator":"Sotarks","mods_str": "+HDHR","od":10,"ar":10,"cs":5.45,"hp":8.67,"combo": 439,"max_combo": 439,"num_circles": 174,"num_sliders": 131,"num_spinners": 0,"misses": 0,"score_version": 1,"stars": 5.7100678584207669,"speed_stars": 2.1866054254630947,"aim_stars": 3.0778434304594797,"rhythm_awkwardness": 1.2105010286350117,"nsingles": 293,"nsingles_timing": 304,"nsingles_threshold": 304,"pp":269.26079658519092}```

Build issue, cannot find std::string

When compiling on my Linux machine, I get the following compilation error:

In file included from main.cc:81:0:
beatmap.cc: In static member function ‘static void beatmap::parse(const char*, beatmap&)’:
beatmap.cc:446:4: error: ‘string’ is not a member of ‘std’
    std::string sline{tok};
    ^~~
beatmap.cc:447:18: error: ‘sline’ was not declared in this scope
    char* line = &sline[0];
                  ^~~~~

If I change line 2 of beatmap.cc to include <string> instead of <string.h> the build succeeds. Seems like a simple typo.

make oppai-java build easy

it's not nice to make people copypaste huge gcc/msvc strings to compile oppai-java. we should have a simple build.sh and build.bat script that does it for the most commonly used compilers like node-oppai and pyoppai do.

@dpisdaniel

Allow inputing beatmap over stdin.

It would be useful to allow using oppai without having a physical beatmap file. The best solution for this would be to enable inputing the beatmap file data over stdin.

This would allow applications to have a more versatile way of interacting with oppai.

Compilation error

On commit d3d9bc5 compilation fails with the following result:

In file included from main.cc:92:0:
beatmap.cc: In member function ‘timing_point* beatmap::parent_timing(timing_point*)’:
beatmap.cc:991:39: error: self-comparison always evaluates to false [-Werror=tautological-compare]
                 if (!res || res->time > res->time) {
                             ~~~~~~~~~~^~~~~~~~~~~
cc1plus: all warnings being treated as errors

[question] Monolithic build?

I was looking at the source and I couldn't help but wonder, why do you squash all of the sources into main.cc via includes rather than having separate object files with headers? Is there a design reason for this?

Max combo wrong

In this map the max combo is 2216. Oppai says it is 2240.

Showing adjusted HP drain in the output

Hey there.
The application I'm currently developing makes use of some of the secondary features, presented by oppai - mod-adjusted star rating and AR, OD, CS values. They are very valuable and it's convenient to have them produced by the same tool that calculates PP instead of having to write a separate algorithm of my own. However, it doesn't seem to output the mod-adjusted HP drain values. I know it doesn't have any impact on PP and it's not difficult to calculate by myself, but it would be great if I could just snatch it from the oppai output, along with the rest of the values.

investigate cache robustness

some guy managed to get pyoppai to write a broken cache which wasn't being detected as broken, resulting in incorrect values

I haven't been able to duplicate this

TODO: investigate this, but it was probably just caused by incorrect usage of the buffer = corrupted memory, because I triple checked the code and I can't see how this is possible

Windows Build Error

Hello!

Can't build oppai for Windows.
Got this ↓

7ef3a8795a 1

P.S. Sorry for Russian VS D:

Cache use.

I don't understand how to make use of the cache. If my oppai has already downloaded the osu file, how do I then use that in subsequent calls? Do I specify the beatmap id after oppai.exe?

Some clarification would be nice. Thanks.

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.