Skip to content

Commit e755142

Browse files
committed
removed redundant code
1 parent e6ca3a3 commit e755142

File tree

2 files changed

+17
-57
lines changed

2 files changed

+17
-57
lines changed

effects.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,9 @@ void bars()
3232
glEnd();
3333
}
3434
//sync
35-
//j++;
36-
//Sleep(97);
37-
38-
//sync3
3935
if( curtime > (j*100+100))
4036
{
4137
j++;
42-
//cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
43-
//sync++;
4438
}
4539
}
4640

@@ -171,14 +165,12 @@ void circle3d()
171165

172166
}
173167
deg+=6;
174-
//deg+=5.625;
175168
}
176169

177-
//sync3
170+
//sync
178171
if( curtime > (j*100+100))
179172
{
180173
j++;
181-
//cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
182174
}
183175
}
184176

@@ -209,7 +201,6 @@ void pentagon()
209201
if( curtime > (j*100+100))
210202
{
211203
j++;
212-
//cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
213204
}
214205
}
215206

@@ -368,7 +359,6 @@ void waves()
368359
if( curtime > (j*100+100))
369360
{
370361
j++;
371-
//cout<<"arr_sz: "<<(int)avgarr.size()<<" j:"<<j<<" cur time:"<<curtime<<endl;
372362
}
373363
}
374364

main.cpp

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ sf::Sound sound(buffer);
1515
pthread_t threads[1]; //for multi threading
1616
int rc1;
1717
int flag=0,temp=0,loading=0,timerFlag=0;
18-
int W,H;
1918
typedef unsigned long long timestamp_t;
2019
int j=0;
2120
float r=23.0; //circle "r"
@@ -57,15 +56,12 @@ void getFft(const kiss_fft_cpx in[N], kiss_fft_cpx out[N])
5756

5857
void reshape(int w, int h)
5958
{
60-
// W=w;
61-
// H=h;
6259
glViewport(0, 0, w, h);
6360
glMatrixMode(GL_PROJECTION);
6461
glLoadIdentity();
6562
gluPerspective(90,(float)w/(float)h, 1, 1000);
6663
glMatrixMode(GL_MODELVIEW);
6764
glLoadIdentity() ;
68-
// glutReshapeWindow(W,H);
6965
}
7066

7167
void drawStrokeText(char*str,int x,int y,int z)
@@ -242,7 +238,6 @@ int BinSrch(int freq)
242238

