aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Effect/crossfade/effectcrossfadefactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Effect/crossfade/effectcrossfadefactory.cpp')
0 files changed, 0 insertions, 0 deletions
div>
7375ed80c

4b6239e2e
2702b572b
2d622fd9b
7375ed80c
2d622fd9b




c4749f20a


2702b572b
2d622fd9b
2702b572b
2d622fd9b
2702b572b


2d622fd9b

2784732d3
2d622fd9b
ecc137abe
97c98d9d5
2784732d3
7375ed80c

2784732d3
c4749f20a
2702b572b
2784732d3


2d622fd9b



2784732d3
7375ed80c

2784732d3
7375ed80c


2784732d3
2702b572b
2d622fd9b

7375ed80c
2d622fd9b
7375ed80c










2d622fd9b

342ada45a
2d622fd9b
c4749f20a
342ada45a

9c7dd7313
342ada45a
2d622fd9b

435f1da1d
2d622fd9b
7375ed80c

435f1da1d
c4749f20a
eb25fd643
c4749f20a
2784732d3
c4749f20a






2784732d3
c4749f20a


2784732d3
eb25fd643
c4749f20a

2d622fd9b



3ffc8b54a
f57072cfd
c4749f20a
eb25fd643
c4749f20a

eb25fd643
f57072cfd
c4749f20a
eb25fd643
2784732d3
c4749f20a
2784732d3
7375ed80c


eb25fd643
c4749f20a
9c7dd7313
2d622fd9b

da088637d
2d622fd9b
da088637d

eb25fd643

da088637d
eb25fd643
7375ed80c
2d622fd9b

da088637d
eb25fd643
7375ed80c

eb25fd643
2d622fd9b
7375ed80c
2d622fd9b
7375ed80c


eb25fd643
3648eb33c
7375ed80c
3f6b60f23
7375ed80c
3f6b60f23
7375ed80c


2784732d3
7375ed80c
eb25fd643
2784732d3




eb25fd643
2784732d3
eb25fd643
2d622fd9b

7375ed80c
2d622fd9b
97c98d9d5
da088637d
7de09343d



7375ed80c
97c98d9d5
eb25fd643
7375ed80c
97c98d9d5

7375ed80c





eb25fd643
2d622fd9b

2784732d3
2d622fd9b
ae75e5707
fa1e4194b
2784732d3

7375ed80c
2784732d3
2d622fd9b
fa1e4194b
2d622fd9b
7375ed80c
2784732d3
7375ed80c
2784732d3
fa1e4194b
7de09343d
7375ed80c
2784732d3
eb25fd643
2784732d3

2d622fd9b

7375ed80c
2d622fd9b
7375ed80c
2784732d3

7375ed80c

013ee07b5
7375ed80c

2784732d3
7375ed80c
eb25fd643
013ee07b5
7375ed80c

eb25fd643
7375ed80c









013ee07b5
7375ed80c
eb25fd643
7375ed80c

eb25fd643
013ee07b5
7375ed80c
eb25fd643
7375ed80c

013ee07b5
7375ed80c



013ee07b5
7375ed80c




eb25fd643
013ee07b5
7375ed80c
eb25fd643

7375ed80c

013ee07b5
2784732d3




7375ed80c

013ee07b5
7375ed80c

eb25fd643
7375ed80c

013ee07b5
2784732d3




7375ed80c
eb25fd643
013ee07b5
7375ed80c
eb25fd643
7de09343d

013ee07b5
7375ed80c
2d622fd9b

2d622fd9b
7375ed80c
2d622fd9b
ae75e5707
fa1e4194b
2784732d3



7375ed80c
2784732d3




































7de09343d
2784732d3




















2d622fd9b

3f6b60f23

7375ed80c
2d622fd9b
342ada45a
ecc137abe
97c98d9d5
2d622fd9b
ae75e5707
fa1e4194b
2784732d3

fa1e4194b
2d622fd9b
fa1e4194b

2d622fd9b

7375ed80c

2d622fd9b
342ada45a

f57072cfd
342ada45a





c4749f20a
2d622fd9b
eb25fd643
f57072cfd
eb25fd643
eb25fd643

c4749f20a
da088637d






7375ed80c
c4749f20a
da088637d



eb25fd643
c4749f20a

eb25fd643
7375ed80c
eb25fd643
f57072cfd
eb25fd643
7375ed80c
f57072cfd
7375ed80c
f57072cfd
7375ed80c


f57072cfd
7375ed80c
f57072cfd
7375ed80c

eb25fd643
7375ed80c
f57072cfd
eb25fd643
7375ed80c
f57072cfd
7375ed80c
f57072cfd
7375ed80c










