1
2 // exercise3.cc
3
4 #include "artsflow.h"
5 #include "connect.h"
6
7 using namespace Arts;
8
9
10 int main()
11 {
12 Dispatcher dispatcher;
13
14 Synth_FREQUENCY freq1,freq2,freqspin; // object creation
15 Synth_WAVE_SIN sin1,sin2,sinspin;
16 Synth_MUL mulspin1,mulspin2;
17 Synth_ADD addspin1,addspin2;
18 Synth_MUL mul1spin1,mul1spin2,mul2spin1,mul2spin2;
19 Synth_ADD addleft,addright;
20 Synth_PLAY play;
21
22 setValue(freq1, 440.0); // set frequencies
23 setValue(freq2, 880.0);
24 setValue(freqspin, 0.4);
25
26 connect(freq1, sin1); // object connection
27 connect(freq2, sin2);
28 connect(freqspin, sinspin);
29
30 // first side: (freqspin * 0.5) + 0.5 (is between 0..1)
31 connect(sinspin, mulspin1, "invalue1");
32 setValue(mulspin1, "invalue2", 0.5);
33 connect(mulspin1, addspin1, "invalue1");
34 setValue(addspin1, "invalue2",0.5);
35
36 // first side: (freqspin * (-0.5)) + 0.5 (is between 1..0)
37 connect(sinspin, mulspin2, "invalue1");
38 setValue(mulspin2, "invalue2", -0.5);
39 connect(mulspin2, addspin2, "invalue1");
40 setValue(addspin2, "invalue2",0.5);
41
42 // multiply sin1 with the (0..1) and (1..0) ranges
43 connect(sin1,mul1spin1,invalue1");
44 connect(addspin1,mul1spin1,"invalue2");
45 connect(sin1,mul1spin2,"invalue1");
46 connect(addspin2,mul1spin2,"invalue2");
47
48 // multiply sin2 with the (0..1) and (1..0) ranges
49 connect(sin2,mul2spin1,"invalue1");
50 connect(addspin1,mul2spin1,"invalue2");
51 connect(sin2,mul2spin2,"invalue1");
52 connect(addspin2,mul2spin2,"invalue2");
53
54 // left channel output
55 connect(mul1spin1,addleft,"invalue1");
56 connect(mul2spin2,addleft,"invalue2");
57 connect(addleft, play, "invalue_left");
58
59 // right channel output
60 connect(mul2spin1,addright,"invalue1");
61 connect(mul1spin2,addright,"invalue2");
62 connect(addright, play, "invalue_right");
63
64 // start and go ;-)
65 freq1.start(); freq2.start(); freqspin.start();
66 sin1.start(); sin2.start(); sinspin.start();
67 mulspin1.start(); mulspin2.start();
68 addspin1.start(); addspin2.start();
69 mul1spin1.start(); mul1spin2.start();
70 mul2spin1.start(); mul2spin2.start();
71 addleft.start(); addright.start();
72 play.start();
73 dispatcher.run();
74 }
75 |