summaryrefslogtreecommitdiffstats
path: root/ksayit/Freeverb_plugin/ksayitfreeverblib.cpp
blob: 1141e680f2238f9f8a0fa7baa3577d38a37c6178 (plain)
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
//
// C++ Implementation: KSayItFXPlugin
//
// Description: 
//
//
// Author: Robert Vogl <voglrobe@lapislazuli>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//

// QT includes
// #include <tqtextcodec.h>
#include <tqstringlist.h>

// KDE includes
#include <kdebug.h>
#include <tdelocale.h>
#include <kdemacros.h>
#include <arts/artsmodules.h>

// App specific includes
#include "ksayitfreeverblib.h"
#include "freeverbsetupimpl.h"


// The class factory
K_EXPORT_COMPONENT_FACTORY( libFreeverb_plugin, FreeverbPluginFactory )
/** replaced by macro
extern "C"
{
    void* init_libFreeverb_plugin()
    {
        return new FreeverbPluginFactory;    
    }
};
*/

TDEInstance *FreeverbPluginFactory::p_instance = 0L;


// Factory Constructor
FreeverbPluginFactory::FreeverbPluginFactory(TQObject *parent, const char* name)
{
    p_instance = new TDEInstance("FreeverbPluginFactory");
}

    
TQObject* FreeverbPluginFactory::createObject(TQObject *parent, const char* name, 
            const char*, 
            const TQStringList &)
{
    kdDebug(100200) << "FreeverbPluginFactory::createObject()" << endl;
    
    TQObject* obj = new FreeverbPlugin( parent, name );
    emit objectCreated( obj );
    return obj;  
}        




// Plugin Constructor
FreeverbPlugin::FreeverbPlugin(TQObject *parent, const char* name) //, TDEApplication *Appl)
 : FXPlugin(parent, name) //, m_Appl(Appl)
{
    m_config = new KSimpleConfig("ksayit_freeverbrc");
    
}

FreeverbPlugin::~FreeverbPlugin()
{
    delete m_config;
}

/** sets the Main application object
*/
void FreeverbPlugin::setApplication(TDEApplication *Appl)
{
    m_Appl = Appl;
}


/** returns the Name of the Plugin
*/
TQString FreeverbPlugin::getName_KS() const
{
    return "Synth_FREEVERB";
}

/** returns a description of the plugin
*/
TQString FreeverbPlugin::getDescription_KS() const
{
    return i18n("This is a freeverb effect.");
}

/** shows the GUI to configure the plugin
*/
bool FreeverbPlugin::showGUI_KS()
{     
    FreeverbSetupImpl *dlg = new FreeverbSetupImpl(0, "Freeverb", true, m_config);
    if ( !dlg ){
        delete dlg;
        return false;
    }
    dlg->exec();
    delete dlg;
     
    return true;
}

/** activate the effect
*/
long FreeverbPlugin::activate_KS(KArtsServer *server,
                            StereoEffectStack *fx_stack) const
{
    // kdDebug(100200) << "Aktiviere Synth_FREEVERB-Effekt" << endl;
    Synth_FREEVERB fv = DynamicCast( server->server().createObject("Arts::Synth_FREEVERB") );
    if ( !fv.isNull() ){
        // kdDebug(100200) << "Filter angelegt" << endl;
        // get filter parameter
        m_config->setGroup("Synth_FREEVERB");            
        fv.roomsize( m_config->readDoubleNumEntry("roomsize", 50.0)/100.0 );
        fv.damp    ( m_config->readDoubleNumEntry("damp", 50.0    )/100.0 );
        fv.wet     ( m_config->readDoubleNumEntry("wet", 50.0     )/100.0 );
        fv.dry     ( m_config->readDoubleNumEntry("dry", 50.0     )/100.0 );
        fv.width   ( m_config->readDoubleNumEntry("width", 50.0   )/100.0 );
        
        fv.start();
        return fx_stack->insertBottom( fv, "Freeverb" );
    }
    return 0;
}

/** deactivates the effect
*/
bool FreeverbPlugin::deactivate_KS(StereoEffectStack *fx_stack,
                            long EffectID ) const
{
    // kdDebug(100200) << "Deaktiviere Synth_FREEVERB-Effekt" << endl;
    if (EffectID!=0){
        fx_stack->remove(EffectID);
    }
    return true;
}
















#include "ksayitfreeverblib.moc"