1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/MIDI/src/midistandardcustomcommands.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1728 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <mmf/common/midistandardcustomcommands.h>
1.20 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.21 +#include <mmf/common/mmfmidiconfig.h>
1.22 +#include <mmf/common/midieventreceiver.h>
1.23 +#endif
1.24 +
1.25 +/**
1.26 +Constructor.
1.27 +@param aController
1.28 + The client side controller object to be used by this custom command interface.
1.29 +*/
1.30 +EXPORT_C RMidiControllerCustomCommands::RMidiControllerCustomCommands(RMMFController& aController) :
1.31 + RMMFCustomCommandsBase(aController, KUidInterfaceMidi)
1.32 + {
1.33 + }
1.34 +
1.35 +/**
1.36 +Change the position of the currently playing MIDI resource to the given position.
1.37 +May be called whenever a MIDI resource is open.
1.38 +
1.39 +@param aMicroBeats
1.40 + Metrical position to move to. Clamped to (0, DurationMicroBeats()).
1.41 +@return One of the system-wide error codes.
1.42 +*/
1.43 +EXPORT_C TInt RMidiControllerCustomCommands::SetPositionMicroBeats(TInt64 aMicroBeats) const
1.44 + {
1.45 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.46 + configPackage().iPositionMicroBeats = aMicroBeats;
1.47 + return iController.CustomCommandSync(iDestinationPckg,
1.48 + EMMFMidiControllerSetPositionMicroBeats,
1.49 + configPackage,
1.50 + KNullDesC8);
1.51 + }
1.52 +
1.53 +/**
1.54 +Gets the current metrical position of the MIDI resource being played.
1.55 +
1.56 +@param aMicroBeats
1.57 + (BPM*1000000) relative to the start of the resource.
1.58 +@return One of the system-wide error codes.
1.59 +*/
1.60 +EXPORT_C TInt RMidiControllerCustomCommands::PositionMicroBeats(TInt64& aMicroBeats) const
1.61 + {
1.62 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.63 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.64 + EMMFMidiControllerPositionMicroBeats,
1.65 + KNullDesC8,
1.66 + KNullDesC8,
1.67 + configPackage);
1.68 + if (!error)
1.69 + aMicroBeats = configPackage().iPositionMicroBeats;
1.70 + return error;
1.71 + }
1.72 +
1.73 +/**
1.74 +Synchronous function to play a single note.
1.75 +Multiple calls to this function will be accommodated as far as the MIDI engine can
1.76 +manage. The same functionality could be implemented using the SendMessage function.
1.77 +
1.78 +@param aChannel
1.79 + Logical channel to play note on. 0 <= aChannel <= 15.
1.80 +@param aNote
1.81 + Note to play. 0 <= aNote <= 127
1.82 +@param aDuration
1.83 + Length of time to play note for.
1.84 +@param aNoteOnVelocity
1.85 + Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
1.86 +@param aNoteOffVelocity
1.87 + Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
1.88 +@return One of the system-wide error codes.
1.89 +*/
1.90 +EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
1.91 + {
1.92 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.93 + configPackage().iChannel = aChannel;
1.94 + configPackage().iNote = aNote;
1.95 + configPackage().iDurationMicroSeconds = aDuration;
1.96 + configPackage().iNoteOnVelocity = aNoteOnVelocity;
1.97 + configPackage().iNoteOffVelocity = aNoteOffVelocity;
1.98 + return iController.CustomCommandSync(iDestinationPckg,
1.99 + EMMFMidiControllerPlayNote,
1.100 + configPackage,
1.101 + KNullDesC8);
1.102 + }
1.103 +
1.104 +/**
1.105 +Synchronous function to play a single note at a specified time.
1.106 +Multiple calls to this function will be accommodated as far as the MIDI engine can
1.107 +manage. The same functionality could be implemented using the SendMessage function.
1.108 +
1.109 +@param aChannel
1.110 + Logical channel to play note on. 0 <= aChannel <= 15.
1.111 +@param aNote
1.112 + Note to play. 0 <= aNote <= 127
1.113 +@param aStartTime
1.114 + Specifies the time at which to start playing the note, relative
1.115 + to the MIDI resource playing time or the time elapsed since Play()
1.116 + was called if no resource is present.
1.117 +@param aDuration
1.118 + Length of time to play note for.
1.119 +@param aNoteOnVelocity
1.120 + Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127.
1.121 +@param aNoteOffVelocity
1.122 + Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127.
1.123 +@return One of the system-wide error codes.
1.124 +*/
1.125 +EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity)
1.126 + {
1.127 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.128 + configPackage().iChannel = aChannel;
1.129 + configPackage().iNote = aNote;
1.130 + configPackage().iStartTime = aStartTime;
1.131 + configPackage().iDurationMicroSeconds = aDuration;
1.132 + configPackage().iNoteOnVelocity = aNoteOnVelocity;
1.133 + configPackage().iNoteOffVelocity = aNoteOffVelocity;
1.134 + return iController.CustomCommandSync(iDestinationPckg,
1.135 + EMMFMidiControllerPlayNoteWithStartTime,
1.136 + configPackage,
1.137 + KNullDesC8);
1.138 + }
1.139 +
1.140 +/**
1.141 +Stops the playback of all notes on the given channel, by means of an All Notes Off MIDI message.
1.142 +
1.143 +@param aChannel
1.144 + Logical channel to stop notes on. 0 <= aChannel <= 15.
1.145 +@return One of the system-wide error codes.
1.146 +*/
1.147 +EXPORT_C TInt RMidiControllerCustomCommands::StopNotes(TInt aChannel)
1.148 + {
1.149 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.150 + configPackage().iChannel = aChannel;
1.151 + return iController.CustomCommandSync(iDestinationPckg,
1.152 + EMMFMidiControllerStopNotes,
1.153 + configPackage,
1.154 + KNullDesC8);
1.155 + }
1.156 +
1.157 +/**
1.158 +Synchronous function to commence playback of a note. Multiple calls to this
1.159 +function will be accommodated as far as the MIDI engine can manage.
1.160 +
1.161 +@param aChannel
1.162 + Logical channel to play note on. 0 <= aChannel <= 15.
1.163 +@param aNote
1.164 + Note to play. 0 <= aNote <= 127.
1.165 +@param aVelocity
1.166 + Velocity with which to start the note. The legal integer range is
1.167 + 0 <= aVelocity <= 127, but the value zero actually causes the message
1.168 + to be interpreted as a Note Off message instead of a Note On.
1.169 +@return One of the system-wide error codes.
1.170 +*/
1.171 +EXPORT_C TInt RMidiControllerCustomCommands::NoteOn(TInt aChannel, TInt aNote, TInt aVelocity)
1.172 + {
1.173 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.174 + configPackage().iChannel = aChannel;
1.175 + configPackage().iNote = aNote;
1.176 + configPackage().iNoteOnVelocity = aVelocity;
1.177 + return iController.CustomCommandSync(iDestinationPckg,
1.178 + EMMFMidiControllerNoteOn,
1.179 + configPackage,
1.180 + KNullDesC8);
1.181 + }
1.182 +
1.183 +/**
1.184 +Synchronous function to terminate playback of a note. If no corresponding note
1.185 +is found then no error is raised.
1.186 +
1.187 +@param aChannel
1.188 + Logical channel on which the note is playing. 0 <= aChannel <= 15.
1.189 +@param aNote
1.190 + Note to terminate. 0 <= aNote <= 127.
1.191 +@param aVelocity
1.192 + Velocity with which to stop the note. 0 <= aVelocity <= 127. There is no
1.193 + standard behaviour corresponding with note off velocity.
1.194 +@return One of the system-wide error codes.
1.195 +*/
1.196 +EXPORT_C TInt RMidiControllerCustomCommands::NoteOff(TInt aChannel,TInt aNote,TInt aVelocity)
1.197 + {
1.198 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.199 + configPackage().iChannel = aChannel;
1.200 + configPackage().iNote = aNote;
1.201 + configPackage().iNoteOffVelocity = aVelocity;
1.202 + return iController.CustomCommandSync(iDestinationPckg,
1.203 + EMMFMidiControllerNoteOff,
1.204 + configPackage,
1.205 + KNullDesC8);
1.206 + }
1.207 +
1.208 +/**
1.209 +Gets the current playback rate factor of the currently open MIDI resource.
1.210 +The playback rate is independent from tempo, i.e., it can be used to give
1.211 +an overall speed factor for playback.
1.212 +
1.213 +@param aPlayBackRate
1.214 + Current playback rate in percent times 1000, i.e., 100000 means original
1.215 + playback speed, 200000 means double speed, and 50000 means half speed playback.
1.216 +@return One of the system-wide error codes.
1.217 +*/
1.218 +EXPORT_C TInt RMidiControllerCustomCommands::PlaybackRate(TInt& aPlayBackRate) const
1.219 + {
1.220 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.221 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.222 + EMMFMidiControllerPlaybackRate,
1.223 + KNullDesC8,
1.224 + KNullDesC8,
1.225 + configPackage);
1.226 + if (!error)
1.227 + aPlayBackRate = configPackage().iPlayBackRate;
1.228 + return error;
1.229 + }
1.230 +
1.231 +/**
1.232 +Sets the playback rate for the playback of the current MIDI resource.
1.233 +The playback rate is independent from tempo, i.e., it can be used to give
1.234 +an overall speed factor for playback. May be called whether playback
1.235 +is in progress or not.
1.236 +
1.237 +@param aPlayBackRate
1.238 + Playback rate in percent times 1000, i.e., 100000 means original
1.239 + playback speed, 200000 means double speed, and 50000 means half speed playback.
1.240 +@return One of the system-wide error codes.
1.241 +*/
1.242 +EXPORT_C TInt RMidiControllerCustomCommands::SetPlaybackRate(TInt aPlayBackRate)
1.243 + {
1.244 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.245 + configPackage().iPlayBackRate = aPlayBackRate;
1.246 + return iController.CustomCommandSync(iDestinationPckg,
1.247 + EMMFMidiControllerSetPlaybackRate,
1.248 + configPackage,
1.249 + KNullDesC8);
1.250 + }
1.251 +
1.252 +/**
1.253 +Gets the maximum playback rate in milli-percentage from the MIDI engine.
1.254 +@see SetPlaybackRate() for milli-percentage details.
1.255 +
1.256 +@param aMaxRate
1.257 + Playback rate supported by MIDI player.
1.258 +@return One of the system-wide error codes.
1.259 +*/
1.260 +EXPORT_C TInt RMidiControllerCustomCommands::MaxPlaybackRate(TInt& aMaxRate) const
1.261 + {
1.262 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.263 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.264 + EMMFMidiControllerMaxPlaybackRate,
1.265 + KNullDesC8,
1.266 + KNullDesC8,
1.267 + configPackage);
1.268 + if (!error)
1.269 + aMaxRate = configPackage().iPlayBackMaxRate;
1.270 + return error;
1.271 + }
1.272 +
1.273 +/**
1.274 +Gets the minimum playback rate in milli-percentage from the MIDI engine.
1.275 +@see SetPlaybackRate() for milli-percentage details.
1.276 +
1.277 +@param aMinRate
1.278 + Minimum playback rate supported by MIDI player.
1.279 +@return One of the system-wide error codes.
1.280 +*/
1.281 +EXPORT_C TInt RMidiControllerCustomCommands::MinPlaybackRate(TInt& aMinRate) const
1.282 + {
1.283 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.284 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.285 + EMMFMidiControllerMinPlaybackRate,
1.286 + KNullDesC8,
1.287 + KNullDesC8,
1.288 + configPackage);
1.289 + if (!error)
1.290 + aMinRate = configPackage().iPlayBackMinRate;
1.291 + return error;
1.292 + }
1.293 +
1.294 +/**
1.295 +Gets the current tempo of the currently open MIDI resource. The tempo is independent
1.296 +from the playback rate, i.e., the resulting playback speed will be affected by both.
1.297 +
1.298 +@param aMicroBeatsPerMinute
1.299 + Tempo at the current position of the currently open resource in microbeats
1.300 + per minute, i.e. BPM * 1000000. Filled in by the controller framework.
1.301 +@return One of the system-wide error codes.
1.302 +*/
1.303 +EXPORT_C TInt RMidiControllerCustomCommands::TempoMicroBeatsPerMinute(TInt& aMicroBeatsPerMinute) const
1.304 + {
1.305 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.306 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.307 + EMMFMidiControllerTempo,
1.308 + KNullDesC8,
1.309 + KNullDesC8,
1.310 + configPackage);
1.311 + if (!error)
1.312 + aMicroBeatsPerMinute = configPackage().iTempo;
1.313 + return error;
1.314 + }
1.315 +
1.316 +/**
1.317 +Sets the tempo at which the current MIDI resource should be played. May be
1.318 +called whether playback is in progress or not. The tempo is independent
1.319 +from the playback rate, i.e., the resulting playback speed will be affected by both.
1.320 +
1.321 +@param aMicroBeatsPerMinute
1.322 + Tempo in microbeats per minute (BPM*1000000) to set.
1.323 +@return One of the system-wide error codes.
1.324 +*/
1.325 +EXPORT_C TInt RMidiControllerCustomCommands::SetTempo(TInt aMicroBeatsPerMinute)
1.326 + {
1.327 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.328 + configPackage().iTempo = aMicroBeatsPerMinute;
1.329 + return iController.CustomCommandSync(iDestinationPckg,
1.330 + EMMFMidiControllerSetTempo,
1.331 + configPackage,
1.332 + KNullDesC8);
1.333 + }
1.334 +
1.335 +/**
1.336 +Gets the pitch shift in use for the currently open MIDI resource.
1.337 +
1.338 +@param aPitch
1.339 + Shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
1.340 +@return One of the system-wide error codes.
1.341 +*/
1.342 +EXPORT_C TInt RMidiControllerCustomCommands::PitchTranspositionCents(TInt& aPitch) const
1.343 + {
1.344 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.345 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.346 + EMMFMidiControllerPitch,
1.347 + KNullDesC8,
1.348 + KNullDesC8,
1.349 + configPackage);
1.350 + if (!error)
1.351 + aPitch = configPackage().iPitch;
1.352 + return error;
1.353 + }
1.354 +
1.355 +/**
1.356 +Sets the pitch shift to apply to the currently open MIDI resource.
1.357 +May be called during playback.
1.358 +
1.359 +@param aCents
1.360 + Pitch shift in cents, i.e. semitones * 100. One octave equals 1200 cents.
1.361 +@param aCentsApplied
1.362 + Actual pitch shift applied - may differ from the requested value due to
1.363 + limitations of the MIDI engine.
1.364 +@return One of the system-wide error codes.
1.365 +*/
1.366 +EXPORT_C TInt RMidiControllerCustomCommands::SetPitchTransposition(TInt aCents, TInt& aCentsApplied)
1.367 + {
1.368 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.369 + configPackage().iPitch = aCents;
1.370 + TInt err = iController.CustomCommandSync(iDestinationPckg,
1.371 + EMMFMidiControllerSetPitch,
1.372 + configPackage,
1.373 + KNullDesC8,
1.374 + configPackage);
1.375 + aCentsApplied = configPackage().iPitch;
1.376 + return err;
1.377 + }
1.378 +
1.379 +/**
1.380 +Gets the length of the currently open MIDI resource in micro-beats.
1.381 +
1.382 +@param aDuration
1.383 + Duration in microbeats (beats * 1000000).
1.384 +@return One of the system-wide error codes.
1.385 +*/
1.386 +EXPORT_C TInt RMidiControllerCustomCommands::DurationMicroBeats(TInt64& aDuration) const
1.387 + {
1.388 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.389 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.390 + EMMFMidiControllerDurationMicroBeats,
1.391 + KNullDesC8,
1.392 + KNullDesC8,
1.393 + configPackage);
1.394 + if (!error)
1.395 + aDuration = configPackage().iDurationMicroBeats;
1.396 + return error;
1.397 + }
1.398 +
1.399 +/**
1.400 +Gets the number of tracks present in the currently open MIDI resource.
1.401 +
1.402 +@param aTracks
1.403 + Number of tracks.
1.404 +@return One of the system-wide error codes.
1.405 +*/
1.406 +EXPORT_C TInt RMidiControllerCustomCommands::NumTracks(TInt& aTracks) const
1.407 + {
1.408 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.409 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.410 + EMMFMidiControllerNumTracks,
1.411 + KNullDesC8,
1.412 + KNullDesC8,
1.413 + configPackage);
1.414 + if (!error)
1.415 + aTracks = configPackage().iNumTracks;
1.416 + return error;
1.417 + }
1.418 +
1.419 +/**
1.420 +Mutes or unmutes a particular track.
1.421 +
1.422 +@param aTrack
1.423 + Index of the track to mute - 0 <= aTrack < NumTracksL().
1.424 +@param aMuted
1.425 + ETrue to mute the track, EFalse to unmute it.
1.426 +@return One of the system-wide error codes.
1.427 +*/
1.428 +EXPORT_C TInt RMidiControllerCustomCommands::SetTrackMute(TInt aTrack, TBool aMuted) const
1.429 + {
1.430 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.431 + configPackage().iTrack = aTrack;
1.432 + configPackage().iMuted = aMuted;
1.433 + return iController.CustomCommandSync(iDestinationPckg,
1.434 + EMMFMidiControllerSetTrackMute,
1.435 + configPackage,
1.436 + KNullDesC8);
1.437 + }
1.438 +
1.439 +/**
1.440 +Gets the MIME type of the MIDI resource currently open.
1.441 +
1.442 +@param aMimeType
1.443 + Descriptor containing the MIDI mime type.
1.444 +@return One of the system-wide error codes.
1.445 +*/
1.446 +EXPORT_C TInt RMidiControllerCustomCommands::MimeType(TDes8& aMimeType) const
1.447 + {
1.448 + return iController.CustomCommandSync(iDestinationPckg,
1.449 + EMMFMidiControllerMimeType,
1.450 + KNullDesC8,
1.451 + KNullDesC8,
1.452 + aMimeType);
1.453 + }
1.454 +
1.455 +/**
1.456 +Sets the frequency at which MMIDIClientUtilityObserver::MmcuoSyncUpdateL() is called
1.457 +to allow other components to synchronise with playback of this MIDI resource.
1.458 +
1.459 +@param aMicroSeconds
1.460 + Temporal interval to callback at. Used in preference to aMicroBeats if both are set.
1.461 +@param aMicroBeats
1.462 + Metrical interval to callback at. Set both parameters to zero to cancel.
1.463 +@return One of the system-wide error codes.
1.464 +*/
1.465 +EXPORT_C TInt RMidiControllerCustomCommands::SetSyncUpdateCallbackInterval(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats)
1.466 + {
1.467 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.468 + configPackage().iCallbackIntervalMicroSeconds = aMicroSeconds;
1.469 + configPackage().iCallbackIntervalMicroBeats = aMicroBeats;
1.470 + return iController.CustomCommandSync(iDestinationPckg,
1.471 + EMMFMidiControllerSetSyncUpdateCallbackInterval,
1.472 + configPackage,
1.473 + KNullDesC8);
1.474 + }
1.475 +
1.476 +/**
1.477 +Sends a single MIDI message to the MIDI engine.
1.478 +
1.479 +@param aMidiMessage
1.480 + Descriptor containing the MIDI message data. If there are several
1.481 + MIDI messages in the buffer, only the first one is processed.
1.482 +@param aBytes
1.483 + Number of bytes of the message buffer actually processed.
1.484 +@return One of the system-wide error codes.
1.485 +*/
1.486 +EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage, TInt& aBytes)
1.487 + {
1.488 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.489 + configPackage().iMidiMessage = &aMidiMessage;
1.490 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.491 + EMMFMidiControllerSendMessage,
1.492 + configPackage,
1.493 + KNullDesC8,
1.494 + configPackage);
1.495 + if (!error)
1.496 + aBytes = configPackage().iBytesProcessed;
1.497 + return error;
1.498 + }
1.499 +
1.500 +/**
1.501 +Sends a single MIDI message, with time stamp, to the MIDI engine.
1.502 +
1.503 +@param aMidiMessage
1.504 + Descriptor containing the MIDI message data. If there are several
1.505 + MIDI messages in the buffer, only the first one is processed.
1.506 +@param aTime
1.507 + The time at which to execute the message, relative to the MIDI resource playing
1.508 + time or the time elapsed since Play() was called if no resource is present.
1.509 +@param aBytes
1.510 + Number of bytes of the message buffer actually processed.
1.511 +@return One of the system-wide error codes.
1.512 +*/
1.513 +EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes)
1.514 + {
1.515 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.516 + configPackage().iMidiMessage = &aMidiMessage;
1.517 + configPackage().iTimeStamp = aTime;
1.518 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.519 + EMMFMidiControllerSendMessageWithTimeStamp,
1.520 + configPackage,
1.521 + KNullDesC8,
1.522 + configPackage);
1.523 + if (!error)
1.524 + aBytes = configPackage().iBytesProcessed;
1.525 + return error;
1.526 + }
1.527 +
1.528 +/**
1.529 +Sends a mip message to the MIDI engine. This is a convenience function,
1.530 +because the same functionality could be achieved with the SendMessage() function.
1.531 +
1.532 +@param aEntry
1.533 + Array of logical {channel, MIP} value pairs to send, highest priority first.
1.534 +@return One of the system-wide error codes.
1.535 +*/
1.536 +EXPORT_C TInt RMidiControllerCustomCommands::SendMipMessage(const RArray<TMipMessageEntry>& aEntry)
1.537 + {
1.538 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.539 + TArray<TMipMessageEntry> mipMessage(aEntry.Array());
1.540 + configPackage().iMipMessage = &mipMessage;
1.541 + return iController.CustomCommandSync(iDestinationPckg,
1.542 + EMMFMidiControllerSendMipMessage,
1.543 + configPackage,
1.544 + KNullDesC8);
1.545 + }
1.546 +
1.547 +/**
1.548 +Gets the number of standard or custom sound banks currently available.
1.549 +
1.550 +@param aCustom
1.551 + Specifies whether to reference a custom or standard sound bank.
1.552 +@param aNumBanks
1.553 + Number of custom or standard sound banks available.
1.554 +@return One of the system-wide error codes.
1.555 +*/
1.556 +EXPORT_C TInt RMidiControllerCustomCommands::NumberOfBanks(TBool aCustom, TInt& aNumBanks) const
1.557 + {
1.558 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.559 + configPackage().iCustom = aCustom;
1.560 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.561 + EMMFMidiControllerNumberOfBanks,
1.562 + configPackage,
1.563 + KNullDesC8,
1.564 + configPackage);
1.565 + if (!error)
1.566 + aNumBanks = configPackage().iNumBanks;
1.567 + return error;
1.568 + }
1.569 +
1.570 +/**
1.571 +Gets the identifier of a sound bank. Bank identifier (aka bank number) is a
1.572 +14-bit value consisting of MIDI bank MSB and LSB values.
1.573 +
1.574 +@param aCustom
1.575 + Specifies whether to reference a custom or standard sound bank.
1.576 +@param aBankIndex
1.577 + Index of sound bank where 0 <= aBankIndex < NumberOfBanks().
1.578 +@param aBankId
1.579 + Identifier of the specified bank occupying, at most, 14 bits.
1.580 +@return One of the system-wide error codes.
1.581 +*/
1.582 +EXPORT_C TInt RMidiControllerCustomCommands::GetBankId(TBool aCustom, TInt aBankIndex, TInt& aBankId) const
1.583 + {
1.584 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.585 + configPackage().iCustom = aCustom;
1.586 + configPackage().iBankIndex = aBankIndex;
1.587 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.588 + EMMFMidiControllerGetBankId,
1.589 + configPackage,
1.590 + KNullDesC8,
1.591 + configPackage);
1.592 + if (!error)
1.593 + aBankId = configPackage().iBankId;
1.594 + return error;
1.595 + }
1.596 +
1.597 +
1.598 +/**
1.599 +Loads one or more custom sound banks from a file into memory for use.
1.600 +If several banks are loaded with consequent LoadCustomBanks() function calls,
1.601 +the banks are combined if the bank sets have conflicting bank numbers.
1.602 +
1.603 +@param aFileName
1.604 + Name of the file containing the custom sound bank.
1.605 +@param aBankCollectionIndex
1.606 + Identifier of the custom sound bank loaded, occupying no more than 14 bits.
1.607 +@return One of the system-wide error codes.
1.608 +*/
1.609 +EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBank(const TDesC& aFileName,TInt& aBankCollectionIndex)
1.610 + {
1.611 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.612 + configPackage().iFileName = &aFileName;
1.613 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.614 + EMMFMidiControllerLoadCustomBank,
1.615 + configPackage,
1.616 + KNullDesC8,
1.617 + configPackage);
1.618 + if (!error)
1.619 + aBankCollectionIndex = configPackage().iBankId;
1.620 + return error;
1.621 + }
1.622 +
1.623 +
1.624 +/**
1.625 +Loads one or more custom sound banks from a descriptor into memory for use.
1.626 +If several banks are loaded with consequent LoadCustomBanks() function calls,
1.627 +the banks are combined if the bank sets have conflicting bank numbers.
1.628 +
1.629 +@param aBankData
1.630 + Descriptor containing the custom sound bank.
1.631 +@param aBankCollectionIndex
1.632 + Identifier of the custom sound bank loaded, occupying no more than 14 bits.
1.633 +@return One of the system-wide error codes.
1.634 +*/
1.635 +EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBankData(const TDesC8& aBankData,TInt& aBankCollectionIndex)
1.636 + {
1.637 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.638 + configPackage().iBankData = &aBankData;
1.639 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.640 + EMMFMidiControllerLoadCustomBankData,
1.641 + configPackage,
1.642 + KNullDesC8,
1.643 + configPackage);
1.644 + if (!error)
1.645 + aBankCollectionIndex = configPackage().iBankId;
1.646 + return error;
1.647 + }
1.648 +
1.649 +
1.650 +/**
1.651 +Removes a custom sound bank from memory. Only valid for sound banks previously
1.652 +loaded from file. Once unloaded the custom sound bank is no longer available for use.
1.653 +
1.654 +@param aBankCollectionIndex
1.655 + Identifier of the custom sound bank to unload,occupying no more than 14 bits.
1.656 +@return One of the system-wide error codes.
1.657 +*/
1.658 +EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomBank(TInt aBankCollectionIndex)
1.659 + {
1.660 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.661 + configPackage().iBankId= aBankCollectionIndex;
1.662 + return iController.CustomCommandSync(iDestinationPckg,
1.663 + EMMFMidiControllerUnloadCustomBank,
1.664 + configPackage,
1.665 + KNullDesC8);
1.666 + }
1.667 +
1.668 +/**
1.669 +Query if a bank has been loaded to the memory.
1.670 +
1.671 +@param aBankCollectionIndex
1.672 + Identifier of the custom sound bank to check if it's in memory or not.
1.673 +@param aBankLoaded
1.674 + ETrue if the specified bank is in memory, EFalse otherwise.
1.675 +@return One of the system-wide error codes.
1.676 +*/
1.677 +EXPORT_C TInt RMidiControllerCustomCommands::CustomBankLoaded(TInt aBankCollectionIndex, TBool& aBankLoaded) const
1.678 + {
1.679 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.680 + configPackage().iBankId= aBankCollectionIndex;
1.681 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.682 + EMMFMidiControllerCustomBankLoaded,
1.683 + configPackage,
1.684 + KNullDesC8,
1.685 + configPackage);
1.686 + if (!error)
1.687 + aBankLoaded = configPackage().iBankLoaded;
1.688 + return error;
1.689 + }
1.690 +
1.691 +
1.692 +/**
1.693 +Removes all custom sound banks from memory.
1.694 +
1.695 +@return One of the system-wide error codes.
1.696 +*/
1.697 +EXPORT_C TInt RMidiControllerCustomCommands::UnloadAllCustomBanks()
1.698 + {
1.699 + return iController.CustomCommandSync(iDestinationPckg,
1.700 + EMMFMidiControllerUnloadAllCustomBanks,
1.701 + KNullDesC8,
1.702 + KNullDesC8);
1.703 + }
1.704 +
1.705 +/**
1.706 +Gets the number of instruments available in a given sound bank.
1.707 +
1.708 +@param aBankId
1.709 + Identifier of sound bank to reference, occupying no more than 14 bits.
1.710 +@param aCustom
1.711 + Specifies whether to reference a custom or standard sound bank.
1.712 +@param aNumInstruments
1.713 + Count of the number of instruments available for the specified sound bank.
1.714 +@return One of the system-wide error codes.
1.715 +*/
1.716 +EXPORT_C TInt RMidiControllerCustomCommands::NumberOfInstruments(TInt aBankId, TBool aCustom, TInt& aNumInstruments) const
1.717 + {
1.718 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.719 + configPackage().iBankId = aBankId;
1.720 + configPackage().iCustom = aCustom;
1.721 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.722 + EMMFMidiControllerNumberOfInstruments,
1.723 + configPackage,
1.724 + KNullDesC8,
1.725 + configPackage);
1.726 + if (!error)
1.727 + aNumInstruments = configPackage().iNumInstruments;
1.728 + return error;
1.729 + }
1.730 +
1.731 +
1.732 +/**
1.733 +Gets the identifier of an instrument.
1.734 +
1.735 +@param aBankId
1.736 + Identifier of the sound bank to reference, occupying no more than 14 bits.
1.737 +@param aCustom
1.738 + Specifies whether to reference a custom or standard sound bank.
1.739 +@param aInstrumentIndex
1.740 + Index of the instrument to reference where 0 <= aInstrumentIndex < NumberOfInstruments().
1.741 +@param aInstrumentId
1.742 + Identifier of specified instrument. This may differ from the index since the index
1.743 + simply enumerates the instruments, whereas identifiers may not be contiguous,
1.744 + especially where certain instruments correspond to General MIDI-defined instruments
1.745 + but not all instruments are present. Instrument identifiers are between 0 and 127 inclusive.
1.746 +@return One of the system-wide error codes.
1.747 +*/
1.748 +EXPORT_C TInt RMidiControllerCustomCommands::GetInstrumentId(TInt aBankId, TBool aCustom, TInt aInstrumentIndex, TInt& aInstrumentId) const
1.749 + {
1.750 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.751 + configPackage().iBankId = aBankId;
1.752 + configPackage().iCustom = aCustom;
1.753 + configPackage().iInstrumentIndex = aInstrumentIndex;
1.754 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.755 + EMMFMidiControllerGetInstrumentId,
1.756 + configPackage,
1.757 + KNullDesC8,
1.758 + configPackage);
1.759 + if (!error)
1.760 + aInstrumentId = configPackage().iInstrumentId;
1.761 + return error;
1.762 + }
1.763 +
1.764 +
1.765 +/**
1.766 +Gets the name of the given instrument.
1.767 +
1.768 +@param aBankId
1.769 + Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1.770 +@param aCustom
1.771 + Specifies whether to reference a custom or standard sound bank.
1.772 +@param aInstrumentId
1.773 + Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
1.774 +@return Buffer containing the name of the specified instrument. If it has no name
1.775 + then an empty descriptor is returned.
1.776 +*/
1.777 +EXPORT_C HBufC* RMidiControllerCustomCommands::InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const
1.778 + {
1.779 + // First, get the size of the instrument name so we can create a descriptor big enough to hold it
1.780 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.781 + configPackage().iBankId = aBankId;
1.782 + configPackage().iCustom = aCustom;
1.783 + configPackage().iInstrumentId = aInstrumentId;
1.784 + TPckgBuf<TInt> descriptorSizePckg;
1.785 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.786 + EMMFMidiControllerInstrumentName,
1.787 + configPackage,
1.788 + KNullDesC8,
1.789 + descriptorSizePckg));
1.790 +
1.791 + // Now create a descriptor of appropriate size and get the server to copy the data into it
1.792 + HBufC8* instrumentNameBuffer = HBufC8::NewLC(descriptorSizePckg());
1.793 + TPtr8 instrumentNameBufferPtr = instrumentNameBuffer->Des();
1.794 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.795 + EMMFMidiControllerCopyInstrumentName,
1.796 + KNullDesC8,
1.797 + KNullDesC8,
1.798 + instrumentNameBufferPtr));
1.799 +
1.800 + // Stream data out of the 8bit descriptor into a 16bit descriptor
1.801 + RDesReadStream stream;
1.802 + stream.Open(*instrumentNameBuffer);
1.803 + CleanupClosePushL(stream);
1.804 +
1.805 + HBufC* instrumentName = HBufC::NewL(stream, KMaxTInt);
1.806 +
1.807 + CleanupStack::PopAndDestroy();//stream
1.808 + CleanupStack::PopAndDestroy(instrumentNameBuffer);
1.809 +
1.810 + return instrumentName;
1.811 + }
1.812 +
1.813 +
1.814 +/**
1.815 +Sets a logical channel to use the given instrument.
1.816 +
1.817 +@param aChannel
1.818 + Logical channel to set the instrument for. 0 <= aChannel <= 15.
1.819 +@param aBankId
1.820 + Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1.821 + The bank ID is a concatenation of MIDI bank MSB and LSB values.
1.822 +@param aInstrumentId
1.823 + Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127.
1.824 +@return One of the system-wide error codes.
1.825 +*/
1.826 +EXPORT_C TInt RMidiControllerCustomCommands::SetInstrument(TInt aChannel,TInt aBankId,TInt aInstrumentId)
1.827 + {
1.828 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.829 + configPackage().iChannel = aChannel;
1.830 + configPackage().iBankId = aBankId;
1.831 + configPackage().iInstrumentId = aInstrumentId;
1.832 + return iController.CustomCommandSync(iDestinationPckg,
1.833 + EMMFMidiControllerSetInstrument,
1.834 + configPackage,
1.835 + KNullDesC8);
1.836 + }
1.837 +
1.838 +/**
1.839 +Loads an individual instrument from file into custom sound bank memory for use.
1.840 +The bank and instrument id given in the file can be mapped into different bank
1.841 +and instrument id in memory.
1.842 +
1.843 +@param aFileName
1.844 + Name of the file containing the instrument.
1.845 +@param aFileBankId
1.846 + Identifier of the bank in the file from which to load the instrument,
1.847 + occupying no more than 14 bits.
1.848 +@param aFileInstrumentId
1.849 + Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
1.850 +@param aMemoryBankId
1.851 + Identifier of the custom bank in memory to load the instrument into,
1.852 + occupying no more than 14 bits.
1.853 +@param aMemoryInstrumentId
1.854 + Identifier of the instrument in memory to load the new instrument into.
1.855 + 0 <= aInstrumentId <= 127.
1.856 +@return One of the system-wide error codes.
1.857 +*/
1.858 +EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrument(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
1.859 + {
1.860 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.861 + configPackage().iFileName = &aFileName;
1.862 + configPackage().iBankId = aFileBankId;
1.863 + configPackage().iInstrumentId = aFileInstrumentId;
1.864 + configPackage().iMemoryBankId = aMemoryBankId;
1.865 + configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
1.866 + return iController.CustomCommandSync(iDestinationPckg,
1.867 + EMMFMidiControllerLoadCustomInstrument,
1.868 + configPackage,
1.869 + KNullDesC8);
1.870 + }
1.871 +
1.872 +
1.873 +/**
1.874 +Loads an individual instrument from descriptor into custom sound bank memory for use.
1.875 +The bank and instrument id given in the descriptor can be mapped into different bank
1.876 +and instrument id in memory.
1.877 +
1.878 +@param aInstrumentData
1.879 + Descriptor containing the instrument.
1.880 +@param aBankDataId
1.881 + Identifier of the bank in the descriptor from which to load the instrument,
1.882 + occupying no more than 14 bits.
1.883 +@param aInstrumentDataId
1.884 + Identifier of the instrument to load. 0 <= aInstrumentId <= 127.
1.885 +@param aMemoryBankId
1.886 + Identifier of the custom bank in memory to load the instrument into,
1.887 + occupying no more than 14 bits.
1.888 +@param aMemoryInstrumentId
1.889 + Identifier of the instrument in memory to load the new instrument into.
1.890 + 0 <= aInstrumentId <= 127.
1.891 +@return One of the system-wide error codes.
1.892 +*/
1.893 +EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrumentData(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId)
1.894 + {
1.895 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.896 + configPackage().iInstrumentData = &aInstrumentData;
1.897 + configPackage().iBankId = aBankDataId;
1.898 + configPackage().iInstrumentId = aInstrumentDataId;
1.899 + configPackage().iMemoryBankId = aMemoryBankId;
1.900 + configPackage().iMemoryInstrumentId = aMemoryInstrumentId;
1.901 + return iController.CustomCommandSync(iDestinationPckg,
1.902 + EMMFMidiControllerLoadCustomInstrumentData,
1.903 + configPackage,
1.904 + KNullDesC8);
1.905 + }
1.906 +
1.907 +/**
1.908 +Removes an instrument from custom sound bank memory. Only valid for
1.909 +instruments previously loaded from file. Once unloaded the instrument
1.910 +is no longer available for use.
1.911 +
1.912 +@param aCustomBankId
1.913 + Identifier of the custom sound bank containing the instrument to unload,
1.914 + occupying no more than 14 bits.
1.915 +@param aInstrumentId
1.916 + Identifier of the instrument to unload. 0 <= aInstrumentId <= 127.
1.917 +@return One of the system-wide error codes.
1.918 +*/
1.919 +EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomInstrument(TInt aCustomBankId,TInt aInstrumentId)
1.920 + {
1.921 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.922 + configPackage().iBankId = aCustomBankId;
1.923 + configPackage().iInstrumentId = aInstrumentId;
1.924 + return iController.CustomCommandSync(iDestinationPckg,
1.925 + EMMFMidiControllerUnloadCustomInstrument,
1.926 + configPackage,
1.927 + KNullDesC8);
1.928 + }
1.929 +
1.930 +/**
1.931 +Gets the name of a particular percussion key corresponding to a given note.
1.932 +
1.933 +@param aNote
1.934 + Note to query. 0 <= aNote <= 127.
1.935 +@param aBankId
1.936 + Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1.937 + The bank ID is a concatenation of MIDI bank MSB and LSB values.
1.938 +@param aCustom
1.939 + Specifies whether to reference a custom or standard sound bank.
1.940 +@param aInstrumentId
1.941 + Identifier of an instrument.
1.942 +@return Descriptor containing the name of the percussion key. If the key
1.943 + does not have a name then an empty descriptor is returned.
1.944 +*/
1.945 +EXPORT_C HBufC* RMidiControllerCustomCommands::PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const
1.946 + {
1.947 + // First, get the size of the percussion key name so we can create a descriptor big enough to hold it
1.948 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.949 + configPackage().iNote = aNote;
1.950 + configPackage().iBankId = aBankId;
1.951 + configPackage().iCustom = aCustom;
1.952 + configPackage().iInstrumentId = aInstrumentId;
1.953 + TPckgBuf<TInt> descriptorSizePckg;
1.954 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.955 + EMMFMidiControllerPercussionKeyName,
1.956 + configPackage,
1.957 + KNullDesC8,
1.958 + descriptorSizePckg));
1.959 +
1.960 + // Now create a descriptor of appropriate size and get the server to copy the data into it
1.961 + HBufC8* keyNameBuffer = HBufC8::NewLC(descriptorSizePckg());
1.962 + TPtr8 keyNameBufferPtr = keyNameBuffer->Des();
1.963 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.964 + EMMFMidiControllerCopyPercussionKeyName,
1.965 + KNullDesC8,
1.966 + KNullDesC8,
1.967 + keyNameBufferPtr));
1.968 +
1.969 + // Stream data out of the 8bit descriptor into a 16bit descriptor
1.970 + RDesReadStream stream;
1.971 + stream.Open(*keyNameBuffer);
1.972 + CleanupClosePushL(stream);
1.973 +
1.974 + HBufC* keyName = HBufC::NewL(stream, KMaxTInt);
1.975 +
1.976 + CleanupStack::PopAndDestroy();//stream
1.977 + CleanupStack::PopAndDestroy(keyNameBuffer);
1.978 +
1.979 + return keyName;
1.980 + }
1.981 +
1.982 +/**
1.983 +Get the stop time currently set for the MIDI resource.
1.984 +
1.985 +@param aStopTime
1.986 + Time at which playback will stop, relative to the start of the resource.
1.987 +@return One of the system-wide error codes.
1.988 +*/
1.989 +EXPORT_C TInt RMidiControllerCustomCommands::StopTime(TTimeIntervalMicroSeconds& aStopTime) const
1.990 + {
1.991 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.992 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.993 + EMMFMidiControllerStopTime,
1.994 + KNullDesC8,
1.995 + KNullDesC8,
1.996 + configPackage);
1.997 + if (!error)
1.998 + aStopTime = configPackage().iStopTime;
1.999 + return error;
1.1000 + }
1.1001 +
1.1002 +
1.1003 +/**
1.1004 +Sets the stop time to use for the currently open MIDI resource
1.1005 +
1.1006 +@param aStopTime
1.1007 + Time at which playback will stop, relative to the start of the resource.
1.1008 + Clamped to 0 and the duration of the resource.
1.1009 +@return One of the system-wide error codes.
1.1010 +*/
1.1011 +EXPORT_C TInt RMidiControllerCustomCommands::SetStopTime(const TTimeIntervalMicroSeconds& aStopTime) const
1.1012 + {
1.1013 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1014 + configPackage().iStopTime = aStopTime;
1.1015 + return iController.CustomCommandSync(iDestinationPckg,
1.1016 + EMMFMidiControllerSetStopTime,
1.1017 + configPackage,
1.1018 + KNullDesC8);
1.1019 + }
1.1020 +
1.1021 +/**
1.1022 +Gets the polyphony of the MIDI engine.
1.1023 +
1.1024 +@param aNumNotes
1.1025 + The number of currently active voices.
1.1026 +@return One of the system-wide error codes.
1.1027 +*/
1.1028 +EXPORT_C TInt RMidiControllerCustomCommands::Polyphony(TInt& aNumNotes) const
1.1029 + {
1.1030 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1031 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1032 + EMMFMidiControllerPolyphony,
1.1033 + KNullDesC8,
1.1034 + KNullDesC8,
1.1035 + configPackage);
1.1036 + if (!error)
1.1037 + aNumNotes = configPackage().iNumNotes;
1.1038 + return error;
1.1039 + }
1.1040 +
1.1041 +
1.1042 +/**
1.1043 +Gets the current maximum number of notes the engine can handle
1.1044 +This can be greater than the value returned by RMidiControllerCustomCommands::Polyphony
1.1045 +
1.1046 +@param aNumNotes
1.1047 + The maximum number of notes the engine can handle
1.1048 +@return One of the system-wide error codes.
1.1049 +*/
1.1050 +EXPORT_C TInt RMidiControllerCustomCommands::MaxPolyphony(TInt& aMaxNotes) const
1.1051 + {
1.1052 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1053 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1054 + EMMFMidiControllerMaxPolyphony,
1.1055 + KNullDesC8,
1.1056 + KNullDesC8,
1.1057 + configPackage);
1.1058 + if (!error)
1.1059 + aMaxNotes = configPackage().iMaxNotes;
1.1060 + return error;
1.1061 + }
1.1062 +
1.1063 +/**
1.1064 +Get the maximum number of logical channels supported by the MIDI engine.
1.1065 +
1.1066 +@param aChannels
1.1067 + The maximum number of logical channels that the MIDI engine supports,
1.1068 + 0 <= aChannels <=15.
1.1069 +@return One of the system-wide error codes.
1.1070 +*/
1.1071 +EXPORT_C TInt RMidiControllerCustomCommands::ChannelsSupported(TInt& aChannels) const
1.1072 + {
1.1073 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1074 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1075 + EMMFMidiControllerChannelsSupported,
1.1076 + KNullDesC8,
1.1077 + KNullDesC8,
1.1078 + configPackage);
1.1079 + if (!error)
1.1080 + aChannels = configPackage().iChannel;
1.1081 + return error;
1.1082 + }
1.1083 +
1.1084 +
1.1085 +/**
1.1086 +Get the current volume setting of a logical channel.
1.1087 +
1.1088 +@param aChannel
1.1089 + Logical channel to query. 0 <= aChannel <= 15.
1.1090 +@param aChannelVol
1.1091 + Volume currently set on the specified channel in decibels.
1.1092 +@return One of the system-wide error codes.
1.1093 +*/
1.1094 +EXPORT_C TInt RMidiControllerCustomCommands::ChannelVolume(TInt aChannel, TReal32& aChannelVol) const
1.1095 + {
1.1096 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1097 + configPackage().iChannel = aChannel;
1.1098 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1099 + EMMFMidiControllerChannelVolume,
1.1100 + configPackage,
1.1101 + KNullDesC8,
1.1102 + configPackage);
1.1103 + if (!error)
1.1104 + aChannelVol = configPackage().iChannelVol;
1.1105 + return error;
1.1106 + }
1.1107 +
1.1108 +/**
1.1109 +Gets the Maximum volume setting that may be applied to a logical channel.
1.1110 +
1.1111 +@param aMaxVol
1.1112 + Maximum volume setting. Minimum value is -infinity dB, which is the
1.1113 + smallest possible value that TReal32 supports.
1.1114 +@return One of the system-wide error codes.
1.1115 +*/
1.1116 +EXPORT_C TInt RMidiControllerCustomCommands::MaxChannelVolume(TReal32& aMaxVol) const
1.1117 + {
1.1118 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1119 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1120 + EMMFMidiControllerMaxChannelVolume,
1.1121 + KNullDesC8,
1.1122 + KNullDesC8,
1.1123 + configPackage);
1.1124 + if (!error)
1.1125 + aMaxVol = configPackage().iMaxChannelVol;
1.1126 + return error;
1.1127 + }
1.1128 +
1.1129 +/**
1.1130 +Set the volume of a channel.
1.1131 +
1.1132 +@param aChannel
1.1133 + Logical channel to set the volume on. 0 <= aChannel <= 15.
1.1134 +@param aVolume
1.1135 + The channel volume can be set within a range. The minimum
1.1136 + channel volume is -infinity dB, which is the smallest possible
1.1137 + value that TReal32 supports while the maximum channel volume
1.1138 + is set via MaxVolumeL() which represents the volume level in dB
1.1139 + corresponding to the MIDI Channel Volume controller.
1.1140 +@return One of the system-wide error codes.
1.1141 +*/
1.1142 +EXPORT_C TInt RMidiControllerCustomCommands::SetChannelVolume(TInt aChannel,TReal32 aVolume)
1.1143 + {
1.1144 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1145 + configPackage().iChannel = aChannel;
1.1146 + configPackage().iChannelVol = aVolume;
1.1147 + return iController.CustomCommandSync(iDestinationPckg,
1.1148 + EMMFMidiControllerSetChannelVolume,
1.1149 + configPackage,
1.1150 + KNullDesC8);
1.1151 + }
1.1152 +
1.1153 +/**
1.1154 +Set the muting state of a channel without changing its volume setting.
1.1155 +When unmuted the channel goes back to its previous volume setting.
1.1156 +
1.1157 +@param aChannel
1.1158 + Logical channel to set the mute state of. 0 <= aChannel <= 15.
1.1159 +@param aMuted
1.1160 + ETrue to mute the channel, EFalse to unmute it.
1.1161 +@return One of the system-wide error codes.
1.1162 +*/
1.1163 +EXPORT_C TInt RMidiControllerCustomCommands::SetChannelMute(TInt aChannel,TBool aMuted)
1.1164 + {
1.1165 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1166 + configPackage().iChannel = aChannel;
1.1167 + configPackage().iMuted = aMuted;
1.1168 + return iController.CustomCommandSync(iDestinationPckg,
1.1169 + EMMFMidiControllerSetChannelMute,
1.1170 + configPackage,
1.1171 + KNullDesC8);
1.1172 + }
1.1173 +
1.1174 +
1.1175 +/**
1.1176 +Gets the overall volume of the MIDI client.
1.1177 +
1.1178 +@param aVolume
1.1179 + The current overall volume setting.
1.1180 +@return One of the system-wide error codes.
1.1181 +*/
1.1182 +EXPORT_C TInt RMidiControllerCustomCommands::Volume(TInt& aVolume) const
1.1183 + {
1.1184 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1185 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1186 + EMMFMidiControllerVolume,
1.1187 + KNullDesC8,
1.1188 + KNullDesC8,
1.1189 + configPackage);
1.1190 + if (!error)
1.1191 + aVolume = configPackage().iVolume;
1.1192 + return error;
1.1193 + }
1.1194 +
1.1195 +
1.1196 +/**
1.1197 +Maximum volume setting that may be applied overall.
1.1198 +
1.1199 +@param aMaxVolume
1.1200 + Maximum volume setting. Minimum value is always zero which is silent.
1.1201 +@return One of the system-wide error codes.
1.1202 +*/
1.1203 +EXPORT_C TInt RMidiControllerCustomCommands::MaxVolume(TInt& aMaxVolume) const
1.1204 + {
1.1205 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1206 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1207 + EMMFMidiControllerMaxVolume,
1.1208 + KNullDesC8,
1.1209 + KNullDesC8,
1.1210 + configPackage);
1.1211 + if (!error)
1.1212 + aMaxVolume = configPackage().iMaxVolume;
1.1213 + return error;
1.1214 + }
1.1215 +
1.1216 +
1.1217 +/**
1.1218 +Set the overall volume of the MIDI client.
1.1219 +This setting scales all channel volumes respectively so the actual volume
1.1220 +that a channel is played at is (overall volume * channel volume / max volume).
1.1221 +
1.1222 +@param aVolume
1.1223 + Overall volume setting to use.
1.1224 +@return One of the system-wide error codes.
1.1225 +*/
1.1226 +EXPORT_C TInt RMidiControllerCustomCommands::SetVolume(TInt aVolume)
1.1227 + {
1.1228 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1229 + configPackage().iVolume = aVolume;
1.1230 + return iController.CustomCommandSync(iDestinationPckg,
1.1231 + EMMFMidiControllerSetVolume,
1.1232 + configPackage,
1.1233 + KNullDesC8);
1.1234 + }
1.1235 +
1.1236 +/**
1.1237 +Length of time over which the volume is faded up from zero to the current setting
1.1238 +when playback is started.
1.1239 +
1.1240 +@param aRampDuration
1.1241 + Duration of the ramping period.
1.1242 +@return One of the system-wide error codes.
1.1243 +*/
1.1244 +EXPORT_C TInt RMidiControllerCustomCommands::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
1.1245 + {
1.1246 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1247 + configPackage().iRampDuration = aRampDuration;
1.1248 + return iController.CustomCommandSync(iDestinationPckg,
1.1249 + EMMFMidiControllerSetVolumeRamp,
1.1250 + configPackage,
1.1251 + KNullDesC8);
1.1252 + }
1.1253 +
1.1254 +/**
1.1255 +Get the current stereo balance value.
1.1256 +
1.1257 +@param aBalance
1.1258 + Balance value ranging from KMMFBalanceMaxLeft to KMMFBalanceMaxRight.
1.1259 +@return One of the system-wide error codes.
1.1260 +*/
1.1261 +EXPORT_C TInt RMidiControllerCustomCommands::GetBalance(TInt& aBalance) const
1.1262 + {
1.1263 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1264 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1265 + EMMFMidiControllerGetBalance,
1.1266 + KNullDesC8,
1.1267 + KNullDesC8,
1.1268 + configPackage);
1.1269 + if (!error)
1.1270 + aBalance = configPackage().iBalance;
1.1271 + return error;
1.1272 + }
1.1273 +
1.1274 +/**
1.1275 +Set the current stereo balance value.
1.1276 +
1.1277 +@param aBalance
1.1278 + Balance value to set. Defaults to KMMFBalanceCenter to restore equal left-right balance.
1.1279 +@return One of the system-wide error codes.
1.1280 +*/
1.1281 +EXPORT_C TInt RMidiControllerCustomCommands::SetBalance(TInt aBalance)
1.1282 + {
1.1283 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1284 + configPackage().iBalance = aBalance;
1.1285 + return iController.CustomCommandSync(iDestinationPckg,
1.1286 + EMMFMidiControllerSetBalance,
1.1287 + configPackage,
1.1288 + KNullDesC8);
1.1289 + }
1.1290 +
1.1291 +/**
1.1292 +Set the max polyphony the engine can handle.
1.1293 +
1.1294 +@param aMaxNotes
1.1295 + Max polyphony level, 1 <= Polyphony() <= aMaxNotes.
1.1296 +@return One of the system-wide error codes.
1.1297 +*/
1.1298 +EXPORT_C TInt RMidiControllerCustomCommands::SetMaxPolyphony(TInt aMaxNotes)
1.1299 + {
1.1300 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1301 + configPackage().iMaxNotes = aMaxNotes;
1.1302 + return iController.CustomCommandSync(iDestinationPckg,
1.1303 + EMMFMidiControllerSetMaxPolyphony,
1.1304 + configPackage,
1.1305 + KNullDesC8);
1.1306 + }
1.1307 +
1.1308 +/**
1.1309 +Gets the number of times the current opened resources has to be repeated.
1.1310 +
1.1311 +@param aNumRepeats
1.1312 + The number of times the current opened resources has to be repeated.
1.1313 +@return One of the system-wide error codes.
1.1314 +*/
1.1315 +EXPORT_C TInt RMidiControllerCustomCommands::GetRepeats(TInt& aNumRepeats) const
1.1316 + {
1.1317 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1318 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1319 + EMMFMidiControllerGetRepeats,
1.1320 + KNullDesC8,
1.1321 + KNullDesC8,
1.1322 + configPackage);
1.1323 + if (!error)
1.1324 + aNumRepeats = configPackage().iNumRepeats;
1.1325 + return error;
1.1326 + }
1.1327 +
1.1328 +/**
1.1329 +Set the number of times to repeat the current MIDI resource.
1.1330 +After Stop() has been called, repeat number of times and the
1.1331 +trailing silence are reset.
1.1332 +
1.1333 +@param aRepeatNumberOfTimes
1.1334 + Number of times to repeat the resource during playback. This includes the first playing.
1.1335 +@param aTrailingSilence
1.1336 + Time in microseconds to pause between repeats.
1.1337 +@return One of the system-wide error codes.
1.1338 +*/
1.1339 +EXPORT_C TInt RMidiControllerCustomCommands::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
1.1340 + {
1.1341 +
1.1342 + TPckgBuf<TMMFMidiConfig3> configPackage;
1.1343 + configPackage().iRepeatNumberOfTimes = aRepeatNumberOfTimes;
1.1344 + configPackage().iTrailingSilence = aTrailingSilence;
1.1345 + return iController.CustomCommandSync(iDestinationPckg,
1.1346 + EMMFMidiControllerSetRepeats,
1.1347 + configPackage,
1.1348 + KNullDesC8);
1.1349 + }
1.1350 +
1.1351 +/**
1.1352 +Tell the MIDI engine to use a custom bank or a standard bank.
1.1353 +
1.1354 +@param aCustom
1.1355 + If Etrue the custom bank in memory is used otherwise the standard bank
1.1356 + is used leaving the custom bank in memory.
1.1357 +@return One of the system-wide error codes.
1.1358 +*/
1.1359 +EXPORT_C TInt RMidiControllerCustomCommands::SetBank(TBool aCustom)
1.1360 + {
1.1361 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1362 + configPackage().iCustom = aCustom;
1.1363 + return iController.CustomCommandSync(iDestinationPckg,
1.1364 + EMMFMidiControllerSetBank,
1.1365 + configPackage,
1.1366 + KNullDesC8);
1.1367 + }
1.1368 +
1.1369 +/**
1.1370 +Gets the muting status of a specific track.
1.1371 +
1.1372 +@param aTrack
1.1373 + The track to query.
1.1374 +@param aTrackMute
1.1375 + The mute status of the track.
1.1376 +@return One of the system-wide error codes.
1.1377 +*/
1.1378 +EXPORT_C TInt RMidiControllerCustomCommands::IsTrackMute(TInt aTrack, TBool& aTrackMute) const
1.1379 + {
1.1380 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1381 + configPackage().iTrack = aTrack;
1.1382 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1383 + EMMFMidiControllerIsTrackMute,
1.1384 + configPackage,
1.1385 + KNullDesC8,
1.1386 + configPackage);
1.1387 + if (!error)
1.1388 + aTrackMute = configPackage().iMuted;
1.1389 + return error;
1.1390 + }
1.1391 +
1.1392 +
1.1393 +/**
1.1394 +Gets the muting status of a specific channel.
1.1395 +
1.1396 +@param aChannel
1.1397 + The channel to query.
1.1398 +@param aChannelMute
1.1399 + The mute status of the channel.
1.1400 +@return One of the system-wide error codes.
1.1401 +*/
1.1402 +EXPORT_C TInt RMidiControllerCustomCommands::IsChannelMute(TInt aChannel, TBool& aChannelMute) const
1.1403 + {
1.1404 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1405 + configPackage().iChannel = aChannel;
1.1406 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1407 + EMMFMidiControllerIsChannelMute,
1.1408 + configPackage,
1.1409 + KNullDesC8,
1.1410 + configPackage);
1.1411 + if (!error)
1.1412 + aChannelMute = configPackage().iMuted;
1.1413 + return error;
1.1414 + }
1.1415 +
1.1416 +
1.1417 +/**
1.1418 +Gets the instrument assigned to a specified channel.
1.1419 +
1.1420 +@param aChannel
1.1421 + Logical channel, 0 <= aChannel <= 15.
1.1422 +@param aInstrumentId
1.1423 + Identifier of the instrument assigned to aChannel. 0 <= aInstrumentId <= 127.
1.1424 +@param aBankId
1.1425 + Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1.1426 +@return One of the system-wide error codes.
1.1427 +*/
1.1428 +EXPORT_C TInt RMidiControllerCustomCommands::GetInstrument(TInt aChannel, TInt& aInstrumentId, TInt& aBankId)
1.1429 + {
1.1430 + TPckgBuf<TMMFMidiConfig2> configPackage;
1.1431 + configPackage().iChannel = aChannel;
1.1432 + TInt error = iController.CustomCommandSync(iDestinationPckg,
1.1433 + EMMFMidiControllerGetInstrument,
1.1434 + configPackage,
1.1435 + KNullDesC8,
1.1436 + configPackage);
1.1437 + if (!error)
1.1438 + {
1.1439 + aInstrumentId = configPackage().iInstrumentId;
1.1440 + aBankId = configPackage().iBankId;
1.1441 + }
1.1442 + return error;
1.1443 + }
1.1444 +
1.1445 +/**
1.1446 +Closes any currently open resources, such as files, descriptors or URLs in use.
1.1447 +Does nothing if there is nothing currently open.
1.1448 +
1.1449 +@return One of the system-wide error codes.
1.1450 +*/
1.1451 +EXPORT_C TInt RMidiControllerCustomCommands::Close()
1.1452 + {
1.1453 + return iController.CustomCommandSync(iDestinationPckg,
1.1454 + EMMFMidiControllerClose,
1.1455 + KNullDesC8,
1.1456 + KNullDesC8);
1.1457 + }
1.1458 +
1.1459 +/**
1.1460 +Stops playback of a resource but does not change the current position
1.1461 +or release any resources. Pauses the internal timer if no resource is open.
1.1462 +
1.1463 +@param aFadeOutDuration
1.1464 + Length of time over which the volume is faded out from the current setting to zero.
1.1465 +@return One of the system-wide error codes.
1.1466 +*/
1.1467 +EXPORT_C TInt RMidiControllerCustomCommands::Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration)
1.1468 + {
1.1469 + TPckgBuf<TMMFMidiConfig1> configPackage;
1.1470 + configPackage().iFadeOutDuration = aFadeOutDuration;
1.1471 + return iController.CustomCommandSync(iDestinationPckg,
1.1472 + EMMFMidiControllerStop,
1.1473 + configPackage,
1.1474 + KNullDesC8);
1.1475 + }
1.1476 +
1.1477 +
1.1478 +/**
1.1479 +Start receiving events from the controller. This can only be called once the controller is open.
1.1480 +
1.1481 +@param aSizeOfMidiEvent
1.1482 + The size of the MIDI event object.
1.1483 +@param aStatus
1.1484 + Status flag belonging to an active object that will have it's RunL() called
1.1485 + when this request complete.
1.1486 +*/
1.1487 +EXPORT_C void RMidiControllerCustomCommands::ReceiveEvents(TPckgBuf<TInt>& aSizeOfMidiEvent, TRequestStatus& aStatus)
1.1488 + {
1.1489 + iController.CustomCommandAsync(iDestinationPckg,
1.1490 + EMMFMidiControllerReceiveEvents,
1.1491 + KNullDesC8,
1.1492 + KNullDesC8,
1.1493 + aSizeOfMidiEvent,
1.1494 + aStatus);
1.1495 + }
1.1496 +
1.1497 +/**
1.1498 +Get the MIDI event from the MIDI controller.
1.1499 +
1.1500 +@param aMidiEventPckg
1.1501 + MIDI event.
1.1502 +@return One of the system-wide error codes.
1.1503 +*/
1.1504 +EXPORT_C TInt RMidiControllerCustomCommands::RetrieveEvent(TDes8& aMidiEventPckg)
1.1505 + {
1.1506 + return iController.CustomCommandSync(iDestinationPckg,
1.1507 + EMMFMidiControllerRetrieveEvent,
1.1508 + KNullDesC8,
1.1509 + KNullDesC8,
1.1510 + aMidiEventPckg);
1.1511 + }
1.1512 +
1.1513 +/**
1.1514 +Stop receiving events from the MIDI controller.
1.1515 +
1.1516 +@return One of the system-wide error codes.
1.1517 +*/
1.1518 +EXPORT_C TInt RMidiControllerCustomCommands::CancelReceiveEvents()
1.1519 + {
1.1520 + return iController.CustomCommandSync(iDestinationPckg,
1.1521 + EMMFMidiControllerCancelReceiveEvents,
1.1522 + KNullDesC8,
1.1523 + KNullDesC8);
1.1524 + }
1.1525 +
1.1526 +
1.1527 +CMidiEventReceiver* CMidiEventReceiver::NewL(const TMMFMessage& aMessage)
1.1528 + {
1.1529 + return new(ELeave) CMidiEventReceiver(aMessage);
1.1530 + }
1.1531 +
1.1532 +CMidiEventReceiver::~CMidiEventReceiver()
1.1533 + {
1.1534 + if (!(iMessage.IsCompleted()))
1.1535 + iMessage.Complete(KErrDied);
1.1536 + delete iEventBuf;
1.1537 + }
1.1538 +
1.1539 +void CMidiEventReceiver::PrepareEventL(const CMMFMidiEvent& aEvent)
1.1540 + {
1.1541 + // eventbuf should be NULL. delete it anyway though to prevent memory leaks in release mode
1.1542 + ASSERT(!iEventBuf);
1.1543 +
1.1544 + delete iEventBuf;
1.1545 + iEventBuf = NULL;
1.1546 +
1.1547 + iEventBuf = CBufFlat::NewL(32);
1.1548 + RBufWriteStream s;
1.1549 + s.Open(*iEventBuf);
1.1550 + CleanupClosePushL(s);
1.1551 + aEvent.ExternalizeL(s);
1.1552 + CleanupStack::PopAndDestroy();//s
1.1553 + // Write the size of the externalised data back to the client
1.1554 + TPckgBuf<TInt> pckg;
1.1555 + pckg() = iEventBuf->Ptr(0).Length();
1.1556 + TInt error = iMessage.WriteDataToClient(pckg);
1.1557 + iMessage.Complete(error);
1.1558 + }
1.1559 +
1.1560 +void CMidiEventReceiver::SendEventL(TMMFMessage& aMessage)
1.1561 + {
1.1562 + if (!iEventBuf)
1.1563 + {
1.1564 + User::Leave(KErrNotReady);
1.1565 + }
1.1566 + else
1.1567 + {
1.1568 + aMessage.WriteDataToClientL(iEventBuf->Ptr(0));
1.1569 + }
1.1570 + }
1.1571 +
1.1572 +TBool CMidiEventReceiver::IsWaitingToSendEvent()
1.1573 + {
1.1574 + return (iEventBuf!=NULL);
1.1575 + }
1.1576 +
1.1577 +CMidiEventReceiver::CMidiEventReceiver(const TMMFMessage& aMessage) : iMessage(aMessage)
1.1578 + {
1.1579 + }
1.1580 +
1.1581 +
1.1582 +/**
1.1583 +Constructor.
1.1584 +
1.1585 +@param aEventType
1.1586 + A UID to define the type of MIDI event.
1.1587 +@param aErrorCode
1.1588 + The error code associated with the MIDI event.
1.1589 +*/
1.1590 +EXPORT_C CMMFMidiEvent::CMMFMidiEvent(TUid aEventType, TInt aErrorCode)
1.1591 + : iEventType(aEventType), iErrorCode(aErrorCode)
1.1592 + {
1.1593 + ZeroMembers();
1.1594 + }
1.1595 +
1.1596 +/**
1.1597 +Default constructor.
1.1598 +*/
1.1599 +EXPORT_C CMMFMidiEvent::CMMFMidiEvent()
1.1600 + : iEventType(KNullUid), iErrorCode(KErrNone)
1.1601 + {
1.1602 + ZeroMembers();
1.1603 + }
1.1604 +
1.1605 +/**
1.1606 +Set to default values all the data members.
1.1607 +*/
1.1608 +void CMMFMidiEvent::ZeroMembers()
1.1609 + {
1.1610 + iOldState = EMidiStateClosedDisengaged;
1.1611 + iNewState = EMidiStateClosedDisengaged;
1.1612 + iMicroSeconds = 0;
1.1613 + iMicroBeats = 0;
1.1614 + iChannel = 0;
1.1615 + iVolumeInDecibels = 0;
1.1616 + iMute = EFalse;
1.1617 + iMetaDataEntryId = 0;
1.1618 + iPolyphony = 0;
1.1619 + iBankId = 0;
1.1620 + iInstrumentId = 0;
1.1621 + iTempoMicroBeats = 0;
1.1622 + }
1.1623 +
1.1624 +/**
1.1625 +Destructor.
1.1626 +*/
1.1627 +EXPORT_C CMMFMidiEvent::~CMMFMidiEvent()
1.1628 + {
1.1629 + iMipMessage.Close();
1.1630 + }
1.1631 +
1.1632 +/**
1.1633 +Externalize the object to a stream. All the member variables will be written to the stream.
1.1634 +
1.1635 +@param aStream
1.1636 + The write stream object.
1.1637 +*/
1.1638 +EXPORT_C void CMMFMidiEvent::ExternalizeL(RWriteStream& aStream) const
1.1639 + {
1.1640 + aStream << iEventType;
1.1641 + aStream.WriteInt32L(iErrorCode);
1.1642 + aStream.WriteInt32L(iOldState);
1.1643 + aStream.WriteInt32L(iNewState);
1.1644 + aStream << iMicroSeconds.Int64();
1.1645 + aStream << iMicroBeats;
1.1646 + aStream.WriteInt32L(iChannel);
1.1647 + aStream << iVolumeInDecibels;
1.1648 + aStream.WriteInt32L(iMute);
1.1649 + aStream.WriteInt32L(iMetaDataEntryId);
1.1650 +
1.1651 + aStream.WriteInt32L(iMipMessage.Count());
1.1652 + for (TInt i=0; i<iMipMessage.Count(); i++)
1.1653 + {
1.1654 + aStream.WriteInt32L(iMipMessage[i].iChannel);
1.1655 + aStream.WriteInt32L(iMipMessage[i].iMIPValue);
1.1656 + }
1.1657 +
1.1658 + aStream.WriteInt32L(iPolyphony);
1.1659 + aStream.WriteInt32L(iBankId);
1.1660 + aStream.WriteInt32L(iInstrumentId);
1.1661 + aStream.WriteInt32L(iTempoMicroBeats);
1.1662 + }
1.1663 +
1.1664 +/**
1.1665 +Internalize the object from a stream. All the member variables will be read from the stream.
1.1666 +
1.1667 +@param aStream
1.1668 + The read stream object.
1.1669 +*/
1.1670 +EXPORT_C void CMMFMidiEvent::InternalizeL(RReadStream& aStream)
1.1671 + {
1.1672 + aStream >> iEventType;
1.1673 + iErrorCode = aStream.ReadInt32L();
1.1674 + iOldState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
1.1675 + iNewState = STATIC_CAST(TMidiState, aStream.ReadInt32L());
1.1676 +
1.1677 + TInt64 microSeconds;
1.1678 + aStream >> microSeconds;
1.1679 + iMicroSeconds = microSeconds;
1.1680 +
1.1681 + aStream >> iMicroBeats;
1.1682 + iChannel = aStream.ReadInt32L();
1.1683 + aStream >> iVolumeInDecibels;
1.1684 + iMute = aStream.ReadInt32L();
1.1685 + iMetaDataEntryId = aStream.ReadInt32L();
1.1686 +
1.1687 + TInt count = aStream.ReadInt32L();
1.1688 + for (TInt i=0; i<count; i++)
1.1689 + {
1.1690 + TMipMessageEntry entry;
1.1691 + entry.iChannel = aStream.ReadInt32L();
1.1692 + entry.iMIPValue = aStream.ReadInt32L();
1.1693 + User::LeaveIfError(iMipMessage.Append(entry));
1.1694 + }
1.1695 +
1.1696 + iPolyphony = aStream.ReadInt32L();
1.1697 + iBankId = aStream.ReadInt32L();
1.1698 + iInstrumentId = aStream.ReadInt32L();
1.1699 + iTempoMicroBeats = aStream.ReadInt32L();
1.1700 + }
1.1701 +
1.1702 +/**
1.1703 +Copies a MIDI event into this CMMFMidiEvent.
1.1704 +
1.1705 +@param aOther
1.1706 + The CMMFMidiEvent to copy from.
1.1707 +*/
1.1708 +EXPORT_C void CMMFMidiEvent::CopyL(const CMMFMidiEvent& aOther)
1.1709 + {
1.1710 + iEventType = aOther.iEventType;
1.1711 + iErrorCode = aOther.iErrorCode;
1.1712 + iOldState = aOther.iOldState;
1.1713 + iNewState = aOther.iNewState;
1.1714 + iMicroSeconds = aOther.iMicroSeconds;
1.1715 + iMicroBeats = aOther.iMicroBeats;
1.1716 + iChannel = aOther.iChannel;
1.1717 + iVolumeInDecibels = aOther.iVolumeInDecibels;
1.1718 + iMute = aOther.iMute;
1.1719 + iMetaDataEntryId = aOther.iMetaDataEntryId;
1.1720 + iPolyphony = aOther.iPolyphony;
1.1721 + iBankId = aOther.iBankId;
1.1722 + iInstrumentId = aOther.iInstrumentId;
1.1723 + iTempoMicroBeats = aOther.iTempoMicroBeats;
1.1724 +
1.1725 + for (TInt i=0; i<aOther.iMipMessage.Count(); i++)
1.1726 + {
1.1727 + User::LeaveIfError(iMipMessage.Append(aOther.iMipMessage[i]));
1.1728 + }
1.1729 + }
1.1730 +
1.1731 +