aboutsummaryrefslogblamecommitdiff
path: root/src/plugins/Effect/ladspa/effectladspafactory.cpp
blob: b0b73fd7dfd4b62155032f3b05cfbbe1193ee3fa (plain) (tree)
1
2
3
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            

                                                                             
                      
                      
                           

                                





                                                              

                                  


                      
                                     
 
                              








                                                       


                                                                 
                                                                             




                                                                         




                                                
/***************************************************************************
 *   Copyright (C) 2009-2015 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 <QMessageBox>
#include <qmmp/qmmp.h>
#include "settingsdialog.h"
#include "ladspahelper.h"
#include "effectladspafactory.h"

const EffectProperties EffectLADSPAFactory::properties() const
{
    EffectProperties properties;
    properties.name = tr("LADSPA Plugin");
    properties.shortName = "ladspa";
    properties.hasSettings = true;
    properties.hasAbout = true;
    return properties;
}

Effect *EffectLADSPAFactory::create()
{
    return new LADSPAHelper();
}

void EffectLADSPAFactory::showSettings(QWidget *parent)
{
    SettingsDialog *s = new SettingsDialog(parent);
    s->show();
}

void EffectLADSPAFactory::showAbout(QWidget *parent)
{
    QMessageBox::about (parent, tr("About LADSPA Host for Qmmp"),
                        tr("LADSPA Host for Qmmp")+"\n"+
                        tr("Written by: Ilya Kotov <forkotov02@ya.ru>")+"\n"+
                        tr("Based on the LADSPA Host for BMP")+"\n"+
                        tr("BMP-ladspa developers:")+"\n"+
                        tr("Nick Lamb <njl195@zepler.org.uk>")+"\n"+
                        tr("Giacomo Lozito <city_hunter@users.sf.net>"));
}

QString EffectLADSPAFactory::translation() const
{
    return QLatin1String(":/ladspa_plugin_");
}
2@90c681e8-e032-0410-971d-27865f9a5e38> 2013-08-05 13:14:32 +0000 fixed some regressions' href='/qmmp/commit/src/qmmpui/playstate.cpp?id=664d78f03b2ae95368c70ca8a45cc746a1612ccd'>664d78f03
245d0ac0c
664d78f03

2d622fd9b
664d78f03
35804feb8


245d0ac0c
664d78f03
11b7655bb
245d0ac0c


2d622fd9b



664d78f03
245d0ac0c


2d622fd9b
664d78f03

245d0ac0c
664d78f03
2d622fd9b

664d78f03
245d0ac0c
664d78f03


245d0ac0c
664d78f03
245d0ac0c
11b7655bb
2d622fd9b

e2bc4908a

664d78f03
e2bc4908a

664d78f03
e2bc4908a

3b1c5a1db






e2bc4908a
664d78f03
245d0ac0c
664d78f03
245d0ac0c
664d78f03
245d0ac0c

e2bc4908a
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
                                                                            
                                                                            














                                                                            
                                                                            

                                                                             
                        







                                                                            

                         
 
                                                             
     

                                         
            
                      
     




                                                                                   

 

                                 
                         

                  






                                                             
                                                                                        

 

                                 

                         
 
                                
     


                                         
         

                                                                
         
     
 

                             
 
                                                                          




                                
                                             
     
                                                                


                                    

                                                                      
 
                                                        







                                   


                                                                          

                            
                         

                     
                                                                                       
     
                             
                                          
                                                           
                                          

                         
     
 


                                                          
                                                                
                                                               
                     


                                                                



                                
                         


                                   
     

                                                                
                                             
                                                             

     
                                                            
                     


                                                          
                                                                
                                                                                          
                                                                
                 

 

                                
                         

                  
                                                        

                                        






                                        
     
                                                     
                                           
                                                               
                  
                                                          

                                           
 
/***************************************************************************
 *   Copyright (C) 2006-2013 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 "playstate_p.h"

ShufflePlayState::ShufflePlayState(PlayListModel * model) : PlayState(model)
{
    prepare();
}

bool ShufflePlayState::next()
{
    if(!m_model->count())
        return false;

    if (m_shuffled_current >= m_shuffled_indexes.count() - 1)
    {
        if (!m_model->isRepeatableList())
            return false;
        else
            prepare();
    }
    else
        m_shuffled_current = (m_shuffled_current + 1) % m_shuffled_indexes.count();

    return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current));

}

int ShufflePlayState::nextIndex()
{
    if(!m_model->count())
        return -1;

    if (m_shuffled_current >= m_shuffled_indexes.count() - 1)
    {
        if (!m_model->isRepeatableList())
            return -1;
        else
            prepare();
    }
    return m_shuffled_indexes.at((m_shuffled_current + 1) % m_shuffled_indexes.count());
}

bool ShufflePlayState::previous()
{
    if(!m_model->count())
        return false;

    if (m_shuffled_current <= 0)
    {
        if (!m_model->isRepeatableList())
            return false;
        else
        {
            prepare();
            m_shuffled_current = m_shuffled_indexes.count() - 1;
        }
    }

    if (m_model->count() > 1)
        m_shuffled_current--;

    return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current));
}

void ShufflePlayState::prepare()
{
    resetState();
    for(int i = 0; i < m_model->count(); i++)
    {
        if (i != m_model->currentIndex() && m_model->isTrack(i))
            m_shuffled_indexes << i;
    }

    for (int i = 0; i < m_shuffled_indexes.count(); i++)
        m_shuffled_indexes.swap(i, qrand()%m_shuffled_indexes.size());

    m_shuffled_indexes.prepend(m_model->currentIndex());
}

void ShufflePlayState::resetState()
{
    m_shuffled_indexes.clear();
    m_shuffled_current = 0;
}

NormalPlayState::NormalPlayState(PlayListModel * model) : PlayState(model)
{}

bool NormalPlayState::next()
{
    if(!m_model->count())
        return false;

    if (m_model->isRepeatableList() && m_model->currentIndex() == m_model->count() - 1)
    {
        if(m_model->track(0))
            return m_model->setCurrent(0);
        else if(m_model->count() >= 2 && m_model->track(1))
            return m_model->setCurrent(1);
        else
            return false;
    }

    if(m_model->currentIndex() + 1 >= m_model->count())
        return false;
    else if(m_model->track((m_model->currentIndex() + 1)))
        return m_model->setCurrent(m_model->currentIndex() + 1);
    else if(m_model->currentIndex() + 2 > m_model->count() - 1)
        return false;
    else if(m_model->track(m_model->currentIndex() + 2))
        return m_model->setCurrent(m_model->currentIndex() + 2);
    return false;
}

bool NormalPlayState::previous()
{
    if(!m_model->count())
        return false;

    if(m_model->isRepeatableList())
    {
        if(m_model->currentIndex() == 1 && !m_model->isTrack(0))
            return (m_model->setCurrent(m_model->count() - 1));
        else if(m_model->currentIndex() == 0)
            return m_model->setCurrent(m_model->count() - 1);
    }

    if(m_model->currentIndex() == 1 && !m_model->isTrack(0))
        return false;
    else if(m_model->currentIndex() == 0)
        return false;
    else if(m_model->isTrack(m_model->currentIndex() - 1))
        return m_model->setCurrent(m_model->currentIndex() - 1);
    else if(m_model->currentIndex() >= 2 && m_model->isTrack(m_model->currentIndex() - 2))
        return m_model->setCurrent(m_model->currentIndex() - 2);
    return false;
}

int NormalPlayState::nextIndex()
{
    if(!m_model->count())
        return -1;

    if (m_model->currentIndex() == m_model->count() - 1)
    {
        if (m_model->isRepeatableList())
        {
            if(m_model->isTrack(0))
                return 0;
            else if(m_model->isTrack(1))
                return 1;
        }
        return -1;
    }
    if(m_model->isTrack(m_model->currentIndex() + 1))
        return m_model->currentIndex() + 1;
    else if(m_model->currentIndex() + 2 > m_model->count() - 1)
        return -1;
    else if(m_model->isTrack(m_model->currentIndex() + 2))
        return m_model->currentIndex() + 2;
    return -1;
}