import jp.crestmuse.cmx.amusaj.sp.* import jp.crestmuse.cmx.amusaj.filewrappers.* import jp.crestmuse.cmx.amusaj.commands.* import jp.crestmuse.cmx.math.* import static jp.crestmuse.cmx.math.Utils.* class MyF0Tracker extends SPModule { static { DoubleArray.mixin(Operations) } void execute(Object[] src, TimeSeriesCompatible[] dest) { def freq = src[0].freq() def power = src[0].power() def power_thrs = 0.001 * power.sum() def f0 = 0.0 if (freq.length() > 0) { for (i in 0..(freq.length() - 1)) { if (power[i] > power_thrs && freq[i] > 20) { f0 = freq[i] break } } } dest[0].add(create1dimDoubleArray(f0)) } Class[] getInputClasses() { [PeakSet.class] } Class[] getOutputClasses() { [DoubleArray.class] } }