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/midieventreceiver.h>
|
sl@0
|
19 |
#include <mmf/common/mmfmidiconfig.h>
|
sl@0
|
20 |
#endif
|
sl@0
|
21 |
const TInt KMimeTypeLength = 256;
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
Creates a new MIDI custom command parser capable of handling MIDI controller commands.
|
sl@0
|
26 |
|
sl@0
|
27 |
@param aImplementor A reference to the controller plugin that owns this new object.
|
sl@0
|
28 |
@leave This function may leave with one of the system-wide error codes.
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
EXPORT_C CMidiCustomCommandParser* CMidiCustomCommandParser::NewL(MMidiCustomCommandImplementor& aImplementor)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
return new(ELeave) CMidiCustomCommandParser(aImplementor);
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
CMidiCustomCommandParser::CMidiCustomCommandParser(MMidiCustomCommandImplementor& aImplementor) :
|
sl@0
|
36 |
CMMFCustomCommandParserBase(KUidInterfaceMidi),
|
sl@0
|
37 |
iImplementor(aImplementor)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
/**
|
sl@0
|
42 |
Destructor.
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
EXPORT_C CMidiCustomCommandParser::~CMidiCustomCommandParser()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
delete iMidiEventReceiver;
|
sl@0
|
47 |
delete iInstrumentName;
|
sl@0
|
48 |
delete iPercussionKeyName;
|
sl@0
|
49 |
iMidiEvents.ResetAndDestroy();
|
sl@0
|
50 |
iMidiEvents.Close();
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
Handles a request from the client. Called by the controller framework.
|
sl@0
|
55 |
|
sl@0
|
56 |
@param aMessage The message to be handled.
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
void CMidiCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
if (aMessage.Destination().InterfaceId() == KUidInterfaceMidi)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
TRAPD(error, DoHandleRequestL(aMessage));
|
sl@0
|
63 |
if (error)
|
sl@0
|
64 |
aMessage.Complete(error);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
else
|
sl@0
|
67 |
{
|
sl@0
|
68 |
aMessage.Complete(KErrNotSupported);
|
sl@0
|
69 |
}
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
void CMidiCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
TBool complete = ETrue;
|
sl@0
|
75 |
switch (aMessage.Function())
|
sl@0
|
76 |
{
|
sl@0
|
77 |
case EMMFMidiControllerSetPositionMicroBeats:
|
sl@0
|
78 |
complete = DoSetPositionMicroBeatsL(aMessage);
|
sl@0
|
79 |
break;
|
sl@0
|
80 |
case EMMFMidiControllerPositionMicroBeats:
|
sl@0
|
81 |
complete = DoPositionMicroBeatsL(aMessage);
|
sl@0
|
82 |
break;
|
sl@0
|
83 |
case EMMFMidiControllerPlayNote:
|
sl@0
|
84 |
complete = DoPlayNoteL(aMessage);
|
sl@0
|
85 |
break;
|
sl@0
|
86 |
case EMMFMidiControllerPlayNoteWithStartTime:
|
sl@0
|
87 |
complete = DoPlayNoteWithStartTimeL(aMessage);
|
sl@0
|
88 |
break;
|
sl@0
|
89 |
case EMMFMidiControllerStopNotes:
|
sl@0
|
90 |
complete = DoStopNotesL(aMessage);
|
sl@0
|
91 |
break;
|
sl@0
|
92 |
case EMMFMidiControllerNoteOn:
|
sl@0
|
93 |
complete = DoNoteOnL(aMessage);
|
sl@0
|
94 |
break;
|
sl@0
|
95 |
case EMMFMidiControllerNoteOff:
|
sl@0
|
96 |
complete = DoNoteOffL(aMessage);
|
sl@0
|
97 |
break;
|
sl@0
|
98 |
case EMMFMidiControllerPlaybackRate:
|
sl@0
|
99 |
complete = DoPlaybackRateL(aMessage);
|
sl@0
|
100 |
break;
|
sl@0
|
101 |
case EMMFMidiControllerSetPlaybackRate:
|
sl@0
|
102 |
complete = DoSetPlaybackRateL(aMessage);
|
sl@0
|
103 |
break;
|
sl@0
|
104 |
case EMMFMidiControllerMaxPlaybackRate:
|
sl@0
|
105 |
complete = DoMaxPlaybackRateL(aMessage);
|
sl@0
|
106 |
break;
|
sl@0
|
107 |
case EMMFMidiControllerMinPlaybackRate:
|
sl@0
|
108 |
complete = DoMinPlaybackRateL(aMessage);
|
sl@0
|
109 |
break;
|
sl@0
|
110 |
case EMMFMidiControllerTempo:
|
sl@0
|
111 |
complete = DoTempoMicroBeatsPerMinuteL(aMessage);
|
sl@0
|
112 |
break;
|
sl@0
|
113 |
case EMMFMidiControllerSetTempo:
|
sl@0
|
114 |
complete = DoSetTempoL(aMessage);
|
sl@0
|
115 |
break;
|
sl@0
|
116 |
case EMMFMidiControllerPitch:
|
sl@0
|
117 |
complete = DoPitchTranspositionCentsL(aMessage);
|
sl@0
|
118 |
break;
|
sl@0
|
119 |
case EMMFMidiControllerSetPitch:
|
sl@0
|
120 |
complete = DoSetPitchTranspositionL(aMessage);
|
sl@0
|
121 |
break;
|
sl@0
|
122 |
case EMMFMidiControllerDurationMicroBeats:
|
sl@0
|
123 |
complete = DoDurationMicroBeatsL(aMessage);
|
sl@0
|
124 |
break;
|
sl@0
|
125 |
case EMMFMidiControllerNumTracks:
|
sl@0
|
126 |
complete = DoNumTracksL(aMessage);
|
sl@0
|
127 |
break;
|
sl@0
|
128 |
case EMMFMidiControllerSetTrackMute:
|
sl@0
|
129 |
complete = DoSetTrackMuteL(aMessage);
|
sl@0
|
130 |
break;
|
sl@0
|
131 |
case EMMFMidiControllerMimeType:
|
sl@0
|
132 |
complete = DoMimeTypeL(aMessage);
|
sl@0
|
133 |
break;
|
sl@0
|
134 |
case EMMFMidiControllerSetSyncUpdateCallbackInterval:
|
sl@0
|
135 |
complete = DoSetSyncUpdateCallbackIntervalL(aMessage);
|
sl@0
|
136 |
break;
|
sl@0
|
137 |
case EMMFMidiControllerSendMessage:
|
sl@0
|
138 |
complete = DoSendMessageL(aMessage);
|
sl@0
|
139 |
break;
|
sl@0
|
140 |
case EMMFMidiControllerSendMessageWithTimeStamp:
|
sl@0
|
141 |
complete = DoSendMessageWithTimeStampL(aMessage);
|
sl@0
|
142 |
break;
|
sl@0
|
143 |
case EMMFMidiControllerSendMipMessage:
|
sl@0
|
144 |
complete = DoSendMipMessageL(aMessage);
|
sl@0
|
145 |
break;
|
sl@0
|
146 |
case EMMFMidiControllerNumberOfBanks:
|
sl@0
|
147 |
complete = DoNumberOfBanksL(aMessage);
|
sl@0
|
148 |
break;
|
sl@0
|
149 |
case EMMFMidiControllerGetBankId:
|
sl@0
|
150 |
complete = DoGetBankIdL(aMessage);
|
sl@0
|
151 |
break;
|
sl@0
|
152 |
case EMMFMidiControllerLoadCustomBank:
|
sl@0
|
153 |
complete = DoLoadCustomBankL(aMessage);
|
sl@0
|
154 |
break;
|
sl@0
|
155 |
case EMMFMidiControllerLoadCustomBankData:
|
sl@0
|
156 |
complete = DoLoadCustomBankDataL(aMessage);
|
sl@0
|
157 |
break;
|
sl@0
|
158 |
case EMMFMidiControllerUnloadCustomBank:
|
sl@0
|
159 |
complete = DoUnloadCustomBankL(aMessage);
|
sl@0
|
160 |
break;
|
sl@0
|
161 |
case EMMFMidiControllerCustomBankLoaded:
|
sl@0
|
162 |
complete = DoCustomBankLoadedL(aMessage);
|
sl@0
|
163 |
break;
|
sl@0
|
164 |
case EMMFMidiControllerUnloadAllCustomBanks:
|
sl@0
|
165 |
complete = DoUnloadAllCustomBanksL(aMessage);
|
sl@0
|
166 |
break;
|
sl@0
|
167 |
case EMMFMidiControllerNumberOfInstruments:
|
sl@0
|
168 |
complete = DoNumberOfInstrumentsL(aMessage);
|
sl@0
|
169 |
break;
|
sl@0
|
170 |
case EMMFMidiControllerGetInstrumentId:
|
sl@0
|
171 |
complete = DoGetInstrumentIdL(aMessage);
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
case EMMFMidiControllerInstrumentName:
|
sl@0
|
174 |
complete = DoInstrumentNameL(aMessage);
|
sl@0
|
175 |
break;
|
sl@0
|
176 |
case EMMFMidiControllerCopyInstrumentName:
|
sl@0
|
177 |
complete = DoCopyInstrumentNameL(aMessage);
|
sl@0
|
178 |
break;
|
sl@0
|
179 |
case EMMFMidiControllerSetInstrument:
|
sl@0
|
180 |
complete = DoSetInstrumentL(aMessage);
|
sl@0
|
181 |
break;
|
sl@0
|
182 |
case EMMFMidiControllerLoadCustomInstrument:
|
sl@0
|
183 |
complete = DoLoadCustomInstrumentL(aMessage);
|
sl@0
|
184 |
break;
|
sl@0
|
185 |
case EMMFMidiControllerLoadCustomInstrumentData:
|
sl@0
|
186 |
complete = DoLoadCustomInstrumentDataL(aMessage);
|
sl@0
|
187 |
break;
|
sl@0
|
188 |
case EMMFMidiControllerUnloadCustomInstrument:
|
sl@0
|
189 |
complete = DoUnloadCustomInstrumentL(aMessage);
|
sl@0
|
190 |
break;
|
sl@0
|
191 |
case EMMFMidiControllerPercussionKeyName:
|
sl@0
|
192 |
complete = DoPercussionKeyNameL(aMessage);
|
sl@0
|
193 |
break;
|
sl@0
|
194 |
case EMMFMidiControllerCopyPercussionKeyName:
|
sl@0
|
195 |
complete = DoCopyPercussionKeyNameL(aMessage);
|
sl@0
|
196 |
break;
|
sl@0
|
197 |
case EMMFMidiControllerStopTime:
|
sl@0
|
198 |
complete = DoStopTimeL(aMessage);
|
sl@0
|
199 |
break;
|
sl@0
|
200 |
case EMMFMidiControllerSetStopTime:
|
sl@0
|
201 |
complete = DoSetStopTimeL(aMessage);
|
sl@0
|
202 |
break;
|
sl@0
|
203 |
case EMMFMidiControllerPolyphony:
|
sl@0
|
204 |
complete = DoPolyphonyL(aMessage);
|
sl@0
|
205 |
break;
|
sl@0
|
206 |
case EMMFMidiControllerChannelsSupported:
|
sl@0
|
207 |
complete = DoChannelsSupportedL(aMessage);
|
sl@0
|
208 |
break;
|
sl@0
|
209 |
case EMMFMidiControllerChannelVolume:
|
sl@0
|
210 |
complete = DoChannelVolumeL(aMessage);
|
sl@0
|
211 |
break;
|
sl@0
|
212 |
case EMMFMidiControllerMaxChannelVolume:
|
sl@0
|
213 |
complete = DoMaxChannelVolumeL(aMessage);
|
sl@0
|
214 |
break;
|
sl@0
|
215 |
case EMMFMidiControllerSetChannelVolume:
|
sl@0
|
216 |
complete = DoSetChannelVolumeL(aMessage);
|
sl@0
|
217 |
break;
|
sl@0
|
218 |
case EMMFMidiControllerSetChannelMute:
|
sl@0
|
219 |
complete = DoSetChannelMuteL(aMessage);
|
sl@0
|
220 |
break;
|
sl@0
|
221 |
case EMMFMidiControllerVolume:
|
sl@0
|
222 |
complete = DoVolumeL(aMessage);
|
sl@0
|
223 |
break;
|
sl@0
|
224 |
case EMMFMidiControllerMaxVolume:
|
sl@0
|
225 |
complete = DoMaxVolumeL(aMessage);
|
sl@0
|
226 |
break;
|
sl@0
|
227 |
case EMMFMidiControllerSetVolume:
|
sl@0
|
228 |
complete = DoSetVolumeL(aMessage);
|
sl@0
|
229 |
break;
|
sl@0
|
230 |
case EMMFMidiControllerSetVolumeRamp:
|
sl@0
|
231 |
complete = DoSetVolumeRampL(aMessage);
|
sl@0
|
232 |
break;
|
sl@0
|
233 |
case EMMFMidiControllerGetBalance:
|
sl@0
|
234 |
complete = DoGetBalanceL(aMessage);
|
sl@0
|
235 |
break;
|
sl@0
|
236 |
case EMMFMidiControllerSetBalance:
|
sl@0
|
237 |
complete = DoSetBalanceL(aMessage);
|
sl@0
|
238 |
break;
|
sl@0
|
239 |
case EMMFMidiControllerSetMaxPolyphony:
|
sl@0
|
240 |
complete = DoSetMaxPolyphonyL(aMessage);
|
sl@0
|
241 |
break;
|
sl@0
|
242 |
case EMMFMidiControllerGetRepeats:
|
sl@0
|
243 |
complete = DoGetRepeatsL(aMessage);
|
sl@0
|
244 |
break;
|
sl@0
|
245 |
case EMMFMidiControllerSetRepeats:
|
sl@0
|
246 |
complete = DoSetRepeatsL(aMessage);
|
sl@0
|
247 |
break;
|
sl@0
|
248 |
case EMMFMidiControllerSetBank:
|
sl@0
|
249 |
DoSetBankL(aMessage);
|
sl@0
|
250 |
break;
|
sl@0
|
251 |
case EMMFMidiControllerIsTrackMute:
|
sl@0
|
252 |
DoIsTrackMuteL(aMessage);
|
sl@0
|
253 |
break;
|
sl@0
|
254 |
case EMMFMidiControllerIsChannelMute:
|
sl@0
|
255 |
DoIsChannelMuteL(aMessage);
|
sl@0
|
256 |
break;
|
sl@0
|
257 |
case EMMFMidiControllerGetInstrument:
|
sl@0
|
258 |
DoGetInstrumentL(aMessage);
|
sl@0
|
259 |
break;
|
sl@0
|
260 |
case EMMFMidiControllerClose:
|
sl@0
|
261 |
complete = DoCloseL(aMessage);
|
sl@0
|
262 |
break;
|
sl@0
|
263 |
case EMMFMidiControllerStop:
|
sl@0
|
264 |
complete = DoStopL(aMessage);
|
sl@0
|
265 |
break;
|
sl@0
|
266 |
case EMMFMidiControllerReceiveEvents:
|
sl@0
|
267 |
complete = DoReceiveEventsL(aMessage);
|
sl@0
|
268 |
break;
|
sl@0
|
269 |
case EMMFMidiControllerRetrieveEvent:
|
sl@0
|
270 |
complete = DoRetrieveEventL(aMessage);
|
sl@0
|
271 |
break;
|
sl@0
|
272 |
case EMMFMidiControllerCancelReceiveEvents:
|
sl@0
|
273 |
complete = DoCancelReceiveEventsL(aMessage);
|
sl@0
|
274 |
break;
|
sl@0
|
275 |
case EMMFMidiControllerMaxPolyphony:
|
sl@0
|
276 |
complete = DoMaxPolyphonyL(aMessage);
|
sl@0
|
277 |
break;
|
sl@0
|
278 |
default:
|
sl@0
|
279 |
User::Leave(KErrNotSupported);
|
sl@0
|
280 |
break;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
if (complete)
|
sl@0
|
283 |
aMessage.Complete(KErrNone);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
TBool CMidiCustomCommandParser::DoSetPositionMicroBeatsL(TMMFMessage& aMessage)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
289 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
290 |
iImplementor.MmcSetPositionMicroBeatsL(pckg().iPositionMicroBeats);
|
sl@0
|
291 |
return ETrue;
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
TBool CMidiCustomCommandParser::DoPositionMicroBeatsL(TMMFMessage& aMessage)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
TInt64 microBeats = 0;
|
sl@0
|
297 |
iImplementor.MmcPositionMicroBeatsL(microBeats);
|
sl@0
|
298 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
299 |
pckg().iPositionMicroBeats = microBeats;
|
sl@0
|
300 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
301 |
return ETrue;
|
sl@0
|
302 |
}
|
sl@0
|
303 |
|
sl@0
|
304 |
TBool CMidiCustomCommandParser::DoPlayNoteL(TMMFMessage& aMessage)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
307 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
308 |
iImplementor.MmcPlayNoteL(pckg().iChannel, pckg().iNote, pckg().iDurationMicroSeconds, pckg().iNoteOnVelocity, pckg().iNoteOffVelocity);
|
sl@0
|
309 |
return ETrue;
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
TBool CMidiCustomCommandParser::DoPlayNoteWithStartTimeL(TMMFMessage& aMessage)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
315 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
316 |
iImplementor.MmcPlayNoteL(pckg().iChannel, pckg().iNote, pckg().iStartTime, pckg().iDurationMicroSeconds, pckg().iNoteOnVelocity, pckg().iNoteOffVelocity);
|
sl@0
|
317 |
return ETrue;
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
TBool CMidiCustomCommandParser::DoStopNotesL(TMMFMessage& aMessage)
|
sl@0
|
321 |
{
|
sl@0
|
322 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
323 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
324 |
iImplementor.MmcStopNotesL(pckg().iChannel);
|
sl@0
|
325 |
return ETrue;
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
TBool CMidiCustomCommandParser::DoNoteOnL(TMMFMessage& aMessage)
|
sl@0
|
329 |
{
|
sl@0
|
330 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
331 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
332 |
iImplementor.MmcNoteOnL(pckg().iChannel, pckg().iNote, pckg().iNoteOnVelocity);
|
sl@0
|
333 |
return ETrue;
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
TBool CMidiCustomCommandParser::DoNoteOffL(TMMFMessage& aMessage)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
339 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
340 |
iImplementor.MmcNoteOffL(pckg().iChannel, pckg().iNote, pckg().iNoteOffVelocity);
|
sl@0
|
341 |
return ETrue;
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
TBool CMidiCustomCommandParser::DoPlaybackRateL(TMMFMessage& aMessage)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
TInt playBackRate;
|
sl@0
|
347 |
iImplementor.MmcPlaybackRateL(playBackRate);
|
sl@0
|
348 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
349 |
pckg().iPlayBackRate = playBackRate;
|
sl@0
|
350 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
351 |
return ETrue;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
TBool CMidiCustomCommandParser::DoSetPlaybackRateL(TMMFMessage& aMessage)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
357 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
358 |
iImplementor.MmcSetPlaybackRateL(pckg().iPlayBackRate);
|
sl@0
|
359 |
return ETrue;
|
sl@0
|
360 |
}
|
sl@0
|
361 |
|
sl@0
|
362 |
TBool CMidiCustomCommandParser::DoMaxPlaybackRateL(TMMFMessage& aMessage)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
TInt maxRate;
|
sl@0
|
365 |
iImplementor.MmcMaxPlaybackRateL(maxRate);
|
sl@0
|
366 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
367 |
pckg().iPlayBackMaxRate = maxRate;
|
sl@0
|
368 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
369 |
return ETrue;
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
TBool CMidiCustomCommandParser::DoMinPlaybackRateL(TMMFMessage& aMessage)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
TInt minRate;
|
sl@0
|
375 |
iImplementor.MmcMinPlaybackRateL(minRate);
|
sl@0
|
376 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
377 |
pckg().iPlayBackMinRate = minRate;
|
sl@0
|
378 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
379 |
return ETrue;
|
sl@0
|
380 |
}
|
sl@0
|
381 |
|
sl@0
|
382 |
TBool CMidiCustomCommandParser::DoTempoMicroBeatsPerMinuteL(TMMFMessage& aMessage)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
TInt microBeatsPerMinute;
|
sl@0
|
385 |
iImplementor.MmcTempoMicroBeatsPerMinuteL(microBeatsPerMinute);
|
sl@0
|
386 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
387 |
pckg().iTempo = microBeatsPerMinute;
|
sl@0
|
388 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
389 |
return ETrue;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
TBool CMidiCustomCommandParser::DoSetTempoL(TMMFMessage& aMessage)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
395 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
396 |
iImplementor.MmcSetTempoL(pckg().iTempo);
|
sl@0
|
397 |
return ETrue;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
TBool CMidiCustomCommandParser::DoPitchTranspositionCentsL(TMMFMessage& aMessage)
|
sl@0
|
401 |
{
|
sl@0
|
402 |
TInt pitch;
|
sl@0
|
403 |
iImplementor.MmcPitchTranspositionCentsL(pitch);
|
sl@0
|
404 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
405 |
pckg().iPitch = pitch;
|
sl@0
|
406 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
407 |
return ETrue;
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
TBool CMidiCustomCommandParser::DoSetPitchTranspositionL(TMMFMessage& aMessage)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
413 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
414 |
TInt centsApplied;
|
sl@0
|
415 |
iImplementor.MmcSetPitchTranspositionL(pckg().iPitch, centsApplied);
|
sl@0
|
416 |
pckg().iPitch = centsApplied;
|
sl@0
|
417 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
418 |
return ETrue;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
|
sl@0
|
421 |
TBool CMidiCustomCommandParser::DoDurationMicroBeatsL(TMMFMessage& aMessage)
|
sl@0
|
422 |
{
|
sl@0
|
423 |
TInt64 duration;
|
sl@0
|
424 |
iImplementor.MmcDurationMicroBeatsL(duration);
|
sl@0
|
425 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
426 |
pckg().iDurationMicroBeats = duration;
|
sl@0
|
427 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
428 |
return ETrue;
|
sl@0
|
429 |
}
|
sl@0
|
430 |
|
sl@0
|
431 |
TBool CMidiCustomCommandParser::DoNumTracksL(TMMFMessage& aMessage)
|
sl@0
|
432 |
{
|
sl@0
|
433 |
TInt numTracks;
|
sl@0
|
434 |
iImplementor.MmcNumTracksL(numTracks);
|
sl@0
|
435 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
436 |
pckg().iNumTracks = numTracks;
|
sl@0
|
437 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
438 |
return ETrue;
|
sl@0
|
439 |
}
|
sl@0
|
440 |
|
sl@0
|
441 |
TBool CMidiCustomCommandParser::DoSetTrackMuteL(TMMFMessage& aMessage)
|
sl@0
|
442 |
{
|
sl@0
|
443 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
444 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
445 |
iImplementor.MmcSetTrackMuteL(pckg().iTrack, pckg().iMuted);
|
sl@0
|
446 |
return ETrue;
|
sl@0
|
447 |
}
|
sl@0
|
448 |
|
sl@0
|
449 |
TBool CMidiCustomCommandParser::DoMimeTypeL(TMMFMessage& aMessage)
|
sl@0
|
450 |
{
|
sl@0
|
451 |
HBufC8* mimeType = HBufC8::NewL(KMimeTypeLength);
|
sl@0
|
452 |
TPtr8 des = mimeType->Des();
|
sl@0
|
453 |
CleanupStack::PushL(mimeType);
|
sl@0
|
454 |
iImplementor.MmcMimeTypeL(des);
|
sl@0
|
455 |
aMessage.WriteDataToClientL(des);
|
sl@0
|
456 |
CleanupStack::PopAndDestroy();//mimeType
|
sl@0
|
457 |
return ETrue;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
TBool CMidiCustomCommandParser::DoSetSyncUpdateCallbackIntervalL(TMMFMessage& aMessage)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
463 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
464 |
iImplementor.MmcSetSyncUpdateCallbackIntervalL(pckg().iCallbackIntervalMicroSeconds, pckg().iCallbackIntervalMicroBeats);
|
sl@0
|
465 |
return ETrue;
|
sl@0
|
466 |
}
|
sl@0
|
467 |
|
sl@0
|
468 |
TBool CMidiCustomCommandParser::DoSendMessageL(TMMFMessage& aMessage)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
471 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
472 |
TInt bytesProcessed;
|
sl@0
|
473 |
iImplementor.MmcSendMessageL(*(pckg().iMidiMessage), bytesProcessed);
|
sl@0
|
474 |
pckg().iBytesProcessed = bytesProcessed;
|
sl@0
|
475 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
476 |
return ETrue;
|
sl@0
|
477 |
}
|
sl@0
|
478 |
|
sl@0
|
479 |
TBool CMidiCustomCommandParser::DoSendMessageWithTimeStampL(TMMFMessage& aMessage)
|
sl@0
|
480 |
{
|
sl@0
|
481 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
482 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
483 |
TInt bytesProcessed;
|
sl@0
|
484 |
iImplementor.MmcSendMessageL(*(pckg().iMidiMessage), pckg().iTimeStamp, bytesProcessed);
|
sl@0
|
485 |
pckg().iBytesProcessed = bytesProcessed;
|
sl@0
|
486 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
487 |
return ETrue;
|
sl@0
|
488 |
}
|
sl@0
|
489 |
|
sl@0
|
490 |
TBool CMidiCustomCommandParser::DoSendMipMessageL(TMMFMessage& aMessage)
|
sl@0
|
491 |
{
|
sl@0
|
492 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
493 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
494 |
iImplementor.MmcSendMipMessageL(*(pckg().iMipMessage));
|
sl@0
|
495 |
return ETrue;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
TBool CMidiCustomCommandParser::DoNumberOfBanksL(TMMFMessage& aMessage)
|
sl@0
|
499 |
{
|
sl@0
|
500 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
501 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
502 |
TInt numBanks;
|
sl@0
|
503 |
iImplementor.MmcNumberOfBanksL(pckg().iCustom, numBanks);
|
sl@0
|
504 |
pckg().iNumBanks = numBanks;
|
sl@0
|
505 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
506 |
return ETrue;
|
sl@0
|
507 |
}
|
sl@0
|
508 |
|
sl@0
|
509 |
TBool CMidiCustomCommandParser::DoGetBankIdL(TMMFMessage& aMessage)
|
sl@0
|
510 |
{
|
sl@0
|
511 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
512 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
513 |
TInt bankId;
|
sl@0
|
514 |
iImplementor.MmcGetBankIdL(pckg().iCustom, pckg().iBankIndex, bankId);
|
sl@0
|
515 |
pckg().iBankId = bankId;
|
sl@0
|
516 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
517 |
return ETrue;
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
TBool CMidiCustomCommandParser::DoLoadCustomBankL(TMMFMessage& aMessage)
|
sl@0
|
521 |
{
|
sl@0
|
522 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
523 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
524 |
TInt bankId;
|
sl@0
|
525 |
iImplementor.MmcLoadCustomBankL(*(pckg().iFileName), bankId);
|
sl@0
|
526 |
pckg().iBankId = bankId;
|
sl@0
|
527 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
528 |
return ETrue;
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
TBool CMidiCustomCommandParser::DoLoadCustomBankDataL(TMMFMessage& aMessage)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
534 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
535 |
TInt bankId;
|
sl@0
|
536 |
iImplementor.MmcLoadCustomBankDataL(*(pckg().iBankData), bankId);
|
sl@0
|
537 |
pckg().iBankId = bankId;
|
sl@0
|
538 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
539 |
return ETrue;
|
sl@0
|
540 |
}
|
sl@0
|
541 |
|
sl@0
|
542 |
TBool CMidiCustomCommandParser::DoUnloadCustomBankL(TMMFMessage& aMessage)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
545 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
546 |
iImplementor.MmcUnloadCustomBankL(pckg().iBankId);
|
sl@0
|
547 |
return ETrue;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
TBool CMidiCustomCommandParser::DoCustomBankLoadedL(TMMFMessage& aMessage)
|
sl@0
|
551 |
{
|
sl@0
|
552 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
553 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
554 |
TBool bankLoaded;
|
sl@0
|
555 |
iImplementor.MmcCustomBankLoadedL(pckg().iBankId, bankLoaded);
|
sl@0
|
556 |
pckg().iBankLoaded = bankLoaded;
|
sl@0
|
557 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
558 |
return ETrue;
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
TBool CMidiCustomCommandParser::DoUnloadAllCustomBanksL(TMMFMessage& /*aMessage*/)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
iImplementor.MmcUnloadAllCustomBanksL();
|
sl@0
|
564 |
return ETrue;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
|
sl@0
|
567 |
TBool CMidiCustomCommandParser::DoNumberOfInstrumentsL(TMMFMessage& aMessage)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
570 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
571 |
TInt numInstruments;
|
sl@0
|
572 |
iImplementor.MmcNumberOfInstrumentsL(pckg().iBankId, pckg().iCustom, numInstruments);
|
sl@0
|
573 |
pckg().iNumInstruments = numInstruments;
|
sl@0
|
574 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
575 |
return ETrue;
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
TBool CMidiCustomCommandParser::DoGetInstrumentIdL(TMMFMessage& aMessage)
|
sl@0
|
579 |
{
|
sl@0
|
580 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
581 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
582 |
TInt instrumentId;
|
sl@0
|
583 |
iImplementor.MmcGetInstrumentIdL(pckg().iBankId, pckg().iCustom, pckg().iInstrumentIndex, instrumentId);
|
sl@0
|
584 |
pckg().iInstrumentId = instrumentId;
|
sl@0
|
585 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
586 |
return ETrue;
|
sl@0
|
587 |
}
|
sl@0
|
588 |
|
sl@0
|
589 |
TBool CMidiCustomCommandParser::DoInstrumentNameL(TMMFMessage& aMessage)
|
sl@0
|
590 |
{
|
sl@0
|
591 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
592 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
593 |
|
sl@0
|
594 |
// Prevent memory leaks by deleting old instrument name - something must have gone wrong in the client
|
sl@0
|
595 |
// if it already exists
|
sl@0
|
596 |
delete iInstrumentName;
|
sl@0
|
597 |
iInstrumentName = NULL;
|
sl@0
|
598 |
|
sl@0
|
599 |
// Get the instrument name from the controller
|
sl@0
|
600 |
const TDesC& instrumentName = iImplementor.MmcInstrumentNameL(pckg().iBankId, pckg().iCustom, pckg().iInstrumentId);
|
sl@0
|
601 |
|
sl@0
|
602 |
iInstrumentName = CBufFlat::NewL(32);
|
sl@0
|
603 |
RBufWriteStream stream;
|
sl@0
|
604 |
stream.Open(*iInstrumentName);
|
sl@0
|
605 |
CleanupClosePushL(stream);
|
sl@0
|
606 |
stream << instrumentName;
|
sl@0
|
607 |
CleanupStack::PopAndDestroy();//s
|
sl@0
|
608 |
|
sl@0
|
609 |
// Write the size of the descriptor back to the client
|
sl@0
|
610 |
TPckgBuf<TInt> descriptorSizePckg(iInstrumentName->Ptr(0).Length());
|
sl@0
|
611 |
aMessage.WriteDataToClientL(descriptorSizePckg);
|
sl@0
|
612 |
|
sl@0
|
613 |
return ETrue;
|
sl@0
|
614 |
}
|
sl@0
|
615 |
|
sl@0
|
616 |
TBool CMidiCustomCommandParser::DoCopyInstrumentNameL(TMMFMessage& aMessage)
|
sl@0
|
617 |
{
|
sl@0
|
618 |
if (!iInstrumentName)
|
sl@0
|
619 |
User::Leave(KErrNotReady);
|
sl@0
|
620 |
|
sl@0
|
621 |
// Copy the instrument name back to the client
|
sl@0
|
622 |
aMessage.WriteDataToClientL(iInstrumentName->Ptr(0));
|
sl@0
|
623 |
delete iInstrumentName;
|
sl@0
|
624 |
iInstrumentName = NULL;
|
sl@0
|
625 |
return ETrue;
|
sl@0
|
626 |
}
|
sl@0
|
627 |
|
sl@0
|
628 |
TBool CMidiCustomCommandParser::DoSetInstrumentL(TMMFMessage& aMessage)
|
sl@0
|
629 |
{
|
sl@0
|
630 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
631 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
632 |
iImplementor.MmcSetInstrumentL(pckg().iChannel, pckg().iBankId, pckg().iInstrumentId);
|
sl@0
|
633 |
return ETrue;
|
sl@0
|
634 |
}
|
sl@0
|
635 |
|
sl@0
|
636 |
TBool CMidiCustomCommandParser::DoLoadCustomInstrumentL(TMMFMessage& aMessage)
|
sl@0
|
637 |
{
|
sl@0
|
638 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
639 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
640 |
iImplementor.MmcLoadCustomInstrumentL(*(pckg().iFileName), pckg().iBankId, pckg().iInstrumentId, pckg().iMemoryBankId, pckg().iMemoryInstrumentId);
|
sl@0
|
641 |
return ETrue;
|
sl@0
|
642 |
}
|
sl@0
|
643 |
|
sl@0
|
644 |
TBool CMidiCustomCommandParser::DoLoadCustomInstrumentDataL(TMMFMessage& aMessage)
|
sl@0
|
645 |
{
|
sl@0
|
646 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
647 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
648 |
iImplementor.MmcLoadCustomInstrumentDataL(*(pckg().iInstrumentData), pckg().iBankId, pckg().iInstrumentId, pckg().iMemoryBankId, pckg().iMemoryInstrumentId);
|
sl@0
|
649 |
return ETrue;
|
sl@0
|
650 |
}
|
sl@0
|
651 |
|
sl@0
|
652 |
TBool CMidiCustomCommandParser::DoUnloadCustomInstrumentL(TMMFMessage& aMessage)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
655 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
656 |
iImplementor.MmcUnloadCustomInstrumentL(pckg().iBankId, pckg().iInstrumentId);
|
sl@0
|
657 |
return ETrue;
|
sl@0
|
658 |
}
|
sl@0
|
659 |
|
sl@0
|
660 |
TBool CMidiCustomCommandParser::DoPercussionKeyNameL(TMMFMessage& aMessage)
|
sl@0
|
661 |
{
|
sl@0
|
662 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
663 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
664 |
|
sl@0
|
665 |
// Prevent memory leaks by deleting old key name - something must have gone wrong in the client
|
sl@0
|
666 |
// if it already exists
|
sl@0
|
667 |
delete iPercussionKeyName;
|
sl@0
|
668 |
iPercussionKeyName = NULL;
|
sl@0
|
669 |
|
sl@0
|
670 |
const TDesC& percussionKeyName = iImplementor.MmcPercussionKeyNameL(pckg().iNote, pckg().iBankId, pckg().iCustom, pckg().iInstrumentId);
|
sl@0
|
671 |
|
sl@0
|
672 |
iPercussionKeyName = CBufFlat::NewL(32);
|
sl@0
|
673 |
RBufWriteStream stream;
|
sl@0
|
674 |
stream.Open(*iPercussionKeyName);
|
sl@0
|
675 |
CleanupClosePushL(stream);
|
sl@0
|
676 |
stream << percussionKeyName;
|
sl@0
|
677 |
CleanupStack::PopAndDestroy();//s
|
sl@0
|
678 |
|
sl@0
|
679 |
// Write the size of the descriptor back to the client
|
sl@0
|
680 |
TPckgBuf<TInt> descriptorSizePckg(iPercussionKeyName->Ptr(0).Length());
|
sl@0
|
681 |
aMessage.WriteDataToClientL(descriptorSizePckg);
|
sl@0
|
682 |
|
sl@0
|
683 |
return ETrue;
|
sl@0
|
684 |
}
|
sl@0
|
685 |
|
sl@0
|
686 |
|
sl@0
|
687 |
TBool CMidiCustomCommandParser::DoCopyPercussionKeyNameL(TMMFMessage& aMessage)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
if (!iPercussionKeyName)
|
sl@0
|
690 |
User::Leave(KErrNotReady);
|
sl@0
|
691 |
|
sl@0
|
692 |
// Copy the instrument name back to the client
|
sl@0
|
693 |
aMessage.WriteDataToClientL(iPercussionKeyName->Ptr(0));
|
sl@0
|
694 |
delete iPercussionKeyName;
|
sl@0
|
695 |
iPercussionKeyName = NULL;
|
sl@0
|
696 |
return ETrue;
|
sl@0
|
697 |
}
|
sl@0
|
698 |
|
sl@0
|
699 |
|
sl@0
|
700 |
TBool CMidiCustomCommandParser::DoStopTimeL(TMMFMessage& aMessage)
|
sl@0
|
701 |
{
|
sl@0
|
702 |
TTimeIntervalMicroSeconds stopTime;
|
sl@0
|
703 |
iImplementor.MmcStopTimeL(stopTime);
|
sl@0
|
704 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
705 |
pckg().iStopTime = stopTime;
|
sl@0
|
706 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
707 |
return ETrue;
|
sl@0
|
708 |
}
|
sl@0
|
709 |
|
sl@0
|
710 |
TBool CMidiCustomCommandParser::DoSetStopTimeL(TMMFMessage& aMessage)
|
sl@0
|
711 |
{
|
sl@0
|
712 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
713 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
714 |
iImplementor.MmcSetStopTimeL(pckg().iStopTime);
|
sl@0
|
715 |
return ETrue;
|
sl@0
|
716 |
}
|
sl@0
|
717 |
|
sl@0
|
718 |
TBool CMidiCustomCommandParser::DoPolyphonyL(TMMFMessage& aMessage)
|
sl@0
|
719 |
{
|
sl@0
|
720 |
TInt numNotes;
|
sl@0
|
721 |
iImplementor.MmcPolyphonyL(numNotes);
|
sl@0
|
722 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
723 |
pckg().iNumNotes = numNotes;
|
sl@0
|
724 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
725 |
return ETrue;
|
sl@0
|
726 |
}
|
sl@0
|
727 |
|
sl@0
|
728 |
TBool CMidiCustomCommandParser::DoMaxPolyphonyL(TMMFMessage& aMessage)
|
sl@0
|
729 |
{
|
sl@0
|
730 |
TInt maxNotes;
|
sl@0
|
731 |
iImplementor.MmcMaxPolyphonyL(maxNotes);
|
sl@0
|
732 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
733 |
pckg().iMaxNotes = maxNotes;
|
sl@0
|
734 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
735 |
return ETrue;
|
sl@0
|
736 |
}
|
sl@0
|
737 |
|
sl@0
|
738 |
TBool CMidiCustomCommandParser::DoChannelsSupportedL(TMMFMessage& aMessage)
|
sl@0
|
739 |
{
|
sl@0
|
740 |
TInt channels;
|
sl@0
|
741 |
iImplementor.MmcChannelsSupportedL(channels);
|
sl@0
|
742 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
743 |
pckg().iChannel = channels;
|
sl@0
|
744 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
745 |
return ETrue;
|
sl@0
|
746 |
}
|
sl@0
|
747 |
|
sl@0
|
748 |
TBool CMidiCustomCommandParser::DoChannelVolumeL(TMMFMessage& aMessage)
|
sl@0
|
749 |
{
|
sl@0
|
750 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
751 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
752 |
TReal32 channelVol;
|
sl@0
|
753 |
iImplementor.MmcChannelVolumeL(pckg().iChannel, channelVol);
|
sl@0
|
754 |
pckg().iChannelVol = channelVol;
|
sl@0
|
755 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
756 |
return ETrue;
|
sl@0
|
757 |
}
|
sl@0
|
758 |
|
sl@0
|
759 |
TBool CMidiCustomCommandParser::DoMaxChannelVolumeL(TMMFMessage& aMessage)
|
sl@0
|
760 |
{
|
sl@0
|
761 |
TReal32 maxVol;
|
sl@0
|
762 |
iImplementor.MmcMaxChannelVolumeL(maxVol);
|
sl@0
|
763 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
764 |
pckg().iMaxChannelVol = maxVol;
|
sl@0
|
765 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
766 |
return ETrue;
|
sl@0
|
767 |
}
|
sl@0
|
768 |
|
sl@0
|
769 |
TBool CMidiCustomCommandParser::DoSetChannelVolumeL(TMMFMessage& aMessage)
|
sl@0
|
770 |
{
|
sl@0
|
771 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
772 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
773 |
iImplementor.MmcSetChannelVolumeL(pckg().iChannel, pckg().iChannelVol);
|
sl@0
|
774 |
return ETrue;
|
sl@0
|
775 |
}
|
sl@0
|
776 |
|
sl@0
|
777 |
TBool CMidiCustomCommandParser::DoSetChannelMuteL(TMMFMessage& aMessage)
|
sl@0
|
778 |
{
|
sl@0
|
779 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
780 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
781 |
iImplementor.MmcSetChannelMuteL(pckg().iChannel, pckg().iMuted);
|
sl@0
|
782 |
return ETrue;
|
sl@0
|
783 |
}
|
sl@0
|
784 |
|
sl@0
|
785 |
TBool CMidiCustomCommandParser::DoVolumeL(TMMFMessage& aMessage)
|
sl@0
|
786 |
{
|
sl@0
|
787 |
TInt vol;
|
sl@0
|
788 |
iImplementor.MmcVolumeL(vol);
|
sl@0
|
789 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
790 |
pckg().iVolume = vol;
|
sl@0
|
791 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
792 |
return ETrue;
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
TBool CMidiCustomCommandParser::DoMaxVolumeL(TMMFMessage& aMessage)
|
sl@0
|
796 |
{
|
sl@0
|
797 |
TInt maxVol;
|
sl@0
|
798 |
iImplementor.MmcMaxVolumeL(maxVol);
|
sl@0
|
799 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
800 |
pckg().iMaxVolume = maxVol;
|
sl@0
|
801 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
802 |
return ETrue;
|
sl@0
|
803 |
}
|
sl@0
|
804 |
|
sl@0
|
805 |
TBool CMidiCustomCommandParser::DoSetVolumeL(TMMFMessage& aMessage)
|
sl@0
|
806 |
{
|
sl@0
|
807 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
808 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
809 |
iImplementor.MmcSetVolumeL(pckg().iVolume);
|
sl@0
|
810 |
return ETrue;
|
sl@0
|
811 |
}
|
sl@0
|
812 |
|
sl@0
|
813 |
TBool CMidiCustomCommandParser::DoSetVolumeRampL(TMMFMessage& aMessage)
|
sl@0
|
814 |
{
|
sl@0
|
815 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
816 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
817 |
iImplementor.MmcSetVolumeRampL(pckg().iRampDuration);
|
sl@0
|
818 |
return ETrue;
|
sl@0
|
819 |
}
|
sl@0
|
820 |
|
sl@0
|
821 |
TBool CMidiCustomCommandParser::DoGetBalanceL(TMMFMessage& aMessage)
|
sl@0
|
822 |
{
|
sl@0
|
823 |
TInt balance;
|
sl@0
|
824 |
iImplementor.MmcGetBalanceL(balance);
|
sl@0
|
825 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
826 |
pckg().iBalance = balance;
|
sl@0
|
827 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
828 |
return ETrue;
|
sl@0
|
829 |
}
|
sl@0
|
830 |
|
sl@0
|
831 |
TBool CMidiCustomCommandParser::DoSetBalanceL(TMMFMessage& aMessage)
|
sl@0
|
832 |
{
|
sl@0
|
833 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
834 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
835 |
iImplementor.MmcSetBalanceL(pckg().iBalance);
|
sl@0
|
836 |
return ETrue;
|
sl@0
|
837 |
}
|
sl@0
|
838 |
|
sl@0
|
839 |
TBool CMidiCustomCommandParser::DoSetMaxPolyphonyL(TMMFMessage& aMessage)
|
sl@0
|
840 |
{
|
sl@0
|
841 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
842 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
843 |
iImplementor.MmcSetMaxPolyphonyL(pckg().iMaxNotes);
|
sl@0
|
844 |
return ETrue;
|
sl@0
|
845 |
}
|
sl@0
|
846 |
|
sl@0
|
847 |
TBool CMidiCustomCommandParser::DoGetRepeatsL(TMMFMessage& aMessage)
|
sl@0
|
848 |
{
|
sl@0
|
849 |
TInt numRepeats;
|
sl@0
|
850 |
iImplementor.MmcGetRepeatsL(numRepeats);
|
sl@0
|
851 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
852 |
pckg().iNumRepeats = numRepeats;
|
sl@0
|
853 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
854 |
return ETrue;
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
TBool CMidiCustomCommandParser::DoSetRepeatsL(TMMFMessage& aMessage)
|
sl@0
|
858 |
{
|
sl@0
|
859 |
TPckgBuf<TMMFMidiConfig3> pckg;
|
sl@0
|
860 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
861 |
iImplementor.MmcSetRepeatsL(pckg().iRepeatNumberOfTimes, pckg().iTrailingSilence);
|
sl@0
|
862 |
return ETrue;
|
sl@0
|
863 |
}
|
sl@0
|
864 |
|
sl@0
|
865 |
TBool CMidiCustomCommandParser::DoSetBankL(TMMFMessage& aMessage)
|
sl@0
|
866 |
{
|
sl@0
|
867 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
868 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
869 |
iImplementor.MmcSetBankL(pckg().iCustom);
|
sl@0
|
870 |
return ETrue;
|
sl@0
|
871 |
}
|
sl@0
|
872 |
|
sl@0
|
873 |
TBool CMidiCustomCommandParser::DoIsTrackMuteL(TMMFMessage& aMessage)
|
sl@0
|
874 |
{
|
sl@0
|
875 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
876 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
877 |
TBool mute;
|
sl@0
|
878 |
iImplementor.MmcIsTrackMuteL(pckg().iTrack, mute);
|
sl@0
|
879 |
pckg().iMuted = mute;
|
sl@0
|
880 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
881 |
return ETrue;
|
sl@0
|
882 |
}
|
sl@0
|
883 |
|
sl@0
|
884 |
TBool CMidiCustomCommandParser::DoIsChannelMuteL(TMMFMessage& aMessage)
|
sl@0
|
885 |
{
|
sl@0
|
886 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
887 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
888 |
TBool mute;
|
sl@0
|
889 |
iImplementor.MmcIsChannelMuteL(pckg().iChannel, mute);
|
sl@0
|
890 |
pckg().iMuted = mute;
|
sl@0
|
891 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
892 |
return ETrue;
|
sl@0
|
893 |
}
|
sl@0
|
894 |
|
sl@0
|
895 |
TBool CMidiCustomCommandParser::DoGetInstrumentL(TMMFMessage& aMessage)
|
sl@0
|
896 |
{
|
sl@0
|
897 |
TPckgBuf<TMMFMidiConfig2> pckg;
|
sl@0
|
898 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
899 |
TInt instrumentId;
|
sl@0
|
900 |
TInt bankId;
|
sl@0
|
901 |
iImplementor.MmcGetInstrumentL(pckg().iChannel, instrumentId, bankId);
|
sl@0
|
902 |
pckg().iInstrumentId = instrumentId;
|
sl@0
|
903 |
pckg().iBankId = bankId;
|
sl@0
|
904 |
aMessage.WriteDataToClientL(pckg);
|
sl@0
|
905 |
return ETrue;
|
sl@0
|
906 |
}
|
sl@0
|
907 |
|
sl@0
|
908 |
TBool CMidiCustomCommandParser::DoCloseL(TMMFMessage& /*aMessage*/)
|
sl@0
|
909 |
{
|
sl@0
|
910 |
iImplementor.MmcCloseL();
|
sl@0
|
911 |
return ETrue;
|
sl@0
|
912 |
}
|
sl@0
|
913 |
|
sl@0
|
914 |
TBool CMidiCustomCommandParser::DoStopL(TMMFMessage& aMessage)
|
sl@0
|
915 |
{
|
sl@0
|
916 |
TPckgBuf<TMMFMidiConfig1> pckg;
|
sl@0
|
917 |
aMessage.ReadData1FromClientL(pckg);
|
sl@0
|
918 |
iImplementor.MmcStopL(pckg().iFadeOutDuration);
|
sl@0
|
919 |
return ETrue;
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
TBool CMidiCustomCommandParser::DoReceiveEventsL(TMMFMessage& aMessage)
|
sl@0
|
923 |
{
|
sl@0
|
924 |
if (iMidiEventReceiver)
|
sl@0
|
925 |
{
|
sl@0
|
926 |
if (iMidiEventReceiver->IsWaitingToSendEvent())
|
sl@0
|
927 |
{
|
sl@0
|
928 |
//Something must have gone wrong in the client
|
sl@0
|
929 |
// - we're waiting to get a RetrieveEvent() call, but it didn't come.
|
sl@0
|
930 |
// So, delete the existing event receiver
|
sl@0
|
931 |
delete iMidiEventReceiver;
|
sl@0
|
932 |
iMidiEventReceiver = NULL;
|
sl@0
|
933 |
}
|
sl@0
|
934 |
else
|
sl@0
|
935 |
{
|
sl@0
|
936 |
User::Leave(KErrAlreadyExists);
|
sl@0
|
937 |
}
|
sl@0
|
938 |
}
|
sl@0
|
939 |
ASSERT(!iMidiEventReceiver);
|
sl@0
|
940 |
iMidiEventReceiver = CMidiEventReceiver::NewL(aMessage);
|
sl@0
|
941 |
//send the next cached event (if any) to the client
|
sl@0
|
942 |
if (iMidiEvents.Count() > 0)
|
sl@0
|
943 |
{
|
sl@0
|
944 |
CMMFMidiEvent* midiEvent = iMidiEvents[0];
|
sl@0
|
945 |
iMidiEventReceiver->PrepareEventL(*midiEvent);
|
sl@0
|
946 |
iMidiEvents.Remove(0);
|
sl@0
|
947 |
delete midiEvent;
|
sl@0
|
948 |
}
|
sl@0
|
949 |
return EFalse;
|
sl@0
|
950 |
}
|
sl@0
|
951 |
|
sl@0
|
952 |
TBool CMidiCustomCommandParser::DoRetrieveEventL(TMMFMessage& aMessage)
|
sl@0
|
953 |
{
|
sl@0
|
954 |
if (iMidiEventReceiver)
|
sl@0
|
955 |
{
|
sl@0
|
956 |
iMidiEventReceiver->SendEventL(aMessage);
|
sl@0
|
957 |
delete iMidiEventReceiver;
|
sl@0
|
958 |
iMidiEventReceiver = NULL;
|
sl@0
|
959 |
}
|
sl@0
|
960 |
else
|
sl@0
|
961 |
{
|
sl@0
|
962 |
User::Leave(KErrNotReady);
|
sl@0
|
963 |
}
|
sl@0
|
964 |
|
sl@0
|
965 |
return ETrue;
|
sl@0
|
966 |
}
|
sl@0
|
967 |
|
sl@0
|
968 |
/**
|
sl@0
|
969 |
Sent a MIDI event back to the client.
|
sl@0
|
970 |
|
sl@0
|
971 |
@param aEvent MIDI event to be sent to the client.
|
sl@0
|
972 |
@return One of the system-wide error codes.
|
sl@0
|
973 |
*/
|
sl@0
|
974 |
TInt CMidiCustomCommandParser::SendMidiEventToClient(const CMMFMidiEvent& aEvent)
|
sl@0
|
975 |
{
|
sl@0
|
976 |
TInt error = KErrNone;
|
sl@0
|
977 |
if (iMidiEventReceiver && !iMidiEventReceiver->IsWaitingToSendEvent())
|
sl@0
|
978 |
{
|
sl@0
|
979 |
//prepare to send event to client
|
sl@0
|
980 |
TRAP(error, iMidiEventReceiver->PrepareEventL(aEvent));
|
sl@0
|
981 |
}
|
sl@0
|
982 |
else
|
sl@0
|
983 |
{
|
sl@0
|
984 |
//queue the request for later
|
sl@0
|
985 |
CMMFMidiEvent* midiEvent = new CMMFMidiEvent();
|
sl@0
|
986 |
if (!midiEvent)
|
sl@0
|
987 |
return KErrNoMemory;
|
sl@0
|
988 |
|
sl@0
|
989 |
// coverity[leave_without_push]
|
sl@0
|
990 |
TRAP(error, midiEvent->CopyL(aEvent));
|
sl@0
|
991 |
//if we've exceeded the max number of cached messages, delete the first and append this one to the end
|
sl@0
|
992 |
if (!error)
|
sl@0
|
993 |
{
|
sl@0
|
994 |
error = iMidiEvents.Append(midiEvent);
|
sl@0
|
995 |
}
|
sl@0
|
996 |
|
sl@0
|
997 |
if(error != KErrNone)
|
sl@0
|
998 |
delete midiEvent;
|
sl@0
|
999 |
}
|
sl@0
|
1000 |
return error;
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
|
sl@0
|
1003 |
|
sl@0
|
1004 |
TBool CMidiCustomCommandParser::DoCancelReceiveEventsL(TMMFMessage& /*aMessage*/)
|
sl@0
|
1005 |
{
|
sl@0
|
1006 |
delete iMidiEventReceiver;
|
sl@0
|
1007 |
iMidiEventReceiver = NULL;
|
sl@0
|
1008 |
return ETrue;
|
sl@0
|
1009 |
}
|