sl@0
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <mmf/common/midistandardcustomcommands.h>
|
sl@0
|
17 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
18 |
#include <mmf/common/mmfmidiconfig.h>
|
sl@0
|
19 |
#include <mmf/common/midieventreceiver.h>
|
sl@0
|
20 |
#endif
|
sl@0
|
21 |
|
sl@0
|
22 |
/**
|
sl@0
|
23 |
Constructor.
|
sl@0
|
24 |
@param aController
|
sl@0
|
25 |
The client side controller object to be used by this custom command interface.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
EXPORT_C RMidiControllerCustomCommands::RMidiControllerCustomCommands(RMMFController& aController) :
|
sl@0
|
28 |
RMMFCustomCommandsBase(aController, KUidInterfaceMidi)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
Change the position of the currently playing MIDI resource to the given position.
|
sl@0
|
34 |
May be called whenever a MIDI resource is open.
|
sl@0
|
35 |
|
sl@0
|
36 |
@param aMicroBeats
|
sl@0
|
37 |
Metrical position to move to. Clamped to (0, DurationMicroBeats()).
|
sl@0
|
38 |
@return One of the system-wide error codes.
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
EXPORT_C TInt RMidiControllerCustomCommands::SetPositionMicroBeats(TInt64 aMicroBeats) const
|
sl@0
|
41 |
{
|
sl@0
|
42 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
43 |
configPackage().iPositionMicroBeats = aMicroBeats;
|
sl@0
|
44 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
45 |
EMMFMidiControllerSetPositionMicroBeats,
|
sl@0
|
46 |
configPackage,
|
sl@0
|
47 |
KNullDesC8);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
Gets the current metrical position of the MIDI resource being played.
|
sl@0
|
52 |
|
sl@0
|
53 |
@param aMicroBeats
|
sl@0
|
54 |
(BPM*1000000) relative to the start of the resource.
|
sl@0
|
55 |
@return One of the system-wide error codes.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
EXPORT_C TInt RMidiControllerCustomCommands::PositionMicroBeats(TInt64& aMicroBeats) const
|
sl@0
|
58 |
{
|
sl@0
|
59 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
60 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
61 |
EMMFMidiControllerPositionMicroBeats,
|
sl@0
|
62 |
KNullDesC8,
|
sl@0
|
63 |
KNullDesC8,
|
sl@0
|
64 |
configPackage);
|
sl@0
|
65 |
if (!error)
|
sl@0
|
66 |
aMicroBeats = configPackage().iPositionMicroBeats;
|
sl@0
|
67 |
return error;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Synchronous function to play a single note.
|
sl@0
|
72 |
Multiple calls to this function will be accommodated as far as the MIDI engine can
|
sl@0
|
73 |
manage. The same functionality could be implemented using the SendMessage function.
|
sl@0
|
74 |
|
sl@0
|
75 |
@param aChannel
|
sl@0
|
76 |
Logical channel to play note on. 0 <= aChannel <= 15.
|
sl@0
|
77 |
@param aNote
|
sl@0
|
78 |
Note to play. 0 <= aNote <= 127
|
sl@0
|
79 |
@param aDuration
|
sl@0
|
80 |
Length of time to play note for.
|
sl@0
|
81 |
@param aNoteOnVelocity
|
sl@0
|
82 |
Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
|
sl@0
|
83 |
@param aNoteOffVelocity
|
sl@0
|
84 |
Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
|
sl@0
|
85 |
@return One of the system-wide error codes.
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
90 |
configPackage().iChannel = aChannel;
|
sl@0
|
91 |
configPackage().iNote = aNote;
|
sl@0
|
92 |
configPackage().iDurationMicroSeconds = aDuration;
|
sl@0
|
93 |
configPackage().iNoteOnVelocity = aNoteOnVelocity;
|
sl@0
|
94 |
configPackage().iNoteOffVelocity = aNoteOffVelocity;
|
sl@0
|
95 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
96 |
EMMFMidiControllerPlayNote,
|
sl@0
|
97 |
configPackage,
|
sl@0
|
98 |
KNullDesC8);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
/**
|
sl@0
|
102 |
Synchronous function to play a single note at a specified time.
|
sl@0
|
103 |
Multiple calls to this function will be accommodated as far as the MIDI engine can
|
sl@0
|
104 |
manage. The same functionality could be implemented using the SendMessage function.
|
sl@0
|
105 |
|
sl@0
|
106 |
@param aChannel
|
sl@0
|
107 |
Logical channel to play note on. 0 <= aChannel <= 15.
|
sl@0
|
108 |
@param aNote
|
sl@0
|
109 |
Note to play. 0 <= aNote <= 127
|
sl@0
|
110 |
@param aStartTime
|
sl@0
|
111 |
Specifies the time at which to start playing the note, relative
|
sl@0
|
112 |
to the MIDI resource playing time or the time elapsed since Play()
|
sl@0
|
113 |
was called if no resource is present.
|
sl@0
|
114 |
@param aDuration
|
sl@0
|
115 |
Length of time to play note for.
|
sl@0
|
116 |
@param aNoteOnVelocity
|
sl@0
|
117 |
Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
|
sl@0
|
118 |
@param aNoteOffVelocity
|
sl@0
|
119 |
Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
|
sl@0
|
120 |
@return One of the system-wide error codes.
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
125 |
configPackage().iChannel = aChannel;
|
sl@0
|
126 |
configPackage().iNote = aNote;
|
sl@0
|
127 |
configPackage().iStartTime = aStartTime;
|
sl@0
|
128 |
configPackage().iDurationMicroSeconds = aDuration;
|
sl@0
|
129 |
configPackage().iNoteOnVelocity = aNoteOnVelocity;
|
sl@0
|
130 |
configPackage().iNoteOffVelocity = aNoteOffVelocity;
|
sl@0
|
131 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
132 |
EMMFMidiControllerPlayNoteWithStartTime,
|
sl@0
|
133 |
configPackage,
|
sl@0
|
134 |
KNullDesC8);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
Stops the playback of all notes on the given channel, by means of an All Notes Off MIDI message.
|
sl@0
|
139 |
|
sl@0
|
140 |
@param aChannel
|
sl@0
|
141 |
Logical channel to stop notes on. 0 <= aChannel <= 15.
|
sl@0
|
142 |
@return One of the system-wide error codes.
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
EXPORT_C TInt RMidiControllerCustomCommands::StopNotes(TInt aChannel)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
147 |
configPackage().iChannel = aChannel;
|
sl@0
|
148 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
149 |
EMMFMidiControllerStopNotes,
|
sl@0
|
150 |
configPackage,
|
sl@0
|
151 |
KNullDesC8);
|
sl@0
|
152 |
}
|
sl@0
|
153 |
|
sl@0
|
154 |
/**
|
sl@0
|
155 |
Synchronous function to commence playback of a note. Multiple calls to this
|
sl@0
|
156 |
function will be accommodated as far as the MIDI engine can manage.
|
sl@0
|
157 |
|
sl@0
|
158 |
@param aChannel
|
sl@0
|
159 |
Logical channel to play note on. 0 <= aChannel <= 15.
|
sl@0
|
160 |
@param aNote
|
sl@0
|
161 |
Note to play. 0 <= aNote <= 127.
|
sl@0
|
162 |
@param aVelocity
|
sl@0
|
163 |
Velocity with which to start the note. The legal integer range is
|
sl@0
|
164 |
0 <= aVelocity <= 127, but the value zero actually causes the message
|
sl@0
|
165 |
to be interpreted as a Note Off message instead of a Note On.
|
sl@0
|
166 |
@return One of the system-wide error codes.
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
EXPORT_C TInt RMidiControllerCustomCommands::NoteOn(TInt aChannel, TInt aNote, TInt aVelocity)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
171 |
configPackage().iChannel = aChannel;
|
sl@0
|
172 |
configPackage().iNote = aNote;
|
sl@0
|
173 |
configPackage().iNoteOnVelocity = aVelocity;
|
sl@0
|
174 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
175 |
EMMFMidiControllerNoteOn,
|
sl@0
|
176 |
configPackage,
|
sl@0
|
177 |
KNullDesC8);
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
/**
|
sl@0
|
181 |
Synchronous function to terminate playback of a note. If no corresponding note
|
sl@0
|
182 |
is found then no error is raised.
|
sl@0
|
183 |
|
sl@0
|
184 |
@param aChannel
|
sl@0
|
185 |
Logical channel on which the note is playing. 0 <= aChannel <= 15.
|
sl@0
|
186 |
@param aNote
|
sl@0
|
187 |
Note to terminate. 0 <= aNote <= 127.
|
sl@0
|
188 |
@param aVelocity
|
sl@0
|
189 |
Velocity with which to stop the note. 0 <= aVelocity <= 127. There is no
|
sl@0
|
190 |
standard behaviour corresponding with note off velocity.
|
sl@0
|
191 |
@return One of the system-wide error codes.
|
sl@0
|
192 |
*/
|
sl@0
|
193 |
EXPORT_C TInt RMidiControllerCustomCommands::NoteOff(TInt aChannel,TInt aNote,TInt aVelocity)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
196 |
configPackage().iChannel = aChannel;
|
sl@0
|
197 |
configPackage().iNote = aNote;
|
sl@0
|
198 |
configPackage().iNoteOffVelocity = aVelocity;
|
sl@0
|
199 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
200 |
EMMFMidiControllerNoteOff,
|
sl@0
|
201 |
configPackage,
|
sl@0
|
202 |
KNullDesC8);
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
/**
|
sl@0
|
206 |
Gets the current playback rate factor of the currently open MIDI resource.
|
sl@0
|
207 |
The playback rate is independent from tempo, i.e., it can be used to give
|
sl@0
|
208 |
an overall speed factor for playback.
|
sl@0
|
209 |
|
sl@0
|
210 |
@param aPlayBackRate
|
sl@0
|
211 |
Current playback rate in percent times 1000, i.e., 100000 means original
|
sl@0
|
212 |
playback speed, 200000 means double speed, and 50000 means half speed playback.
|
sl@0
|
213 |
@return One of the system-wide error codes.
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
EXPORT_C TInt RMidiControllerCustomCommands::PlaybackRate(TInt& aPlayBackRate) const
|
sl@0
|
216 |
{
|
sl@0
|
217 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
218 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
219 |
EMMFMidiControllerPlaybackRate,
|
sl@0
|
220 |
KNullDesC8,
|
sl@0
|
221 |
KNullDesC8,
|
sl@0
|
222 |
configPackage);
|
sl@0
|
223 |
if (!error)
|
sl@0
|
224 |
aPlayBackRate = configPackage().iPlayBackRate;
|
sl@0
|
225 |
return error;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
/**
|
sl@0
|
229 |
Sets the playback rate for the playback of the current MIDI resource.
|
sl@0
|
230 |
The playback rate is independent from tempo, i.e., it can be used to give
|
sl@0
|
231 |
an overall speed factor for playback. May be called whether playback
|
sl@0
|
232 |
is in progress or not.
|
sl@0
|
233 |
|
sl@0
|
234 |
@param aPlayBackRate
|
sl@0
|
235 |
Playback rate in percent times 1000, i.e., 100000 means original
|
sl@0
|
236 |
playback speed, 200000 means double speed, and 50000 means half speed playback.
|
sl@0
|
237 |
@return One of the system-wide error codes.
|
sl@0
|
238 |
*/
|
sl@0
|
239 |
EXPORT_C TInt RMidiControllerCustomCommands::SetPlaybackRate(TInt aPlayBackRate)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
242 |
configPackage().iPlayBackRate = aPlayBackRate;
|
sl@0
|
243 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
244 |
EMMFMidiControllerSetPlaybackRate,
|
sl@0
|
245 |
configPackage,
|
sl@0
|
246 |
KNullDesC8);
|
sl@0
|
247 |
}
|
sl@0
|
248 |
|
sl@0
|
249 |
/**
|
sl@0
|
250 |
Gets the maximum playback rate in milli-percentage from the MIDI engine.
|
sl@0
|
251 |
@see SetPlaybackRate() for milli-percentage details.
|
sl@0
|
252 |
|
sl@0
|
253 |
@param aMaxRate
|
sl@0
|
254 |
Playback rate supported by MIDI player.
|
sl@0
|
255 |
@return One of the system-wide error codes.
|
sl@0
|
256 |
*/
|
sl@0
|
257 |
EXPORT_C TInt RMidiControllerCustomCommands::MaxPlaybackRate(TInt& aMaxRate) const
|
sl@0
|
258 |
{
|
sl@0
|
259 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
260 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
261 |
EMMFMidiControllerMaxPlaybackRate,
|
sl@0
|
262 |
KNullDesC8,
|
sl@0
|
263 |
KNullDesC8,
|
sl@0
|
264 |
configPackage);
|
sl@0
|
265 |
if (!error)
|
sl@0
|
266 |
aMaxRate = configPackage().iPlayBackMaxRate;
|
sl@0
|
267 |
return error;
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
/**
|
sl@0
|
271 |
Gets the minimum playback rate in milli-percentage from the MIDI engine.
|
sl@0
|
272 |
@see SetPlaybackRate() for milli-percentage details.
|
sl@0
|
273 |
|
sl@0
|
274 |
@param aMinRate
|
sl@0
|
275 |
Minimum playback rate supported by MIDI player.
|
sl@0
|
276 |
@return One of the system-wide error codes.
|
sl@0
|
277 |
*/
|
sl@0
|
278 |
EXPORT_C TInt RMidiControllerCustomCommands::MinPlaybackRate(TInt& aMinRate) const
|
sl@0
|
279 |
{
|
sl@0
|
280 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
281 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
282 |
EMMFMidiControllerMinPlaybackRate,
|
sl@0
|
283 |
KNullDesC8,
|
sl@0
|
284 |
KNullDesC8,
|
sl@0
|
285 |
configPackage);
|
sl@0
|
286 |
if (!error)
|
sl@0
|
287 |
aMinRate = configPackage().iPlayBackMinRate;
|
sl@0
|
288 |
return error;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
/**
|
sl@0
|
292 |
Gets the current tempo of the currently open MIDI resource. The tempo is independent
|
sl@0
|
293 |
from the playback rate, i.e., the resulting playback speed will be affected by both.
|
sl@0
|
294 |
|
sl@0
|
295 |
@param aMicroBeatsPerMinute
|
sl@0
|
296 |
Tempo at the current position of the currently open resource in microbeats
|
sl@0
|
297 |
per minute, i.e. BPM * 1000000. Filled in by the controller framework.
|
sl@0
|
298 |
@return One of the system-wide error codes.
|
sl@0
|
299 |
*/
|
sl@0
|
300 |
EXPORT_C TInt RMidiControllerCustomCommands::TempoMicroBeatsPerMinute(TInt& aMicroBeatsPerMinute) const
|
sl@0
|
301 |
{
|
sl@0
|
302 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
303 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
304 |
EMMFMidiControllerTempo,
|
sl@0
|
305 |
KNullDesC8,
|
sl@0
|
306 |
KNullDesC8,
|
sl@0
|
307 |
configPackage);
|
sl@0
|
308 |
if (!error)
|
sl@0
|
309 |
aMicroBeatsPerMinute = configPackage().iTempo;
|
sl@0
|
310 |
return error;
|
sl@0
|
311 |
}
|
sl@0
|
312 |
|
sl@0
|
313 |
/**
|
sl@0
|
314 |
Sets the tempo at which the current MIDI resource should be played. May be
|
sl@0
|
315 |
called whether playback is in progress or not. The tempo is independent
|
sl@0
|
316 |
from the playback rate, i.e., the resulting playback speed will be affected by both.
|
sl@0
|
317 |
|
sl@0
|
318 |
@param aMicroBeatsPerMinute
|
sl@0
|
319 |
Tempo in microbeats per minute (BPM*1000000) to set.
|
sl@0
|
320 |
@return One of the system-wide error codes.
|
sl@0
|
321 |
*/
|
sl@0
|
322 |
EXPORT_C TInt RMidiControllerCustomCommands::SetTempo(TInt aMicroBeatsPerMinute)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
325 |
configPackage().iTempo = aMicroBeatsPerMinute;
|
sl@0
|
326 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
327 |
EMMFMidiControllerSetTempo,
|
sl@0
|
328 |
configPackage,
|
sl@0
|
329 |
KNullDesC8);
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
/**
|
sl@0
|
333 |
Gets the pitch shift in use for the currently open MIDI resource.
|
sl@0
|
334 |
|
sl@0
|
335 |
@param aPitch
|
sl@0
|
336 |
Shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
|
sl@0
|
337 |
@return One of the system-wide error codes.
|
sl@0
|
338 |
*/
|
sl@0
|
339 |
EXPORT_C TInt RMidiControllerCustomCommands::PitchTranspositionCents(TInt& aPitch) const
|
sl@0
|
340 |
{
|
sl@0
|
341 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
342 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
343 |
EMMFMidiControllerPitch,
|
sl@0
|
344 |
KNullDesC8,
|
sl@0
|
345 |
KNullDesC8,
|
sl@0
|
346 |
configPackage);
|
sl@0
|
347 |
if (!error)
|
sl@0
|
348 |
aPitch = configPackage().iPitch;
|
sl@0
|
349 |
return error;
|
sl@0
|
350 |
}
|
sl@0
|
351 |
|
sl@0
|
352 |
/**
|
sl@0
|
353 |
Sets the pitch shift to apply to the currently open MIDI resource.
|
sl@0
|
354 |
May be called during playback.
|
sl@0
|
355 |
|
sl@0
|
356 |
@param aCents
|
sl@0
|
357 |
Pitch shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
|
sl@0
|
358 |
@param aCentsApplied
|
sl@0
|
359 |
Actual pitch shift applied - may differ from the requested value due to
|
sl@0
|
360 |
limitations of the MIDI engine.
|
sl@0
|
361 |
@return One of the system-wide error codes.
|
sl@0
|
362 |
*/
|
sl@0
|
363 |
EXPORT_C TInt RMidiControllerCustomCommands::SetPitchTransposition(TInt aCents, TInt& aCentsApplied)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
366 |
configPackage().iPitch = aCents;
|
sl@0
|
367 |
TInt err = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
368 |
EMMFMidiControllerSetPitch,
|
sl@0
|
369 |
configPackage,
|
sl@0
|
370 |
KNullDesC8,
|
sl@0
|
371 |
configPackage);
|
sl@0
|
372 |
aCentsApplied = configPackage().iPitch;
|
sl@0
|
373 |
return err;
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
/**
|
sl@0
|
377 |
Gets the length of the currently open MIDI resource in micro-beats.
|
sl@0
|
378 |
|
sl@0
|
379 |
@param aDuration
|
sl@0
|
380 |
Duration in microbeats (beats * 1000000).
|
sl@0
|
381 |
@return One of the system-wide error codes.
|
sl@0
|
382 |
*/
|
sl@0
|
383 |
EXPORT_C TInt RMidiControllerCustomCommands::DurationMicroBeats(TInt64& aDuration) const
|
sl@0
|
384 |
{
|
sl@0
|
385 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
386 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
387 |
EMMFMidiControllerDurationMicroBeats,
|
sl@0
|
388 |
KNullDesC8,
|
sl@0
|
389 |
KNullDesC8,
|
sl@0
|
390 |
configPackage);
|
sl@0
|
391 |
if (!error)
|
sl@0
|
392 |
aDuration = configPackage().iDurationMicroBeats;
|
sl@0
|
393 |
return error;
|
sl@0
|
394 |
}
|
sl@0
|
395 |
|
sl@0
|
396 |
/**
|
sl@0
|
397 |
Gets the number of tracks present in the currently open MIDI resource.
|
sl@0
|
398 |
|
sl@0
|
399 |
@param aTracks
|
sl@0
|
400 |
Number of tracks.
|
sl@0
|
401 |
@return One of the system-wide error codes.
|
sl@0
|
402 |
*/
|
sl@0
|
403 |
EXPORT_C TInt RMidiControllerCustomCommands::NumTracks(TInt& aTracks) const
|
sl@0
|
404 |
{
|
sl@0
|
405 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
406 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
407 |
EMMFMidiControllerNumTracks,
|
sl@0
|
408 |
KNullDesC8,
|
sl@0
|
409 |
KNullDesC8,
|
sl@0
|
410 |
configPackage);
|
sl@0
|
411 |
if (!error)
|
sl@0
|
412 |
aTracks = configPackage().iNumTracks;
|
sl@0
|
413 |
return error;
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
/**
|
sl@0
|
417 |
Mutes or unmutes a particular track.
|
sl@0
|
418 |
|
sl@0
|
419 |
@param aTrack
|
sl@0
|
420 |
Index of the track to mute - 0 <= aTrack < NumTracksL().
|
sl@0
|
421 |
@param aMuted
|
sl@0
|
422 |
ETrue to mute the track, EFalse to unmute it.
|
sl@0
|
423 |
@return One of the system-wide error codes.
|
sl@0
|
424 |
*/
|
sl@0
|
425 |
EXPORT_C TInt RMidiControllerCustomCommands::SetTrackMute(TInt aTrack, TBool aMuted) const
|
sl@0
|
426 |
{
|
sl@0
|
427 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
428 |
configPackage().iTrack = aTrack;
|
sl@0
|
429 |
configPackage().iMuted = aMuted;
|
sl@0
|
430 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
431 |
EMMFMidiControllerSetTrackMute,
|
sl@0
|
432 |
configPackage,
|
sl@0
|
433 |
KNullDesC8);
|
sl@0
|
434 |
}
|
sl@0
|
435 |
|
sl@0
|
436 |
/**
|
sl@0
|
437 |
Gets the MIME type of the MIDI resource currently open.
|
sl@0
|
438 |
|
sl@0
|
439 |
@param aMimeType
|
sl@0
|
440 |
Descriptor containing the MIDI mime type.
|
sl@0
|
441 |
@return One of the system-wide error codes.
|
sl@0
|
442 |
*/
|
sl@0
|
443 |
EXPORT_C TInt RMidiControllerCustomCommands::MimeType(TDes8& aMimeType) const
|
sl@0
|
444 |
{
|
sl@0
|
445 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
446 |
EMMFMidiControllerMimeType,
|
sl@0
|
447 |
KNullDesC8,
|
sl@0
|
448 |
KNullDesC8,
|
sl@0
|
449 |
aMimeType);
|
sl@0
|
450 |
}
|
sl@0
|
451 |
|
sl@0
|
452 |
/**
|
sl@0
|
453 |
Sets the frequency at which MMIDIClientUtilityObserver::MmcuoSyncUpdateL() is called
|
sl@0
|
454 |
to allow other components to synchronise with playback of this MIDI resource.
|
sl@0
|
455 |
|
sl@0
|
456 |
@param aMicroSeconds
|
sl@0
|
457 |
Temporal interval to callback at. Used in preference to aMicroBeats if both are set.
|
sl@0
|
458 |
@param aMicroBeats
|
sl@0
|
459 |
Metrical interval to callback at. Set both parameters to zero to cancel.
|
sl@0
|
460 |
@return One of the system-wide error codes.
|
sl@0
|
461 |
*/
|
sl@0
|
462 |
EXPORT_C TInt RMidiControllerCustomCommands::SetSyncUpdateCallbackInterval(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
465 |
configPackage().iCallbackIntervalMicroSeconds = aMicroSeconds;
|
sl@0
|
466 |
configPackage().iCallbackIntervalMicroBeats = aMicroBeats;
|
sl@0
|
467 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
468 |
EMMFMidiControllerSetSyncUpdateCallbackInterval,
|
sl@0
|
469 |
configPackage,
|
sl@0
|
470 |
KNullDesC8);
|
sl@0
|
471 |
}
|
sl@0
|
472 |
|
sl@0
|
473 |
/**
|
sl@0
|
474 |
Sends a single MIDI message to the MIDI engine.
|
sl@0
|
475 |
|
sl@0
|
476 |
@param aMidiMessage
|
sl@0
|
477 |
Descriptor containing the MIDI message data. If there are several
|
sl@0
|
478 |
MIDI messages in the buffer, only the first one is processed.
|
sl@0
|
479 |
@param aBytes
|
sl@0
|
480 |
Number of bytes of the message buffer actually processed.
|
sl@0
|
481 |
@return One of the system-wide error codes.
|
sl@0
|
482 |
*/
|
sl@0
|
483 |
EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage, TInt& aBytes)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
486 |
configPackage().iMidiMessage = &aMidiMessage;
|
sl@0
|
487 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
488 |
EMMFMidiControllerSendMessage,
|
sl@0
|
489 |
configPackage,
|
sl@0
|
490 |
KNullDesC8,
|
sl@0
|
491 |
configPackage);
|
sl@0
|
492 |
if (!error)
|
sl@0
|
493 |
aBytes = configPackage().iBytesProcessed;
|
sl@0
|
494 |
return error;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
/**
|
sl@0
|
498 |
Sends a single MIDI message, with time stamp, to the MIDI engine.
|
sl@0
|
499 |
|
sl@0
|
500 |
@param aMidiMessage
|
sl@0
|
501 |
Descriptor containing the MIDI message data. If there are several
|
sl@0
|
502 |
MIDI messages in the buffer, only the first one is processed.
|
sl@0
|
503 |
@param aTime
|
sl@0
|
504 |
The time at which to execute the message, relative to the MIDI resource playing
|
sl@0
|
505 |
time or the time elapsed since Play() was called if no resource is present.
|
sl@0
|
506 |
@param aBytes
|
sl@0
|
507 |
Number of bytes of the message buffer actually processed.
|
sl@0
|
508 |
@return One of the system-wide error codes.
|
sl@0
|
509 |
*/
|
sl@0
|
510 |
EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes)
|
sl@0
|
511 |
{
|
sl@0
|
512 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
513 |
configPackage().iMidiMessage = &aMidiMessage;
|
sl@0
|
514 |
configPackage().iTimeStamp = aTime;
|
sl@0
|
515 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
516 |
EMMFMidiControllerSendMessageWithTimeStamp,
|
sl@0
|
517 |
configPackage,
|
sl@0
|
518 |
KNullDesC8,
|
sl@0
|
519 |
configPackage);
|
sl@0
|
520 |
if (!error)
|
sl@0
|
521 |
aBytes = configPackage().iBytesProcessed;
|
sl@0
|
522 |
return error;
|
sl@0
|
523 |
}
|
sl@0
|
524 |
|
sl@0
|
525 |
/**
|
sl@0
|
526 |
Sends a mip message to the MIDI engine. This is a convenience function,
|
sl@0
|
527 |
because the same functionality could be achieved with the SendMessage() function.
|
sl@0
|
528 |
|
sl@0
|
529 |
@param aEntry
|
sl@0
|
530 |
Array of logical {channel, MIP} value pairs to send, highest priority first.
|
sl@0
|
531 |
@return One of the system-wide error codes.
|
sl@0
|
532 |
*/
|
sl@0
|
533 |
EXPORT_C TInt RMidiControllerCustomCommands::SendMipMessage(const RArray<TMipMessageEntry>& aEntry)
|
sl@0
|
534 |
{
|
sl@0
|
535 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
536 |
TArray<TMipMessageEntry> mipMessage(aEntry.Array());
|
sl@0
|
537 |
configPackage().iMipMessage = &mipMessage;
|
sl@0
|
538 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
539 |
EMMFMidiControllerSendMipMessage,
|
sl@0
|
540 |
configPackage,
|
sl@0
|
541 |
KNullDesC8);
|
sl@0
|
542 |
}
|
sl@0
|
543 |
|
sl@0
|
544 |
/**
|
sl@0
|
545 |
Gets the number of standard or custom sound banks currently available.
|
sl@0
|
546 |
|
sl@0
|
547 |
@param aCustom
|
sl@0
|
548 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
549 |
@param aNumBanks
|
sl@0
|
550 |
Number of custom or standard sound banks available.
|
sl@0
|
551 |
@return One of the system-wide error codes.
|
sl@0
|
552 |
*/
|
sl@0
|
553 |
EXPORT_C TInt RMidiControllerCustomCommands::NumberOfBanks(TBool aCustom, TInt& aNumBanks) const
|
sl@0
|
554 |
{
|
sl@0
|
555 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
556 |
configPackage().iCustom = aCustom;
|
sl@0
|
557 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
558 |
EMMFMidiControllerNumberOfBanks,
|
sl@0
|
559 |
configPackage,
|
sl@0
|
560 |
KNullDesC8,
|
sl@0
|
561 |
configPackage);
|
sl@0
|
562 |
if (!error)
|
sl@0
|
563 |
aNumBanks = configPackage().iNumBanks;
|
sl@0
|
564 |
return error;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
|
sl@0
|
567 |
/**
|
sl@0
|
568 |
Gets the identifier of a sound bank. Bank identifier (aka bank number) is a
|
sl@0
|
569 |
14-bit value consisting of MIDI bank MSB and LSB values.
|
sl@0
|
570 |
|
sl@0
|
571 |
@param aCustom
|
sl@0
|
572 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
573 |
@param aBankIndex
|
sl@0
|
574 |
Index of sound bank where 0 <= aBankIndex < NumberOfBanks().
|
sl@0
|
575 |
@param aBankId
|
sl@0
|
576 |
Identifier of the specified bank occupying, at most, 14 bits.
|
sl@0
|
577 |
@return One of the system-wide error codes.
|
sl@0
|
578 |
*/
|
sl@0
|
579 |
EXPORT_C TInt RMidiControllerCustomCommands::GetBankId(TBool aCustom, TInt aBankIndex, TInt& aBankId) const
|
sl@0
|
580 |
{
|
sl@0
|
581 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
582 |
configPackage().iCustom = aCustom;
|
sl@0
|
583 |
configPackage().iBankIndex = aBankIndex;
|
sl@0
|
584 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
585 |
EMMFMidiControllerGetBankId,
|
sl@0
|
586 |
configPackage,
|
sl@0
|
587 |
KNullDesC8,
|
sl@0
|
588 |
configPackage);
|
sl@0
|
589 |
if (!error)
|
sl@0
|
590 |
aBankId = configPackage().iBankId;
|
sl@0
|
591 |
return error;
|
sl@0
|
592 |
}
|
sl@0
|
593 |
|
sl@0
|
594 |
|
sl@0
|
595 |
/**
|
sl@0
|
596 |
Loads one or more custom sound banks from a file into memory for use.
|
sl@0
|
597 |
If several banks are loaded with consequent LoadCustomBanks() function calls,
|
sl@0
|
598 |
the banks are combined if the bank sets have conflicting bank numbers.
|
sl@0
|
599 |
|
sl@0
|
600 |
@param aFileName
|
sl@0
|
601 |
Name of the file containing the custom sound bank.
|
sl@0
|
602 |
@param aBankCollectionIndex
|
sl@0
|
603 |
Identifier of the custom sound bank loaded, occupying no more than 14 bits.
|
sl@0
|
604 |
@return One of the system-wide error codes.
|
sl@0
|
605 |
*/
|
sl@0
|
606 |
EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBank(const TDesC& aFileName,TInt& aBankCollectionIndex)
|
sl@0
|
607 |
{
|
sl@0
|
608 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
609 |
configPackage().iFileName = &aFileName;
|
sl@0
|
610 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
611 |
EMMFMidiControllerLoadCustomBank,
|
sl@0
|
612 |
configPackage,
|
sl@0
|
613 |
KNullDesC8,
|
sl@0
|
614 |
configPackage);
|
sl@0
|
615 |
if (!error)
|
sl@0
|
616 |
aBankCollectionIndex = configPackage().iBankId;
|
sl@0
|
617 |
return error;
|
sl@0
|
618 |
}
|
sl@0
|
619 |
|
sl@0
|
620 |
|
sl@0
|
621 |
/**
|
sl@0
|
622 |
Loads one or more custom sound banks from a descriptor into memory for use.
|
sl@0
|
623 |
If several banks are loaded with consequent LoadCustomBanks() function calls,
|
sl@0
|
624 |
the banks are combined if the bank sets have conflicting bank numbers.
|
sl@0
|
625 |
|
sl@0
|
626 |
@param aBankData
|
sl@0
|
627 |
Descriptor containing the custom sound bank.
|
sl@0
|
628 |
@param aBankCollectionIndex
|
sl@0
|
629 |
Identifier of the custom sound bank loaded, occupying no more than 14 bits.
|
sl@0
|
630 |
@return One of the system-wide error codes.
|
sl@0
|
631 |
*/
|
sl@0
|
632 |
EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBankData(const TDesC8& aBankData,TInt& aBankCollectionIndex)
|
sl@0
|
633 |
{
|
sl@0
|
634 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
635 |
configPackage().iBankData = &aBankData;
|
sl@0
|
636 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
637 |
EMMFMidiControllerLoadCustomBankData,
|
sl@0
|
638 |
configPackage,
|
sl@0
|
639 |
KNullDesC8,
|
sl@0
|
640 |
configPackage);
|
sl@0
|
641 |
if (!error)
|
sl@0
|
642 |
aBankCollectionIndex = configPackage().iBankId;
|
sl@0
|
643 |
return error;
|
sl@0
|
644 |
}
|
sl@0
|
645 |
|
sl@0
|
646 |
|
sl@0
|
647 |
/**
|
sl@0
|
648 |
Removes a custom sound bank from memory. Only valid for sound banks previously
|
sl@0
|
649 |
loaded from file. Once unloaded the custom sound bank is no longer available for use.
|
sl@0
|
650 |
|
sl@0
|
651 |
@param aBankCollectionIndex
|
sl@0
|
652 |
Identifier of the custom sound bank to unload,occupying no more than 14 bits.
|
sl@0
|
653 |
@return One of the system-wide error codes.
|
sl@0
|
654 |
*/
|
sl@0
|
655 |
EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomBank(TInt aBankCollectionIndex)
|
sl@0
|
656 |
{
|
sl@0
|
657 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
658 |
configPackage().iBankId= aBankCollectionIndex;
|
sl@0
|
659 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
660 |
EMMFMidiControllerUnloadCustomBank,
|
sl@0
|
661 |
configPackage,
|
sl@0
|
662 |
KNullDesC8);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
/**
|
sl@0
|
666 |
Query if a bank has been loaded to the memory.
|
sl@0
|
667 |
|
sl@0
|
668 |
@param aBankCollectionIndex
|
sl@0
|
669 |
Identifier of the custom sound bank to check if it's in memory or not.
|
sl@0
|
670 |
@param aBankLoaded
|
sl@0
|
671 |
ETrue if the specified bank is in memory, EFalse otherwise.
|
sl@0
|
672 |
@return One of the system-wide error codes.
|
sl@0
|
673 |
*/
|
sl@0
|
674 |
EXPORT_C TInt RMidiControllerCustomCommands::CustomBankLoaded(TInt aBankCollectionIndex, TBool& aBankLoaded) const
|
sl@0
|
675 |
{
|
sl@0
|
676 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
677 |
configPackage().iBankId= aBankCollectionIndex;
|
sl@0
|
678 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
679 |
EMMFMidiControllerCustomBankLoaded,
|
sl@0
|
680 |
configPackage,
|
sl@0
|
681 |
KNullDesC8,
|
sl@0
|
682 |
configPackage);
|
sl@0
|
683 |
if (!error)
|
sl@0
|
684 |
aBankLoaded = configPackage().iBankLoaded;
|
sl@0
|
685 |
return error;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
|
sl@0
|
689 |
/**
|
sl@0
|
690 |
Removes all custom sound banks from memory.
|
sl@0
|
691 |
|
sl@0
|
692 |
@return One of the system-wide error codes.
|
sl@0
|
693 |
*/
|
sl@0
|
694 |
EXPORT_C TInt RMidiControllerCustomCommands::UnloadAllCustomBanks()
|
sl@0
|
695 |
{
|
sl@0
|
696 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
697 |
EMMFMidiControllerUnloadAllCustomBanks,
|
sl@0
|
698 |
KNullDesC8,
|
sl@0
|
699 |
KNullDesC8);
|
sl@0
|
700 |
}
|
sl@0
|
701 |
|
sl@0
|
702 |
/**
|
sl@0
|
703 |
Gets the number of instruments available in a given sound bank.
|
sl@0
|
704 |
|
sl@0
|
705 |
@param aBankId
|
sl@0
|
706 |
Identifier of sound bank to reference, occupying no more than 14 bits.
|
sl@0
|
707 |
@param aCustom
|
sl@0
|
708 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
709 |
@param aNumInstruments
|
sl@0
|
710 |
Count of the number of instruments available for the specified sound bank.
|
sl@0
|
711 |
@return One of the system-wide error codes.
|
sl@0
|
712 |
*/
|
sl@0
|
713 |
EXPORT_C TInt RMidiControllerCustomCommands::NumberOfInstruments(TInt aBankId, TBool aCustom, TInt& aNumInstruments) const
|
sl@0
|
714 |
{
|
sl@0
|
715 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
716 |
configPackage().iBankId = aBankId;
|
sl@0
|
717 |
configPackage().iCustom = aCustom;
|
sl@0
|
718 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
719 |
EMMFMidiControllerNumberOfInstruments,
|
sl@0
|
720 |
configPackage,
|
sl@0
|
721 |
KNullDesC8,
|
sl@0
|
722 |
configPackage);
|
sl@0
|
723 |
if (!error)
|
sl@0
|
724 |
aNumInstruments = configPackage().iNumInstruments;
|
sl@0
|
725 |
return error;
|
sl@0
|
726 |
}
|
sl@0
|
727 |
|
sl@0
|
728 |
|
sl@0
|
729 |
/**
|
sl@0
|
730 |
Gets the identifier of an instrument.
|
sl@0
|
731 |
|
sl@0
|
732 |
@param aBankId
|
sl@0
|
733 |
Identifier of the sound bank to reference, occupying no more than 14 bits.
|
sl@0
|
734 |
@param aCustom
|
sl@0
|
735 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
736 |
@param aInstrumentIndex
|
sl@0
|
737 |
Index of the instrument to reference where 0 <= aInstrumentIndex < NumberOfInstruments().
|
sl@0
|
738 |
@param aInstrumentId
|
sl@0
|
739 |
Identifier of specified instrument. This may differ from the index since the index
|
sl@0
|
740 |
simply enumerates the instruments, whereas identifiers may not be contiguous,
|
sl@0
|
741 |
especially where certain instruments correspond to General MIDI-defined instruments
|
sl@0
|
742 |
but not all instruments are present. Instrument identifiers are between 0 and 127 inclusive.
|
sl@0
|
743 |
@return One of the system-wide error codes.
|
sl@0
|
744 |
*/
|
sl@0
|
745 |
EXPORT_C TInt RMidiControllerCustomCommands::GetInstrumentId(TInt aBankId, TBool aCustom, TInt aInstrumentIndex, TInt& aInstrumentId) const
|
sl@0
|
746 |
{
|
sl@0
|
747 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
748 |
configPackage().iBankId = aBankId;
|
sl@0
|
749 |
configPackage().iCustom = aCustom;
|
sl@0
|
750 |
configPackage().iInstrumentIndex = aInstrumentIndex;
|
sl@0
|
751 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
752 |
EMMFMidiControllerGetInstrumentId,
|
sl@0
|
753 |
configPackage,
|
sl@0
|
754 |
KNullDesC8,
|
sl@0
|
755 |
configPackage);
|
sl@0
|
756 |
if (!error)
|
sl@0
|
757 |
aInstrumentId = configPackage().iInstrumentId;
|
sl@0
|
758 |
return error;
|
sl@0
|
759 |
}
|
sl@0
|
760 |
|
sl@0
|
761 |
|
sl@0
|
762 |
/**
|
sl@0
|
763 |
Gets the name of the given instrument.
|
sl@0
|
764 |
|
sl@0
|
765 |
@param aBankId
|
sl@0
|
766 |
Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
|
sl@0
|
767 |
@param aCustom
|
sl@0
|
768 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
769 |
@param aInstrumentId
|
sl@0
|
770 |
Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
|
sl@0
|
771 |
@return Buffer containing the name of the specified instrument. If it has no name
|
sl@0
|
772 |
then an empty descriptor is returned.
|
sl@0
|
773 |
*/
|
sl@0
|
774 |
EXPORT_C HBufC* RMidiControllerCustomCommands::InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const
|
sl@0
|
775 |
{
|
sl@0
|
776 |
// First, get the size of the instrument name so we can create a descriptor big enough to hold it
|
sl@0
|
777 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
778 |
configPackage().iBankId = aBankId;
|
sl@0
|
779 |
configPackage().iCustom = aCustom;
|
sl@0
|
780 |
configPackage().iInstrumentId = aInstrumentId;
|
sl@0
|
781 |
TPckgBuf<TInt> descriptorSizePckg;
|
sl@0
|
782 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
783 |
EMMFMidiControllerInstrumentName,
|
sl@0
|
784 |
configPackage,
|
sl@0
|
785 |
KNullDesC8,
|
sl@0
|
786 |
descriptorSizePckg));
|
sl@0
|
787 |
|
sl@0
|
788 |
// Now create a descriptor of appropriate size and get the server to copy the data into it
|
sl@0
|
789 |
HBufC8* instrumentNameBuffer = HBufC8::NewLC(descriptorSizePckg());
|
sl@0
|
790 |
TPtr8 instrumentNameBufferPtr = instrumentNameBuffer->Des();
|
sl@0
|
791 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
792 |
EMMFMidiControllerCopyInstrumentName,
|
sl@0
|
793 |
KNullDesC8,
|
sl@0
|
794 |
KNullDesC8,
|
sl@0
|
795 |
instrumentNameBufferPtr));
|
sl@0
|
796 |
|
sl@0
|
797 |
// Stream data out of the 8bit descriptor into a 16bit descriptor
|
sl@0
|
798 |
RDesReadStream stream;
|
sl@0
|
799 |
stream.Open(*instrumentNameBuffer);
|
sl@0
|
800 |
CleanupClosePushL(stream);
|
sl@0
|
801 |
|
sl@0
|
802 |
HBufC* instrumentName = HBufC::NewL(stream, KMaxTInt);
|
sl@0
|
803 |
|
sl@0
|
804 |
CleanupStack::PopAndDestroy();//stream
|
sl@0
|
805 |
CleanupStack::PopAndDestroy(instrumentNameBuffer);
|
sl@0
|
806 |
|
sl@0
|
807 |
return instrumentName;
|
sl@0
|
808 |
}
|
sl@0
|
809 |
|
sl@0
|
810 |
|
sl@0
|
811 |
/**
|
sl@0
|
812 |
Sets a logical channel to use the given instrument.
|
sl@0
|
813 |
|
sl@0
|
814 |
@param aChannel
|
sl@0
|
815 |
Logical channel to set the instrument for. 0 <= aChannel <= 15.
|
sl@0
|
816 |
@param aBankId
|
sl@0
|
817 |
Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
|
sl@0
|
818 |
The bank ID is a concatenation of MIDI bank MSB and LSB values.
|
sl@0
|
819 |
@param aInstrumentId
|
sl@0
|
820 |
Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
|
sl@0
|
821 |
@return One of the system-wide error codes.
|
sl@0
|
822 |
*/
|
sl@0
|
823 |
EXPORT_C TInt RMidiControllerCustomCommands::SetInstrument(TInt aChannel,TInt aBankId,TInt aInstrumentId)
|
sl@0
|
824 |
{
|
sl@0
|
825 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
826 |
configPackage().iChannel = aChannel;
|
sl@0
|
827 |
configPackage().iBankId = aBankId;
|
sl@0
|
828 |
configPackage().iInstrumentId = aInstrumentId;
|
sl@0
|
829 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
830 |
EMMFMidiControllerSetInstrument,
|
sl@0
|
831 |
configPackage,
|
sl@0
|
832 |
KNullDesC8);
|
sl@0
|
833 |
}
|
sl@0
|
834 |
|
sl@0
|
835 |
/**
|
sl@0
|
836 |
Loads an individual instrument from file into custom sound bank memory for use.
|
sl@0
|
837 |
The bank and instrument id given in the file can be mapped into different bank
|
sl@0
|
838 |
and instrument id in memory.
|
sl@0
|
839 |
|
sl@0
|
840 |
@param aFileName
|
sl@0
|
841 |
Name of the file containing the instrument.
|
sl@0
|
842 |
@param aFileBankId
|
sl@0
|
843 |
Identifier of the bank in the file from which to load the instrument,
|
sl@0
|
844 |
occupying no more than 14 bits.
|
sl@0
|
845 |
@param aFileInstrumentId
|
sl@0
|
846 |
Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
|
sl@0
|
847 |
@param aMemoryBankId
|
sl@0
|
848 |
Identifier of the custom bank in memory to load the instrument into,
|
sl@0
|
849 |
occupying no more than 14 bits.
|
sl@0
|
850 |
@param aMemoryInstrumentId
|
sl@0
|
851 |
Identifier of the instrument in memory to load the new instrument into.
|
sl@0
|
852 |
0 <= aInstrumentId <= 127.
|
sl@0
|
853 |
@return One of the system-wide error codes.
|
sl@0
|
854 |
*/
|
sl@0
|
855 |
EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrument(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
858 |
configPackage().iFileName = &aFileName;
|
sl@0
|
859 |
configPackage().iBankId = aFileBankId;
|
sl@0
|
860 |
configPackage().iInstrumentId = aFileInstrumentId;
|
sl@0
|
861 |
configPackage().iMemoryBankId = aMemoryBankId;
|
sl@0
|
862 |
configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
|
sl@0
|
863 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
864 |
EMMFMidiControllerLoadCustomInstrument,
|
sl@0
|
865 |
configPackage,
|
sl@0
|
866 |
KNullDesC8);
|
sl@0
|
867 |
}
|
sl@0
|
868 |
|
sl@0
|
869 |
|
sl@0
|
870 |
/**
|
sl@0
|
871 |
Loads an individual instrument from descriptor into custom sound bank memory for use.
|
sl@0
|
872 |
The bank and instrument id given in the descriptor can be mapped into different bank
|
sl@0
|
873 |
and instrument id in memory.
|
sl@0
|
874 |
|
sl@0
|
875 |
@param aInstrumentData
|
sl@0
|
876 |
Descriptor containing the instrument.
|
sl@0
|
877 |
@param aBankDataId
|
sl@0
|
878 |
Identifier of the bank in the descriptor from which to load the instrument,
|
sl@0
|
879 |
occupying no more than 14 bits.
|
sl@0
|
880 |
@param aInstrumentDataId
|
sl@0
|
881 |
Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
|
sl@0
|
882 |
@param aMemoryBankId
|
sl@0
|
883 |
Identifier of the custom bank in memory to load the instrument into,
|
sl@0
|
884 |
occupying no more than 14 bits.
|
sl@0
|
885 |
@param aMemoryInstrumentId
|
sl@0
|
886 |
Identifier of the instrument in memory to load the new instrument into.
|
sl@0
|
887 |
0 <= aInstrumentId <= 127.
|
sl@0
|
888 |
@return One of the system-wide error codes.
|
sl@0
|
889 |
*/
|
sl@0
|
890 |
EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrumentData(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
|
sl@0
|
891 |
{
|
sl@0
|
892 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
893 |
configPackage().iInstrumentData = &aInstrumentData;
|
sl@0
|
894 |
configPackage().iBankId = aBankDataId;
|
sl@0
|
895 |
configPackage().iInstrumentId = aInstrumentDataId;
|
sl@0
|
896 |
configPackage().iMemoryBankId = aMemoryBankId;
|
sl@0
|
897 |
configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
|
sl@0
|
898 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
899 |
EMMFMidiControllerLoadCustomInstrumentData,
|
sl@0
|
900 |
configPackage,
|
sl@0
|
901 |
KNullDesC8);
|
sl@0
|
902 |
}
|
sl@0
|
903 |
|
sl@0
|
904 |
/**
|
sl@0
|
905 |
Removes an instrument from custom sound bank memory. Only valid for
|
sl@0
|
906 |
instruments previously loaded from file. Once unloaded the instrument
|
sl@0
|
907 |
is no longer available for use.
|
sl@0
|
908 |
|
sl@0
|
909 |
@param aCustomBankId
|
sl@0
|
910 |
Identifier of the custom sound bank containing the instrument to unload,
|
sl@0
|
911 |
occupying no more than 14 bits.
|
sl@0
|
912 |
@param aInstrumentId
|
sl@0
|
913 |
Identifier of the instrument to unload. 0 <= aInstrumentId <= 127.
|
sl@0
|
914 |
@return One of the system-wide error codes.
|
sl@0
|
915 |
*/
|
sl@0
|
916 |
EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomInstrument(TInt aCustomBankId,TInt aInstrumentId)
|
sl@0
|
917 |
{
|
sl@0
|
918 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
919 |
configPackage().iBankId = aCustomBankId;
|
sl@0
|
920 |
configPackage().iInstrumentId = aInstrumentId;
|
sl@0
|
921 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
922 |
EMMFMidiControllerUnloadCustomInstrument,
|
sl@0
|
923 |
configPackage,
|
sl@0
|
924 |
KNullDesC8);
|
sl@0
|
925 |
}
|
sl@0
|
926 |
|
sl@0
|
927 |
/**
|
sl@0
|
928 |
Gets the name of a particular percussion key corresponding to a given note.
|
sl@0
|
929 |
|
sl@0
|
930 |
@param aNote
|
sl@0
|
931 |
Note to query. 0 <= aNote <= 127.
|
sl@0
|
932 |
@param aBankId
|
sl@0
|
933 |
Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
|
sl@0
|
934 |
The bank ID is a concatenation of MIDI bank MSB and LSB values.
|
sl@0
|
935 |
@param aCustom
|
sl@0
|
936 |
Specifies whether to reference a custom or standard sound bank.
|
sl@0
|
937 |
@param aInstrumentId
|
sl@0
|
938 |
Identifier of an instrument.
|
sl@0
|
939 |
@return Descriptor containing the name of the percussion key. If the key
|
sl@0
|
940 |
does not have a name then an empty descriptor is returned.
|
sl@0
|
941 |
*/
|
sl@0
|
942 |
EXPORT_C HBufC* RMidiControllerCustomCommands::PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const
|
sl@0
|
943 |
{
|
sl@0
|
944 |
// First, get the size of the percussion key name so we can create a descriptor big enough to hold it
|
sl@0
|
945 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
946 |
configPackage().iNote = aNote;
|
sl@0
|
947 |
configPackage().iBankId = aBankId;
|
sl@0
|
948 |
configPackage().iCustom = aCustom;
|
sl@0
|
949 |
configPackage().iInstrumentId = aInstrumentId;
|
sl@0
|
950 |
TPckgBuf<TInt> descriptorSizePckg;
|
sl@0
|
951 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
952 |
EMMFMidiControllerPercussionKeyName,
|
sl@0
|
953 |
configPackage,
|
sl@0
|
954 |
KNullDesC8,
|
sl@0
|
955 |
descriptorSizePckg));
|
sl@0
|
956 |
|
sl@0
|
957 |
// Now create a descriptor of appropriate size and get the server to copy the data into it
|
sl@0
|
958 |
HBufC8* keyNameBuffer = HBufC8::NewLC(descriptorSizePckg());
|
sl@0
|
959 |
TPtr8 keyNameBufferPtr = keyNameBuffer->Des();
|
sl@0
|
960 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
961 |
EMMFMidiControllerCopyPercussionKeyName,
|
sl@0
|
962 |
KNullDesC8,
|
sl@0
|
963 |
KNullDesC8,
|
sl@0
|
964 |
keyNameBufferPtr));
|
sl@0
|
965 |
|
sl@0
|
966 |
// Stream data out of the 8bit descriptor into a 16bit descriptor
|
sl@0
|
967 |
RDesReadStream stream;
|
sl@0
|
968 |
stream.Open(*keyNameBuffer);
|
sl@0
|
969 |
CleanupClosePushL(stream);
|
sl@0
|
970 |
|
sl@0
|
971 |
HBufC* keyName = HBufC::NewL(stream, KMaxTInt);
|
sl@0
|
972 |
|
sl@0
|
973 |
CleanupStack::PopAndDestroy();//stream
|
sl@0
|
974 |
CleanupStack::PopAndDestroy(keyNameBuffer);
|
sl@0
|
975 |
|
sl@0
|
976 |
return keyName;
|
sl@0
|
977 |
}
|
sl@0
|
978 |
|
sl@0
|
979 |
/**
|
sl@0
|
980 |
Get the stop time currently set for the MIDI resource.
|
sl@0
|
981 |
|
sl@0
|
982 |
@param aStopTime
|
sl@0
|
983 |
Time at which playback will stop, relative to the start of the resource.
|
sl@0
|
984 |
@return One of the system-wide error codes.
|
sl@0
|
985 |
*/
|
sl@0
|
986 |
EXPORT_C TInt RMidiControllerCustomCommands::StopTime(TTimeIntervalMicroSeconds& aStopTime) const
|
sl@0
|
987 |
{
|
sl@0
|
988 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
989 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
990 |
EMMFMidiControllerStopTime,
|
sl@0
|
991 |
KNullDesC8,
|
sl@0
|
992 |
KNullDesC8,
|
sl@0
|
993 |
configPackage);
|
sl@0
|
994 |
if (!error)
|
sl@0
|
995 |
aStopTime = configPackage().iStopTime;
|
sl@0
|
996 |
return error;
|
sl@0
|
997 |
}
|
sl@0
|
998 |
|
sl@0
|
999 |
|
sl@0
|
1000 |
/**
|
sl@0
|
1001 |
Sets the stop time to use for the currently open MIDI resource
|
sl@0
|
1002 |
|
sl@0
|
1003 |
@param aStopTime
|
sl@0
|
1004 |
Time at which playback will stop, relative to the start of the resource.
|
sl@0
|
1005 |
Clamped to 0 and the duration of the resource.
|
sl@0
|
1006 |
@return One of the system-wide error codes.
|
sl@0
|
1007 |
*/
|
sl@0
|
1008 |
EXPORT_C TInt RMidiControllerCustomCommands::SetStopTime(const TTimeIntervalMicroSeconds& aStopTime) const
|
sl@0
|
1009 |
{
|
sl@0
|
1010 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1011 |
configPackage().iStopTime = aStopTime;
|
sl@0
|
1012 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1013 |
EMMFMidiControllerSetStopTime,
|
sl@0
|
1014 |
configPackage,
|
sl@0
|
1015 |
KNullDesC8);
|
sl@0
|
1016 |
}
|
sl@0
|
1017 |
|
sl@0
|
1018 |
/**
|
sl@0
|
1019 |
Gets the polyphony of the MIDI engine.
|
sl@0
|
1020 |
|
sl@0
|
1021 |
@param aNumNotes
|
sl@0
|
1022 |
The number of currently active voices.
|
sl@0
|
1023 |
@return One of the system-wide error codes.
|
sl@0
|
1024 |
*/
|
sl@0
|
1025 |
EXPORT_C TInt RMidiControllerCustomCommands::Polyphony(TInt& aNumNotes) const
|
sl@0
|
1026 |
{
|
sl@0
|
1027 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1028 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1029 |
EMMFMidiControllerPolyphony,
|
sl@0
|
1030 |
KNullDesC8,
|
sl@0
|
1031 |
KNullDesC8,
|
sl@0
|
1032 |
configPackage);
|
sl@0
|
1033 |
if (!error)
|
sl@0
|
1034 |
aNumNotes = configPackage().iNumNotes;
|
sl@0
|
1035 |
return error;
|
sl@0
|
1036 |
}
|
sl@0
|
1037 |
|
sl@0
|
1038 |
|
sl@0
|
1039 |
/**
|
sl@0
|
1040 |
Gets the current maximum number of notes the engine can handle
|
sl@0
|
1041 |
This can be greater than the value returned by RMidiControllerCustomCommands::Polyphony
|
sl@0
|
1042 |
|
sl@0
|
1043 |
@param aNumNotes
|
sl@0
|
1044 |
The maximum number of notes the engine can handle
|
sl@0
|
1045 |
@return One of the system-wide error codes.
|
sl@0
|
1046 |
*/
|
sl@0
|
1047 |
EXPORT_C TInt RMidiControllerCustomCommands::MaxPolyphony(TInt& aMaxNotes) const
|
sl@0
|
1048 |
{
|
sl@0
|
1049 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1050 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1051 |
EMMFMidiControllerMaxPolyphony,
|
sl@0
|
1052 |
KNullDesC8,
|
sl@0
|
1053 |
KNullDesC8,
|
sl@0
|
1054 |
configPackage);
|
sl@0
|
1055 |
if (!error)
|
sl@0
|
1056 |
aMaxNotes = configPackage().iMaxNotes;
|
sl@0
|
1057 |
return error;
|
sl@0
|
1058 |
}
|
sl@0
|
1059 |
|
sl@0
|
1060 |
/**
|
sl@0
|
1061 |
Get the maximum number of logical channels supported by the MIDI engine.
|
sl@0
|
1062 |
|
sl@0
|
1063 |
@param aChannels
|
sl@0
|
1064 |
The maximum number of logical channels that the MIDI engine supports,
|
sl@0
|
1065 |
0 <= aChannels <=15.
|
sl@0
|
1066 |
@return One of the system-wide error codes.
|
sl@0
|
1067 |
*/
|
sl@0
|
1068 |
EXPORT_C TInt RMidiControllerCustomCommands::ChannelsSupported(TInt& aChannels) const
|
sl@0
|
1069 |
{
|
sl@0
|
1070 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1071 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1072 |
EMMFMidiControllerChannelsSupported,
|
sl@0
|
1073 |
KNullDesC8,
|
sl@0
|
1074 |
KNullDesC8,
|
sl@0
|
1075 |
configPackage);
|
sl@0
|
1076 |
if (!error)
|
sl@0
|
1077 |
aChannels = configPackage().iChannel;
|
sl@0
|
1078 |
return error;
|
sl@0
|
1079 |
}
|
sl@0
|
1080 |
|
sl@0
|
1081 |
|
sl@0
|
1082 |
/**
|
sl@0
|
1083 |
Get the current volume setting of a logical channel.
|
sl@0
|
1084 |
|
sl@0
|
1085 |
@param aChannel
|
sl@0
|
1086 |
Logical channel to query. 0 <= aChannel <= 15.
|
sl@0
|
1087 |
@param aChannelVol
|
sl@0
|
1088 |
Volume currently set on the specified channel in decibels.
|
sl@0
|
1089 |
@return One of the system-wide error codes.
|
sl@0
|
1090 |
*/
|
sl@0
|
1091 |
EXPORT_C TInt RMidiControllerCustomCommands::ChannelVolume(TInt aChannel, TReal32& aChannelVol) const
|
sl@0
|
1092 |
{
|
sl@0
|
1093 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1094 |
configPackage().iChannel = aChannel;
|
sl@0
|
1095 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1096 |
EMMFMidiControllerChannelVolume,
|
sl@0
|
1097 |
configPackage,
|
sl@0
|
1098 |
KNullDesC8,
|
sl@0
|
1099 |
configPackage);
|
sl@0
|
1100 |
if (!error)
|
sl@0
|
1101 |
aChannelVol = configPackage().iChannelVol;
|
sl@0
|
1102 |
return error;
|
sl@0
|
1103 |
}
|
sl@0
|
1104 |
|
sl@0
|
1105 |
/**
|
sl@0
|
1106 |
Gets the Maximum volume setting that may be applied to a logical channel.
|
sl@0
|
1107 |
|
sl@0
|
1108 |
@param aMaxVol
|
sl@0
|
1109 |
Maximum volume setting. Minimum value is -infinity dB, which is the
|
sl@0
|
1110 |
smallest possible value that TReal32 supports.
|
sl@0
|
1111 |
@return One of the system-wide error codes.
|
sl@0
|
1112 |
*/
|
sl@0
|
1113 |
EXPORT_C TInt RMidiControllerCustomCommands::MaxChannelVolume(TReal32& aMaxVol) const
|
sl@0
|
1114 |
{
|
sl@0
|
1115 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1116 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1117 |
EMMFMidiControllerMaxChannelVolume,
|
sl@0
|
1118 |
KNullDesC8,
|
sl@0
|
1119 |
KNullDesC8,
|
sl@0
|
1120 |
configPackage);
|
sl@0
|
1121 |
if (!error)
|
sl@0
|
1122 |
aMaxVol = configPackage().iMaxChannelVol;
|
sl@0
|
1123 |
return error;
|
sl@0
|
1124 |
}
|
sl@0
|
1125 |
|
sl@0
|
1126 |
/**
|
sl@0
|
1127 |
Set the volume of a channel.
|
sl@0
|
1128 |
|
sl@0
|
1129 |
@param aChannel
|
sl@0
|
1130 |
Logical channel to set the volume on. 0 <= aChannel <= 15.
|
sl@0
|
1131 |
@param aVolume
|
sl@0
|
1132 |
The channel volume can be set within a range. The minimum
|
sl@0
|
1133 |
channel volume is -infinity dB, which is the smallest possible
|
sl@0
|
1134 |
value that TReal32 supports while the maximum channel volume
|
sl@0
|
1135 |
is set via MaxVolumeL() which represents the volume level in dB
|
sl@0
|
1136 |
corresponding to the MIDI Channel Volume controller.
|
sl@0
|
1137 |
@return One of the system-wide error codes.
|
sl@0
|
1138 |
*/
|
sl@0
|
1139 |
EXPORT_C TInt RMidiControllerCustomCommands::SetChannelVolume(TInt aChannel,TReal32 aVolume)
|
sl@0
|
1140 |
{
|
sl@0
|
1141 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1142 |
configPackage().iChannel = aChannel;
|
sl@0
|
1143 |
configPackage().iChannelVol = aVolume;
|
sl@0
|
1144 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1145 |
EMMFMidiControllerSetChannelVolume,
|
sl@0
|
1146 |
configPackage,
|
sl@0
|
1147 |
KNullDesC8);
|
sl@0
|
1148 |
}
|
sl@0
|
1149 |
|
sl@0
|
1150 |
/**
|
sl@0
|
1151 |
Set the muting state of a channel without changing its volume setting.
|
sl@0
|
1152 |
When unmuted the channel goes back to its previous volume setting.
|
sl@0
|
1153 |
|
sl@0
|
1154 |
@param aChannel
|
sl@0
|
1155 |
Logical channel to set the mute state of. 0 <= aChannel <= 15.
|
sl@0
|
1156 |
@param aMuted
|
sl@0
|
1157 |
ETrue to mute the channel, EFalse to unmute it.
|
sl@0
|
1158 |
@return One of the system-wide error codes.
|
sl@0
|
1159 |
*/
|
sl@0
|
1160 |
EXPORT_C TInt RMidiControllerCustomCommands::SetChannelMute(TInt aChannel,TBool aMuted)
|
sl@0
|
1161 |
{
|
sl@0
|
1162 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1163 |
configPackage().iChannel = aChannel;
|
sl@0
|
1164 |
configPackage().iMuted = aMuted;
|
sl@0
|
1165 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1166 |
EMMFMidiControllerSetChannelMute,
|
sl@0
|
1167 |
configPackage,
|
sl@0
|
1168 |
KNullDesC8);
|
sl@0
|
1169 |
}
|
sl@0
|
1170 |
|
sl@0
|
1171 |
|
sl@0
|
1172 |
/**
|
sl@0
|
1173 |
Gets the overall volume of the MIDI client.
|
sl@0
|
1174 |
|
sl@0
|
1175 |
@param aVolume
|
sl@0
|
1176 |
The current overall volume setting.
|
sl@0
|
1177 |
@return One of the system-wide error codes.
|
sl@0
|
1178 |
*/
|
sl@0
|
1179 |
EXPORT_C TInt RMidiControllerCustomCommands::Volume(TInt& aVolume) const
|
sl@0
|
1180 |
{
|
sl@0
|
1181 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1182 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1183 |
EMMFMidiControllerVolume,
|
sl@0
|
1184 |
KNullDesC8,
|
sl@0
|
1185 |
KNullDesC8,
|
sl@0
|
1186 |
configPackage);
|
sl@0
|
1187 |
if (!error)
|
sl@0
|
1188 |
aVolume = configPackage().iVolume;
|
sl@0
|
1189 |
return error;
|
sl@0
|
1190 |
}
|
sl@0
|
1191 |
|
sl@0
|
1192 |
|
sl@0
|
1193 |
/**
|
sl@0
|
1194 |
Maximum volume setting that may be applied overall.
|
sl@0
|
1195 |
|
sl@0
|
1196 |
@param aMaxVolume
|
sl@0
|
1197 |
Maximum volume setting. Minimum value is always zero which is silent.
|
sl@0
|
1198 |
@return One of the system-wide error codes.
|
sl@0
|
1199 |
*/
|
sl@0
|
1200 |
EXPORT_C TInt RMidiControllerCustomCommands::MaxVolume(TInt& aMaxVolume) const
|
sl@0
|
1201 |
{
|
sl@0
|
1202 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1203 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1204 |
EMMFMidiControllerMaxVolume,
|
sl@0
|
1205 |
KNullDesC8,
|
sl@0
|
1206 |
KNullDesC8,
|
sl@0
|
1207 |
configPackage);
|
sl@0
|
1208 |
if (!error)
|
sl@0
|
1209 |
aMaxVolume = configPackage().iMaxVolume;
|
sl@0
|
1210 |
return error;
|
sl@0
|
1211 |
}
|
sl@0
|
1212 |
|
sl@0
|
1213 |
|
sl@0
|
1214 |
/**
|
sl@0
|
1215 |
Set the overall volume of the MIDI client.
|
sl@0
|
1216 |
This setting scales all channel volumes respectively so the actual volume
|
sl@0
|
1217 |
that a channel is played at is (overall volume * channel volume / max volume).
|
sl@0
|
1218 |
|
sl@0
|
1219 |
@param aVolume
|
sl@0
|
1220 |
Overall volume setting to use.
|
sl@0
|
1221 |
@return One of the system-wide error codes.
|
sl@0
|
1222 |
*/
|
sl@0
|
1223 |
EXPORT_C TInt RMidiControllerCustomCommands::SetVolume(TInt aVolume)
|
sl@0
|
1224 |
{
|
sl@0
|
1225 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1226 |
configPackage().iVolume = aVolume;
|
sl@0
|
1227 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1228 |
EMMFMidiControllerSetVolume,
|
sl@0
|
1229 |
configPackage,
|
sl@0
|
1230 |
KNullDesC8);
|
sl@0
|
1231 |
}
|
sl@0
|
1232 |
|
sl@0
|
1233 |
/**
|
sl@0
|
1234 |
Length of time over which the volume is faded up from zero to the current setting
|
sl@0
|
1235 |
when playback is started.
|
sl@0
|
1236 |
|
sl@0
|
1237 |
@param aRampDuration
|
sl@0
|
1238 |
Duration of the ramping period.
|
sl@0
|
1239 |
@return One of the system-wide error codes.
|
sl@0
|
1240 |
*/
|
sl@0
|
1241 |
EXPORT_C TInt RMidiControllerCustomCommands::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
|
sl@0
|
1242 |
{
|
sl@0
|
1243 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1244 |
configPackage().iRampDuration = aRampDuration;
|
sl@0
|
1245 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1246 |
EMMFMidiControllerSetVolumeRamp,
|
sl@0
|
1247 |
configPackage,
|
sl@0
|
1248 |
KNullDesC8);
|
sl@0
|
1249 |
}
|
sl@0
|
1250 |
|
sl@0
|
1251 |
/**
|
sl@0
|
1252 |
Get the current stereo balance value.
|
sl@0
|
1253 |
|
sl@0
|
1254 |
@param aBalance
|
sl@0
|
1255 |
Balance value ranging from KMMFBalanceMaxLeft to KMMFBalanceMaxRight.
|
sl@0
|
1256 |
@return One of the system-wide error codes.
|
sl@0
|
1257 |
*/
|
sl@0
|
1258 |
EXPORT_C TInt RMidiControllerCustomCommands::GetBalance(TInt& aBalance) const
|
sl@0
|
1259 |
{
|
sl@0
|
1260 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1261 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1262 |
EMMFMidiControllerGetBalance,
|
sl@0
|
1263 |
KNullDesC8,
|
sl@0
|
1264 |
KNullDesC8,
|
sl@0
|
1265 |
configPackage);
|
sl@0
|
1266 |
if (!error)
|
sl@0
|
1267 |
aBalance = configPackage().iBalance;
|
sl@0
|
1268 |
return error;
|
sl@0
|
1269 |
}
|
sl@0
|
1270 |
|
sl@0
|
1271 |
/**
|
sl@0
|
1272 |
Set the current stereo balance value.
|
sl@0
|
1273 |
|
sl@0
|
1274 |
@param aBalance
|
sl@0
|
1275 |
Balance value to set. Defaults to KMMFBalanceCenter to restore equal left-right balance.
|
sl@0
|
1276 |
@return One of the system-wide error codes.
|
sl@0
|
1277 |
*/
|
sl@0
|
1278 |
EXPORT_C TInt RMidiControllerCustomCommands::SetBalance(TInt aBalance)
|
sl@0
|
1279 |
{
|
sl@0
|
1280 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1281 |
configPackage().iBalance = aBalance;
|
sl@0
|
1282 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1283 |
EMMFMidiControllerSetBalance,
|
sl@0
|
1284 |
configPackage,
|
sl@0
|
1285 |
KNullDesC8);
|
sl@0
|
1286 |
}
|
sl@0
|
1287 |
|
sl@0
|
1288 |
/**
|
sl@0
|
1289 |
Set the max polyphony the engine can handle.
|
sl@0
|
1290 |
|
sl@0
|
1291 |
@param aMaxNotes
|
sl@0
|
1292 |
Max polyphony level, 1 <= Polyphony() <= aMaxNotes.
|
sl@0
|
1293 |
@return One of the system-wide error codes.
|
sl@0
|
1294 |
*/
|
sl@0
|
1295 |
EXPORT_C TInt RMidiControllerCustomCommands::SetMaxPolyphony(TInt aMaxNotes)
|
sl@0
|
1296 |
{
|
sl@0
|
1297 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1298 |
configPackage().iMaxNotes = aMaxNotes;
|
sl@0
|
1299 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1300 |
EMMFMidiControllerSetMaxPolyphony,
|
sl@0
|
1301 |
configPackage,
|
sl@0
|
1302 |
KNullDesC8);
|
sl@0
|
1303 |
}
|
sl@0
|
1304 |
|
sl@0
|
1305 |
/**
|
sl@0
|
1306 |
Gets the number of times the current opened resources has to be repeated.
|
sl@0
|
1307 |
|
sl@0
|
1308 |
@param aNumRepeats
|
sl@0
|
1309 |
The number of times the current opened resources has to be repeated.
|
sl@0
|
1310 |
@return One of the system-wide error codes.
|
sl@0
|
1311 |
*/
|
sl@0
|
1312 |
EXPORT_C TInt RMidiControllerCustomCommands::GetRepeats(TInt& aNumRepeats) const
|
sl@0
|
1313 |
{
|
sl@0
|
1314 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1315 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1316 |
EMMFMidiControllerGetRepeats,
|
sl@0
|
1317 |
KNullDesC8,
|
sl@0
|
1318 |
KNullDesC8,
|
sl@0
|
1319 |
configPackage);
|
sl@0
|
1320 |
if (!error)
|
sl@0
|
1321 |
aNumRepeats = configPackage().iNumRepeats;
|
sl@0
|
1322 |
return error;
|
sl@0
|
1323 |
}
|
sl@0
|
1324 |
|
sl@0
|
1325 |
/**
|
sl@0
|
1326 |
Set the number of times to repeat the current MIDI resource.
|
sl@0
|
1327 |
After Stop() has been called, repeat number of times and the
|
sl@0
|
1328 |
trailing silence are reset.
|
sl@0
|
1329 |
|
sl@0
|
1330 |
@param aRepeatNumberOfTimes
|
sl@0
|
1331 |
Number of times to repeat the resource during playback. This includes the first playing.
|
sl@0
|
1332 |
@param aTrailingSilence
|
sl@0
|
1333 |
Time in microseconds to pause between repeats.
|
sl@0
|
1334 |
@return One of the system-wide error codes.
|
sl@0
|
1335 |
*/
|
sl@0
|
1336 |
EXPORT_C TInt RMidiControllerCustomCommands::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
|
sl@0
|
1337 |
{
|
sl@0
|
1338 |
|
sl@0
|
1339 |
TPckgBuf<TMMFMidiConfig3> configPackage;
|
sl@0
|
1340 |
configPackage().iRepeatNumberOfTimes = aRepeatNumberOfTimes;
|
sl@0
|
1341 |
configPackage().iTrailingSilence = aTrailingSilence;
|
sl@0
|
1342 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1343 |
EMMFMidiControllerSetRepeats,
|
sl@0
|
1344 |
configPackage,
|
sl@0
|
1345 |
KNullDesC8);
|
sl@0
|
1346 |
}
|
sl@0
|
1347 |
|
sl@0
|
1348 |
/**
|
sl@0
|
1349 |
Tell the MIDI engine to use a custom bank or a standard bank.
|
sl@0
|
1350 |
|
sl@0
|
1351 |
@param aCustom
|
sl@0
|
1352 |
If Etrue the custom bank in memory is used otherwise the standard bank
|
sl@0
|
1353 |
is used leaving the custom bank in memory.
|
sl@0
|
1354 |
@return One of the system-wide error codes.
|
sl@0
|
1355 |
*/
|
sl@0
|
1356 |
EXPORT_C TInt RMidiControllerCustomCommands::SetBank(TBool aCustom)
|
sl@0
|
1357 |
{
|
sl@0
|
1358 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1359 |
configPackage().iCustom = aCustom;
|
sl@0
|
1360 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1361 |
EMMFMidiControllerSetBank,
|
sl@0
|
1362 |
configPackage,
|
sl@0
|
1363 |
KNullDesC8);
|
sl@0
|
1364 |
}
|
sl@0
|
1365 |
|
sl@0
|
1366 |
/**
|
sl@0
|
1367 |
Gets the muting status of a specific track.
|
sl@0
|
1368 |
|
sl@0
|
1369 |
@param aTrack
|
sl@0
|
1370 |
The track to query.
|
sl@0
|
1371 |
@param aTrackMute
|
sl@0
|
1372 |
The mute status of the track.
|
sl@0
|
1373 |
@return One of the system-wide error codes.
|
sl@0
|
1374 |
*/
|
sl@0
|
1375 |
EXPORT_C TInt RMidiControllerCustomCommands::IsTrackMute(TInt aTrack, TBool& aTrackMute) const
|
sl@0
|
1376 |
{
|
sl@0
|
1377 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1378 |
configPackage().iTrack = aTrack;
|
sl@0
|
1379 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1380 |
EMMFMidiControllerIsTrackMute,
|
sl@0
|
1381 |
configPackage,
|
sl@0
|
1382 |
KNullDesC8,
|
sl@0
|
1383 |
configPackage);
|
sl@0
|
1384 |
if (!error)
|
sl@0
|
1385 |
aTrackMute = configPackage().iMuted;
|
sl@0
|
1386 |
return error;
|
sl@0
|
1387 |
}
|
sl@0
|
1388 |
|
sl@0
|
1389 |
|
sl@0
|
1390 |
/**
|
sl@0
|
1391 |
Gets the muting status of a specific channel.
|
sl@0
|
1392 |
|
sl@0
|
1393 |
@param aChannel
|
sl@0
|
1394 |
The channel to query.
|
sl@0
|
1395 |
@param aChannelMute
|
sl@0
|
1396 |
The mute status of the channel.
|
sl@0
|
1397 |
@return One of the system-wide error codes.
|
sl@0
|
1398 |
*/
|
sl@0
|
1399 |
EXPORT_C TInt RMidiControllerCustomCommands::IsChannelMute(TInt aChannel, TBool& aChannelMute) const
|
sl@0
|
1400 |
{
|
sl@0
|
1401 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1402 |
configPackage().iChannel = aChannel;
|
sl@0
|
1403 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1404 |
EMMFMidiControllerIsChannelMute,
|
sl@0
|
1405 |
configPackage,
|
sl@0
|
1406 |
KNullDesC8,
|
sl@0
|
1407 |
configPackage);
|
sl@0
|
1408 |
if (!error)
|
sl@0
|
1409 |
aChannelMute = configPackage().iMuted;
|
sl@0
|
1410 |
return error;
|
sl@0
|
1411 |
}
|
sl@0
|
1412 |
|
sl@0
|
1413 |
|
sl@0
|
1414 |
/**
|
sl@0
|
1415 |
Gets the instrument assigned to a specified channel.
|
sl@0
|
1416 |
|
sl@0
|
1417 |
@param aChannel
|
sl@0
|
1418 |
Logical channel, 0 <= aChannel <= 15.
|
sl@0
|
1419 |
@param aInstrumentId
|
sl@0
|
1420 |
Identifier of the instrument assigned to aChannel. 0 <= aInstrumentId <= 127.
|
sl@0
|
1421 |
@param aBankId
|
sl@0
|
1422 |
Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
|
sl@0
|
1423 |
@return One of the system-wide error codes.
|
sl@0
|
1424 |
*/
|
sl@0
|
1425 |
EXPORT_C TInt RMidiControllerCustomCommands::GetInstrument(TInt aChannel, TInt& aInstrumentId, TInt& aBankId)
|
sl@0
|
1426 |
{
|
sl@0
|
1427 |
TPckgBuf<TMMFMidiConfig2> configPackage;
|
sl@0
|
1428 |
configPackage().iChannel = aChannel;
|
sl@0
|
1429 |
TInt error = iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1430 |
EMMFMidiControllerGetInstrument,
|
sl@0
|
1431 |
configPackage,
|
sl@0
|
1432 |
KNullDesC8,
|
sl@0
|
1433 |
configPackage);
|
sl@0
|
1434 |
if (!error)
|
sl@0
|
1435 |
{
|
sl@0
|
1436 |
aInstrumentId = configPackage().iInstrumentId;
|
sl@0
|
1437 |
aBankId = configPackage().iBankId;
|
sl@0
|
1438 |
}
|
sl@0
|
1439 |
return error;
|
sl@0
|
1440 |
}
|
sl@0
|
1441 |
|
sl@0
|
1442 |
/**
|
sl@0
|
1443 |
Closes any currently open resources, such as files, descriptors or URLs in use.
|
sl@0
|
1444 |
Does nothing if there is nothing currently open.
|
sl@0
|
1445 |
|
sl@0
|
1446 |
@return One of the system-wide error codes.
|
sl@0
|
1447 |
*/
|
sl@0
|
1448 |
EXPORT_C TInt RMidiControllerCustomCommands::Close()
|
sl@0
|
1449 |
{
|
sl@0
|
1450 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1451 |
EMMFMidiControllerClose,
|
sl@0
|
1452 |
KNullDesC8,
|
sl@0
|
1453 |
KNullDesC8);
|
sl@0
|
1454 |
}
|
sl@0
|
1455 |
|
sl@0
|
1456 |
/**
|
sl@0
|
1457 |
Stops playback of a resource but does not change the current position
|
sl@0
|
1458 |
or release any resources. Pauses the internal timer if no resource is open.
|
sl@0
|
1459 |
|
sl@0
|
1460 |
@param aFadeOutDuration
|
sl@0
|
1461 |
Length of time over which the volume is faded out from the current setting to zero.
|
sl@0
|
1462 |
@return One of the system-wide error codes.
|
sl@0
|
1463 |
*/
|
sl@0
|
1464 |
EXPORT_C TInt RMidiControllerCustomCommands::Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration)
|
sl@0
|
1465 |
{
|
sl@0
|
1466 |
TPckgBuf<TMMFMidiConfig1> configPackage;
|
sl@0
|
1467 |
configPackage().iFadeOutDuration = aFadeOutDuration;
|
sl@0
|
1468 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1469 |
EMMFMidiControllerStop,
|
sl@0
|
1470 |
configPackage,
|
sl@0
|
1471 |
KNullDesC8);
|
sl@0
|
1472 |
}
|
sl@0
|
1473 |
|
sl@0
|
1474 |
|
sl@0
|
1475 |
/**
|
sl@0
|
1476 |
Start receiving events from the controller. This can only be called once the controller is open.
|
sl@0
|
1477 |
|
sl@0
|
1478 |
@param aSizeOfMidiEvent
|
sl@0
|
1479 |
The size of the MIDI event object.
|
sl@0
|
1480 |
@param aStatus
|
sl@0
|
1481 |
Status flag belonging to an active object that will have it's RunL() called
|
sl@0
|
1482 |
when this request complete.
|
sl@0
|
1483 |
*/
|
sl@0
|
1484 |
EXPORT_C void RMidiControllerCustomCommands::ReceiveEvents(TPckgBuf<TInt>& aSizeOfMidiEvent, TRequestStatus& aStatus)
|
sl@0
|
1485 |
{
|
sl@0
|
1486 |
iController.CustomCommandAsync(iDestinationPckg,
|
sl@0
|
1487 |
EMMFMidiControllerReceiveEvents,
|
sl@0
|
1488 |
KNullDesC8,
|
sl@0
|
1489 |
KNullDesC8,
|
sl@0
|
1490 |
aSizeOfMidiEvent,
|
sl@0
|
1491 |
aStatus);
|
sl@0
|
1492 |
}
|
sl@0
|
1493 |
|
sl@0
|
1494 |
/**
|
sl@0
|
1495 |
Get the MIDI event from the MIDI controller.
|
sl@0
|
1496 |
|
sl@0
|
1497 |
@param aMidiEventPckg
|
sl@0
|
1498 |
MIDI event.
|
sl@0
|
1499 |
@return One of the system-wide error codes.
|
sl@0
|
1500 |
*/
|
sl@0
|
1501 |
EXPORT_C TInt RMidiControllerCustomCommands::RetrieveEvent(TDes8& aMidiEventPckg)
|
sl@0
|
1502 |
{
|
sl@0
|
1503 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1504 |
EMMFMidiControllerRetrieveEvent,
|
sl@0
|
1505 |
KNullDesC8,
|
sl@0
|
1506 |
KNullDesC8,
|
sl@0
|
1507 |
aMidiEventPckg);
|
sl@0
|
1508 |
}
|
sl@0
|
1509 |
|
sl@0
|
1510 |
/**
|
sl@0
|
1511 |
Stop receiving events from the MIDI controller.
|
sl@0
|
1512 |
|
sl@0
|
1513 |
@return One of the system-wide error codes.
|
sl@0
|
1514 |
*/
|
sl@0
|
1515 |
EXPORT_C TInt RMidiControllerCustomCommands::CancelReceiveEvents()
|
sl@0
|
1516 |
{
|
sl@0
|
1517 |
return iController.CustomCommandSync(iDestinationPckg,
|
sl@0
|
1518 |
EMMFMidiControllerCancelReceiveEvents,
|
sl@0
|
1519 |
KNullDesC8,
|
sl@0
|
1520 |
KNullDesC8);
|
sl@0
|
1521 |
}
|
sl@0
|
1522 |
|
sl@0
|
1523 |
|
sl@0
|
1524 |
CMidiEventReceiver* CMidiEventReceiver::NewL(const TMMFMessage& aMessage)
|
sl@0
|
1525 |
{
|
sl@0
|
1526 |
return new(ELeave) CMidiEventReceiver(aMessage);
|
sl@0
|
1527 |
}
|
sl@0
|
1528 |
|
sl@0
|
1529 |
CMidiEventReceiver::~CMidiEventReceiver()
|
sl@0
|
1530 |
{
|
sl@0
|
1531 |
if (!(iMessage.IsCompleted()))
|
sl@0
|
1532 |
iMessage.Complete(KErrDied);
|
sl@0
|
1533 |
delete iEventBuf;
|
sl@0
|
1534 |
}
|
sl@0
|
1535 |
|
sl@0
|
1536 |
void CMidiEventReceiver::PrepareEventL(const CMMFMidiEvent& aEvent)
|
sl@0
|
1537 |
{
|
sl@0
|
1538 |
// eventbuf should be NULL. delete it anyway though to prevent memory leaks in release mode
|
sl@0
|
1539 |
ASSERT(!iEventBuf);
|
sl@0
|
1540 |
|
sl@0
|
1541 |
delete iEventBuf;
|
sl@0
|
1542 |
iEventBuf = NULL;
|
sl@0
|
1543 |
|
sl@0
|
1544 |
iEventBuf = CBufFlat::NewL(32);
|
sl@0
|
1545 |
RBufWriteStream s;
|
sl@0
|
1546 |
s.Open(*iEventBuf);
|
sl@0
|
1547 |
CleanupClosePushL(s);
|
sl@0
|
1548 |
aEvent.ExternalizeL(s);
|
sl@0
|
1549 |
CleanupStack::PopAndDestroy();//s
|
sl@0
|
1550 |
// Write the size of the externalised data back to the client
|
sl@0
|
1551 |
TPckgBuf<TInt> pckg;
|
sl@0
|
1552 |
pckg() = iEventBuf->Ptr(0).Length();
|
sl@0
|
1553 |
TInt error = iMessage.WriteDataToClient(pckg);
|
sl@0
|
1554 |
iMessage.Complete(error);
|
sl@0
|
1555 |
}
|
sl@0
|
1556 |
|
sl@0
|
1557 |
void CMidiEventReceiver::SendEventL(TMMFMessage& aMessage)
|
sl@0
|
1558 |
{
|
sl@0
|
1559 |
if (!iEventBuf)
|
sl@0
|
1560 |
{
|
sl@0
|
1561 |
User::Leave(KErrNotReady);
|
sl@0
|
1562 |
}
|
sl@0
|
1563 |
else
|
sl@0
|
1564 |
{
|
sl@0
|
1565 |
aMessage.WriteDataToClientL(iEventBuf->Ptr(0));
|
sl@0
|
1566 |
}
|
sl@0
|
1567 |
}
|
sl@0
|
1568 |
|
sl@0
|
1569 |
TBool CMidiEventReceiver::IsWaitingToSendEvent()
|
sl@0
|
1570 |
{
|
sl@0
|
1571 |
return (iEventBuf!=NULL);
|
sl@0
|
1572 |
}
|
sl@0
|
1573 |
|
sl@0
|
1574 |
CMidiEventReceiver::CMidiEventReceiver(const TMMFMessage& aMessage) : iMessage(aMessage)
|
sl@0
|
1575 |
{
|
sl@0
|
1576 |
}
|
sl@0
|
1577 |
|
sl@0
|
1578 |
|
sl@0
|
1579 |
/**
|
sl@0
|
1580 |
Constructor.
|
sl@0
|
1581 |
|
sl@0
|
1582 |
@param aEventType
|
sl@0
|
1583 |
A UID to define the type of MIDI event.
|
sl@0
|
1584 |
@param aErrorCode
|
sl@0
|
1585 |
The error code associated with the MIDI event.
|
sl@0
|
1586 |
*/
|
sl@0
|
1587 |
EXPORT_C CMMFMidiEvent::CMMFMidiEvent(TUid aEventType, TInt aErrorCode)
|
sl@0
|
1588 |
: iEventType(aEventType), iErrorCode(aErrorCode)
|
sl@0
|
1589 |
{
|
sl@0
|
1590 |
ZeroMembers();
|
sl@0
|
1591 |
}
|
sl@0
|
1592 |
|
sl@0
|
1593 |
/**
|
sl@0
|
1594 |
Default constructor.
|
sl@0
|
1595 |
*/
|
sl@0
|
1596 |
EXPORT_C CMMFMidiEvent::CMMFMidiEvent()
|
sl@0
|
1597 |
: iEventType(KNullUid), iErrorCode(KErrNone)
|
sl@0
|
1598 |
{
|
sl@0
|
1599 |
ZeroMembers();
|
sl@0
|
1600 |
}
|
sl@0
|
1601 |
|
sl@0
|
1602 |
/**
|
sl@0
|
1603 |
Set to default values all the data members.
|
sl@0
|
1604 |
*/
|
sl@0
|
1605 |
void CMMFMidiEvent::ZeroMembers()
|
sl@0
|
1606 |
{
|
sl@0
|
1607 |
iOldState = EMidiStateClosedDisengaged;
|
sl@0
|
1608 |
iNewState = EMidiStateClosedDisengaged;
|
sl@0
|
1609 |
iMicroSeconds = 0;
|
sl@0
|
1610 |
iMicroBeats = 0;
|
sl@0
|
1611 |
iChannel = 0;
|
sl@0
|
1612 |
iVolumeInDecibels = 0;
|
sl@0
|
1613 |
iMute = EFalse;
|
sl@0
|
1614 |
iMetaDataEntryId = 0;
|
sl@0
|
1615 |
iPolyphony = 0;
|
sl@0
|
1616 |
iBankId = 0;
|
sl@0
|
1617 |
iInstrumentId = 0;
|
sl@0
|
1618 |
iTempoMicroBeats = 0;
|
sl@0
|
1619 |
}
|
sl@0
|
1620 |
|
sl@0
|
1621 |
/**
|
sl@0
|
1622 |
Destructor.
|
sl@0
|
1623 |
*/
|
sl@0
|
1624 |
EXPORT_C CMMFMidiEvent::~CMMFMidiEvent()
|
sl@0
|
1625 |
{
|
sl@0
|
1626 |
iMipMessage.Close();
|
sl@0
|
1627 |
}
|
sl@0
|
1628 |
|
sl@0
|
1629 |
/**
|
sl@0
|
1630 |
Externalize the object to a stream. All the member variables will be written to the stream.
|
sl@0
|
1631 |
|
sl@0
|
1632 |
@param aStream
|
sl@0
|
1633 |
The write stream object.
|
sl@0
|
1634 |
*/
|
sl@0
|
1635 |
EXPORT_C void CMMFMidiEvent::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
1636 |
{
|
sl@0
|
1637 |
aStream << iEventType;
|
sl@0
|
1638 |
aStream.WriteInt32L(iErrorCode);
|
sl@0
|
1639 |
aStream.WriteInt32L(iOldState);
|
sl@0
|
1640 |
aStream.WriteInt32L(iNewState);
|
sl@0
|
1641 |
aStream << iMicroSeconds.Int64();
|
sl@0
|
1642 |
aStream << iMicroBeats;
|
sl@0
|
1643 |
aStream.WriteInt32L(iChannel);
|
sl@0
|
1644 |
aStream << iVolumeInDecibels;
|
sl@0
|
1645 |
aStream.WriteInt32L(iMute);
|
sl@0
|
1646 |
aStream.WriteInt32L(iMetaDataEntryId);
|
sl@0
|
1647 |
|
sl@0
|
1648 |
aStream.WriteInt32L(iMipMessage.Count());
|
sl@0
|
1649 |
for (TInt i=0; i<iMipMessage.Count(); i++)
|
sl@0
|
1650 |
{
|
sl@0
|
1651 |
aStream.WriteInt32L(iMipMessage[i].iChannel);
|
sl@0
|
1652 |
aStream.WriteInt32L(iMipMessage[i].iMIPValue);
|
sl@0
|
1653 |
}
|
sl@0
|
1654 |
|
sl@0
|
1655 |
aStream.WriteInt32L(iPolyphony);
|
sl@0
|
1656 |
aStream.WriteInt32L(iBankId);
|
sl@0
|
1657 |
aStream.WriteInt32L(iInstrumentId);
|
sl@0
|
1658 |
aStream.WriteInt32L(iTempoMicroBeats);
|
sl@0
|
1659 |
}
|
sl@0
|
1660 |
|
sl@0
|
1661 |
/**
|
sl@0
|
1662 |
Internalize the object from a stream. All the member variables will be read from the stream.
|
sl@0
|
1663 |
|
sl@0
|
1664 |
@param aStream
|
sl@0
|
1665 |
The read stream object.
|
sl@0
|
1666 |
*/
|
sl@0
|
1667 |
EXPORT_C void CMMFMidiEvent::InternalizeL(RReadStream& aStream)
|
sl@0
|
1668 |
{
|
sl@0
|
1669 |
aStream >> iEventType;
|
sl@0
|
1670 |
iErrorCode = aStream.ReadInt32L();
|
sl@0
|
1671 |
iOldState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
|
sl@0
|
1672 |
iNewState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
|
sl@0
|
1673 |
|
sl@0
|
1674 |
TInt64 microSeconds;
|
sl@0
|
1675 |
aStream >> microSeconds;
|
sl@0
|
1676 |
iMicroSeconds = microSeconds;
|
sl@0
|
1677 |
|
sl@0
|
1678 |
aStream >> iMicroBeats;
|
sl@0
|
1679 |
iChannel = aStream.ReadInt32L();
|
sl@0
|
1680 |
aStream >> iVolumeInDecibels;
|
sl@0
|
1681 |
iMute = aStream.ReadInt32L();
|
sl@0
|
1682 |
iMetaDataEntryId = aStream.ReadInt32L();
|
sl@0
|
1683 |
|
sl@0
|
1684 |
TInt count = aStream.ReadInt32L();
|
sl@0
|
1685 |
for (TInt i=0; i<count; i++)
|
sl@0
|
1686 |
{
|
sl@0
|
1687 |
TMipMessageEntry entry;
|
sl@0
|
1688 |
entry.iChannel = aStream.ReadInt32L();
|
sl@0
|
1689 |
entry.iMIPValue = aStream.ReadInt32L();
|
sl@0
|
1690 |
User::LeaveIfError(iMipMessage.Append(entry));
|
sl@0
|
1691 |
}
|
sl@0
|
1692 |
|
sl@0
|
1693 |
iPolyphony = aStream.ReadInt32L();
|
sl@0
|
1694 |
iBankId = aStream.ReadInt32L();
|
sl@0
|
1695 |
iInstrumentId = aStream.ReadInt32L();
|
sl@0
|
1696 |
iTempoMicroBeats = aStream.ReadInt32L();
|
sl@0
|
1697 |
}
|
sl@0
|
1698 |
|
sl@0
|
1699 |
/**
|
sl@0
|
1700 |
Copies a MIDI event into this CMMFMidiEvent.
|
sl@0
|
1701 |
|
sl@0
|
1702 |
@param aOther
|
sl@0
|
1703 |
The CMMFMidiEvent to copy from.
|
sl@0
|
1704 |
*/
|
sl@0
|
1705 |
EXPORT_C void CMMFMidiEvent::CopyL(const CMMFMidiEvent& aOther)
|
sl@0
|
1706 |
{
|
sl@0
|
1707 |
iEventType = aOther.iEventType;
|
sl@0
|
1708 |
iErrorCode = aOther.iErrorCode;
|
sl@0
|
1709 |
iOldState = aOther.iOldState;
|
sl@0
|
1710 |
iNewState = aOther.iNewState;
|
sl@0
|
1711 |
iMicroSeconds = aOther.iMicroSeconds;
|
sl@0
|
1712 |
iMicroBeats = aOther.iMicroBeats;
|
sl@0
|
1713 |
iChannel = aOther.iChannel;
|
sl@0
|
1714 |
iVolumeInDecibels = aOther.iVolumeInDecibels;
|
sl@0
|
1715 |
iMute = aOther.iMute;
|
sl@0
|
1716 |
iMetaDataEntryId = aOther.iMetaDataEntryId;
|
sl@0
|
1717 |
iPolyphony = aOther.iPolyphony;
|
sl@0
|
1718 |
iBankId = aOther.iBankId;
|
sl@0
|
1719 |
iInstrumentId = aOther.iInstrumentId;
|
sl@0
|
1720 |
iTempoMicroBeats = aOther.iTempoMicroBeats;
|
sl@0
|
1721 |
|
sl@0
|
1722 |
for (TInt i=0; i<aOther.iMipMessage.Count(); i++)
|
sl@0
|
1723 |
{
|
sl@0
|
1724 |
User::LeaveIfError(iMipMessage.Append(aOther.iMipMessage[i]));
|
sl@0
|
1725 |
}
|
sl@0
|
1726 |
}
|
sl@0
|
1727 |
|
sl@0
|
1728 |
|