Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <mmf/common/midistandardcustomcommands.h>
17 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
18 #include <mmf/common/mmfmidiconfig.h>
19 #include <mmf/common/midieventreceiver.h>
25 The client side controller object to be used by this custom command interface.
27 EXPORT_C RMidiControllerCustomCommands::RMidiControllerCustomCommands(RMMFController& aController) :
28 RMMFCustomCommandsBase(aController, KUidInterfaceMidi)
33 Change the position of the currently playing MIDI resource to the given position.
34 May be called whenever a MIDI resource is open.
37 Metrical position to move to. Clamped to (0, DurationMicroBeats()).
38 @return One of the system-wide error codes.
40 EXPORT_C TInt RMidiControllerCustomCommands::SetPositionMicroBeats(TInt64 aMicroBeats) const
42 TPckgBuf<TMMFMidiConfig2> configPackage;
43 configPackage().iPositionMicroBeats = aMicroBeats;
44 return iController.CustomCommandSync(iDestinationPckg,
45 EMMFMidiControllerSetPositionMicroBeats,
51 Gets the current metrical position of the MIDI resource being played.
54 (BPM*1000000) relative to the start of the resource.
55 @return One of the system-wide error codes.
57 EXPORT_C TInt RMidiControllerCustomCommands::PositionMicroBeats(TInt64& aMicroBeats) const
59 TPckgBuf<TMMFMidiConfig2> configPackage;
60 TInt error = iController.CustomCommandSync(iDestinationPckg,
61 EMMFMidiControllerPositionMicroBeats,
66 aMicroBeats = configPackage().iPositionMicroBeats;
71 Synchronous function to play a single note.
72 Multiple calls to this function will be accommodated as far as the MIDI engine can
73 manage. The same functionality could be implemented using the SendMessage function.
76 Logical channel to play note on. 0 <= aChannel <= 15.
78 Note to play. 0 <= aNote <= 127
80 Length of time to play note for.
81 @param aNoteOnVelocity
82 Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
83 @param aNoteOffVelocity
84 Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
85 @return One of the system-wide error codes.
87 EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
89 TPckgBuf<TMMFMidiConfig2> configPackage;
90 configPackage().iChannel = aChannel;
91 configPackage().iNote = aNote;
92 configPackage().iDurationMicroSeconds = aDuration;
93 configPackage().iNoteOnVelocity = aNoteOnVelocity;
94 configPackage().iNoteOffVelocity = aNoteOffVelocity;
95 return iController.CustomCommandSync(iDestinationPckg,
96 EMMFMidiControllerPlayNote,
102 Synchronous function to play a single note at a specified time.
103 Multiple calls to this function will be accommodated as far as the MIDI engine can
104 manage. The same functionality could be implemented using the SendMessage function.
107 Logical channel to play note on. 0 <= aChannel <= 15.
109 Note to play. 0 <= aNote <= 127
111 Specifies the time at which to start playing the note, relative
112 to the MIDI resource playing time or the time elapsed since Play()
113 was called if no resource is present.
115 Length of time to play note for.
116 @param aNoteOnVelocity
117 Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
118 @param aNoteOffVelocity
119 Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
120 @return One of the system-wide error codes.
122 EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
124 TPckgBuf<TMMFMidiConfig2> configPackage;
125 configPackage().iChannel = aChannel;
126 configPackage().iNote = aNote;
127 configPackage().iStartTime = aStartTime;
128 configPackage().iDurationMicroSeconds = aDuration;
129 configPackage().iNoteOnVelocity = aNoteOnVelocity;
130 configPackage().iNoteOffVelocity = aNoteOffVelocity;
131 return iController.CustomCommandSync(iDestinationPckg,
132 EMMFMidiControllerPlayNoteWithStartTime,
138 Stops the playback of all notes on the given channel, by means of an All Notes Off MIDI message.
141 Logical channel to stop notes on. 0 <= aChannel <= 15.
142 @return One of the system-wide error codes.
144 EXPORT_C TInt RMidiControllerCustomCommands::StopNotes(TInt aChannel)
146 TPckgBuf<TMMFMidiConfig2> configPackage;
147 configPackage().iChannel = aChannel;
148 return iController.CustomCommandSync(iDestinationPckg,
149 EMMFMidiControllerStopNotes,
155 Synchronous function to commence playback of a note. Multiple calls to this
156 function will be accommodated as far as the MIDI engine can manage.
159 Logical channel to play note on. 0 <= aChannel <= 15.
161 Note to play. 0 <= aNote <= 127.
163 Velocity with which to start the note. The legal integer range is
164 0 <= aVelocity <= 127, but the value zero actually causes the message
165 to be interpreted as a Note Off message instead of a Note On.
166 @return One of the system-wide error codes.
168 EXPORT_C TInt RMidiControllerCustomCommands::NoteOn(TInt aChannel, TInt aNote, TInt aVelocity)
170 TPckgBuf<TMMFMidiConfig2> configPackage;
171 configPackage().iChannel = aChannel;
172 configPackage().iNote = aNote;
173 configPackage().iNoteOnVelocity = aVelocity;
174 return iController.CustomCommandSync(iDestinationPckg,
175 EMMFMidiControllerNoteOn,
181 Synchronous function to terminate playback of a note. If no corresponding note
182 is found then no error is raised.
185 Logical channel on which the note is playing. 0 <= aChannel <= 15.
187 Note to terminate. 0 <= aNote <= 127.
189 Velocity with which to stop the note. 0 <= aVelocity <= 127. There is no
190 standard behaviour corresponding with note off velocity.
191 @return One of the system-wide error codes.
193 EXPORT_C TInt RMidiControllerCustomCommands::NoteOff(TInt aChannel,TInt aNote,TInt aVelocity)
195 TPckgBuf<TMMFMidiConfig2> configPackage;
196 configPackage().iChannel = aChannel;
197 configPackage().iNote = aNote;
198 configPackage().iNoteOffVelocity = aVelocity;
199 return iController.CustomCommandSync(iDestinationPckg,
200 EMMFMidiControllerNoteOff,
206 Gets the current playback rate factor of the currently open MIDI resource.
207 The playback rate is independent from tempo, i.e., it can be used to give
208 an overall speed factor for playback.
211 Current playback rate in percent times 1000, i.e., 100000 means original
212 playback speed, 200000 means double speed, and 50000 means half speed playback.
213 @return One of the system-wide error codes.
215 EXPORT_C TInt RMidiControllerCustomCommands::PlaybackRate(TInt& aPlayBackRate) const
217 TPckgBuf<TMMFMidiConfig3> configPackage;
218 TInt error = iController.CustomCommandSync(iDestinationPckg,
219 EMMFMidiControllerPlaybackRate,
224 aPlayBackRate = configPackage().iPlayBackRate;
229 Sets the playback rate for the playback of the current MIDI resource.
230 The playback rate is independent from tempo, i.e., it can be used to give
231 an overall speed factor for playback. May be called whether playback
232 is in progress or not.
235 Playback rate in percent times 1000, i.e., 100000 means original
236 playback speed, 200000 means double speed, and 50000 means half speed playback.
237 @return One of the system-wide error codes.
239 EXPORT_C TInt RMidiControllerCustomCommands::SetPlaybackRate(TInt aPlayBackRate)
241 TPckgBuf<TMMFMidiConfig3> configPackage;
242 configPackage().iPlayBackRate = aPlayBackRate;
243 return iController.CustomCommandSync(iDestinationPckg,
244 EMMFMidiControllerSetPlaybackRate,
250 Gets the maximum playback rate in milli-percentage from the MIDI engine.
251 @see SetPlaybackRate() for milli-percentage details.
254 Playback rate supported by MIDI player.
255 @return One of the system-wide error codes.
257 EXPORT_C TInt RMidiControllerCustomCommands::MaxPlaybackRate(TInt& aMaxRate) const
259 TPckgBuf<TMMFMidiConfig3> configPackage;
260 TInt error = iController.CustomCommandSync(iDestinationPckg,
261 EMMFMidiControllerMaxPlaybackRate,
266 aMaxRate = configPackage().iPlayBackMaxRate;
271 Gets the minimum playback rate in milli-percentage from the MIDI engine.
272 @see SetPlaybackRate() for milli-percentage details.
275 Minimum playback rate supported by MIDI player.
276 @return One of the system-wide error codes.
278 EXPORT_C TInt RMidiControllerCustomCommands::MinPlaybackRate(TInt& aMinRate) const
280 TPckgBuf<TMMFMidiConfig3> configPackage;
281 TInt error = iController.CustomCommandSync(iDestinationPckg,
282 EMMFMidiControllerMinPlaybackRate,
287 aMinRate = configPackage().iPlayBackMinRate;
292 Gets the current tempo of the currently open MIDI resource. The tempo is independent
293 from the playback rate, i.e., the resulting playback speed will be affected by both.
295 @param aMicroBeatsPerMinute
296 Tempo at the current position of the currently open resource in microbeats
297 per minute, i.e. BPM * 1000000. Filled in by the controller framework.
298 @return One of the system-wide error codes.
300 EXPORT_C TInt RMidiControllerCustomCommands::TempoMicroBeatsPerMinute(TInt& aMicroBeatsPerMinute) const
302 TPckgBuf<TMMFMidiConfig1> configPackage;
303 TInt error = iController.CustomCommandSync(iDestinationPckg,
304 EMMFMidiControllerTempo,
309 aMicroBeatsPerMinute = configPackage().iTempo;
314 Sets the tempo at which the current MIDI resource should be played. May be
315 called whether playback is in progress or not. The tempo is independent
316 from the playback rate, i.e., the resulting playback speed will be affected by both.
318 @param aMicroBeatsPerMinute
319 Tempo in microbeats per minute (BPM*1000000) to set.
320 @return One of the system-wide error codes.
322 EXPORT_C TInt RMidiControllerCustomCommands::SetTempo(TInt aMicroBeatsPerMinute)
324 TPckgBuf<TMMFMidiConfig1> configPackage;
325 configPackage().iTempo = aMicroBeatsPerMinute;
326 return iController.CustomCommandSync(iDestinationPckg,
327 EMMFMidiControllerSetTempo,
333 Gets the pitch shift in use for the currently open MIDI resource.
336 Shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
337 @return One of the system-wide error codes.
339 EXPORT_C TInt RMidiControllerCustomCommands::PitchTranspositionCents(TInt& aPitch) const
341 TPckgBuf<TMMFMidiConfig1> configPackage;
342 TInt error = iController.CustomCommandSync(iDestinationPckg,
343 EMMFMidiControllerPitch,
348 aPitch = configPackage().iPitch;
353 Sets the pitch shift to apply to the currently open MIDI resource.
354 May be called during playback.
357 Pitch shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
359 Actual pitch shift applied - may differ from the requested value due to
360 limitations of the MIDI engine.
361 @return One of the system-wide error codes.
363 EXPORT_C TInt RMidiControllerCustomCommands::SetPitchTransposition(TInt aCents, TInt& aCentsApplied)
365 TPckgBuf<TMMFMidiConfig1> configPackage;
366 configPackage().iPitch = aCents;
367 TInt err = iController.CustomCommandSync(iDestinationPckg,
368 EMMFMidiControllerSetPitch,
372 aCentsApplied = configPackage().iPitch;
377 Gets the length of the currently open MIDI resource in micro-beats.
380 Duration in microbeats (beats * 1000000).
381 @return One of the system-wide error codes.
383 EXPORT_C TInt RMidiControllerCustomCommands::DurationMicroBeats(TInt64& aDuration) const
385 TPckgBuf<TMMFMidiConfig2> configPackage;
386 TInt error = iController.CustomCommandSync(iDestinationPckg,
387 EMMFMidiControllerDurationMicroBeats,
392 aDuration = configPackage().iDurationMicroBeats;
397 Gets the number of tracks present in the currently open MIDI resource.
401 @return One of the system-wide error codes.
403 EXPORT_C TInt RMidiControllerCustomCommands::NumTracks(TInt& aTracks) const
405 TPckgBuf<TMMFMidiConfig1> configPackage;
406 TInt error = iController.CustomCommandSync(iDestinationPckg,
407 EMMFMidiControllerNumTracks,
412 aTracks = configPackage().iNumTracks;
417 Mutes or unmutes a particular track.
420 Index of the track to mute - 0 <= aTrack < NumTracksL().
422 ETrue to mute the track, EFalse to unmute it.
423 @return One of the system-wide error codes.
425 EXPORT_C TInt RMidiControllerCustomCommands::SetTrackMute(TInt aTrack, TBool aMuted) const
427 TPckgBuf<TMMFMidiConfig2> configPackage;
428 configPackage().iTrack = aTrack;
429 configPackage().iMuted = aMuted;
430 return iController.CustomCommandSync(iDestinationPckg,
431 EMMFMidiControllerSetTrackMute,
437 Gets the MIME type of the MIDI resource currently open.
440 Descriptor containing the MIDI mime type.
441 @return One of the system-wide error codes.
443 EXPORT_C TInt RMidiControllerCustomCommands::MimeType(TDes8& aMimeType) const
445 return iController.CustomCommandSync(iDestinationPckg,
446 EMMFMidiControllerMimeType,
453 Sets the frequency at which MMIDIClientUtilityObserver::MmcuoSyncUpdateL() is called
454 to allow other components to synchronise with playback of this MIDI resource.
457 Temporal interval to callback at. Used in preference to aMicroBeats if both are set.
459 Metrical interval to callback at. Set both parameters to zero to cancel.
460 @return One of the system-wide error codes.
462 EXPORT_C TInt RMidiControllerCustomCommands::SetSyncUpdateCallbackInterval(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats)
464 TPckgBuf<TMMFMidiConfig3> configPackage;
465 configPackage().iCallbackIntervalMicroSeconds = aMicroSeconds;
466 configPackage().iCallbackIntervalMicroBeats = aMicroBeats;
467 return iController.CustomCommandSync(iDestinationPckg,
468 EMMFMidiControllerSetSyncUpdateCallbackInterval,
474 Sends a single MIDI message to the MIDI engine.
477 Descriptor containing the MIDI message data. If there are several
478 MIDI messages in the buffer, only the first one is processed.
480 Number of bytes of the message buffer actually processed.
481 @return One of the system-wide error codes.
483 EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage, TInt& aBytes)
485 TPckgBuf<TMMFMidiConfig3> configPackage;
486 configPackage().iMidiMessage = &aMidiMessage;
487 TInt error = iController.CustomCommandSync(iDestinationPckg,
488 EMMFMidiControllerSendMessage,
493 aBytes = configPackage().iBytesProcessed;
498 Sends a single MIDI message, with time stamp, to the MIDI engine.
501 Descriptor containing the MIDI message data. If there are several
502 MIDI messages in the buffer, only the first one is processed.
504 The time at which to execute the message, relative to the MIDI resource playing
505 time or the time elapsed since Play() was called if no resource is present.
507 Number of bytes of the message buffer actually processed.
508 @return One of the system-wide error codes.
510 EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes)
512 TPckgBuf<TMMFMidiConfig3> configPackage;
513 configPackage().iMidiMessage = &aMidiMessage;
514 configPackage().iTimeStamp = aTime;
515 TInt error = iController.CustomCommandSync(iDestinationPckg,
516 EMMFMidiControllerSendMessageWithTimeStamp,
521 aBytes = configPackage().iBytesProcessed;
526 Sends a mip message to the MIDI engine. This is a convenience function,
527 because the same functionality could be achieved with the SendMessage() function.
530 Array of logical {channel, MIP} value pairs to send, highest priority first.
531 @return One of the system-wide error codes.
533 EXPORT_C TInt RMidiControllerCustomCommands::SendMipMessage(const RArray<TMipMessageEntry>& aEntry)
535 TPckgBuf<TMMFMidiConfig1> configPackage;
536 TArray<TMipMessageEntry> mipMessage(aEntry.Array());
537 configPackage().iMipMessage = &mipMessage;
538 return iController.CustomCommandSync(iDestinationPckg,
539 EMMFMidiControllerSendMipMessage,
545 Gets the number of standard or custom sound banks currently available.
548 Specifies whether to reference a custom or standard sound bank.
550 Number of custom or standard sound banks available.
551 @return One of the system-wide error codes.
553 EXPORT_C TInt RMidiControllerCustomCommands::NumberOfBanks(TBool aCustom, TInt& aNumBanks) const
555 TPckgBuf<TMMFMidiConfig2> configPackage;
556 configPackage().iCustom = aCustom;
557 TInt error = iController.CustomCommandSync(iDestinationPckg,
558 EMMFMidiControllerNumberOfBanks,
563 aNumBanks = configPackage().iNumBanks;
568 Gets the identifier of a sound bank. Bank identifier (aka bank number) is a
569 14-bit value consisting of MIDI bank MSB and LSB values.
572 Specifies whether to reference a custom or standard sound bank.
574 Index of sound bank where 0 <= aBankIndex < NumberOfBanks().
576 Identifier of the specified bank occupying, at most, 14 bits.
577 @return One of the system-wide error codes.
579 EXPORT_C TInt RMidiControllerCustomCommands::GetBankId(TBool aCustom, TInt aBankIndex, TInt& aBankId) const
581 TPckgBuf<TMMFMidiConfig2> configPackage;
582 configPackage().iCustom = aCustom;
583 configPackage().iBankIndex = aBankIndex;
584 TInt error = iController.CustomCommandSync(iDestinationPckg,
585 EMMFMidiControllerGetBankId,
590 aBankId = configPackage().iBankId;
596 Loads one or more custom sound banks from a file into memory for use.
597 If several banks are loaded with consequent LoadCustomBanks() function calls,
598 the banks are combined if the bank sets have conflicting bank numbers.
601 Name of the file containing the custom sound bank.
602 @param aBankCollectionIndex
603 Identifier of the custom sound bank loaded, occupying no more than 14 bits.
604 @return One of the system-wide error codes.
606 EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBank(const TDesC& aFileName,TInt& aBankCollectionIndex)
608 TPckgBuf<TMMFMidiConfig2> configPackage;
609 configPackage().iFileName = &aFileName;
610 TInt error = iController.CustomCommandSync(iDestinationPckg,
611 EMMFMidiControllerLoadCustomBank,
616 aBankCollectionIndex = configPackage().iBankId;
622 Loads one or more custom sound banks from a descriptor into memory for use.
623 If several banks are loaded with consequent LoadCustomBanks() function calls,
624 the banks are combined if the bank sets have conflicting bank numbers.
627 Descriptor containing the custom sound bank.
628 @param aBankCollectionIndex
629 Identifier of the custom sound bank loaded, occupying no more than 14 bits.
630 @return One of the system-wide error codes.
632 EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBankData(const TDesC8& aBankData,TInt& aBankCollectionIndex)
634 TPckgBuf<TMMFMidiConfig2> configPackage;
635 configPackage().iBankData = &aBankData;
636 TInt error = iController.CustomCommandSync(iDestinationPckg,
637 EMMFMidiControllerLoadCustomBankData,
642 aBankCollectionIndex = configPackage().iBankId;
648 Removes a custom sound bank from memory. Only valid for sound banks previously
649 loaded from file. Once unloaded the custom sound bank is no longer available for use.
651 @param aBankCollectionIndex
652 Identifier of the custom sound bank to unload,occupying no more than 14 bits.
653 @return One of the system-wide error codes.
655 EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomBank(TInt aBankCollectionIndex)
657 TPckgBuf<TMMFMidiConfig2> configPackage;
658 configPackage().iBankId= aBankCollectionIndex;
659 return iController.CustomCommandSync(iDestinationPckg,
660 EMMFMidiControllerUnloadCustomBank,
666 Query if a bank has been loaded to the memory.
668 @param aBankCollectionIndex
669 Identifier of the custom sound bank to check if it's in memory or not.
671 ETrue if the specified bank is in memory, EFalse otherwise.
672 @return One of the system-wide error codes.
674 EXPORT_C TInt RMidiControllerCustomCommands::CustomBankLoaded(TInt aBankCollectionIndex, TBool& aBankLoaded) const
676 TPckgBuf<TMMFMidiConfig2> configPackage;
677 configPackage().iBankId= aBankCollectionIndex;
678 TInt error = iController.CustomCommandSync(iDestinationPckg,
679 EMMFMidiControllerCustomBankLoaded,
684 aBankLoaded = configPackage().iBankLoaded;
690 Removes all custom sound banks from memory.
692 @return One of the system-wide error codes.
694 EXPORT_C TInt RMidiControllerCustomCommands::UnloadAllCustomBanks()
696 return iController.CustomCommandSync(iDestinationPckg,
697 EMMFMidiControllerUnloadAllCustomBanks,
703 Gets the number of instruments available in a given sound bank.
706 Identifier of sound bank to reference, occupying no more than 14 bits.
708 Specifies whether to reference a custom or standard sound bank.
709 @param aNumInstruments
710 Count of the number of instruments available for the specified sound bank.
711 @return One of the system-wide error codes.
713 EXPORT_C TInt RMidiControllerCustomCommands::NumberOfInstruments(TInt aBankId, TBool aCustom, TInt& aNumInstruments) const
715 TPckgBuf<TMMFMidiConfig2> configPackage;
716 configPackage().iBankId = aBankId;
717 configPackage().iCustom = aCustom;
718 TInt error = iController.CustomCommandSync(iDestinationPckg,
719 EMMFMidiControllerNumberOfInstruments,
724 aNumInstruments = configPackage().iNumInstruments;
730 Gets the identifier of an instrument.
733 Identifier of the sound bank to reference, occupying no more than 14 bits.
735 Specifies whether to reference a custom or standard sound bank.
736 @param aInstrumentIndex
737 Index of the instrument to reference where 0 <= aInstrumentIndex < NumberOfInstruments().
739 Identifier of specified instrument. This may differ from the index since the index
740 simply enumerates the instruments, whereas identifiers may not be contiguous,
741 especially where certain instruments correspond to General MIDI-defined instruments
742 but not all instruments are present. Instrument identifiers are between 0 and 127 inclusive.
743 @return One of the system-wide error codes.
745 EXPORT_C TInt RMidiControllerCustomCommands::GetInstrumentId(TInt aBankId, TBool aCustom, TInt aInstrumentIndex, TInt& aInstrumentId) const
747 TPckgBuf<TMMFMidiConfig2> configPackage;
748 configPackage().iBankId = aBankId;
749 configPackage().iCustom = aCustom;
750 configPackage().iInstrumentIndex = aInstrumentIndex;
751 TInt error = iController.CustomCommandSync(iDestinationPckg,
752 EMMFMidiControllerGetInstrumentId,
757 aInstrumentId = configPackage().iInstrumentId;
763 Gets the name of the given instrument.
766 Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
768 Specifies whether to reference a custom or standard sound bank.
770 Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
771 @return Buffer containing the name of the specified instrument. If it has no name
772 then an empty descriptor is returned.
774 EXPORT_C HBufC* RMidiControllerCustomCommands::InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const
776 // First, get the size of the instrument name so we can create a descriptor big enough to hold it
777 TPckgBuf<TMMFMidiConfig2> configPackage;
778 configPackage().iBankId = aBankId;
779 configPackage().iCustom = aCustom;
780 configPackage().iInstrumentId = aInstrumentId;
781 TPckgBuf<TInt> descriptorSizePckg;
782 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
783 EMMFMidiControllerInstrumentName,
786 descriptorSizePckg));
788 // Now create a descriptor of appropriate size and get the server to copy the data into it
789 HBufC8* instrumentNameBuffer = HBufC8::NewLC(descriptorSizePckg());
790 TPtr8 instrumentNameBufferPtr = instrumentNameBuffer->Des();
791 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
792 EMMFMidiControllerCopyInstrumentName,
795 instrumentNameBufferPtr));
797 // Stream data out of the 8bit descriptor into a 16bit descriptor
798 RDesReadStream stream;
799 stream.Open(*instrumentNameBuffer);
800 CleanupClosePushL(stream);
802 HBufC* instrumentName = HBufC::NewL(stream, KMaxTInt);
804 CleanupStack::PopAndDestroy();//stream
805 CleanupStack::PopAndDestroy(instrumentNameBuffer);
807 return instrumentName;
812 Sets a logical channel to use the given instrument.
815 Logical channel to set the instrument for. 0 <= aChannel <= 15.
817 Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
818 The bank ID is a concatenation of MIDI bank MSB and LSB values.
820 Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
821 @return One of the system-wide error codes.
823 EXPORT_C TInt RMidiControllerCustomCommands::SetInstrument(TInt aChannel,TInt aBankId,TInt aInstrumentId)
825 TPckgBuf<TMMFMidiConfig2> configPackage;
826 configPackage().iChannel = aChannel;
827 configPackage().iBankId = aBankId;
828 configPackage().iInstrumentId = aInstrumentId;
829 return iController.CustomCommandSync(iDestinationPckg,
830 EMMFMidiControllerSetInstrument,
836 Loads an individual instrument from file into custom sound bank memory for use.
837 The bank and instrument id given in the file can be mapped into different bank
838 and instrument id in memory.
841 Name of the file containing the instrument.
843 Identifier of the bank in the file from which to load the instrument,
844 occupying no more than 14 bits.
845 @param aFileInstrumentId
846 Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
848 Identifier of the custom bank in memory to load the instrument into,
849 occupying no more than 14 bits.
850 @param aMemoryInstrumentId
851 Identifier of the instrument in memory to load the new instrument into.
852 0 <= aInstrumentId <= 127.
853 @return One of the system-wide error codes.
855 EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrument(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
857 TPckgBuf<TMMFMidiConfig2> configPackage;
858 configPackage().iFileName = &aFileName;
859 configPackage().iBankId = aFileBankId;
860 configPackage().iInstrumentId = aFileInstrumentId;
861 configPackage().iMemoryBankId = aMemoryBankId;
862 configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
863 return iController.CustomCommandSync(iDestinationPckg,
864 EMMFMidiControllerLoadCustomInstrument,
871 Loads an individual instrument from descriptor into custom sound bank memory for use.
872 The bank and instrument id given in the descriptor can be mapped into different bank
873 and instrument id in memory.
875 @param aInstrumentData
876 Descriptor containing the instrument.
878 Identifier of the bank in the descriptor from which to load the instrument,
879 occupying no more than 14 bits.
880 @param aInstrumentDataId
881 Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
883 Identifier of the custom bank in memory to load the instrument into,
884 occupying no more than 14 bits.
885 @param aMemoryInstrumentId
886 Identifier of the instrument in memory to load the new instrument into.
887 0 <= aInstrumentId <= 127.
888 @return One of the system-wide error codes.
890 EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrumentData(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
892 TPckgBuf<TMMFMidiConfig2> configPackage;
893 configPackage().iInstrumentData = &aInstrumentData;
894 configPackage().iBankId = aBankDataId;
895 configPackage().iInstrumentId = aInstrumentDataId;
896 configPackage().iMemoryBankId = aMemoryBankId;
897 configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
898 return iController.CustomCommandSync(iDestinationPckg,
899 EMMFMidiControllerLoadCustomInstrumentData,
905 Removes an instrument from custom sound bank memory. Only valid for
906 instruments previously loaded from file. Once unloaded the instrument
907 is no longer available for use.
910 Identifier of the custom sound bank containing the instrument to unload,
911 occupying no more than 14 bits.
913 Identifier of the instrument to unload. 0 <= aInstrumentId <= 127.
914 @return One of the system-wide error codes.
916 EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomInstrument(TInt aCustomBankId,TInt aInstrumentId)
918 TPckgBuf<TMMFMidiConfig2> configPackage;
919 configPackage().iBankId = aCustomBankId;
920 configPackage().iInstrumentId = aInstrumentId;
921 return iController.CustomCommandSync(iDestinationPckg,
922 EMMFMidiControllerUnloadCustomInstrument,
928 Gets the name of a particular percussion key corresponding to a given note.
931 Note to query. 0 <= aNote <= 127.
933 Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
934 The bank ID is a concatenation of MIDI bank MSB and LSB values.
936 Specifies whether to reference a custom or standard sound bank.
938 Identifier of an instrument.
939 @return Descriptor containing the name of the percussion key. If the key
940 does not have a name then an empty descriptor is returned.
942 EXPORT_C HBufC* RMidiControllerCustomCommands::PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const
944 // First, get the size of the percussion key name so we can create a descriptor big enough to hold it
945 TPckgBuf<TMMFMidiConfig2> configPackage;
946 configPackage().iNote = aNote;
947 configPackage().iBankId = aBankId;
948 configPackage().iCustom = aCustom;
949 configPackage().iInstrumentId = aInstrumentId;
950 TPckgBuf<TInt> descriptorSizePckg;
951 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
952 EMMFMidiControllerPercussionKeyName,
955 descriptorSizePckg));
957 // Now create a descriptor of appropriate size and get the server to copy the data into it
958 HBufC8* keyNameBuffer = HBufC8::NewLC(descriptorSizePckg());
959 TPtr8 keyNameBufferPtr = keyNameBuffer->Des();
960 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
961 EMMFMidiControllerCopyPercussionKeyName,
966 // Stream data out of the 8bit descriptor into a 16bit descriptor
967 RDesReadStream stream;
968 stream.Open(*keyNameBuffer);
969 CleanupClosePushL(stream);
971 HBufC* keyName = HBufC::NewL(stream, KMaxTInt);
973 CleanupStack::PopAndDestroy();//stream
974 CleanupStack::PopAndDestroy(keyNameBuffer);
980 Get the stop time currently set for the MIDI resource.
983 Time at which playback will stop, relative to the start of the resource.
984 @return One of the system-wide error codes.
986 EXPORT_C TInt RMidiControllerCustomCommands::StopTime(TTimeIntervalMicroSeconds& aStopTime) const
988 TPckgBuf<TMMFMidiConfig2> configPackage;
989 TInt error = iController.CustomCommandSync(iDestinationPckg,
990 EMMFMidiControllerStopTime,
995 aStopTime = configPackage().iStopTime;
1001 Sets the stop time to use for the currently open MIDI resource
1004 Time at which playback will stop, relative to the start of the resource.
1005 Clamped to 0 and the duration of the resource.
1006 @return One of the system-wide error codes.
1008 EXPORT_C TInt RMidiControllerCustomCommands::SetStopTime(const TTimeIntervalMicroSeconds& aStopTime) const
1010 TPckgBuf<TMMFMidiConfig2> configPackage;
1011 configPackage().iStopTime = aStopTime;
1012 return iController.CustomCommandSync(iDestinationPckg,
1013 EMMFMidiControllerSetStopTime,
1019 Gets the polyphony of the MIDI engine.
1022 The number of currently active voices.
1023 @return One of the system-wide error codes.
1025 EXPORT_C TInt RMidiControllerCustomCommands::Polyphony(TInt& aNumNotes) const
1027 TPckgBuf<TMMFMidiConfig1> configPackage;
1028 TInt error = iController.CustomCommandSync(iDestinationPckg,
1029 EMMFMidiControllerPolyphony,
1034 aNumNotes = configPackage().iNumNotes;
1040 Gets the current maximum number of notes the engine can handle
1041 This can be greater than the value returned by RMidiControllerCustomCommands::Polyphony
1044 The maximum number of notes the engine can handle
1045 @return One of the system-wide error codes.
1047 EXPORT_C TInt RMidiControllerCustomCommands::MaxPolyphony(TInt& aMaxNotes) const
1049 TPckgBuf<TMMFMidiConfig1> configPackage;
1050 TInt error = iController.CustomCommandSync(iDestinationPckg,
1051 EMMFMidiControllerMaxPolyphony,
1056 aMaxNotes = configPackage().iMaxNotes;
1061 Get the maximum number of logical channels supported by the MIDI engine.
1064 The maximum number of logical channels that the MIDI engine supports,
1065 0 <= aChannels <=15.
1066 @return One of the system-wide error codes.
1068 EXPORT_C TInt RMidiControllerCustomCommands::ChannelsSupported(TInt& aChannels) const
1070 TPckgBuf<TMMFMidiConfig2> configPackage;
1071 TInt error = iController.CustomCommandSync(iDestinationPckg,
1072 EMMFMidiControllerChannelsSupported,
1077 aChannels = configPackage().iChannel;
1083 Get the current volume setting of a logical channel.
1086 Logical channel to query. 0 <= aChannel <= 15.
1088 Volume currently set on the specified channel in decibels.
1089 @return One of the system-wide error codes.
1091 EXPORT_C TInt RMidiControllerCustomCommands::ChannelVolume(TInt aChannel, TReal32& aChannelVol) const
1093 TPckgBuf<TMMFMidiConfig2> configPackage;
1094 configPackage().iChannel = aChannel;
1095 TInt error = iController.CustomCommandSync(iDestinationPckg,
1096 EMMFMidiControllerChannelVolume,
1101 aChannelVol = configPackage().iChannelVol;
1106 Gets the Maximum volume setting that may be applied to a logical channel.
1109 Maximum volume setting. Minimum value is -infinity dB, which is the
1110 smallest possible value that TReal32 supports.
1111 @return One of the system-wide error codes.
1113 EXPORT_C TInt RMidiControllerCustomCommands::MaxChannelVolume(TReal32& aMaxVol) const
1115 TPckgBuf<TMMFMidiConfig2> configPackage;
1116 TInt error = iController.CustomCommandSync(iDestinationPckg,
1117 EMMFMidiControllerMaxChannelVolume,
1122 aMaxVol = configPackage().iMaxChannelVol;
1127 Set the volume of a channel.
1130 Logical channel to set the volume on. 0 <= aChannel <= 15.
1132 The channel volume can be set within a range. The minimum
1133 channel volume is -infinity dB, which is the smallest possible
1134 value that TReal32 supports while the maximum channel volume
1135 is set via MaxVolumeL() which represents the volume level in dB
1136 corresponding to the MIDI Channel Volume controller.
1137 @return One of the system-wide error codes.
1139 EXPORT_C TInt RMidiControllerCustomCommands::SetChannelVolume(TInt aChannel,TReal32 aVolume)
1141 TPckgBuf<TMMFMidiConfig2> configPackage;
1142 configPackage().iChannel = aChannel;
1143 configPackage().iChannelVol = aVolume;
1144 return iController.CustomCommandSync(iDestinationPckg,
1145 EMMFMidiControllerSetChannelVolume,
1151 Set the muting state of a channel without changing its volume setting.
1152 When unmuted the channel goes back to its previous volume setting.
1155 Logical channel to set the mute state of. 0 <= aChannel <= 15.
1157 ETrue to mute the channel, EFalse to unmute it.
1158 @return One of the system-wide error codes.
1160 EXPORT_C TInt RMidiControllerCustomCommands::SetChannelMute(TInt aChannel,TBool aMuted)
1162 TPckgBuf<TMMFMidiConfig2> configPackage;
1163 configPackage().iChannel = aChannel;
1164 configPackage().iMuted = aMuted;
1165 return iController.CustomCommandSync(iDestinationPckg,
1166 EMMFMidiControllerSetChannelMute,
1173 Gets the overall volume of the MIDI client.
1176 The current overall volume setting.
1177 @return One of the system-wide error codes.
1179 EXPORT_C TInt RMidiControllerCustomCommands::Volume(TInt& aVolume) const
1181 TPckgBuf<TMMFMidiConfig1> configPackage;
1182 TInt error = iController.CustomCommandSync(iDestinationPckg,
1183 EMMFMidiControllerVolume,
1188 aVolume = configPackage().iVolume;
1194 Maximum volume setting that may be applied overall.
1197 Maximum volume setting. Minimum value is always zero which is silent.
1198 @return One of the system-wide error codes.
1200 EXPORT_C TInt RMidiControllerCustomCommands::MaxVolume(TInt& aMaxVolume) const
1202 TPckgBuf<TMMFMidiConfig1> configPackage;
1203 TInt error = iController.CustomCommandSync(iDestinationPckg,
1204 EMMFMidiControllerMaxVolume,
1209 aMaxVolume = configPackage().iMaxVolume;
1215 Set the overall volume of the MIDI client.
1216 This setting scales all channel volumes respectively so the actual volume
1217 that a channel is played at is (overall volume * channel volume / max volume).
1220 Overall volume setting to use.
1221 @return One of the system-wide error codes.
1223 EXPORT_C TInt RMidiControllerCustomCommands::SetVolume(TInt aVolume)
1225 TPckgBuf<TMMFMidiConfig1> configPackage;
1226 configPackage().iVolume = aVolume;
1227 return iController.CustomCommandSync(iDestinationPckg,
1228 EMMFMidiControllerSetVolume,
1234 Length of time over which the volume is faded up from zero to the current setting
1235 when playback is started.
1237 @param aRampDuration
1238 Duration of the ramping period.
1239 @return One of the system-wide error codes.
1241 EXPORT_C TInt RMidiControllerCustomCommands::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
1243 TPckgBuf<TMMFMidiConfig1> configPackage;
1244 configPackage().iRampDuration = aRampDuration;
1245 return iController.CustomCommandSync(iDestinationPckg,
1246 EMMFMidiControllerSetVolumeRamp,
1252 Get the current stereo balance value.
1255 Balance value ranging from KMMFBalanceMaxLeft to KMMFBalanceMaxRight.
1256 @return One of the system-wide error codes.
1258 EXPORT_C TInt RMidiControllerCustomCommands::GetBalance(TInt& aBalance) const
1260 TPckgBuf<TMMFMidiConfig1> configPackage;
1261 TInt error = iController.CustomCommandSync(iDestinationPckg,
1262 EMMFMidiControllerGetBalance,
1267 aBalance = configPackage().iBalance;
1272 Set the current stereo balance value.
1275 Balance value to set. Defaults to KMMFBalanceCenter to restore equal left-right balance.
1276 @return One of the system-wide error codes.
1278 EXPORT_C TInt RMidiControllerCustomCommands::SetBalance(TInt aBalance)
1280 TPckgBuf<TMMFMidiConfig1> configPackage;
1281 configPackage().iBalance = aBalance;
1282 return iController.CustomCommandSync(iDestinationPckg,
1283 EMMFMidiControllerSetBalance,
1289 Set the max polyphony the engine can handle.
1292 Max polyphony level, 1 <= Polyphony() <= aMaxNotes.
1293 @return One of the system-wide error codes.
1295 EXPORT_C TInt RMidiControllerCustomCommands::SetMaxPolyphony(TInt aMaxNotes)
1297 TPckgBuf<TMMFMidiConfig1> configPackage;
1298 configPackage().iMaxNotes = aMaxNotes;
1299 return iController.CustomCommandSync(iDestinationPckg,
1300 EMMFMidiControllerSetMaxPolyphony,
1306 Gets the number of times the current opened resources has to be repeated.
1309 The number of times the current opened resources has to be repeated.
1310 @return One of the system-wide error codes.
1312 EXPORT_C TInt RMidiControllerCustomCommands::GetRepeats(TInt& aNumRepeats) const
1314 TPckgBuf<TMMFMidiConfig1> configPackage;
1315 TInt error = iController.CustomCommandSync(iDestinationPckg,
1316 EMMFMidiControllerGetRepeats,
1321 aNumRepeats = configPackage().iNumRepeats;
1326 Set the number of times to repeat the current MIDI resource.
1327 After Stop() has been called, repeat number of times and the
1328 trailing silence are reset.
1330 @param aRepeatNumberOfTimes
1331 Number of times to repeat the resource during playback. This includes the first playing.
1332 @param aTrailingSilence
1333 Time in microseconds to pause between repeats.
1334 @return One of the system-wide error codes.
1336 EXPORT_C TInt RMidiControllerCustomCommands::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
1339 TPckgBuf<TMMFMidiConfig3> configPackage;
1340 configPackage().iRepeatNumberOfTimes = aRepeatNumberOfTimes;
1341 configPackage().iTrailingSilence = aTrailingSilence;
1342 return iController.CustomCommandSync(iDestinationPckg,
1343 EMMFMidiControllerSetRepeats,
1349 Tell the MIDI engine to use a custom bank or a standard bank.
1352 If Etrue the custom bank in memory is used otherwise the standard bank
1353 is used leaving the custom bank in memory.
1354 @return One of the system-wide error codes.
1356 EXPORT_C TInt RMidiControllerCustomCommands::SetBank(TBool aCustom)
1358 TPckgBuf<TMMFMidiConfig2> configPackage;
1359 configPackage().iCustom = aCustom;
1360 return iController.CustomCommandSync(iDestinationPckg,
1361 EMMFMidiControllerSetBank,
1367 Gets the muting status of a specific track.
1372 The mute status of the track.
1373 @return One of the system-wide error codes.
1375 EXPORT_C TInt RMidiControllerCustomCommands::IsTrackMute(TInt aTrack, TBool& aTrackMute) const
1377 TPckgBuf<TMMFMidiConfig2> configPackage;
1378 configPackage().iTrack = aTrack;
1379 TInt error = iController.CustomCommandSync(iDestinationPckg,
1380 EMMFMidiControllerIsTrackMute,
1385 aTrackMute = configPackage().iMuted;
1391 Gets the muting status of a specific channel.
1394 The channel to query.
1396 The mute status of the channel.
1397 @return One of the system-wide error codes.
1399 EXPORT_C TInt RMidiControllerCustomCommands::IsChannelMute(TInt aChannel, TBool& aChannelMute) const
1401 TPckgBuf<TMMFMidiConfig2> configPackage;
1402 configPackage().iChannel = aChannel;
1403 TInt error = iController.CustomCommandSync(iDestinationPckg,
1404 EMMFMidiControllerIsChannelMute,
1409 aChannelMute = configPackage().iMuted;
1415 Gets the instrument assigned to a specified channel.
1418 Logical channel, 0 <= aChannel <= 15.
1419 @param aInstrumentId
1420 Identifier of the instrument assigned to aChannel. 0 <= aInstrumentId <= 127.
1422 Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1423 @return One of the system-wide error codes.
1425 EXPORT_C TInt RMidiControllerCustomCommands::GetInstrument(TInt aChannel, TInt& aInstrumentId, TInt& aBankId)
1427 TPckgBuf<TMMFMidiConfig2> configPackage;
1428 configPackage().iChannel = aChannel;
1429 TInt error = iController.CustomCommandSync(iDestinationPckg,
1430 EMMFMidiControllerGetInstrument,
1436 aInstrumentId = configPackage().iInstrumentId;
1437 aBankId = configPackage().iBankId;
1443 Closes any currently open resources, such as files, descriptors or URLs in use.
1444 Does nothing if there is nothing currently open.
1446 @return One of the system-wide error codes.
1448 EXPORT_C TInt RMidiControllerCustomCommands::Close()
1450 return iController.CustomCommandSync(iDestinationPckg,
1451 EMMFMidiControllerClose,
1457 Stops playback of a resource but does not change the current position
1458 or release any resources. Pauses the internal timer if no resource is open.
1460 @param aFadeOutDuration
1461 Length of time over which the volume is faded out from the current setting to zero.
1462 @return One of the system-wide error codes.
1464 EXPORT_C TInt RMidiControllerCustomCommands::Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration)
1466 TPckgBuf<TMMFMidiConfig1> configPackage;
1467 configPackage().iFadeOutDuration = aFadeOutDuration;
1468 return iController.CustomCommandSync(iDestinationPckg,
1469 EMMFMidiControllerStop,
1476 Start receiving events from the controller. This can only be called once the controller is open.
1478 @param aSizeOfMidiEvent
1479 The size of the MIDI event object.
1481 Status flag belonging to an active object that will have it's RunL() called
1482 when this request complete.
1484 EXPORT_C void RMidiControllerCustomCommands::ReceiveEvents(TPckgBuf<TInt>& aSizeOfMidiEvent, TRequestStatus& aStatus)
1486 iController.CustomCommandAsync(iDestinationPckg,
1487 EMMFMidiControllerReceiveEvents,
1495 Get the MIDI event from the MIDI controller.
1497 @param aMidiEventPckg
1499 @return One of the system-wide error codes.
1501 EXPORT_C TInt RMidiControllerCustomCommands::RetrieveEvent(TDes8& aMidiEventPckg)
1503 return iController.CustomCommandSync(iDestinationPckg,
1504 EMMFMidiControllerRetrieveEvent,
1511 Stop receiving events from the MIDI controller.
1513 @return One of the system-wide error codes.
1515 EXPORT_C TInt RMidiControllerCustomCommands::CancelReceiveEvents()
1517 return iController.CustomCommandSync(iDestinationPckg,
1518 EMMFMidiControllerCancelReceiveEvents,
1524 CMidiEventReceiver* CMidiEventReceiver::NewL(const TMMFMessage& aMessage)
1526 return new(ELeave) CMidiEventReceiver(aMessage);
1529 CMidiEventReceiver::~CMidiEventReceiver()
1531 if (!(iMessage.IsCompleted()))
1532 iMessage.Complete(KErrDied);
1536 void CMidiEventReceiver::PrepareEventL(const CMMFMidiEvent& aEvent)
1538 // eventbuf should be NULL. delete it anyway though to prevent memory leaks in release mode
1544 iEventBuf = CBufFlat::NewL(32);
1547 CleanupClosePushL(s);
1548 aEvent.ExternalizeL(s);
1549 CleanupStack::PopAndDestroy();//s
1550 // Write the size of the externalised data back to the client
1551 TPckgBuf<TInt> pckg;
1552 pckg() = iEventBuf->Ptr(0).Length();
1553 TInt error = iMessage.WriteDataToClient(pckg);
1554 iMessage.Complete(error);
1557 void CMidiEventReceiver::SendEventL(TMMFMessage& aMessage)
1561 User::Leave(KErrNotReady);
1565 aMessage.WriteDataToClientL(iEventBuf->Ptr(0));
1569 TBool CMidiEventReceiver::IsWaitingToSendEvent()
1571 return (iEventBuf!=NULL);
1574 CMidiEventReceiver::CMidiEventReceiver(const TMMFMessage& aMessage) : iMessage(aMessage)
1583 A UID to define the type of MIDI event.
1585 The error code associated with the MIDI event.
1587 EXPORT_C CMMFMidiEvent::CMMFMidiEvent(TUid aEventType, TInt aErrorCode)
1588 : iEventType(aEventType), iErrorCode(aErrorCode)
1594 Default constructor.
1596 EXPORT_C CMMFMidiEvent::CMMFMidiEvent()
1597 : iEventType(KNullUid), iErrorCode(KErrNone)
1603 Set to default values all the data members.
1605 void CMMFMidiEvent::ZeroMembers()
1607 iOldState = EMidiStateClosedDisengaged;
1608 iNewState = EMidiStateClosedDisengaged;
1612 iVolumeInDecibels = 0;
1614 iMetaDataEntryId = 0;
1618 iTempoMicroBeats = 0;
1624 EXPORT_C CMMFMidiEvent::~CMMFMidiEvent()
1626 iMipMessage.Close();
1630 Externalize the object to a stream. All the member variables will be written to the stream.
1633 The write stream object.
1635 EXPORT_C void CMMFMidiEvent::ExternalizeL(RWriteStream& aStream) const
1637 aStream << iEventType;
1638 aStream.WriteInt32L(iErrorCode);
1639 aStream.WriteInt32L(iOldState);
1640 aStream.WriteInt32L(iNewState);
1641 aStream << iMicroSeconds.Int64();
1642 aStream << iMicroBeats;
1643 aStream.WriteInt32L(iChannel);
1644 aStream << iVolumeInDecibels;
1645 aStream.WriteInt32L(iMute);
1646 aStream.WriteInt32L(iMetaDataEntryId);
1648 aStream.WriteInt32L(iMipMessage.Count());
1649 for (TInt i=0; i<iMipMessage.Count(); i++)
1651 aStream.WriteInt32L(iMipMessage[i].iChannel);
1652 aStream.WriteInt32L(iMipMessage[i].iMIPValue);
1655 aStream.WriteInt32L(iPolyphony);
1656 aStream.WriteInt32L(iBankId);
1657 aStream.WriteInt32L(iInstrumentId);
1658 aStream.WriteInt32L(iTempoMicroBeats);
1662 Internalize the object from a stream. All the member variables will be read from the stream.
1665 The read stream object.
1667 EXPORT_C void CMMFMidiEvent::InternalizeL(RReadStream& aStream)
1669 aStream >> iEventType;
1670 iErrorCode = aStream.ReadInt32L();
1671 iOldState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
1672 iNewState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
1674 TInt64 microSeconds;
1675 aStream >> microSeconds;
1676 iMicroSeconds = microSeconds;
1678 aStream >> iMicroBeats;
1679 iChannel = aStream.ReadInt32L();
1680 aStream >> iVolumeInDecibels;
1681 iMute = aStream.ReadInt32L();
1682 iMetaDataEntryId = aStream.ReadInt32L();
1684 TInt count = aStream.ReadInt32L();
1685 for (TInt i=0; i<count; i++)
1687 TMipMessageEntry entry;
1688 entry.iChannel = aStream.ReadInt32L();
1689 entry.iMIPValue = aStream.ReadInt32L();
1690 User::LeaveIfError(iMipMessage.Append(entry));
1693 iPolyphony = aStream.ReadInt32L();
1694 iBankId = aStream.ReadInt32L();
1695 iInstrumentId = aStream.ReadInt32L();
1696 iTempoMicroBeats = aStream.ReadInt32L();
1700 Copies a MIDI event into this CMMFMidiEvent.
1703 The CMMFMidiEvent to copy from.
1705 EXPORT_C void CMMFMidiEvent::CopyL(const CMMFMidiEvent& aOther)
1707 iEventType = aOther.iEventType;
1708 iErrorCode = aOther.iErrorCode;
1709 iOldState = aOther.iOldState;
1710 iNewState = aOther.iNewState;
1711 iMicroSeconds = aOther.iMicroSeconds;
1712 iMicroBeats = aOther.iMicroBeats;
1713 iChannel = aOther.iChannel;
1714 iVolumeInDecibels = aOther.iVolumeInDecibels;
1715 iMute = aOther.iMute;
1716 iMetaDataEntryId = aOther.iMetaDataEntryId;
1717 iPolyphony = aOther.iPolyphony;
1718 iBankId = aOther.iBankId;
1719 iInstrumentId = aOther.iInstrumentId;
1720 iTempoMicroBeats = aOther.iTempoMicroBeats;
1722 for (TInt i=0; i<aOther.iMipMessage.Count(); i++)
1724 User::LeaveIfError(iMipMessage.Append(aOther.iMipMessage[i]));