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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
/*
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.
*/
#include <map>
#include <string>
#include <vector>
#include <tqdatastream.h>
#include <tqstring.h>
#include "MappedCommon.h"
#include "Instrument.h"
#include "Device.h"
#include "AudioPluginInstance.h" // for PluginPort::PortDisplayHint //!!!???
#ifndef _MAPPEDSTUDIO_H_
#define _MAPPEDSTUDIO_H_
// A sequencer-side representation of certain elements in the
// gui that enables us to control outgoing or incoming audio
// and MIDI with run-time only persistence. Placeholders for
// our Studio elements on the sequencer.
namespace Rosegarden
{
class SoundDriver;
// Types are in MappedCommon.h
//
class MappedObject
{
public:
// Some common properties
//
static const MappedObjectProperty Name;
static const MappedObjectProperty Instrument;
static const MappedObjectProperty Position;
// The object we can create
//
typedef enum
{
Studio,
AudioFader, // connectable fader - interfaces with devices
AudioBuss, // connectable buss - inferfaces with faders
AudioInput, // connectable record input
PluginSlot,
PluginPort
} MappedObjectType;
MappedObject(MappedObject *parent,
const std::string &name,
MappedObjectType type,
MappedObjectId id):
m_type(type),
m_id(id),
m_name(name),
m_parent(parent) {;}
virtual ~MappedObject() {;}
MappedObjectId getId() { return m_id; }
MappedObjectType getType() { return m_type; }
std::string getName() { return m_name; }
void setName(const std::string &name) { m_name= name; }
// Get and set properties
//
virtual MappedObjectPropertyList
getPropertyList(const MappedObjectProperty &property) = 0;
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value) = 0;
// Only relevant to objects that have string properties
//
virtual bool getProperty(const MappedObjectProperty &/* property */,
TQString &/* value */) { return false; }
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value) = 0;
// Only relevant to objects that have string properties
//
virtual void setProperty(const MappedObjectProperty &/* property */,
TQString /* value */) { }
// Only relevant to objects that have list properties
//
virtual void setPropertyList(const MappedObjectProperty &/* property */,
const MappedObjectPropertyList &/* values */) { }
// Ownership
//
MappedObject* getParent() { return m_parent; }
const MappedObject* getParent() const { return m_parent; }
void setParent(MappedObject *parent) { m_parent = parent; }
// Get a list of child ids - get a list of a certain type
//
MappedObjectPropertyList getChildren();
MappedObjectPropertyList getChildren(MappedObjectType type);
// Child management
//
void addChild(MappedObject *mO);
void removeChild(MappedObject *mO);
// Destruction
//
void destroy();
void destroyChildren();
std::vector<MappedObject*> getChildObjects() { return m_children; }
protected:
MappedObjectType m_type;
MappedObjectId m_id;
std::string m_name;
MappedObject *m_parent;
std::vector<MappedObject*> m_children;
};
class MappedAudioFader;
class MappedAudioBuss;
class MappedAudioInput;
// Works as a factory and virtual plug-board for all our other
// objects whether they be MIDI or audio.
//
//
//
class MappedStudio : public MappedObject
{
public:
MappedStudio();
~MappedStudio();
// Create a new slider of a certain type for a certain
// type of device.
//
MappedObject* createObject(MappedObjectType type);
// And create an object with a specified id
//
MappedObject* createObject(MappedObjectType type,
MappedObjectId id);
bool connectObjects(MappedObjectId mId1, MappedObjectId mId2);
bool disconnectObjects(MappedObjectId mId1, MappedObjectId mId2);
bool disconnectObject(MappedObjectId mId);
// Destroy a MappedObject by ID
//
bool destroyObject(MappedObjectId id);
// Get an object by ID only
//
MappedObject* getObjectById(MappedObjectId);
// Get an object by ID and type. (Returns 0 if the ID does not
// exist or exists but is not of the correct type.) This is
// faster than getObjectById if you know the type already.
//
MappedObject* getObjectByIdAndType(MappedObjectId, MappedObjectType);
// Get an arbitrary object of a given type - to see if any exist
//
MappedObject* getObjectOfType(MappedObjectType type);
// Find out how many objects there are of a certain type
//
unsigned int getObjectCount(MappedObjectType type);
// iterators
MappedObject* getFirst(MappedObjectType type);
MappedObject* getNext(MappedObject *object);
std::vector<MappedObject *> getObjectsOfType(MappedObjectType type);
// Empty the studio of everything
//
void clear();
// Clear a MappedObject reference from the Studio
//
bool clearObject(MappedObjectId id);
// Property list
//
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
// Get an audio fader for an InstrumentId. Convenience function.
//
MappedAudioFader *getAudioFader(InstrumentId id);
MappedAudioBuss *getAudioBuss(int bussNumber); // not buss no., not object id
MappedAudioInput *getAudioInput(int inputNumber); // likewise
// Return the object vector
//
//std::vector<MappedObject*>* getObjects() const { return &m_objects; }
// DCOP streaming
//
/* dunno if we need this
friend TQDataStream& operator>>(TQDataStream &dS, MappedStudio *mS);
friend TQDataStream& operator<<(TQDataStream &dS, MappedStudio *mS);
friend TQDataStream& operator>>(TQDataStream &dS, MappedStudio &mS);
friend TQDataStream& operator<<(TQDataStream &dS, const MappedStudio &mS);
*/
// Set the driver object so that we can do things like
// initialise plugins etc.
//
SoundDriver* getSoundDriver() { return m_soundDriver; }
const SoundDriver* getSoundDriver() const { return m_soundDriver; }
void setSoundDriver(SoundDriver *driver) { m_soundDriver = driver; }
protected:
private:
// We give everything we create a unique MappedObjectId for
// this session. So store the running total in here.
//
MappedObjectId m_runningObjectId;
// All of our mapped (virtual) studio resides in this container as
// well as having all their parent/child relationships. Because
// some things are just blobs with no connections we need to
// maintain both - don't forget about this.
//
// Note that object IDs are globally unique, not just unique within
// a category.
//
typedef std::map<MappedObjectId, MappedObject *> MappedObjectCategory;
typedef std::map<MappedObjectType, MappedObjectCategory> MappedObjectMap;
MappedObjectMap m_objects;
// Driver object
//
SoundDriver *m_soundDriver;
};
// A connectable AudioObject that provides a connection framework
// for MappedAudioFader and MappedAudioBuss (for example). An
// abstract base class.
//
// n input connections and m output connections - subclasses
// can do the cleverness if n != m
//
class MappedConnectableObject : public MappedObject
{
public:
static const MappedObjectProperty ConnectionsIn;
static const MappedObjectProperty ConnectionsOut;
typedef enum
{
In,
Out
} ConnectionDirection;
MappedConnectableObject(MappedObject *parent,
const std::string &name,
MappedObjectType type,
MappedObjectId id);
~MappedConnectableObject();
void setConnections(ConnectionDirection dir,
MappedObjectValueList conns);
void addConnection(ConnectionDirection dir, MappedObjectId id);
void removeConnection(ConnectionDirection dir, MappedObjectId id);
MappedObjectValueList getConnections (ConnectionDirection dir);
protected:
// Which audio connections we have
//
MappedObjectValueList m_connectionsIn;
MappedObjectValueList m_connectionsOut;
};
// Audio fader
//
class MappedAudioFader : public MappedConnectableObject
{
public:
static const MappedObjectProperty Channels;
// properties
//
static const MappedObjectProperty FaderLevel;
static const MappedObjectProperty FaderRecordLevel;
static const MappedObjectProperty Pan;
static const MappedObjectProperty InputChannel;
MappedAudioFader(MappedObject *parent,
MappedObjectId id,
MappedObjectValue channels = 2); // stereo default
~MappedAudioFader();
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
InstrumentId getInstrument() const { return m_instrumentId; }
protected:
MappedObjectValue m_level;
MappedObjectValue m_recordLevel;
InstrumentId m_instrumentId;
// Stereo pan (-1.0 to +1.0)
//
MappedObjectValue m_pan;
// How many channels we carry
//
MappedObjectValue m_channels;
// If we have an input, which channel we take from it (if we are
// a mono fader at least)
//
MappedObjectValue m_inputChannel;
};
class MappedAudioBuss : public MappedConnectableObject
{
public:
// A buss is much simpler than an instrument fader. It's always
// stereo, and just has a level and pan associated with it. The
// level may be a submaster fader level or a send mix level, it
// depends on what the purpose of the buss is. At the moment we
// just have a 1-1 relationship between busses and submasters, and
// no send channels.
static const MappedObjectProperty BussId;
static const MappedObjectProperty Pan;
static const MappedObjectProperty Level;
MappedAudioBuss(MappedObject *parent,
MappedObjectId id);
~MappedAudioBuss();
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
MappedObjectValue getBussId() { return m_bussId; }
// super-convenience function: retrieve the ids of the instruments
// connected to this buss
std::vector<InstrumentId> getInstruments();
protected:
int m_bussId;
MappedObjectValue m_level;
MappedObjectValue m_pan;
};
class MappedAudioInput : public MappedConnectableObject
{
public:
// An input is simpler still -- no properties at all, apart from
// the input number, otherwise just the connections
static const MappedObjectProperty InputNumber;
MappedAudioInput(MappedObject *parent,
MappedObjectId id);
~MappedAudioInput();
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
MappedObjectValue getInputNumber() { return m_inputNumber; }
protected:
MappedObjectValue m_inputNumber;
};
class MappedPluginSlot : public MappedObject
{
public:
static const MappedObjectProperty Identifier;
static const MappedObjectProperty PluginName;
static const MappedObjectProperty Label;
static const MappedObjectProperty Author;
static const MappedObjectProperty Copyright;
static const MappedObjectProperty Category;
static const MappedObjectProperty PortCount;
static const MappedObjectProperty Ports;
static const MappedObjectProperty Program;
static const MappedObjectProperty Programs; // list property
static const MappedObjectProperty Instrument;
static const MappedObjectProperty Position;
static const MappedObjectProperty Bypassed;
static const MappedObjectProperty Configuration; // list property
MappedPluginSlot(MappedObject *parent, MappedObjectId id);
~MappedPluginSlot();
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual bool getProperty(const MappedObjectProperty &property,
TQString &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
virtual void setProperty(const MappedObjectProperty &property,
TQString value);
virtual void setPropertyList(const MappedObjectProperty &,
const MappedObjectPropertyList &);
void setPort(unsigned long portNumber, float value);
float getPort(unsigned long portNumber);
InstrumentId getInstrument() const { return m_instrument; }
int getPosition() const { return m_position; }
TQString getProgram(int bank, int program);
unsigned long getProgram(TQString name); // rv is bank << 16 + program
protected:
TQString m_identifier;
TQString m_name;
TQString m_label;
TQString m_author;
TQString m_copyright;
TQString m_category;
unsigned long m_portCount;
InstrumentId m_instrument;
int m_position;
bool m_bypassed;
std::map<TQString, TQString> m_configuration;
};
class MappedPluginPort : public MappedObject
{
public:
static const MappedObjectProperty PortNumber;
static const MappedObjectProperty Name;
static const MappedObjectProperty Minimum;
static const MappedObjectProperty Maximum;
static const MappedObjectProperty Default;
static const MappedObjectProperty DisplayHint;
static const MappedObjectProperty Value;
MappedPluginPort(MappedObject *parent, MappedObjectId id);
~MappedPluginPort();
virtual MappedObjectPropertyList getPropertyList(
const MappedObjectProperty &property);
virtual bool getProperty(const MappedObjectProperty &property,
MappedObjectValue &value);
virtual bool getProperty(const MappedObjectProperty &property,
TQString &value);
virtual void setProperty(const MappedObjectProperty &property,
MappedObjectValue value);
virtual void setProperty(const MappedObjectProperty &property,
TQString value);
void setValue(MappedObjectValue value);
MappedObjectValue getValue() const;
int getPortNumber() const { return m_portNumber; }
protected:
int m_portNumber;
TQString m_name;
MappedObjectValue m_minimum;
MappedObjectValue m_maximum;
MappedObjectValue m_default;
PluginPort::PortDisplayHint m_displayHint;
};
}
#endif // _MAPPEDSTUDIO_H_
|