aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/CommandLineOptions/IncDecVolumeOption/IncDecVolumeOption.pro
Commit message (Collapse)AuthorAgeFilesLines
* prepare for Spanish translationtrialuser022010-08-201-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1839 90c681e8-e032-0410-971d-27865f9a5e38
* prepare for Japanese translationtrialuser022010-08-201-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1837 90c681e8-e032-0410-971d-27865f9a5e38
* added Dutch translation (author: Ronald ronald645 AT gmail.com)trialuser022010-05-281-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1751 90c681e8-e032-0410-971d-27865f9a5e38
* added Lithuanian translation (author: Algirdas Butkus)trialuser022009-07-271-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1076 90c681e8-e032-0410-971d-27865f9a5e38
* updated Turkish translation (author: Bilgesu Güngör)trialuser022009-07-231-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1070 90c681e8-e032-0410-971d-27865f9a5e38
* added Italian translation (author: Gian Paolo)trialuser022009-05-121-1/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@945 90c681e8-e032-0410-971d-27865f9a5e38
* updated Polish translation (Grzegorz Gibas)trialuser022009-04-031-0/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@887 90c681e8-e032-0410-971d-27865f9a5e38
* fixed command line plugintrialuser022008-11-261-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@640 90c681e8-e032-0410-971d-27865f9a5e38
* updated Chinese Traditional Translation (author: lon)trialuser022008-06-171-1/+3
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@425 90c681e8-e032-0410-971d-27865f9a5e38
* updated Ukrainian translation (author: Gennadi Motsyo)trialuser022008-06-151-2/+3
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@417 90c681e8-e032-0410-971d-27865f9a5e38
* updated Russian translationtrialuser022008-06-141-2/+4
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@414 90c681e8-e032-0410-971d-27865f9a5e38
* updated translationtrialuser022008-06-111-0/+4
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@402 90c681e8-e032-0410-971d-27865f9a5e38
* enabled command line plugins supporttrialuser022008-06-111-0/+26
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@401 90c681e8-e032-0410-971d-27865f9a5e38
isual/analyzer/analyzer.cpp?h=main&id=04fc95c35ace50a1c2b78b89b93c055ebfd5ee84'>04fc95c35
740b179d7




c4749f20a
04fc95c35
680774d70

680774d70




c4749f20a

740b179d7
f57072cfd
740b179d7

04fc95c35
04fc95c35

680774d70
04fc95c35
680774d70























1e31fe896
680774d70



1e31fe896
680774d70



1e31fe896
680774d70





































04fc95c35








740b179d7

04fc95c35




ae75e5707
04fc95c35
cf62fbf3e
04fc95c35

680774d70












740b179d7
04fc95c35
b917024aa
f57072cfd
04fc95c35

5e6fcfd67
























ea340089f
04fc95c35


740b179d7

c4749f20a
19f137d27
ea340089f
19f137d27
04fc95c35
6cf6bc2f6




04fc95c35
5e6fcfd67
ea340089f



6cf6bc2f6
04fc95c35
5e6fcfd67

04fc95c35
ea340089f
5e6fcfd67
c4749f20a
c4749f20a
04fc95c35


5e6fcfd67
04fc95c35
c4749f20a
04fc95c35

5e6fcfd67
04fc95c35

19f137d27
5e6fcfd67
c4749f20a
5e6fcfd67

04fc95c35


19f137d27
c4749f20a

5e6fcfd67

04fc95c35

04fc95c35

740b179d7
04fc95c35

5e6fcfd67
ea340089f
5e6fcfd67

6cf6bc2f6
5e6fcfd67

ea340089f
5e6fcfd67
04fc95c35
19f137d27
04fc95c35
19f137d27
04fc95c35


ea340089f
5e6fcfd67

04fc95c35



5e6fcfd67

04fc95c35


5e6fcfd67
680774d70
5e6fcfd67
680774d70













1e31fe896
680774d70












1e31fe896
680774d70












1e31fe896
680774d70







5e6fcfd67
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
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            





                                                                             
                      

                   

                        



                     
                                                      
 
                                         
                                 

                                                                 
 
            

                   



                     





                                    

 
                      
 



                         
 




                      
 
 

                      




               

                        
                                               
     

                  
     

 
                                 
 























                                                                               
                                                  



                                                                  
                                                           



                                                          
                                                              





































                                                                              








                                       

                         




                                              
                                                                 
                                                           
                                                             

 












                                              
                        
 
                                      
               

                           
























                                                            
 


                      

                                       
 
                                                       
 
                                    
     




                                                  
 
                                            



                           
                                                             
         

                                     
         
 
                       
                 
 


                                                  
                                                         
         
               

                                                  
                                                         

         
                                                                 
                                                                                                       
 

                                                                                                       


                         
                                                        

                                                                             

                                                                             

         

 
                                

                                   
                                                                  
 

                                        
                                            

                                                   
 
                                                       
         
                              
                                         
                                                         


                                         
 

                                                                                   



                         

                                                                                         


         
 
                           
 













                                                                         
                                              












                                                                     
                                                         












                                                                 
                                                      







                                                                                                               
 
