10000 GitHub - Strultz/organya.h: A simple C89 library for reading and decoding Organya music (.org files).
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A simple C89 library for reading and decoding Organya music (.org files).

License

Notifications You must be signed in to change notification settings

Strultz/organya.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

organya.h

Description

organya.h is a simple C89 library for reading and decoding Organya music (.org files).

Organya is a sequenced music format created in 1999 by Studio Pixel. It is the predecessor to PxTone and was used in games such as Cave Story, Azarashi (2001 version), STARGAZER, and more.

Usage

To use this library, just #include "organya.h" in your project. Define ORGANYA_IMPLEMENTATION before including the header in one .c file to create the implementation. You should also link with -lm on Linux/BSD systems.

Example

#define ORGANYA_IMPLEMENTATION
#include "organya.h"

int main()
{
    /* Create the context: */
    organya_context ctx;
    if (organya_context_in
6551
it(&ctx) != ORG_RESULT_SUCCESS)
    {
        /* Handle the error here */
        return -1;
    }

    /* Set everything up (these are the default settings): */
    organya_context_set_sample_rate(&ctx, 44100);
    organya_context_set_interpolation(&ctx, ORG_INTERPOLATION_LAGRANGE);
    organya_context_set_volume(&ctx, 1);
    /* Note: Using Lagrange interpolation produces output that sounds almost completely
     * identical to the original Organya playback (on Windows Vista and later) */

    /* Load a soundbank from a file path: */
    if (organya_context_load_soundbank_file(&ctx, "path/to/file.wdb") != ORG_RESULT_SUCCESS)
    {
        /* Handle the error here */
        organya_context_deinit(&ctx);
        return -1;
    }
    /* Then load a song from a file path: */
    if (organya_context_load_song_file(&ctx, "path/to/file.org") != ORG_RESULT_SUCCESS)
    {
        /* Handle the error here */
        organya_context_deinit(&ctx);
        return -1;
    }
    /* Alternatively, you can load both of these directly from some pointer using
     * organya_context_read_soundbank() and organya_context_read_song(). */

    /* Generate samples (which would then be output to an audio player, or a .wav file, or etc.)
     * This will output interleaved stereo 32-bit floating point PCM to output_buffer.
     * output_buffer should be at least num_samples * sizeof(float) * 2 long. */
    organya_context_generate_samples(&ctx, output_buffer, num_samples);

    /* When you're done, deinitialize and free everything: */
    organya_context_deinit(&ctx);

    return 0;
}
0