ModelTransformerFactory.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_MODEL_TRANSFORMER_FACTORY_H
17 #define SV_MODEL_TRANSFORMER_FACTORY_H
18 
19 #include "Transform.h"
20 #include "TransformDescription.h"
22 
23 #include "ModelTransformer.h"
24 
25 #include <vamp-hostsdk/PluginBase.h>
26 
27 #include <QMap>
28 #include <QMutex>
29 #include <map>
30 #include <set>
31 #include <vector>
32 #include <memory>
33 
34 class AudioPlaySource;
35 
36 class ModelTransformerFactory : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41  virtual ~ModelTransformerFactory();
42 
44 
46  public:
47  virtual bool configure(ModelTransformer::Input &input,
49  std::shared_ptr<Vamp::PluginBase> plugin,
50  ModelId &inputModel,
51  AudioPlaySource *source,
52  sv_frame_t startFrame,
53  sv_frame_t duration,
54  const QMap<QString, ModelId> &modelMap,
55  QStringList candidateModelNames,
56  QString defaultModelName) = 0;
57  };
58 
69  std::vector<ModelId> candidateInputModels,
70  ModelId defaultInputModel,
71  AudioPlaySource *source = 0,
72  sv_frame_t startFrame = 0,
73  sv_frame_t duration = 0,
74  UserConfigurator *configurator = 0);
75 
77  public:
79 
80  // Exactly one of these functions will be called
81  virtual void moreModelsAvailable(std::vector<ModelId> models) = 0;
82  virtual void noMoreModelsAvailable() = 0;
83  };
84 
108  ModelId transform(const Transform &transform,
109  const ModelTransformer::Input &input,
110  QString &message,
111  AdditionalModelHandler *handler = 0);
112 
145  std::vector<ModelId> transformMultiple(const Transforms &transform,
146  const ModelTransformer::Input &input,
147  QString &message,
148  AdditionalModelHandler *handler = 0);
149 
150  bool haveRunningTransformers() const;
151 
152 signals:
153  void transformFailed(QString transformName, QString message);
154 
155 protected slots:
156  void transformerFinished();
157 
158 protected:
159  ModelTransformer *createTransformer(const Transforms &transforms,
160  const ModelTransformer::Input &input);
161 
162  mutable QMutex m_mutex;
163 
164  typedef std::map<TransformId, QString> TransformerConfigurationMap;
165  TransformerConfigurationMap m_lastConfigurations;
166 
167  typedef std::set<ModelTransformer *> TransformerSet;
168  TransformerSet m_runningTransformers;
169 
170  typedef std::map<ModelTransformer *, AdditionalModelHandler *> HandlerMap;
171  HandlerMap m_handlers;
172 
174 };
175 
176 
177 #endif
Simple interface for audio playback.
ModelId transform(const Transform &transform, const ModelTransformer::Input &input, QString &message, AdditionalModelHandler *handler=0)
Return the output model resulting from applying the named transform to the given input model...
ModelTransformer * createTransformer(const Transforms &transforms, const ModelTransformer::Input &input)
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
std::set< ModelTransformer * > TransformerSet
std::vector< Transform > Transforms
Definition: Transform.h:204
static ModelTransformerFactory * getInstance()
virtual bool configure(ModelTransformer::Input &input, Transform &transform, std::shared_ptr< Vamp::PluginBase > plugin, ModelId &inputModel, AudioPlaySource *source, sv_frame_t startFrame, sv_frame_t duration, const QMap< QString, ModelId > &modelMap, QStringList candidateModelNames, QString defaultModelName)=0
static ModelTransformerFactory * m_instance
ModelTransformer::Input getConfigurationForTransform(Transform &transform, std::vector< ModelId > candidateInputModels, ModelId defaultInputModel, AudioPlaySource *source=0, sv_frame_t startFrame=0, sv_frame_t duration=0, UserConfigurator *configurator=0)
Fill out the configuration for the given transform (may include asking the user by calling back on th...
std::vector< ModelId > transformMultiple(const Transforms &transform, const ModelTransformer::Input &input, QString &message, AdditionalModelHandler *handler=0)
Return the multiple output models resulting from applying the named transforms to the given input mod...
void transformFailed(QString transformName, QString message)
TransformerConfigurationMap m_lastConfigurations
A ModelTransformer turns one data model into another.
std::map< TransformId, QString > TransformerConfigurationMap
Definition: ById.h:115
std::map< ModelTransformer *, AdditionalModelHandler * > HandlerMap