/***************************************************************************
 *   Copyright (C) 2007-2021 by Ilya Kotov                                 *
 *   forkotov02@ya.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 <QPaintEvent>
#include <math.h>
#include <stdlib.h>
#include <qmmp/buffer.h>
#include <qmmp/output.h>
#include "fft.h"
#include "inlines.h"
#include "analyzer.h"

Analyzer::Analyzer (QWidget *parent) : Visual (parent)
{
    setWindowTitle (tr("Qmmp Analyzer"));
    setMinimumSize(2*300-30,105);
    m_timer = new QTimer (this);
    connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout()));

    clear();
    createMenu();
    readSettings();
}

Analyzer::~Analyzer()
{
    if(m_peaks)
        delete [] m_peaks;
    if(m_intern_vis_data)
        delete [] m_intern_vis_data;
    if(m_x_scale)
        delete [] m_x_scale;
}

void Analyzer::start()
{
    m_running = true;
    if(isVisible())
        m_timer->start();
}

void Analyzer::stop()
{
    m_running = false;
    m_timer->stop();
    clear();
}

void Analyzer::clear()
{
    m_rows = 0;
    m_cols = 0;
    update();
}

void Analyzer::timeout()
{
    if(takeData(m_left_buffer, m_right_buffer))
    {
        process();
        update();
    }
}

void Analyzer::toggleFullScreen()
{
    setWindowState(windowState() ^Qt::WindowFullScreen);
}

void Analyzer::readSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Analyzer");
    m_peaks_falloff = settings.value("peak_falloff", 0.2).toDouble();
    m_analyzer_falloff = settings.value("analyzer_falloff", 2.2).toDouble();
    m_show_peaks = settings.value("show_peaks", true).toBool();
    m_timer->setInterval(1000 / settings.value("refresh_rate", 25).toInt());
    m_color1.setNamedColor(settings.value("color1", "Green").toString());
    m_color2.setNamedColor(settings.value("color2", "Yellow").toString());
    m_color3.setNamedColor(settings.value("color3", "Red").toString());
    m_bgColor.setNamedColor(settings.value("bg_color", "Black").toString());
    m_peakColor.setNamedColor(settings.value("peak_color", "Cyan").toString());
    m_cell_size = settings.value("cells_size", QSize(15, 6)).toSize();


    if(!m_update)
    {
        m_update = true;
        m_peaksAction->setChecked(m_show_peaks);

        for(QAction *act : m_fpsGroup->actions ())
        {
            if (m_timer->interval() == 1000 / act->data().toInt())
                act->setChecked(true);
        }
        for(QAction *act : m_peaksFalloffGroup->actions ())
        {
            if (m_peaks_falloff == act->data().toDouble())
                act->setChecked(true);
        }
        for(QAction *act : m_analyzerFalloffGroup->actions ())
        {
            if (m_analyzer_falloff == act->data().toDouble())
                act->setChecked(true);
        }

        //fallback
        if(!m_fpsGroup->checkedAction())
        {
            m_fpsGroup->actions().at(1)->setChecked(true);
            m_timer->setInterval(1000 / 25);
        }
        if(!m_peaksFalloffGroup->checkedAction())
        {
            m_peaksFalloffGroup->actions().at(1)->setChecked(2);
            m_peaks_falloff = 0.2;
        }
        if(!m_peaksFalloffGroup->checkedAction())
        {
            m_peaksFalloffGroup->actions().at(1)->setChecked(2);
            m_analyzer_falloff = 2.2;
        }

        restoreGeometry(settings.value("geometry").toByteArray());
    }
}

void Analyzer::writeSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Analyzer");
    QAction *act = m_fpsGroup->checkedAction ();
    settings.setValue("refresh_rate", act ? act->data().toInt() : 25);
    act = m_peaksFalloffGroup->checkedAction ();
    settings.setValue("peak_falloff", act ? act->data().toDouble() : 0.2);
    act = m_analyzerFalloffGroup->checkedAction ();
    settings.setValue("analyzer_falloff", act ? act->data().toDouble() : 2.2);
    settings.setValue("show_peaks", m_peaksAction->isChecked());
    settings.endGroup();
}

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

void Analyzer::showEvent (QShowEvent *)
{
    if(m_running)
        m_timer->start();
}

void Analyzer::closeEvent (QCloseEvent *event)
{
    //save geometry
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.setValue("Analyzer/geometry", saveGeometry());
    Visual::closeEvent(event); //removes visualization object
}

void Analyzer::paintEvent (QPaintEvent * e)
{
    QPainter painter (this);
    painter.fillRect(e->rect(),m_bgColor);
    draw(&painter);
}

void Analyzer::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::RightButton)
        m_menu->exec(e->globalPos());
}

void Analyzer::process()
{
    static fft_state *state = nullptr;
    if (!state)
        state = fft_init();

    int rows = (height() - 2) / m_cell_size.height();
    int cols = (width() - 2) / m_cell_size.width() / 2;

    if(m_rows != rows || m_cols != cols)
    {
        m_rows = rows;
        m_cols = cols;
        if(m_peaks)
            delete [] m_peaks;
        if(m_intern_vis_data)
            delete [] m_intern_vis_data;
        if(m_x_scale)
            delete [] m_x_scale;
        m_peaks = new double[m_cols * 2];
        m_intern_vis_data = new double[m_cols * 2];
        m_x_scale = new int[m_cols + 1];

        for(int i = 0; i < m_cols * 2; ++i)
        {
            m_peaks[i] = 0;
            m_intern_vis_data[i] = 0;
        }
        for(int i = 0; i < m_cols + 1; ++i)