Coder Social home page Coder Social logo

sightread's Introduction

SightRead

SightRead is a library for reading .chart and .mid files for GH/RB-style games.

Requirements

The main library requires no external libraries, only a C++20 compiler. Boost.Test is needed if you want to build the tests.

Crash Course

This is a quick summary of what I expect people are most likely to want. Proper documentation will come when the interface settles down.

Your two parsers are SightRead::ChartParser and SightRead::MidiParser. Find them in sightread/chartparser.hpp and sightread/midiparser.hpp respectively. Both take in their constructor a single const SightRead::Metadata& parameter, which is a simple struct with song name, artist, and charter.

There are some methods to customise their behaviour, but for Clone Hero the only one you care about is .hopo_threshold. This takes a struct representing the song.ini options that determine the cutoff for how close notes need to be to be HOPOs. The default behaviour is as if these tags are absent.

Then to use the parsers, both have a .parse method. ChartParser accepts a std::string_view, MidiParser accepts a std::span<const std::uint8_t>. These are meant to be the contents of the .chart/.midi files. Of note is that ChartParser::parse expects UTF-8. Unfortunately UTF-16 .chart files do exist in the wild, and the conversion is your job.

Both parsers return a SightRead::Song. Here the primary methods are .track to get a SightRead::NoteTrack for a particular instrument and difficulty, and .global_data() which returns a class that crucially contains a SightRead::TempoMap. The tempo map is there to convert between time that is measured in various units: Beat, Measure, OdBeat (for Rock Band), Second, and Tick. Not all the conversion methods currently exist, but you can convert between any two with suitable chaining. I'll clean that up at some point.

Worth noting, right now SightRead::NoteTrack pretty much contains just what is needed for CHOpt. In particular, section names are currently absent. However, HOPO/tap status is present on notes. This has not been thoroughly tested though so for the time being, caveat emptor!

Lastly, no writing. Serialisation is out of scope for SightRead.

Integration

The intended means of consumption is as a git submodule. This gives you a CMake library called sightread, which can then be used in a way similar to the following:

add_subdirectory("extern/sightread")
target_link_libraries(<YOUR-TARGET> PRIVATE sightread)

You should use a tagged version, for now main is a development branch and right now the interface should be treated as very unstable.

Acknowledgements

  • TheNathannator for making my life easier.
  • FireFox2000000, for Moonscraper was useful to understand CH's parsing behaviour back when I first made CHOpt.
  • Matref for the name.

sightread's People

Contributors

genericmadscientist avatar

Watchers

 avatar

Forkers

peancored

sightread's Issues

WASM Compatibility

Hi, thank you for this library, it's great!

I'd really like to use it for an electron app I'm building that converts CH drum charts to sheet music that you can play along to. So I was trying to compile this library as a WASM module.

Been trying to use embind to bind APIs, but been stuck at some parts of the codebase using std::set that Emscripten doesn't provide bindings for.
Unfortunately, my C++ knowledge is not very good so I'm not sure what I need to do to enable things like that.

It sounds like a lot of work to make it wasm compatible, but on the other hand, wasm modules can be used with different languages, so I thought I'd ask whether it's possible to do so. It would really enable devs like me to use this library for different applications.

In any case, this repo provides some great insights into how to parse midi, so if it's impossible to make a wasm module, I can use it as a resource to build my own js parser.

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.