annotate plugin/RealTimePluginFactory.cpp @ 272:8bbc9e336475

* avoid trying to calculate fft from incomplete decoded audio file in spectrum
author Chris Cannam
date Mon, 02 Jul 2007 14:57:01 +0000
parents dc46851837d6
children 15b47d30c085
rev   line source
Chris@49 1 // -*- c-basic-offset: 4 indent-tabs-mode: nil -*-
Chris@0 2
Chris@0 3 /*
Chris@0 4 Rosegarden-4
Chris@0 5 A sequencer and musical notation editor.
Chris@0 6
Chris@17 7 This program is Copyright 2000-2006
Chris@0 8 Guillaume Laurent <glaurent@telegraph-road.org>,
Chris@0 9 Chris Cannam <cannam@all-day-breakfast.com>,
Chris@0 10 Richard Bown <bownie@bownie.com>
Chris@0 11
Chris@0 12 The moral right of the authors to claim authorship of this work
Chris@0 13 has been asserted.
Chris@0 14
Chris@0 15 This program is free software; you can redistribute it and/or
Chris@0 16 modify it under the terms of the GNU General Public License as
Chris@0 17 published by the Free Software Foundation; either version 2 of the
Chris@0 18 License, or (at your option) any later version. See the file
Chris@0 19 COPYING included with this distribution for more information.
Chris@0 20 */
Chris@0 21
Chris@0 22 #include "RealTimePluginFactory.h"
Chris@0 23 #include "PluginIdentifier.h"
Chris@0 24
Chris@0 25 #include "LADSPAPluginFactory.h"
Chris@0 26 #include "DSSIPluginFactory.h"
Chris@0 27
Chris@0 28 #include <iostream>
Chris@0 29
Chris@0 30 int RealTimePluginFactory::m_sampleRate = 48000;
Chris@0 31
Chris@0 32 static LADSPAPluginFactory *_ladspaInstance = 0;
Chris@0 33 static LADSPAPluginFactory *_dssiInstance = 0;
Chris@0 34
Chris@259 35 RealTimePluginFactory::~RealTimePluginFactory()
Chris@259 36 {
Chris@259 37 }
Chris@259 38
Chris@0 39 RealTimePluginFactory *
Chris@0 40 RealTimePluginFactory::instance(QString pluginType)
Chris@0 41 {
Chris@0 42 if (pluginType == "ladspa") {
Chris@0 43 if (!_ladspaInstance) {
Chris@117 44 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@117 45 // << "): creating new LADSPAPluginFactory" << std::endl;
Chris@0 46 _ladspaInstance = new LADSPAPluginFactory();
Chris@0 47 _ladspaInstance->discoverPlugins();
Chris@0 48 }
Chris@0 49 return _ladspaInstance;
Chris@0 50 } else if (pluginType == "dssi") {
Chris@0 51 if (!_dssiInstance) {
Chris@117 52 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@117 53 // << "): creating new DSSIPluginFactory" << std::endl;
Chris@0 54 _dssiInstance = new DSSIPluginFactory();
Chris@0 55 _dssiInstance->discoverPlugins();
Chris@0 56 }
Chris@0 57 return _dssiInstance;
Chris@0 58 }
Chris@0 59
Chris@0 60 else return 0;
Chris@0 61 }
Chris@0 62
Chris@0 63 RealTimePluginFactory *
Chris@0 64 RealTimePluginFactory::instanceFor(QString identifier)
Chris@0 65 {
Chris@0 66 QString type, soName, label;
Chris@0 67 PluginIdentifier::parseIdentifier(identifier, type, soName, label);
Chris@0 68 return instance(type);
Chris@0 69 }
Chris@0 70
Chris@0 71 std::vector<QString>
Chris@0 72 RealTimePluginFactory::getAllPluginIdentifiers()
Chris@0 73 {
Chris@0 74 RealTimePluginFactory *factory;
Chris@0 75 std::vector<QString> rv;
Chris@0 76
Chris@0 77 // Query DSSI plugins before LADSPA ones.
Chris@0 78 // This is to provide for the interesting possibility of plugins
Chris@0 79 // providing either DSSI or LADSPA versions of themselves,
Chris@0 80 // returning both versions if the LADSPA identifiers are queried
Chris@0 81 // first but only the DSSI version if the DSSI identifiers are
Chris@0 82 // queried first.
Chris@0 83
Chris@0 84 factory = instance("dssi");
Chris@0 85 if (factory) {
Chris@0 86 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 87 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 88 rv.push_back(tmp[i]);
Chris@0 89 }
Chris@0 90 }
Chris@0 91
Chris@0 92 factory = instance("ladspa");
Chris@0 93 if (factory) {
Chris@0 94 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 95 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 96 rv.push_back(tmp[i]);
Chris@0 97 }
Chris@0 98 }
Chris@0 99
Chris@0 100 // Plugins can change the locale, revert it to default.
Chris@0 101 setlocale(LC_ALL, "C");
Chris@0 102 return rv;
Chris@0 103 }
Chris@0 104
Chris@0 105 void
Chris@0 106 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list)
Chris@0 107 {
Chris@0 108 RealTimePluginFactory *factory;
Chris@0 109
Chris@0 110 // Query DSSI plugins before LADSPA ones.
Chris@0 111 // This is to provide for the interesting possibility of plugins
Chris@0 112 // providing either DSSI or LADSPA versions of themselves,
Chris@0 113 // returning both versions if the LADSPA identifiers are queried
Chris@0 114 // first but only the DSSI version if the DSSI identifiers are
Chris@0 115 // queried first.
Chris@0 116
Chris@0 117 factory = instance("dssi");
Chris@0 118 if (factory) factory->enumeratePlugins(list);
Chris@0 119
Chris@0 120 factory = instance("ladspa");
Chris@0 121 if (factory) factory->enumeratePlugins(list);
Chris@0 122
Chris@0 123 // Plugins can change the locale, revert it to default.
Chris@0 124 setlocale(LC_ALL, "C");
Chris@0 125 }
Chris@0 126