osu-trainer Documentation

repository·master·Indexed 19 days ago

https://github.com/funorange/osu-trainer

A utility for quickly modifying the difficulty of osu! beatmaps. The project includes documentation for integrating Vorbis (.ogg) playback via NAudio.Vorbis and implementing a global keyboard hook using the globalKeyboardHook submodule.

Tokens
1K
Snippets
6
Records
8
Agent score
66%

What's inside osu-trainer

  1. Integrate globalKeyboardHook into your project

    master

    To use globalKeyboardHook, add the globalKeyboardHook.cs file directly to your project. You must include the Utilities namespace in the file where you intend to use the hook.

    1. Add globalKeyboardHook.cs to your project.
    2. Add using Utilities; to your source file.
    3. Instantiate the hook using new globalKeyboardHook().
    using Utilities;
    
    // Inside your class
    globalKeyboardHook gkh = new globalKeyboardHook();
  2. Integrate Vorbis (.ogg) playback into NAudio projects

    master

    NAudio.Vorbis provides a convenience wrapper to integrate the NVorbis library into NAudio-based projects, allowing you to read .ogg files as standard NAudio wave streams.

    To use it, you must add references to both NVorbis.dll and NAudio.Vorbis.dll in your project.

    // add a reference to NVorbis.dll
    // add a reference to NAudio.Vorbis.dll
    
    using (var vorbisStream = new NAudio.Vorbis.VorbisWaveReader("path/to/file.ogg"))
    using (var waveOut = new NAudio.Wave.WaveOutEvent())
    {
        waveOut.Init(vorbisStream);
        waveOut.Play();
       
        // wait here until playback stops or should stop
    }
  3. Manage generated maps and disk space

    master

    osu-trainer generates new beatmap files which can consume significant disk space over time (e.g., ~1GB for every 333 maps).

    To free up space:

    1. Delete the generated maps within the osu! client.
    2. Click the Clean Up button within the osu-trainer application.
  4. Configure keys and event handlers for globalKeyboardHook

    master

    The globalKeyboardHook automatically installs the hook upon construction. To use it, you must:

    1. Add specific keys to the HookedKeys collection.
    2. Subscribe to the KeyDown and KeyUp events.

    Note on Key Constants: Some keys may not respond to generic constants. For example, Keys.Shift might require Keys.LShiftKey or Keys.RShiftKey, and Keys.Control might require Keys.LControl or Keys.RControl.

    private void Form1_Load(object sender, EventArgs e) {
        gkh.HookedKeys.Add(Keys.A);
        gkh.HookedKeys.Add(Keys.B);
        gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
        gkh.KeyUp += new KeyEventHandler(gkh_KeyUp);
    }
    
    void gkh_KeyDown(object sender, KeyEventArgs e) {
        // Handle key down
        e.Handled = true; // Prevents the key press from being passed to other applications
    }
    
    void gkh_KeyUp(object sender, KeyEventArgs e) {
        // Handle key up
        e.Handled = true;
    }
  5. Use VorbisWaveReader for OGG file streaming

    master

    The NAudio.Vorbis.VorbisWaveReader class is used to open an Ogg Vorbis file and expose it as a stream compatible with NAudio's WaveOutEvent or other wave providers. It requires a valid file path to an .ogg file.

    var vorbisStream = new NAudio.Vorbis.VorbisWaveReader("path/to/file.ogg");