#include "xmp.bi"
#Include "crt.bi"


    Dim As xmp_context c
    Dim As xmp_frame_info mi
    Dim As FILE Ptr f
    '/* The output raw file */
    f = fopen("out.raw", "wb")
    if (f = NULL) Then
        fprintf(stderr, "can't open output file\n")
        Sleep 
        end
    EndIf
    '/* Create the player context */
    c = xmp_create_context()
    '/* Load our module */
    if (xmp_load_module(c, "modules\test_keyoff.it") <> 0) Then
        fprintf(stderr, "can't load module\n")
        Sleep 
        End
    EndIf
    '/* Play the module */
    xmp_start_player(c, 44100, 0)
    while (xmp_play_frame(c) = 0) 
        xmp_get_frame_info(c, @mi)
        if (mi.loop_count > 0) Then Exit While    '/* exit before looping */
        fwrite(mi.buffer, mi.buffer_size, 1, f)  '/* write audio data */
    Wend
    xmp_end_player(c)
    xmp_release_module(c)       '/* unload module */
    xmp_free_context(c)         '/* destroy the player context */
    fclose(f)

