Plan 9 from Bell Labs’s /usr/web/sources/contrib/maht/inferno/appl/lib/fft_seq.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


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();
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.