eb25fd643

013ee07b5
7375ed80c
2d622fd9b
f57072cfd
7375ed80c
97c98d9d5
7375ed80c
f57072cfd
7375ed80c
f57072cfd
7375ed80c






97c98d9d5


7375ed80c


97c98d9d5




7375ed80c











97c98d9d5



7375ed80c


97c98d9d5




2784732d3
97c98d9d5
7375ed80c

eb25fd643
7375ed80c

342ada45a
ecc137abe
2702b572b
342ada45a



2702b572b
1ed6c3a16
7375ed80c
eb25fd643
7375ed80c

eb25fd643
c4749f20a
7375ed80c
c4749f20a
7375ed80c
eb25fd643
2702b572b
7375ed80c

c4749f20a
eb25fd643
1ed6c3a16



eb25fd643
013ee07b5
2d622fd9b

7375ed80c
2d622fd9b
2702b572b
eb25fd643
2702b572b

7375ed80c

1ed6c3a16
2702b572b
eb25fd643
2702b572b
7375ed80c
2d622fd9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
                                                                            
                                                                            














                                                                            
                                                                            



                                                                             

                       
                        
                      
                 
                   




                       


                                               
                                       
 
                                  
 


                                                           

 
                                                                     
 
                              
                              
                                                                       

                                                                 
                                             
                    
                      


                     



                         
                    

              
 


                     
                       
                   

 
                                               
 










                                        

 
                        
 
                    

                       
                    
             

 
                                                                 
 

                                        
 
                                         
     
                                        
                                                                         






                                                                             
                                                                                       


        
                                                                    
     

                          



                          
                     
 
                                      
     

                           
     
 
              
     
                                  
                                        
                                                                         


                              
     
                       
             

 
                                           
 

                                       

 
                                         
 
                    

 
                                         
 

                         
 
 
                                                 
 


                                       
     
                        
                   
                                                
                                             
                                             


                                          
                                                    
                                                         
         




                                              
         
                        
     

 
                                 
 
                                                
                                         



                                    
                            
                                             
     
                                               

                                                       





                                                   
     

 
                                
 
                                                                 
                                   

                                                                               
                                                   
                                                                                  
 
                                                                    
 
                                               
                                                                          
                                               
                                                                          
                                                                              
 
                                           
                                                                        
 

                                                                  

 
                             
 
                              

                                                                         

                                                               
                                       

                                                                   
                                                         
                                                     
     
                                

                                
 









                                                                     
                                
                                     
     

                                                          
     
                                
                                     
     

                                                         
                                      



                                                             
                                   




                                                     
     
                                
                                    

     

                                                                     
                                               




                                                                   

                                                             
                                

                                        
 

                                                               
                                            




                                                                 
                                                          
     
                                
                                     
     

                                                                   
                                            
             

 
 
                               
 
                                                                 
                                   



                                                                        
 




































                                                                                              
 




















                                                                                             

 

                           
                    
 
            
                              
                                                           
 
                                                                 
                                   

                                                                                
                                                                   
 

                                                                  

 

                     
 

                      
                               





                                 
                                 
 
                                
               
                           

                    
                                    






                                                                           
 
                                     



                                                  
 

                        
                                                                 
                                      
 
                                 
     
                    
                                                                        
             
                                


                                
                                                                          
             
                                

                                
                
                          
                   
         
                                               
                               
                               
                              










                                                                  

         
                
 
 
                                 
 
                            
                
                                    
         
                                                           






                                                                                      


                                                                


                                                 




                                                                         











                                                                                      



                                                                                                 


                                                 




                                                                      
                                                                           
             

         
 

              
            
                              
                              



                   
                               
                                 
 
 

               
 
                             
 
                                          
                
 
                                

                    
                                                   
 



                                           
     
                

 
                             
 
                              
     

                                            

                          
                                                           
                                                                      
     
                               
                                 
 
/***************************************************************************
 *   Copyright (C) 2007-2012 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#include <QTimer>
#include <QSettings>
#include <QPainter>
#include <QMenu>
#include <QActionGroup>
#include <qmmp/buffer.h>
#include <qmmp/qmmp.h>
#include <math.h>
#include <stdlib.h>
#include "skin.h"
#include "fft.h"
#include "inlines.h"
#include "mainvisual.h"

#define VISUAL_NODE_SIZE 512 //samples
#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE)

MainVisual *MainVisual::m_instance = 0;

MainVisual *MainVisual::instance()
{
    if (!m_instance)
        qFatal ("MainVisual: this object is not created!");
    return m_instance;
}

MainVisual::MainVisual (QWidget *parent) : Visual (parent), m_vis (0)
{
    m_skin = Skin::instance();
    m_ratio = m_skin->ratio();
    connect(m_skin, SIGNAL(skinChanged()), this, SLOT(readSettings()));
    m_timer = new QTimer (this);
    connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout()));
    m_buffer = new short[VISUAL_BUFFER_SIZE];
    m_buffer_at = 0;
    m_instance = this;
    m_update = false;
    createMenu();
    readSettings();
}

MainVisual::~MainVisual()
{
    writeSettings();
    if (m_vis)
    {

        delete m_vis;
        m_vis = 0;
    }
    delete [] m_buffer;
    m_instance = 0;
}

void MainVisual::setVisual (VisualBase *newvis)
{
    m_timer->stop();
    if (m_vis)
        delete m_vis;
    m_vis = newvis;
    if (m_vis)
        m_timer->start();
    else
    {
        m_pixmap.fill (Qt::transparent);
        update();
    }
}

void MainVisual::clear()
{
    m_buffer_at = 0;
    if (m_vis)
        m_vis->clear();
    m_pixmap = m_bg;
    update();
}

void MainVisual::add (unsigned char *data, qint64 size, int chan)
{
    if (!m_timer->isActive () || !m_vis)
        return;

    if(VISUAL_BUFFER_SIZE == m_buffer_at)
    {
        m_buffer_at -= VISUAL_NODE_SIZE;
        memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1);
        return;
    }

    int frames = qMin((int)size/chan >> 1, VISUAL_BUFFER_SIZE - m_buffer_at);

    if (chan >= 2)
    {
        mono16_from_multichannel(m_buffer + m_buffer_at, (short *) data, frames, chan);
    }
    else
    {
        memcpy(m_buffer + m_buffer_at, (short *) data, frames << 1);
    }

    m_buffer_at += frames;
}

void MainVisual::timeout()
{
    mutex()->lock ();

    if(m_buffer_at < VISUAL_NODE_SIZE)
    {
        mutex()->unlock ();
        return;
    }

    if (m_vis)
    {
        m_vis->process (m_buffer);
        m_buffer_at -= VISUAL_NODE_SIZE;
        memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1);
        m_pixmap = m_bg;
        QPainter p(&m_pixmap);
        m_vis->draw (&p);
    }
    mutex()->unlock ();
    update();
}

void MainVisual::paintEvent (QPaintEvent *)
{
    QPainter painter (this);
    painter.drawPixmap (0,0, m_pixmap);
}

void MainVisual::hideEvent (QHideEvent *)
{
    m_timer->stop();
}

void MainVisual::showEvent (QShowEvent *)
{
    if (m_vis)
        m_timer->start();
}

void MainVisual::mousePressEvent (QMouseEvent *e)
{
    if (e->button() == Qt::RightButton)
        m_menu->exec(e->globalPos());
    else
    {
        m_pixmap = m_bg;
        if (!m_vis)
            setVisual(new mainvisual::Analyzer);
        else if (m_vis->name() == "Analyzer")
            setVisual(new mainvisual::Scope);
        else if (m_vis->name() == "Scope")
            setVisual(0);

        QString str = m_vis ? m_vis->name() : "Off";
        foreach(QAction *act, m_visModeGroup->actions ())
        {
            if (str == act->data().toString())
            {
                act->setChecked(true);
                break;
            }
        }
        writeSettings();
    }
}

void MainVisual::drawBackGround()
{
    m_bg = QPixmap (76 * m_ratio, 16 * m_ratio);
    if (m_transparentAction->isChecked())
    {
        m_bg.fill (Qt::transparent);
        return;
    }
    QPainter painter(&m_bg);
    for (int x = 0; x < 76 * m_ratio; x += 2)
    {
        painter.setPen(m_skin->getVisColor(0));
        painter.drawLine(x + 1, 0, x + 1, 16 *m_ratio);
        for (int y = 0; y < 16 *m_ratio; y += 2)
        {
            painter.setPen(m_skin->getVisColor(0));
            painter.drawPoint(x,y);
            painter.setPen(m_skin->getVisColor(1));
            painter.drawPoint(x,y + 1);
        }
    }
}

void MainVisual::writeSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    QAction *act = m_peaksFalloffGroup->checkedAction ();
    settings.setValue("vis_peaks_falloff", act ? act->data().toDouble() : 0.2);
    act = m_analyzerFalloffGroup->checkedAction ();
    settings.setValue("vis_analyzer_falloff", act ? act->data().toDouble() : 2.2);

    settings.setValue("vis_show_peaks", m_peaksAction->isChecked());

    act = m_analyzerModeGroup->checkedAction();
    settings.setValue("vis_analyzer_mode", act ? act->data().toInt() : 0);
    act = m_analyzerTypeGroup->checkedAction();
    settings.setValue("vis_analyzer_type", act ? act->data().toInt() : 1);
    settings.setValue("vis_transparent_bg", m_transparentAction->isChecked());

    act = m_visModeGroup->checkedAction ();
    settings.setValue("vis_type", act ? act->data().toString() : "Off");

    act = m_fpsGroup->checkedAction();
    settings.setValue("vis_rate", act ? act->data().toInt() : 25);
}

void MainVisual::createMenu()
{
    m_menu = new QMenu (this);
    connect(m_menu, SIGNAL(triggered (QAction *)),SLOT(writeSettings()));
    connect(m_menu, SIGNAL(triggered (QAction *)),SLOT(readSettings()));
    QMenu *visMode = m_menu->addMenu(tr("Visualization Mode"));
    m_visModeGroup = new QActionGroup(this);
    m_visModeGroup->setExclusive(true);
    m_visModeGroup->addAction(tr("Analyzer"))->setData("Analyzer");
    m_visModeGroup->addAction(tr("Scope"))->setData("Scope");
    m_visModeGroup->addAction(tr("Off"))->setData("Off");
    foreach(QAction *act, m_visModeGroup->actions ())
    {
        act->setCheckable(true);
        visMode->addAction(act);
    }

    QMenu *analyzerMode = m_menu->addMenu(tr("Analyzer Mode"));
    m_analyzerModeGroup = new QActionGroup(this);
    m_analyzerTypeGroup = new QActionGroup(this);
    m_analyzerModeGroup->addAction(tr("Normal"))->setData(0);
    m_analyzerModeGroup->addAction(tr("Fire"))->setData(1);
    m_analyzerModeGroup->addAction(tr("Vertical Lines"))->setData(2);
    m_analyzerTypeGroup->addAction(tr("Lines"))->setData(0);
    m_analyzerTypeGroup->addAction(tr("Bars"))->setData(1);
    foreach(QAction *act, m_analyzerModeGroup->actions ())
    {
        act->setCheckable(true);
        analyzerMode->addAction(act);
    }
    analyzerMode->addSeparator ();
    foreach(QAction *act, m_analyzerTypeGroup->actions ())
    {
        act->setCheckable(true);
        analyzerMode->addAction(act);
    }
    analyzerMode->addSeparator ();
    m_peaksAction = analyzerMode->addAction(tr("Peaks"));
    m_peaksAction->setCheckable(true);


    QMenu *refreshRate = m_menu->addMenu(tr("Refresh Rate"));
    m_fpsGroup = new QActionGroup(this);
    m_fpsGroup->setExclusive(true);
    m_fpsGroup->addAction(tr("50 fps"))->setData(50);
    m_fpsGroup->addAction(tr("25 fps"))->setData(25);
    m_fpsGroup->addAction(tr("10 fps"))->setData(10);
    m_fpsGroup->addAction(tr("5 fps"))->setData(5);
    foreach(QAction *act, m_fpsGroup->actions ())
    {
        act->setCheckable(true);
        refreshRate->addAction(act);
    }

    QMenu *analyzerFalloff = m_menu->addMenu(tr("Analyzer Falloff"));
    m_analyzerFalloffGroup = new QActionGroup(this);
    m_analyzerFalloffGroup->setExclusive(true);
    m_analyzerFalloffGroup->addAction(tr("Slowest"))->setData(1.2);
    m_analyzerFalloffGroup->addAction(tr("Slow"))->setData(1.8);
    m_analyzerFalloffGroup->addAction(tr("Medium"))->setData(2.2);
    m_analyzerFalloffGroup->addAction(tr("Fast"))->setData(2.4);
    m_analyzerFalloffGroup->addAction(tr("Fastest"))->setData(2.8);
    foreach(QAction *act, m_analyzerFalloffGroup->actions ())
    {
        act->setCheckable(true);
        analyzerFalloff->addAction(act);
    }

    QMenu *peaksFalloff = m_menu->addMenu(tr("Peaks Falloff"));
    m_peaksFalloffGroup = new QActionGroup(this);
    m_peaksFalloffGroup->setExclusive(true);
    m_peaksFalloffGroup->addAction(tr("Slowest"))->setData(0.05);
    m_peaksFalloffGroup->addAction(tr("Slow"))->setData(0.1);
    m_peaksFalloffGroup->addAction(tr("Medium"))->setData(0.2);
    m_peaksFalloffGroup->addAction(tr("Fast"))->setData(0.4);
    m_peaksFalloffGroup->addAction(tr("Fastest"))->setData(0.8);
    foreach(QAction *act, m_peaksFalloffGroup->actions ())
    {
        act->setCheckable(true);
        peaksFalloff->addAction(act);
    }
    QMenu *background = m_menu->addMenu(tr("Background"));
    m_transparentAction = background->addAction(tr("Transparent"));
    m_transparentAction->setCheckable(true);
    update();
}


void MainVisual::readSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    QString vis_name = settings.value("vis_type","Analyzer").toString();
    if(!m_update)
    {
        m_update = true;

        foreach(QAction *act, m_visModeGroup->actions ())
        {
            if (vis_name == act->data().toString())
                act->setChecked(true);
        }
        m_peaksAction->setChecked(settings.value("vis_show_peaks", true).toBool());
        int fps = settings.value("vis_rate", 25).toInt();
        foreach(QAction *act, m_fpsGroup->actions ())
        {
            if (fps == act->data().toInt())
                act->setChecked(true);
        }
        int mode = settings.value("vis_analyzer_mode", 0).toInt();
        foreach(QAction *act, m_analyzerModeGroup->actions ())
        {
            if (mode == act->data().toInt())
                act->setChecked(true);
        }
        int type = settings.value("vis_analyzer_type", 1).toInt();
        foreach(QAction *act, m_analyzerTypeGroup->actions ())
        {
            if (type == act->data().toInt())
                act->setChecked(true);
        }
        double speed = settings.value("vis_peaks_falloff", 0.2).toDouble();
        foreach(QAction *act, m_peaksFalloffGroup->actions ())
        {
            if (speed == act->data().toDouble())
                act->setChecked(true);
        }
        speed = settings.value("vis_analyzer_falloff", 2.2).toDouble();
        foreach(QAction *act, m_analyzerFalloffGroup->actions ())
        {
            if (speed == act->data().toDouble())
                act->setChecked(true);
        }
        m_transparentAction->setChecked(settings.value("vis_transparent_bg", false).toBool());

        //update settings from previous version
        if(!m_analyzerFalloffGroup->checkedAction() || !m_peaksFalloffGroup->checkedAction())
        {
            m_analyzerFalloffGroup->actions()[2]->setChecked(true);
            m_peaksFalloffGroup->actions()[2]->setChecked(true);
            writeSettings();
        }
    }
    m_ratio = m_skin->ratio();
    drawBackGround();
    m_pixmap = m_bg;
    QAction *act = m_fpsGroup->checkedAction ();
    m_timer->setInterval (act ? 1000 / act->data().toInt() : 25);
    if (vis_name == "Analyzer")
        setVisual(new mainvisual::Analyzer);
    else if (vis_name == "Scope")
        setVisual(new mainvisual::Scope);
    else
        setVisual(0);
    resize(76 * m_ratio, 16 * m_ratio);
    update();
}

using namespace mainvisual;

Analyzer::Analyzer()
{
    clear();
    m_skin = Skin::instance();
    m_size = QSize(76*m_skin->ratio(), 16*m_skin->ratio());

    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    m_peaks_falloff = settings.value("vis_peaks_falloff", 0.2).toDouble();
    m_analyzer_falloff = settings.value("vis_analyzer_falloff", 2.2).toDouble();
    m_show_peaks = settings.value("vis_show_peaks", true).toBool();

    m_lines = settings.value("vis_analyzer_type", 1).toInt() == 0;
    m_mode = settings.value("vis_analyzer_mode", 0).toInt();
}

Analyzer::~Analyzer()
{}

void Analyzer::clear()
{
    for (int i = 0; i< 75; ++i)
    {
        m_intern_vis_data[i] = 0;
        m_peaks[i] = 0;
    }
}

bool Analyzer::process (short *l)
{
    static fft_state *state = 0;
    if (!state)
        state = fft_init();
    short dest[256];

    static const int xscale_long[] =
    {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
        19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
        35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
        52, 53, 54, 55, 56, 57, 58, 61, 66, 71, 76, 81, 87, 93, 100, 107,
        114, 122, 131, 140, 150, 161, 172, 184, 255
    };

    static const int xscale_short[] =
    {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 15, 20, 27,
        36, 47, 62, 82, 107, 141, 184, 255
    };

    calc_freq (dest, l);

    const double y_scale = 3.60673760222;   /* 20.0 / log(256) */
    int max = m_lines ? 75 : 19, y, j;

    for (int i = 0; i < max; i++)
    {
        if (m_lines)
            for (j = xscale_long[i], y = 0; j < xscale_long[i + 1]; j++)
            {
                if (dest[j] > y)
                    y = dest[j];