Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r12985]: branches / edit_controllers / rosegarden / src / gui / studio / StudioControl.cpp Maximize Restore History

Download this file

StudioControl.cpp    244 lines (204 with data), 6.9 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
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
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
Copyright 2000-2012 the Rosegarden development team.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for 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 "StudioControl.h"
#include "sound/Midi.h"
#include "misc/Debug.h"
#include "base/MidiProgram.h"
#include "base/Profiler.h"
#include "base/RealTime.h"
#include "gui/seqmanager/ChannelManager.h"
#include "sequencer/RosegardenSequencer.h"
#include "sound/MappedCommon.h"
#include "sound/MappedEventInserter.h"
#include "sound/MappedEventList.h"
#include "sound/MappedEvent.h"
#include "sound/MappedInstrument.h"
#include "sound/MappedStudio.h"
#include "sound/ImmediateNote.h"
#include <QByteArray>
#include <QDataStream>
#include <QString>
namespace Rosegarden
{
ImmediateNote *
StudioControl::
getFiller(void)
{
m_instanceMutex.lock();
if (!m_immediateNoteFiller)
{ m_immediateNoteFiller = new ImmediateNote(); }
m_instanceMutex.unlock();
return m_immediateNoteFiller;
}
ImmediateNote *
StudioControl::
m_immediateNoteFiller = 0;
QMutex
StudioControl::m_instanceMutex;
MappedObjectId
StudioControl::createStudioObject(MappedObject::MappedObjectType type)
{
return RosegardenSequencer::getInstance()->createMappedObject(type);
}
bool
StudioControl::destroyStudioObject(MappedObjectId id)
{
return RosegardenSequencer::getInstance()->destroyMappedObject(id);
}
MappedObjectPropertyList
StudioControl::getStudioObjectProperty(MappedObjectId id,
const MappedObjectProperty &property)
{
return RosegardenSequencer::getInstance()->getPropertyList(id, property);
}
bool
StudioControl::setStudioObjectProperty(MappedObjectId id,
const MappedObjectProperty &property,
MappedObjectValue value)
{
RosegardenSequencer::getInstance()->setMappedProperty(id, property, value);
return true;
}
bool
StudioControl::setStudioObjectProperties(const MappedObjectIdList &ids,
const MappedObjectPropertyList &properties,
const MappedObjectValueList &values)
{
RosegardenSequencer::getInstance()->setMappedProperties
(ids, properties, values);
return true;
}
bool
StudioControl::setStudioObjectProperty(MappedObjectId id,
const MappedObjectProperty &property,
const QString &value)
{
RosegardenSequencer::getInstance()->setMappedProperty(id, property, value);
return true;
}
QString
StudioControl::setStudioObjectPropertyList(MappedObjectId id,
const MappedObjectProperty &property,
const MappedObjectPropertyList &values)
{
QString error = RosegardenSequencer::getInstance()->setMappedPropertyList(id, property, values);
return error;
}
MappedObjectId
StudioControl::getStudioObjectByType(MappedObject::MappedObjectType type)
{
return RosegardenSequencer::getInstance()->getMappedObjectId(type);
}
void
StudioControl::setStudioPluginPort(MappedObjectId pluginId,
unsigned long portId,
MappedObjectValue value)
{
RosegardenSequencer::getInstance()->setMappedPort(pluginId, portId, value);
}
MappedObjectValue
StudioControl::getStudioPluginPort(MappedObjectId pluginId,
unsigned long portId)
{
return RosegardenSequencer::getInstance()->getMappedPort(pluginId, portId);
}
MappedObjectPropertyList
StudioControl::getPluginInformation()
{
return RosegardenSequencer::getInstance()->getPluginInformation();
}
QString
StudioControl::getPluginProgram(MappedObjectId id, int bank, int program)
{
return RosegardenSequencer::getInstance()->getPluginProgram(id, bank, program);
}
unsigned long
StudioControl::getPluginProgram(MappedObjectId id, QString name)
{
return RosegardenSequencer::getInstance()->getPluginProgram(id, name);
}
void
StudioControl::connectStudioObjects(MappedObjectId id1,
MappedObjectId id2)
{
RosegardenSequencer::getInstance()->connectMappedObjects(id1, id2);
}
void
StudioControl::disconnectStudioObjects(MappedObjectId id1,
MappedObjectId id2)
{
RosegardenSequencer::getInstance()->disconnectMappedObjects(id1, id2);
}
void
StudioControl::disconnectStudioObject(MappedObjectId id)
{
RosegardenSequencer::getInstance()->disconnectMappedObject(id);
}
void
StudioControl::sendMappedEvent(const MappedEvent &mE)
{
RosegardenSequencer::getInstance()->processMappedEvent(mE);
}
void
StudioControl::sendMappedEventList(const MappedEventList &mC)
{
if (mC.size() == 0)
return ;
MappedEventList::const_iterator it = mC.begin();
for (; it != mC.end(); ++it) {
RosegardenSequencer::getInstance()->processMappedEvent(*it);
}
}
void
StudioControl::sendMappedInstrument(const MappedInstrument &mI)
{
RosegardenSequencer::getInstance()->setMappedInstrument(mI.getType(),
mI.getId());
}
void
StudioControl::sendQuarterNoteLength(const RealTime &length)
{
RosegardenSequencer::getInstance()->setQuarterNoteLength(length);
}
void
StudioControl::
playPreviewNote(Instrument *instrument, int pitch,
int velocity, int nsecs, bool oneshot)
{
MappedEventList mC;
ImmediateNote * filler = getFiller();
filler->fillWithNote(mC, instrument, pitch, velocity, nsecs, oneshot);
sendMappedEventList(mC);
}
// Set up a channel for output. This is used for fix channel
// instruments and also to set up MIDI thru channels.
void
StudioControl::
sendChannelSetup(Instrument *instrument, int channel)
{
MappedEventList mC;
MappedEventInserter inserter(mC);
ChannelManager::MapperFunctionalitySimple functionality;
// Acquire it from ChannelManager. Passing -1 for trackId which
// is unused here.
ChannelManager::sendProgramForInstrument(channel, instrument,
inserter,
RealTime::zeroTime, -1);
ChannelManager::setControllers(channel, instrument,
inserter, RealTime::zeroTime,
RealTime::zeroTime,
&functionality, -1);
sendMappedEventList(mC);
}
}