include "inc/cmdsys.plh"
include "inc/args.plh"
include "inc/fileio.plh"
include "inc/sndseq.plh"

//
// These are utility sequences/routines needed to test the music sequencer code.
//
word arg, seq, len
byte ref
//
// Sample background process to show it's working
//
def backgroundProc#0
    putc('.')
end

arg = argNext(argFirst)
if ^arg
    ref = fileio:open(arg)
    if ref
        seq = heapalloc(heapavail - 256)
        len = fileio:read(ref, seq, heapmark - seq)
        fileio:close(ref)
        heaprelease(seq + len)
        musicPlay(seq, TRUE)
        musicGetKey(8, @backgroundProc) // Yield every 8/16 second
        musicStop
    else
        puts("File not found.\n")
    fin
fin

done
