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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
// -*- c-basic-offset: 4 -*-
/*
Rosegarden
A sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <bownie@bownie.com>
The moral right of the authors to claim authorship of this work
has been asserted.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef _DSSIPLUGININSTANCE_H_
#define _DSSIPLUGININSTANCE_H_
#include <vector>
#include <set>
#include <map>
#include <tqstring.h>
#include "Instrument.h"
#ifdef HAVE_DSSI
#include <dssi.h>
#include "RingBuffer.h"
#include "RunnablePluginInstance.h"
#include "Scavenger.h"
#include <pthread.h>
namespace Rosegarden
{
class DSSIPluginInstance : public RunnablePluginInstance
{
public:
virtual ~DSSIPluginInstance();
virtual bool isOK() const { return m_instanceHandle != 0; }
InstrumentId getInstrument() const { return m_instrument; }
virtual TQString getIdentifier() const { return m_identifier; }
int getPosition() const { return m_position; }
virtual void run(const RealTime &);
virtual void setPortValue(unsigned int portNumber, float value);
virtual float getPortValue(unsigned int portNumber);
virtual TQString configure(TQString key, TQString value);
virtual void sendEvent(const RealTime &eventTime,
const void *event);
virtual size_t getBufferSize() { return m_blockSize; }
virtual size_t getAudioInputCount() { return m_audioPortsIn.size(); }
virtual size_t getAudioOutputCount() { return m_idealChannelCount; }
virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; }
virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; }
virtual TQStringList getPrograms();
virtual TQString getCurrentProgram();
virtual TQString getProgram(int bank, int program);
virtual unsigned long getProgram(TQString name);
virtual void selectProgram(TQString program);
virtual bool isBypassed() const { return m_bypassed; }
virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; }
virtual size_t getLatency();
virtual void silence();
virtual void discardEvents();
virtual void setIdealChannelCount(size_t channels); // may re-instantiate
virtual bool isInGroup() const { return m_grouped; }
virtual void detachFromGroup();
protected:
// To be constructed only by DSSIPluginFactory
friend class DSSIPluginFactory;
// Constructor that creates the buffers internally
//
DSSIPluginInstance(PluginFactory *factory,
InstrumentId instrument,
TQString identifier,
int position,
unsigned long sampleRate,
size_t blockSize,
int idealChannelCount,
const DSSI_Descriptor* descriptor);
// Constructor that uses shared buffers
//
DSSIPluginInstance(PluginFactory *factory,
InstrumentId instrument,
TQString identifier,
int position,
unsigned long sampleRate,
size_t blockSize,
sample_t **inputBuffers,
sample_t **outputBuffers,
const DSSI_Descriptor* descriptor);
void init();
void instantiate(unsigned long sampleRate);
void cleanup();
void activate();
void deactivate();
void connectPorts();
bool handleController(snd_seq_event_t *ev);
void setPortValueFromController(unsigned int portNumber, int controlValue);
void selectProgramAux(TQString program, bool backupPortValues);
void checkProgramCache();
void initialiseGroupMembership();
void runGrouped(const RealTime &);
InstrumentId m_instrument;
int m_position;
LADSPA_Handle m_instanceHandle;
const DSSI_Descriptor *m_descriptor;
std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsIn;
std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsOut;
std::vector<LADSPA_Data> m_backupControlPortsIn;
std::vector<bool> m_portChangedSinceProgramChange;
std::map<int, int> m_controllerMap;
std::vector<int> m_audioPortsIn;
std::vector<int> m_audioPortsOut;
struct ProgramControl {
int msb;
int lsb;
int program;
};
ProgramControl m_pending;
struct ProgramDescriptor {
int bank;
int program;
TQString name;
};
std::vector<ProgramDescriptor> m_cachedPrograms;
bool m_programCacheValid;
RingBuffer<snd_seq_event_t> m_eventBuffer;
size_t m_blockSize;
sample_t **m_inputBuffers;
sample_t **m_outputBuffers;
bool m_ownBuffers;
size_t m_idealChannelCount;
size_t m_outputBufferCount;
size_t m_sampleRate;
float *m_latencyPort;
bool m_run;
bool m_runSinceReset;
bool m_bypassed;
TQString m_program;
bool m_grouped;
RealTime m_lastRunTime;
pthread_mutex_t m_processLock;
typedef std::set<DSSIPluginInstance *> PluginSet;
typedef std::map<TQString, PluginSet> GroupMap;
static GroupMap m_groupMap;
static snd_seq_event_t **m_groupLocalEventBuffers;
static size_t m_groupLocalEventBufferCount;
static Scavenger<ScavengerArrayWrapper<snd_seq_event_t *> > m_bufferScavenger;
};
};
#endif // HAVE_DSSI
#endif // _DSSIPLUGININSTANCE_H_
|