[r12861]: branches / logical-instruments / rosegarden / src / base / Studio.h Maximize Restore History

Download this file

Studio.h    216 lines (160 with data), 6.1 kB

  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
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A sequencer and musical notation editor.
Copyright 2000-2011 the Rosegarden development team.
See the AUTHORS file for more details.
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 <string>
#include <vector>
#include "XmlExportable.h"
#include "Instrument.h"
#include "Device.h"
#include "MidiProgram.h"
#include "MidiMetronome.h"
#include "ControlParameter.h"
#include <QCoreApplication>
// The Studio is where Midi and Audio devices live. We can query
// them for a list of Instruments, connect them together or to
// effects units (eventually) and generally do real studio-type
// stuff to them.
//
//
#ifndef _STUDIO_H_
#define _STUDIO_H_
namespace Rosegarden
{
typedef std::vector<Instrument *> InstrumentList;
typedef std::vector<Device*> DeviceList;
typedef std::vector<Buss *> BussList;
typedef std::vector<RecordIn *> RecordInList;
typedef std::vector<Device*>::iterator DeviceListIterator;
typedef std::vector<Device*>::const_iterator DeviceListConstIterator;
class MidiDevice;
class Segment;
class Track;
class Studio : public XmlExportable
{
Q_DECLARE_TR_FUNCTIONS(Rosegarden::Studio)
public:
Studio();
~Studio();
private:
Studio(const Studio &);
Studio& operator=(const Studio &);
public:
void addDevice(const std::string &name,
DeviceId id,
InstrumentId baseInstrumentId,
Device::DeviceType type);
void removeDevice(DeviceId id);
void resyncDeviceConnections(void);
DeviceId getSpareDeviceId(InstrumentId &baseInstrumentId);
// Return the combined instrument list from all devices
//
InstrumentList getAllInstruments();
InstrumentList getPresentationInstruments();
// Return an Instrument
Instrument* getInstrumentById(InstrumentId id);
Instrument* getInstrumentFromList(int index);
// Convenience functions
Instrument *getInstrumentFor(Segment *);
Instrument *getInstrumentFor(Track *);
// Return a Buss
BussList getBusses();
Buss *getBussById(BussId id);
void addBuss(Buss *buss);
// Return an Instrument or a Buss
PluginContainer *getContainerById(InstrumentId id);
RecordInList getRecordIns() { return m_recordIns; }
RecordIn *getRecordIn(int number);
void addRecordIn(RecordIn *ri) { m_recordIns.push_back(ri); }
// A clever method to best guess MIDI file program mappings
// to available MIDI channels across all MidiDevices.
//
// Set the percussion flag if it's a percussion channel (mapped
// channel) we're after.
//
Instrument* assignMidiProgramToInstrument(MidiByte program,
bool percussion) {
return assignMidiProgramToInstrument(program, -1, -1, percussion);
}
// Same again, but with bank select
//
Instrument* assignMidiProgramToInstrument(MidiByte program,
int msb, int lsb,
bool percussion);
// Get a suitable name for a Segment belonging to this instrument.
// Takes into account ProgramChanges.
//
std::string getSegmentName(InstrumentId id);
// Clear down all the ProgramChange flags in all MIDI Instruments
//
void unassignAllInstruments();
// Clear down all MIDI banks and programs on all MidiDevices
// prior to reloading. The Instruments and Devices are generated
// at the Sequencer - the Banks and Programs are loaded from the
// RG4 file.
//
void clearMidiBanksAndPrograms();
void clearBusses();
void clearRecordIns();
// Clear down
void clear();
// Get a MIDI metronome from a given device
//
const MidiMetronome* getMetronomeFromDevice(DeviceId id);
// Return the device list
//
DeviceList* getDevices() { return &m_devices; }
// Const iterators
//
DeviceListConstIterator begin() const { return m_devices.begin(); }
DeviceListConstIterator end() const { return m_devices.end(); }
// Get a device by ID
//
Device *getDevice(DeviceId id);
// Get device of audio type (there is only one)
//
Device *getAudioDevice();
// Get device of soft synth type (there is only one)
//
Device *getSoftSynthDevice();
bool haveMidiDevices() const;
// Export as XML string
//
virtual std::string toXmlString();
// Export a subset of devices as XML string. If devices is empty,
// exports all devices just as the above method does.
//
virtual std::string toXmlString(const std::vector<DeviceId> &devices);
// Get an audio preview Instrument
//
InstrumentId getAudioPreviewInstrument();
// MIDI filtering into and thru Rosegarden
//
void setMIDIThruFilter(MidiFilter filter) { m_midiThruFilter = filter; }
MidiFilter getMIDIThruFilter() const { return m_midiThruFilter; }
void setMIDIRecordFilter(MidiFilter filter) { m_midiRecordFilter = filter; }
MidiFilter getMIDIRecordFilter() const { return m_midiRecordFilter; }
void setMixerDisplayOptions(unsigned int options) { m_mixerDisplayOptions = options; }
unsigned int getMixerDisplayOptions() const { return m_mixerDisplayOptions; }
DeviceId getMetronomeDevice() const { return m_metronomeDevice; }
void setMetronomeDevice(DeviceId device) { m_metronomeDevice = device; }
private:
DeviceList m_devices;
BussList m_busses;
RecordInList m_recordIns;
int m_audioInputs; // stereo pairs
MidiFilter m_midiThruFilter;
MidiFilter m_midiRecordFilter;
unsigned int m_mixerDisplayOptions;
DeviceId m_metronomeDevice;
};
}
#endif // _STUDIO_H_