1 /***************************************************************************
2 **                                                                        **
3 **  Polyphone, a soundfont editor                                         **
4 **  Copyright (C) 2013-2020 Davy Triponney                                **
5 **                                                                        **
6 **  This program is free software: you can redistribute it and/or modify  **
7 **  it under the terms of the GNU General Public License as published by  **
8 **  the Free Software Foundation, either version 3 of the License, or     **
9 **  (at your option) any later version.                                   **
10 **                                                                        **
11 **  This program is distributed in the hope that it will be useful,       **
12 **  but WITHOUT ANY WARRANTY; without even the implied warranty of        **
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          **
14 **  GNU General Public License for more details.                          **
15 **                                                                        **
16 **  You should have received a copy of the GNU General Public License     **
17 **  along with this program. If not, see http://www.gnu.org/licenses/.    **
18 **                                                                        **
19 ****************************************************************************
20 **           Author: Davy Triponney                                       **
21 **  Website/Contact: https://www.polyphone-soundfonts.com                 **
22 **             Date: 01.01.2013                                           **
23 ***************************************************************************/
24 
25 #include "toolfactory.h"
26 #include "abstracttool.h"
27 #include <QApplication>
28 
29 #include "trim_end/tooltrimend.h"
30 #include "auto_loop/toolautoloop.h"
31 #include "external_command/toolexternalcommand.h"
32 #include "trim_start/tooltrimstart.h"
33 #include "frequency_filter/toolfrequencyfilter.h"
34 #include "change_volume/toolchangevolume.h"
35 #include "balance_adjustment/toolbalanceadjustment.h"
36 #include "transpose_smpl/tooltransposesmpl.h"
37 #include "link_sample/toollinksample.h"
38 #include "unlink_sample/toolunlinksample.h"
39 #include "change_attenuation/toolchangeattenuation.h"
40 #include "global_settings/toolglobalsettings.h"
41 #include "celeste_tuning/toolcelestetuning.h"
42 #include "auto_distribution/toolautodistribution.h"
43 #include "clean_unused_elements/toolcleanunused.h"
44 #include "division_duplication/tooldivisionduplication.h"
45 #include "frequency_peaks/toolfrequencypeaks.h"
46 #include "mixture_creation/toolmixturecreation.h"
47 #include "monitor/toolmonitor.h"
48 #include "preset_list/toolpresetlist.h"
49 #include "remove_mods/toolremovemods.h"
50 #include "sound_spatialization/toolsoundspatialization.h"
51 #include "transpose/tooltranspose.h"
52 #include "release/toolrelease.h"
53 #include "chords/toolchords.h"
54 #include "sample_export/toolsampleexport.h"
55 #include "default_mod/tooldefaultmod.h"
56 #include "fast_edit_smpl/toolfasteditsmpl.h"
57 
58 
~ToolFactory()59 ToolFactory::~ToolFactory()
60 {
61     // Delete all tools
62     while (!_tools.empty())
63         delete _tools.takeFirst();
64 }
65 
getTools(IdList ids)66 QList<AbstractTool *> ToolFactory::getTools(IdList ids)
67 {
68     if (_tools.empty())
69         initialize();
70 
71     QList<AbstractTool *> possibleTools;
72     foreach (AbstractTool * tool, _tools)
73         if (tool->setIds(ids))
74             possibleTools << tool;
75     return possibleTools;
76 }
77 
initialize()78 void ToolFactory::initialize()
79 {
80     // Initialize the tools
81     AbstractTool::initialize(QApplication::activeWindow());
82 
83     // Register all possible tools
84     _tools << new ToolTrimEnd() // Samples
85            << new ToolAutoLoop()
86            << new ToolExternalCommand()
87            << new ToolTrimStart()
88            << new ToolFrequencyFilter()
89            << new ToolChangeVolume()
90            << new ToolBalanceAdjustment()
91            << new ToolTransposeSmpl()
92            << new ToolLinkSample()
93            << new ToolUnlinkSample()
94            << new ToolFrequencyPeaks()
95            << new ToolSampleExport()
96            << new ToolFastEditSmpl()
97            << new ToolCelesteTuning() // Instruments
98            << new ToolAutoDistribution()
99            << new ToolMixtureCreation()
100            << new ToolChords()
101            << new ToolSoundSpatialization()
102            << new ToolTranspose()
103            << new ToolRelease()
104            << new ToolDefaultMod()
105            << new ToolChangeAttenuation() // Instruments, presets
106            << new ToolGlobalSettings()
107            << new ToolDivisionDuplication()
108            << new ToolMonitor()
109            << new ToolRemoveMods()
110            << new ToolCleanUnused()   // Sf2
111            << new ToolPresetList();
112 }
113