comparison examples/sound/sampled/Spectro.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 import samer.core.*;
2 import samer.tools.*;
3 import samer.maths.*;
4 import samer.audio.*;
5 import samer.units.*;
6 import samer.functions.*;
7 import samer.models.*;
8
9
10 public class Spectro {
11 public static void main(String [] args) throws Exception {
12 new samer.core.shells.SwingShell();
13
14 CompoundTask tasks=new CompoundTask();
15 RThread thread=new RThread(tasks);
16 AudioSource source=new FileSource();
17 LineIn linein=new LineIn(source,1024,512);
18 Scaler scaler=new Scaler(linein.output());
19 IIDPrior prior=new IIDPrior(scaler.output(),new Abs());
20 FFTVector fft=new FFTVector(scaler.output());
21 VVector y=new VVector("ft-magnitude",fft.size()/2);
22
23 scaler.setOutputModel(prior);
24 tasks.addTask(linein);
25 tasks.addTask(scaler);
26 tasks.addTask(prior);
27 tasks.addTask(new BatchedTrainer(scaler.getTrainer(),4));
28 tasks.addTask(fft.calcTask());
29 tasks.addTask(fft.getFnPower(new Sqrt(),y));
30
31 /* this shows how to put some defaults in the environment
32 they will affect any trace viewers for the ft-magnitude vector */
33 Shell.push(y.getNode());
34 Shell.put("trace.map.log","true");
35 Shell.put("trace.map.maxmimum",new Double(10));
36 Shell.put("trace.map.minimum",new Double(0.01));
37 Shell.pop();
38
39 y.getAgent().execute("trace",Shell.env());
40
41 {
42 Object [] commands = { "expose", "exit" };
43
44 Shell.interpret("expose");
45 Shell.exposeCommands(commands);
46 Shell.exposeCommands(thread);
47 }
48 }
49
50 public static void lineout() {
51 Shell.put("audio.scale",new Integer(1));
52 Shell.put("audio.rate",new Integer(22050));
53 // could create LineOut object to play stuff coming from linein
54 }
55 }