Mercurial > hg > jslab
comparison src/samer/units/SignalWindow.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package samer.units; | |
2 import samer.tools.*; | |
3 import samer.maths.*; | |
4 | |
5 public class SignalWindow extends AnonymousTask | |
6 { | |
7 Generator gen; | |
8 VVector output; | |
9 double out[], buf[]; | |
10 int size, count; | |
11 | |
12 public SignalWindow(Generator g, int size) { | |
13 this(g,size,size); | |
14 } | |
15 | |
16 public SignalWindow(Generator g, int size, int step) | |
17 { | |
18 output=new VVector("signalBlock", size); | |
19 out=output.array(); | |
20 buf=new double[step]; | |
21 this.size=size; | |
22 gen=g; | |
23 } | |
24 | |
25 public VVector output() { return output; } | |
26 public void starting() { count=0; } | |
27 public void run() { buf[count++]=gen.next(); } | |
28 public void flush() { | |
29 System.arraycopy(out,count,out,0,size-count); | |
30 System.arraycopy(buf,0,out,size-count,count); | |
31 count=0; | |
32 output.changed(); | |
33 } | |
34 | |
35 public Task flushTask() { | |
36 return new NullTask() { public void run() { flush(); } }; | |
37 } | |
38 } | |
39 |