annotate plugin/LADSPAPluginInstance.h @ 1769:9a8327e7b2dc

Respect use-flexi-note-model setting
author Chris Cannam
date Thu, 18 Jul 2019 14:42:24 +0100
parents ad5f892c0c4d
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7
Chris@52 8 This program is free software; you can redistribute it and/or
Chris@52 9 modify it under the terms of the GNU General Public License as
Chris@52 10 published by the Free Software Foundation; either version 2 of the
Chris@52 11 License, or (at your option) any later version. See the file
Chris@52 12 COPYING included with this distribution for more information.
Chris@0 13 */
Chris@0 14
Chris@0 15 /*
Chris@0 16 This is a modified version of a source file from the
Chris@0 17 Rosegarden MIDI and audio sequencer and notation editor.
Chris@17 18 This file copyright 2000-2006 Chris Cannam and Richard Bown.
Chris@0 19 */
Chris@0 20
Chris@1581 21 #ifndef SV_LADSPAPLUGININSTANCE_H
Chris@1581 22 #define SV_LADSPAPLUGININSTANCE_H
Chris@0 23
Chris@0 24 #include <vector>
Chris@0 25 #include <set>
Chris@0 26 #include <QString>
Chris@0 27
Chris@0 28 #include "api/ladspa.h"
Chris@0 29 #include "RealTimePluginInstance.h"
Chris@1039 30 #include "base/BaseTypes.h"
Chris@0 31
Chris@0 32 // LADSPA plugin instance. LADSPA is a variable block size API, but
Chris@0 33 // for one reason and another it's more convenient to use a fixed
Chris@0 34 // block size in this wrapper.
Chris@0 35 //
Chris@0 36 class LADSPAPluginInstance : public RealTimePluginInstance
Chris@0 37 {
Chris@0 38 public:
Chris@0 39 virtual ~LADSPAPluginInstance();
Chris@0 40
Chris@1580 41 bool isOK() const override { return m_instanceHandles.size() != 0; }
Chris@0 42
Chris@0 43 int getClientId() const { return m_client; }
Chris@1580 44 QString getPluginIdentifier() const override { return m_identifier; }
Chris@0 45 int getPosition() const { return m_position; }
Chris@0 46
Chris@1580 47 std::string getIdentifier() const override;
Chris@1580 48 std::string getName() const override;
Chris@1580 49 std::string getDescription() const override;
Chris@1580 50 std::string getMaker() const override;
Chris@1580 51 int getPluginVersion() const override;
Chris@1580 52 std::string getCopyright() const override;
Chris@51 53
Chris@1580 54 void run(const RealTime &rt, int count = 0) override;
Chris@0 55
Chris@1580 56 int getParameterCount() const override;
Chris@1580 57 void setParameterValue(int parameter, float value) override;
Chris@1580 58 float getParameterValue(int parameter) const override;
Chris@1580 59 float getParameterDefault(int parameter) const override;
Chris@1580 60 int getParameterDisplayHint(int parameter) const override;
Chris@51 61
Chris@1580 62 ParameterList getParameterDescriptors() const override;
Chris@1580 63 float getParameter(std::string) const override;
Chris@1580 64 void setParameter(std::string, float) override;
Chris@0 65
Chris@1580 66 int getBufferSize() const override { return m_blockSize; }
Chris@1580 67 int getAudioInputCount() const override { return int(m_instanceCount * m_audioPortsIn.size()); }
Chris@1580 68 int getAudioOutputCount() const override { return int(m_instanceCount * m_audioPortsOut.size()); }
Chris@1580 69 sample_t **getAudioInputBuffers() override { return m_inputBuffers; }
Chris@1580 70 sample_t **getAudioOutputBuffers() override { return m_outputBuffers; }
Chris@0 71
Chris@1580 72 int getControlOutputCount() const override { return int(m_controlPortsOut.size()); }
Chris@1580 73 float getControlOutputValue(int n) const override;
Chris@60 74
Chris@1580 75 bool isBypassed() const override { return m_bypassed; }
Chris@1580 76 void setBypassed(bool bypassed) override { m_bypassed = bypassed; }
Chris@0 77
Chris@1580 78 sv_frame_t getLatency() override;
Chris@0 79
Chris@1580 80 void silence() override;
Chris@1580 81 void setIdealChannelCount(int channels) override; // may re-instantiate
Chris@0 82
Chris@1580 83 std::string getType() const override { return "LADSPA Real-Time Plugin"; }
Chris@57 84
Chris@0 85 protected:
Chris@0 86 // To be constructed only by LADSPAPluginFactory
Chris@0 87 friend class LADSPAPluginFactory;
Chris@0 88
Chris@0 89 // Constructor that creates the buffers internally
Chris@0 90 //
Chris@0 91 LADSPAPluginInstance(RealTimePluginFactory *factory,
Chris@1429 92 int client,
Chris@1429 93 QString identifier,
Chris@0 94 int position,
Chris@1429 95 sv_samplerate_t sampleRate,
Chris@1429 96 int blockSize,
Chris@1429 97 int idealChannelCount,
Chris@0 98 const LADSPA_Descriptor* descriptor);
Chris@0 99
Chris@0 100 void init(int idealChannelCount = 0);
Chris@1040 101 void instantiate(sv_samplerate_t sampleRate);
Chris@0 102 void cleanup();
Chris@0 103 void activate();
Chris@0 104 void deactivate();
Chris@0 105
Chris@0 106 // Connection of data (and behind the scenes control) ports
Chris@0 107 //
Chris@0 108 void connectPorts();
Chris@0 109
Chris@0 110 int m_client;
Chris@0 111 int m_position;
Chris@0 112 std::vector<LADSPA_Handle> m_instanceHandles;
Chris@1040 113 int m_instanceCount;
Chris@0 114 const LADSPA_Descriptor *m_descriptor;
Chris@0 115
Chris@1039 116 std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsIn;
Chris@1039 117 std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsOut;
Chris@0 118
Chris@0 119 std::vector<int> m_audioPortsIn;
Chris@0 120 std::vector<int> m_audioPortsOut;
Chris@0 121
Chris@1040 122 int m_blockSize;
Chris@0 123 sample_t **m_inputBuffers;
Chris@0 124 sample_t **m_outputBuffers;
Chris@0 125 bool m_ownBuffers;
Chris@1040 126 sv_samplerate_t m_sampleRate;
Chris@0 127 float *m_latencyPort;
Chris@0 128 bool m_run;
Chris@0 129
Chris@0 130 bool m_bypassed;
Chris@0 131 };
Chris@0 132
Chris@0 133 #endif // _LADSPAPLUGININSTANCE_H_
Chris@0 134