Mercurial > hg > jslab
view examples/sound/sampled/Spectro.java @ 5:b67a33c44de7
Remove some crap, etc
author | samer |
---|---|
date | Fri, 05 Apr 2019 21:34:25 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
import samer.core.*; import samer.tools.*; import samer.maths.*; import samer.audio.*; import samer.units.*; import samer.functions.*; import samer.models.*; public class Spectro { public static void main(String [] args) throws Exception { new samer.core.shells.SwingShell(); CompoundTask tasks=new CompoundTask(); RThread thread=new RThread(tasks); AudioSource source=new FileSource(); LineIn linein=new LineIn(source,1024,512); Scaler scaler=new Scaler(linein.output()); IIDPrior prior=new IIDPrior(scaler.output(),new Abs()); FFTVector fft=new FFTVector(scaler.output()); VVector y=new VVector("ft-magnitude",fft.size()/2); scaler.setOutputModel(prior); tasks.addTask(linein); tasks.addTask(scaler); tasks.addTask(prior); tasks.addTask(new BatchedTrainer(scaler.getTrainer(),4)); tasks.addTask(fft.calcTask()); tasks.addTask(fft.getFnPower(new Sqrt(),y)); /* this shows how to put some defaults in the environment they will affect any trace viewers for the ft-magnitude vector */ Shell.push(y.getNode()); Shell.put("trace.map.log","true"); Shell.put("trace.map.maxmimum",new Double(10)); Shell.put("trace.map.minimum",new Double(0.01)); Shell.pop(); y.getAgent().execute("trace",Shell.env()); { Object [] commands = { "expose", "exit" }; Shell.interpret("expose"); Shell.exposeCommands(commands); Shell.exposeCommands(thread); } } public static void lineout() { Shell.put("audio.scale",new Integer(1)); Shell.put("audio.rate",new Integer(22050)); // could create LineOut object to play stuff coming from linein } }