243239
void loadData(){
244240
loadlogo();
245-
246241
if (!buffer.loadFromFile(fName.c_str()))
247242
exit(0);
248243
//sound.play(); called just before display
@@ -260,7 +255,6 @@ void loadData(){
260255
timestamp_t t0 = get_timestamp();
261256

262257
int i;
263-
int graph[N / 2];
264258
double mag[N / 2];
265259
double sf = buffer.getSampleRate();
266260
double roof = buffer.getSampleCount();
@@ -289,12 +283,10 @@ void loadData(){
289283
{
290284
timestamp_t t1 = get_timestamp();
291285
double secs = (t1 - t0) / 1000000.0L;
292-
// print_vec(ampdb);
293286
std::cout << "Total exec time: " << secs << std::endl;
294287
break;
295288
}
296289

297-
//std::cout<<"Framepointer = "<<framePointer<<std::endl;
298290
// get fft values from kissfft
299291
getFft(in, out);
300292

@@ -304,7 +296,6 @@ void loadData(){
304296
int val,f;
305297
mag[i] = sqrt((out[i].r * out[i].r) + (out[i].i * out[i].i));
306298
f = (i*sf)/N;
307-
//cout<<"amp: "<<mag[i]<<" f: "<<f<<endl;
308299
/*
309300
Frequency_Range Frequency_Values
310301
Sub-bass 20 to 60 Hz
@@ -318,56 +309,51 @@ void loadData(){
318309

319310
if (f<=60)
320311
{
321-
val = graph[i] = abs( (float)(log(mag[i]) * 10)/9.0);
312+
val = abs( (float)(log(mag[i]) * 10)/9.0);
322313
}
323314
else if (f>60 && f<=250)
324315
{
325-
val = graph[i] = abs((float)(log(mag[i]) * 10)/8.0);
316+
val = abs((float)(log(mag[i]) * 10)/8.0);
326317
}
327318
else if (f>250 && f<=500)
328319
{
329-
val = graph[i] = abs((float)(log(mag[i]) * 10)/7.0);
320+
val = abs((float)(log(mag[i]) * 10)/7.0);
330321
}
331322
else if (f>500 && f<=2000)
332323
{
333-
val = graph[i] = abs((float)(log(mag[i]) * 10)/6.0);
324+
val = abs((float)(log(mag[i]) * 10)/6.0);
334325
}
335326
else if (f>2000 && f<=4000)
336327
{
337-
val = graph[i] = abs((float)(log(mag[i]) * 10)/5.0);
328+
val = abs((float)(log(mag[i]) * 10)/5.0);
338329
}
339330
else if (f>4000 && f<=6000)
340331
{
341-
val = graph[i] = abs((float)(log(mag[i]) * 10)/4.0);
332+
val = abs((float)(log(mag[i]) * 10)/4.0);
342333
}
343334
else if (f>6000 && f<=20000)
344335
{
345-
val = graph[i] = abs((float)(log(mag[i]) * 10)/3.5);
336+
val = abs((float)(log(mag[i]) * 10)/3.5);
346337
}
347338
else
348339
{
349-
val = graph[i] = abs((float)(log(mag[i]) * 10)/2.0);
340+
val = abs((float)(log(mag[i]) * 10)/2.0);
350341
}
351342

352-
//std::cout<<"amp: "<<val<<" freq: "<<f<<std::endl;
353343
it = ampdb.end();
354344
f_it = frequency.end();
355345
it = ampdb.insert(it, val);
356346
f_it = frequency.insert(f_it,f);
357-
//std::cout<<"f["<<i<<"]= "<<frequency[i]<<std::endl;
358347
}
359348

360349
}
361-
//std::cout<<array[3]<<std::endl;;
362-
//print_vec(array);
350+
363351
std::cout<<"actual no of samples: "<<ampdb.size();
364-
//std::vector<int>::size_type sz = ampdb.size();
365352

366353
//frequency mapping of amplitudes
367354
int k=0;
368355
for(int i=0;i<(SAMPLE_COUNT)/(SAMPLE_RATE*0.1);i++)
369356
{
370-
//cout<<i<<endl<<ampdb.size()<<endl;;
371357
array <double,60> temp={0};
372358
int cnt[60]={0};
373359
for(int j=0;j<(SAMPLE_RATE*0.1)/2;j++)
@@ -388,22 +374,16 @@ void loadData(){
388374
temp[j]/=cnt[j];
389375
}
390376
avgarr.push_back(temp);
391-
/*
392-
//print display data
393-
for(int ppp=0;ppp<60;ppp++)
394-
cout<<temp[ppp]<<" ";
395-
cout<<endl;
396-
*/
397377
}
398378
}
399379

400-
void *callLoadData(void *thread)
380+
void* callLoadData(void *thread)
401381
{
402382
loadData();
403383
loading=1;
404384
glutKeyboardFunc(processKeys);
405385
glutSpecialFunc(processSpecialKeys);
406-
pthread_exit(NULL);
386+
return (void*)NULL;
407387
}
408388

409389
void loadingScreen()
@@ -431,11 +411,10 @@ void display(void)
431411
{
432412
//sets color buffer bit
433413
glClearColor(28/255.0,49/255.0,58/255.0,0.0);
434-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clears display with buffer color & depth values set in init()
435-
//circle
436-
glLoadIdentity(); //Loads identity matrix for each iteration of display
437-
//circle3d();
438-
glColor3f(0,1,0);
414+
//clears display with buffer color & depth values set in init()
415+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
416+
//Loads identity matrix for each iteration of display
417+
glLoadIdentity();
439418
if(loading==0){
440419
loadingScreen();
441420
if(timerFlag++==0){
@@ -491,7 +470,6 @@ void display(void)
491470
instructText((char*)cstr,-250,-175,-200);
492471
nav();
493472

494-
//instructText((char*)cstr,-250,-175,-200);
495473
if(styleselect==0)
496474
{
497475
bars();
@@ -527,13 +505,10 @@ void display(void)
527505
}
528506
else
529507
{
530-
//instructText((char *)"Paused!",-75,-200,-200);
531508
pausebutton();
532509
}
533510
}
534511
glutSwapBuffers();
535-
//if(sound.getPlayingOffset().asSeconds()==buffer.getDuration().asSeconds())
536-
// exit(0);
537512
}
538513

539514
int main(int argc, char *argv[])
@@ -548,9 +523,6 @@ int main(int argc, char *argv[])
548523
fName=argv[1];
549524

550525
glutInit(&argc, argv);
551-
W=glutGet(GLUT_SCREEN_WIDTH);
552-
H=glutGet(GLUT_SCREEN_HEIGHT);
553-
554526
glutSetOption(GLUT_MULTISAMPLE, 8);
555527
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH|GL_MULTISAMPLE);
556528
glutInitWindowSize(800,600);
@@ -559,15 +531,13 @@ int main(int argc, char *argv[])
559531
glutKeyboardFunc( processKeys );
560532
glutSpecialFunc( processSpecialKeys );
561533

562-
//st=time(NULL);
563-
564534
init();
565535
glutDisplayFunc(display);
566536
glutIdleFunc(idle);
567537
glutFullScreen();
568538
glutReshapeFunc(reshape);
539+
glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);
569540
glutMainLoop();
570-
571541
return 0;
572542

573543
}

0 commit comments

Comments
 (0)