1
1
#include " headers.h"
2
2
3
3
using namespace std ;
4
-
5
4
vector< array<double ,60 > > avgarr (0 ); // for average value
6
5
7
6
/* ****************** BARS **********************/
8
7
void bars ()
9
8
{
10
- glTranslatef (0 ,-10 ,-50.0 );
9
+ glTranslatef (0 ,-13 ,-50.0 );
11
10
// Translation motion along(x,y,z) axis
12
11
d=0.7 ;
13
12
glPointSize (10.0 );
@@ -39,7 +38,7 @@ void bars()
39
38
/* ****************** CIRCLE3D **********************/
40
39
void circle3d ()
41
40
{
42
- glTranslatef (0 ,-10 ,-50.0 );
41
+ glTranslatef (0 ,-5 ,-50.0 );
43
42
// Translation motion along(x,y,z) axis
44
43
// rotation after translation (order matters)
45
44
glRotatef (deg,1 ,0 ,0 ); // (degree, x,y,z);
@@ -49,13 +48,14 @@ void circle3d()
49
48
float deg=0.0 ;
50
49
float r1=38 /255.0 ,g1=87 /255.0 ,b1=235 /255.0 ;
51
50
float r2=countr/255.0 ,g2=countg/255.0 ,b2=countb/255.0 ;
51
+
52
52
for (int i=0 ; i<60 ; i++)
53
53
{
54
-
55
- if ((int )avgarr.size ()<=j)
54
+ if ((int )avgarr.size ()-2 <=j)
56
55
exit (0 );
57
56
float x=r*cos (deg*(3.14 /180 )),y=avgarr[j][i],z=r*sin (deg*(3.14 /180 ));
58
57
// end of music data
58
+ {
59
59
glBegin (GL_QUADS);
60
60
// top
61
61
glColor3f (r2,g2,b2);
@@ -114,9 +114,12 @@ void circle3d()
114
114
glColor3f (r1,g1,b1);
115
115
glVertex3f (x-d,0 ,z-d); // -x,y=0,z
116
116
glEnd ();
117
+ }
118
+
119
+ {
117
120
118
121
glBegin (GL_LINE_LOOP);
119
- glColor3f (0 , 0 , 0 );
122
+ glColor3f (1 , 1 , 1 );
120
123
// left
121
124
glVertex3f (x-d,0 ,z+d); // -x,y=0,z
122
125
glVertex3f (x-d,0 ,z-d); // -x,y=0,-z
@@ -149,22 +152,39 @@ void circle3d()
149
152
150
153
glEnd ();
151
154
155
+ }
152
156
deg+=6 ;
153
157
// deg+=5.625;
154
158
}
155
- j++;
156
- Sleep (97 );
159
+
160
+ // sync3
161
+ if ( curtime > (j*100 +100 ))
162
+ {
163
+ j++;
164
+ // cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
165
+ // sync++;
166
+ }
167
+
168
+ // sync1
169
+ // while((int)sound.getPlayingOffset().asSeconds()<(i*100+100)){
170
+ // Sleep(1);
171
+ // }
172
+
173
+ // sync2
174
+ // Sleep(97);
175
+ // j++;
176
+ // cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<endl;
157
177
}
158
178
/* ****************** PENTAGON **********************/
159
179
void pentagon ()
160
180
{
161
- glTranslatef (0 ,- 10 ,-50.0 );
181
+ glTranslatef (0 ,0 ,-50.0 );
162
182
// Translation motion along(x,y,z) axis
163
183
d=0.7 ;
164
184
glPointSize (2.0 );
165
185
for (int i=0 ; i<60 ; i++)
166
186
{
167
- if ((int )avgarr.size ()<=j)
187
+ if ((int )avgarr.size ()- 2 <=j)
168
188
exit (0 );
169
189
float x=0 ,r=avgarr[j][i],y=0 ,z=-4 ,deg=0 ;
170
190
// end of music data
@@ -179,12 +199,19 @@ void pentagon()
179
199
}
180
200
glEnd ();
181
201
}
182
- j++;
183
- Sleep (97 );
202
+ if ( curtime > (j*100 +100 ))
203
+ {
204
+ j++;
205
+ // cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
206
+ // sync++;
207
+ }
208
+ // j++;
209
+ // Sleep(97);
184
210
}
185
211
186
212
187
213
/* ****************** CUBICAL_MESH **********************/
214
+ /*
188
215
void CubicalMesh()
189
216
{
190
217
glTranslatef(-80,0,-50.0);
@@ -200,7 +227,7 @@ void CubicalMesh()
200
227
for(int i=0; i<60; i++)
201
228
{
202
229
203
- if ((int )avgarr.size ()<=j)
230
+ if((int)avgarr.size()-2 <=j)
204
231
exit(0);
205
232
float y=avgarr[j][i];
206
233
if(i%10==0){
@@ -275,21 +302,25 @@ void CubicalMesh()
275
302
//deg+=6;
276
303
//deg+=5.625;
277
304
}
278
- j++;
279
- Sleep (97 );
305
+ if( curtime > (j*100+100))
306
+ {
307
+ j++;
308
+ //cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
309
+ //sync++;
310
+ }
280
311
}
281
-
312
+ */
282
313
/* ****************** DUST **********************/
283
314
void dust ()
284
315
{
285
- glTranslatef (0 ,- 10 ,-50.0 );
316
+ glTranslatef (0 ,0 ,-50.0 );
286
317
// Translation motion along(x,y,z) axis
287
318
d=0.7 ;
288
319
glPointSize (2.0 );
289
- glColor3f ( 1 , 0 , 1 );
320
+ glColor3ub ( 0x43 , 0xA0 , 0x47 );
290
321
for (int i=0 ; i<60 ; i++)
291
322
{
292
- if ((int )avgarr.size ()<=j)
323
+ if ((int )avgarr.size ()- 2 <=j)
293
324
exit (0 );
294
325
float x=0 ,r=avgarr[j][i],y=0 ,z=-4 ,deg=0 ;
295
326
// end of music data
@@ -303,21 +334,21 @@ void dust()
303
334
deg+=6 ;
304
335
}
305
336
}
306
- j++;
307
- Sleep ( 97 ) ;
337
+ if ( curtime > (j* 100 + 100 ))
338
+ j++ ;
308
339
}
309
340
310
341
/* ****************** WAVES **********************/
311
342
void waves ()
312
343
{
313
- glTranslatef (0 ,- 10 ,-50.0 );
344
+ glTranslatef (0 ,0 ,-50.0 );
314
345
// Translation motion along(x,y,z) axis
315
346
d=2 ;
316
347
glPointSize (10.0 );
317
- glColor3f ( 1 , 0 , 1 );
348
+ glColor3ub ( 0xf9 , 0x26 , 0x72 );
318
349
for (int i=0 ; i<60 ; i++)
319
350
{
320
- if ((int )avgarr.size ()<=j)
351
+ if ((int )avgarr.size ()- 2 <=j)
321
352
exit (0 );
322
353
float x=-60 +(i*d),y=avgarr[j][i],z=-4 ;
323
354
// end of music data
@@ -331,11 +362,18 @@ void waves()
331
362
glVertex3f (x+(d/2 ),0 ,z);
332
363
glEnd ();
333
364
}
334
- j++;
335
- Sleep (97 );
365
+ if ( curtime > (j*100 +100 ))
366
+ {
367
+ j++;
368
+ // cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
369
+ // sync++;
370
+ }
371
+ // j++;
372
+ // Sleep(97);
336
373
}
337
374
338
375
/* ****************** DWaves **********************/
376
+ /*
339
377
void DWaves()
340
378
{
341
379
glTranslatef(-155,-40,-50.0);
@@ -351,7 +389,7 @@ void DWaves()
351
389
for(int i=0; i<60; i++)
352
390
{
353
391
354
- if ((int )avgarr.size ()<=j)
392
+ if((int)avgarr.size()-2 <=j)
355
393
exit(0);
356
394
float y=avgarr[j][i];
357
395
if(i%10==0){
@@ -368,26 +406,33 @@ void DWaves()
368
406
//deg+=6;
369
407
//deg+=5.625;
370
408
}
371
- j++;
372
- Sleep (97 );
409
+ if( curtime > (j*100+100))
410
+ {
411
+ j++;
412
+ //cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
413
+ //sync++;
414
+ }
415
+ // j++;
416
+ // Sleep(97);
373
417
}
418
+ */
374
419
/* ***************** 3D MESH **********************/
375
420
376
- void mesh3D ()
377
- {
378
- glTranslatef (0.0 ,0.0 ,-4.5 );
379
- glPointSize (2.0 );
380
- for (int i=-200 ; i<=200 ; i+=5 )
381
- for (int j=-100 ; j<=300 ; j+=10 )
382
- {
383
-
384
- glBegin (GL_POINTS);
385
- glColor3f (0 .0f ,1 .0f ,0 .0f );
386
- glVertex3f ( i/100.0 ,-1 .0f , j/100.0 );
387
- glEnd ();
388
- }
389
- glFlush ();
390
- }
421
+ // void mesh3D()
422
+ // {
423
+ // glTranslatef(0.0,0.0,-4.5);
424
+ // glPointSize(2.0);
425
+ // for(int i=-200; i<=200; i+=5)
426
+ // for(int j=-100; j<=300; j+=10)
427
+ // {
428
+ //
429
+ // glBegin(GL_POINTS);
430
+ // glColor3f(0.0f,1.0f,0.0f);
431
+ // glVertex3f( i/100.0,-1.0f, j/100.0);
432
+ // glEnd();
433
+ // }
434
+ // glFlush();
435
+ // }
391
436
392
437
/* **************** PAUSE BUTTON *******************/
393
438
void pausebutton ()
0 commit comments