CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

VBAP_test.cpp
Go to the documentation of this file.
1 //
2 // VBSP_test.cpp -- C main functions for the CSL4 VBAP tests.
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 //
5
6 #include "VBAP.h"
7 #include "string.h"
8 #include "SpeakerLayout.h"
9 #include <time.h>
10 #include "CSL_Includes.h" // include all of CSL core
11 #include "PAIO.h" // PortAudio IO
12
13 using namespace csl;
14
15 // MAIN
16
17 int main (int argc, const char * argv[]) {
18
19 Sine vox(220.0); // sine wave
20 AR env(0.25, 0.05, 0.2); // AR constructor dur, att, rel
21 vox.setScale(env);
22
23 SpeakerLayout spl("../../../CSL/Spatializers/5point1.dat");
24 VBAP vbap(kAuto, & spl); // VBAP object (with default spkr layout)
25
26 SpatialSource src(vox, 90.0); // src * 90 degrees
27 vbap.addSource(src);
28
29 PAIO *gIO = new PAIO(44100, 1024, -1, -1, 0, 5);
30
31 logMsg("CSL playing VBAP...");
32 gIO->setRoot(vbap); // make some sound
33 gIO->open();
34 gIO->start(); // start the driver callbacks
35
36 for (float i = 0; i < 40; i++) {
37 env.trigger();
38 sleepMsec(700);
39 src.setPosition('s', 90.0 + (30.0 * i)); // rotate
40 }
41 logMsg("CSL done.");
42 gIO->stop(); // stop the driver and close down
43 gIO->close();
44 return 0; // exit
45
46 }
47
48 // OLD VBAP TEST CODE. LEFT HERE FOR REFERENCE, UNTIL THE NEW VBAP TESTS ARE FINISHED.
49
50 //using namespace csl;
51 //using namespace vbap;
52 //using namespace point;
53 //
54 //
55 //#include "Test_Support.cpp" // include all of CSL core and the test support functions
56 //
57 //// Cmd-line options:
58 //// -r srate -b blksiz -o noch -i nich -v verbosity -l logperiod -p outport -u
59 ////
60 //// MAIN -- sweeps source across arc
61 ////
62 //// Added options
63 //// "-S val" = set source azimuth in degrees
64 //// "-L val" = set loudspeaker azimuth in degrees
65 ////
66 //
67 //#define SOURCE 49
68 //#define SPEAKER 50
69 //
70 ////fMatrix LI(3,3);
71 //
72 //float max_mu = 0.0;
73 //float min_mu = 100.0;
74 //float max_e = 0.0;
75 //float min_e = 100.0;
76 //float max_error = 0.0;
77 //float min_error = 100.0;
78 //
79 //extern unsigned exit_count;
80 //
81 //
82 //int main (int argc, const char * argv[]) {
83 //
84 // unsigned value; // variable used for arg parsing
85 // int sc = SOURCE; // float values for freq and dur
86 // int sp = SPEAKER;
87 // char layout_file[100];
88 //
89 // READ_CSL_OPTS; // parse the standard CSL options:
90 // if (find_option(argc, argv, 'f', &value) > 0) { // "-f filename" = open speaker layout file
91 // strcpy(layout_file, argv[value]);
92 // printf("Layout file: %s\n", layout_file);
93 // }
94 //
95 //
96 // SoundFile fi("/Users/dmccoy/Code/thesis/Demo.aif");
97 // fi.open_for_read();
98 // fi.set_is_looping(true);
99 //// SoundFile fi2("/Users/doug/Code/EMA/trumpet.aif");
100 //// fi2.open_for_read();
101 //// fi2.set_is_looping(true);
102 //// printf("\tFile \"%s\" SR: %d #CH: %d #FR: %d\n", fi._path, fi.rate(), fi.channels(), fi.duration());
103 //// printf("\tFile \"%s\" SR: %d #CH: %d #FR: %d\n", fi2._path, fi2.rate(), fi2.channels(), fi2.duration());
104 //// fflush(stdout);
105 //
106 // ThreadedReader tsf(1);
107 // tsf.set_input(fi);
108 // tsf.set_threshold( 2 * CGestalt::block_size() );
109 //// ThreadedReader tsf2(1);
110 //// tsf2.set_input(fi2);
111 //// tsf2.set_threshold( 2 * CGestalt::block_size() );
112 //
113 //// Sine vox(440.0, 0.8);
114 //
115 //// FanOut fan(tsf, 2);
116 //// DLine delay(vox, 1.0);
117 //// delay.init_delay_time(0.1);
118 //// AddOp mix(fan, delay);
119 //
120 //
121 // CVBAP v;
122 //
123 // v.read_speaker_layout_from_file( layout_file );
124 //
125 // v.find_triples();
126 //
127 // v.dump_speakers();
128 // v.dump_triples();
129 //
130 //// Sine vox(200.0, 0.7);
131 //// vox.set_num_channels(1);
132 //
133 // CSource s(tsf, 0., 0., 0.5); // sawtooth at sc degrees
134 //// CSource s2(vox); // sawtooth at sc degrees
135 //
136 //// CVector R, V;
137 //// R.set(0.0001, 0.5, 0.0);
138 //// V.set(0.0001, 0.003, 0.0001);
139 ////
140 //// double r = R.r();
141 //// double th = R.theta();
142 //// double el = R.ele();
143 ////
144 //// s2.set_position('s', 180., 0.);
145 // v.add_source(&s);
146 //// v.add_source(&s2);
147 //
148 // PMESource ps(s);
149 //// PMESource ps2(s2);
150 //
151 // PME pme("128.111.221.5", 54321);
152 // pme.add_pme_source(ps);
153 //// pme.add_pme_source(ps2);
154 //
155 //
156 //// CGestalt::set_block_size(128);
157 //// gIO = new PAIO(paNoDevice, Pa_GetDefaultOutputDeviceID(), 0, v.channels()); // sets up IO with correct num channels
158 // gIO = new PAIO(Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID(), 5, 8); // sets up IO with correct num channels
159 //// gIO = new PAIO(paNoDevice, Pa_GetDefaultOutputDeviceID(), 0, 1); // sets up IO with correct num channels
160 //
161 // InOut temp(kNoProc, 2);
162 //// temp.setInChan(8);
163 //
164 //
165 // logMsg("CSL playing VBAP...");
166 //// gIO->set_root(v); // make some sound
167 // gIO->set_root(temp); // make some sound
168 // gIO->open();
169 // gIO->start(); // start the driver callbacks
170 //
171 //// Orbit orb;
172 //// orb.calculate_orbital_params(R, V);
173 //// orb.dump();
174 ////// exit(0);
175 //// cout << "R:\t" << R.len() << "\t" << R.theta() << "\t" << R.ele() << endl;
176 //
177 //// int c = 100 * 40;
178 //// while (c--){
179 //// CVector Rnew;
180 //// orb.calculate_new_position_in_orbit();
181 //// orb.calculate_absolute_position(Rnew);
182 ////
183 ////
184 //// s.set_position('s', Rnew.theta(), Rnew.ele(), Rnew.r());
185 //// if (c%20 == 0)
186 //// cout << "Rnew:\t" << Rnew.len() << "\t" << Rnew.theta() << "\t" << Rnew.ele() << endl;
187 ////// cout << "Which triple:\t" << s._which_triple << endl;
188 //// sleep_sec(.01);
189 //// }
190 //
191 //// float d = 50.005;
192 //// float time = 5.;
193 //// float time_interval = 1./100.;
194 ////
195 ////
196 //// for (float dist=-d; dist<d; dist+=d/time*time_interval){
197 //// delay.set_target_delay_time(fabsf(dist/330.0) );
198 //// sleep_sec(time_interval);
199 //// }
200 //
201 //// pme.manage_sources();
202 //
203 // sleep_sec(500);
204 // logMsg("CSL done.");
205 // gIO->stop(); // stop the driver and close down
206 // gIO->close();
207 //
208 // return 0; // exit
209 //
210 //
211 //}