samer@0: import samer.core.*; samer@0: import samer.tools.*; samer@0: import samer.maths.*; samer@0: import samer.audio.*; samer@0: import samer.units.*; samer@0: import samer.functions.*; samer@0: import samer.models.*; samer@0: samer@0: samer@0: public class Spectro { samer@0: public static void main(String [] args) throws Exception { samer@0: new samer.core.shells.SwingShell(); samer@0: samer@0: CompoundTask tasks=new CompoundTask(); samer@0: RThread thread=new RThread(tasks); samer@0: AudioSource source=new FileSource(); samer@0: LineIn linein=new LineIn(source,1024,512); samer@0: Scaler scaler=new Scaler(linein.output()); samer@0: IIDPrior prior=new IIDPrior(scaler.output(),new Abs()); samer@0: FFTVector fft=new FFTVector(scaler.output()); samer@0: VVector y=new VVector("ft-magnitude",fft.size()/2); samer@0: samer@0: scaler.setOutputModel(prior); samer@0: tasks.addTask(linein); samer@0: tasks.addTask(scaler); samer@0: tasks.addTask(prior); samer@0: tasks.addTask(new BatchedTrainer(scaler.getTrainer(),4)); samer@0: tasks.addTask(fft.calcTask()); samer@0: tasks.addTask(fft.getFnPower(new Sqrt(),y)); samer@0: samer@0: /* this shows how to put some defaults in the environment samer@0: they will affect any trace viewers for the ft-magnitude vector */ samer@0: Shell.push(y.getNode()); samer@0: Shell.put("trace.map.log","true"); samer@0: Shell.put("trace.map.maxmimum",new Double(10)); samer@0: Shell.put("trace.map.minimum",new Double(0.01)); samer@0: Shell.pop(); samer@0: samer@0: y.getAgent().execute("trace",Shell.env()); samer@0: samer@0: { samer@0: Object [] commands = { "expose", "exit" }; samer@0: samer@0: Shell.interpret("expose"); samer@0: Shell.exposeCommands(commands); samer@0: Shell.exposeCommands(thread); samer@0: } samer@0: } samer@0: samer@0: public static void lineout() { samer@0: Shell.put("audio.scale",new Integer(1)); samer@0: Shell.put("audio.rate",new Integer(22050)); samer@0: // could create LineOut object to play stuff coming from linein samer@0: } samer@0: }