implement FFT_seq;
include "fft_seq.m";
include "draw.m";
draw : Draw;
include "sys.m";
sys: Sys;
include "bufio.m";
bufio: Bufio;
Iobuf : import bufio;
include "readdir.m";
readdir : Readdir;
init(nil: ref Draw->Context, nil: list of string)
{
draw = load Draw Draw->PATH;
sys = load Sys Sys->PATH;
readdir = load Readdir Readdir->PATH;
}
new_sequence(d : string) : ref Sequence
{
r := ref Sequence(big 33, d, big 0, 255);
r.scan();
return r;
}
get_number(b : ref Iobuf) : int
{
n := b.gett("\n ");
if(n[0] == '#' && n[len n - 1] != '\n') {
b.gets('\n');
return get_number(b);
} else {
return int n;
}
}
Sequence.scan(s : self ref Sequence)
{
(files, filecount) := readdir->init(s.directory, readdir->NAME | readdir->COMPACT);
s.framecount = big filecount;
fname := sys->sprint("%s/%s", s.directory, files[0].name);
b := bufio->open(fname, sys->OREAD);
if(b == nil){
sys->print("Opening %s failed\n", fname);
return;
}
s.samples = get_number(b);
b.gets('\n');
s.offset = b.offset();
}
|