sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #include sl@0: #endif sl@0: sl@0: /** sl@0: Constructor. sl@0: @param aController sl@0: The client side controller object to be used by this custom command interface. sl@0: */ sl@0: EXPORT_C RMidiControllerCustomCommands::RMidiControllerCustomCommands(RMMFController& aController) : sl@0: RMMFCustomCommandsBase(aController, KUidInterfaceMidi) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Change the position of the currently playing MIDI resource to the given position. sl@0: May be called whenever a MIDI resource is open. sl@0: sl@0: @param aMicroBeats sl@0: Metrical position to move to. Clamped to (0, DurationMicroBeats()). sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetPositionMicroBeats(TInt64 aMicroBeats) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iPositionMicroBeats = aMicroBeats; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetPositionMicroBeats, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the current metrical position of the MIDI resource being played. sl@0: sl@0: @param aMicroBeats sl@0: (BPM*1000000) relative to the start of the resource. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::PositionMicroBeats(TInt64& aMicroBeats) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPositionMicroBeats, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMicroBeats = configPackage().iPositionMicroBeats; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Synchronous function to play a single note. sl@0: Multiple calls to this function will be accommodated as far as the MIDI engine can sl@0: manage. The same functionality could be implemented using the SendMessage function. sl@0: sl@0: @param aChannel sl@0: Logical channel to play note on. 0 <= aChannel <= 15. sl@0: @param aNote sl@0: Note to play. 0 <= aNote <= 127 sl@0: @param aDuration sl@0: Length of time to play note for. sl@0: @param aNoteOnVelocity sl@0: Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127. sl@0: @param aNoteOffVelocity sl@0: Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iNote = aNote; sl@0: configPackage().iDurationMicroSeconds = aDuration; sl@0: configPackage().iNoteOnVelocity = aNoteOnVelocity; sl@0: configPackage().iNoteOffVelocity = aNoteOffVelocity; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPlayNote, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Synchronous function to play a single note at a specified time. sl@0: Multiple calls to this function will be accommodated as far as the MIDI engine can sl@0: manage. The same functionality could be implemented using the SendMessage function. sl@0: sl@0: @param aChannel sl@0: Logical channel to play note on. 0 <= aChannel <= 15. sl@0: @param aNote sl@0: Note to play. 0 <= aNote <= 127 sl@0: @param aStartTime sl@0: Specifies the time at which to start playing the note, relative sl@0: to the MIDI resource playing time or the time elapsed since Play() sl@0: was called if no resource is present. sl@0: @param aDuration sl@0: Length of time to play note for. sl@0: @param aNoteOnVelocity sl@0: Velocity with which to start the note. 0 <= aNoteOnVelocity <= 127. sl@0: @param aNoteOffVelocity sl@0: Velocity with which to stop the note. 0 <= aNoteOffVelocity <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iNote = aNote; sl@0: configPackage().iStartTime = aStartTime; sl@0: configPackage().iDurationMicroSeconds = aDuration; sl@0: configPackage().iNoteOnVelocity = aNoteOnVelocity; sl@0: configPackage().iNoteOffVelocity = aNoteOffVelocity; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPlayNoteWithStartTime, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Stops the playback of all notes on the given channel, by means of an All Notes Off MIDI message. sl@0: sl@0: @param aChannel sl@0: Logical channel to stop notes on. 0 <= aChannel <= 15. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::StopNotes(TInt aChannel) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerStopNotes, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Synchronous function to commence playback of a note. Multiple calls to this sl@0: function will be accommodated as far as the MIDI engine can manage. sl@0: sl@0: @param aChannel sl@0: Logical channel to play note on. 0 <= aChannel <= 15. sl@0: @param aNote sl@0: Note to play. 0 <= aNote <= 127. sl@0: @param aVelocity sl@0: Velocity with which to start the note. The legal integer range is sl@0: 0 <= aVelocity <= 127, but the value zero actually causes the message sl@0: to be interpreted as a Note Off message instead of a Note On. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::NoteOn(TInt aChannel, TInt aNote, TInt aVelocity) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iNote = aNote; sl@0: configPackage().iNoteOnVelocity = aVelocity; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerNoteOn, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Synchronous function to terminate playback of a note. If no corresponding note sl@0: is found then no error is raised. sl@0: sl@0: @param aChannel sl@0: Logical channel on which the note is playing. 0 <= aChannel <= 15. sl@0: @param aNote sl@0: Note to terminate. 0 <= aNote <= 127. sl@0: @param aVelocity sl@0: Velocity with which to stop the note. 0 <= aVelocity <= 127. There is no sl@0: standard behaviour corresponding with note off velocity. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::NoteOff(TInt aChannel,TInt aNote,TInt aVelocity) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iNote = aNote; sl@0: configPackage().iNoteOffVelocity = aVelocity; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerNoteOff, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the current playback rate factor of the currently open MIDI resource. sl@0: The playback rate is independent from tempo, i.e., it can be used to give sl@0: an overall speed factor for playback. sl@0: sl@0: @param aPlayBackRate sl@0: Current playback rate in percent times 1000, i.e., 100000 means original sl@0: playback speed, 200000 means double speed, and 50000 means half speed playback. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::PlaybackRate(TInt& aPlayBackRate) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPlaybackRate, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aPlayBackRate = configPackage().iPlayBackRate; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Sets the playback rate for the playback of the current MIDI resource. sl@0: The playback rate is independent from tempo, i.e., it can be used to give sl@0: an overall speed factor for playback. May be called whether playback sl@0: is in progress or not. sl@0: sl@0: @param aPlayBackRate sl@0: Playback rate in percent times 1000, i.e., 100000 means original sl@0: playback speed, 200000 means double speed, and 50000 means half speed playback. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetPlaybackRate(TInt aPlayBackRate) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iPlayBackRate = aPlayBackRate; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetPlaybackRate, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the maximum playback rate in milli-percentage from the MIDI engine. sl@0: @see SetPlaybackRate() for milli-percentage details. sl@0: sl@0: @param aMaxRate sl@0: Playback rate supported by MIDI player. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MaxPlaybackRate(TInt& aMaxRate) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMaxPlaybackRate, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMaxRate = configPackage().iPlayBackMaxRate; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Gets the minimum playback rate in milli-percentage from the MIDI engine. sl@0: @see SetPlaybackRate() for milli-percentage details. sl@0: sl@0: @param aMinRate sl@0: Minimum playback rate supported by MIDI player. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MinPlaybackRate(TInt& aMinRate) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMinPlaybackRate, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMinRate = configPackage().iPlayBackMinRate; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Gets the current tempo of the currently open MIDI resource. The tempo is independent sl@0: from the playback rate, i.e., the resulting playback speed will be affected by both. sl@0: sl@0: @param aMicroBeatsPerMinute sl@0: Tempo at the current position of the currently open resource in microbeats sl@0: per minute, i.e. BPM * 1000000. Filled in by the controller framework. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::TempoMicroBeatsPerMinute(TInt& aMicroBeatsPerMinute) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerTempo, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMicroBeatsPerMinute = configPackage().iTempo; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Sets the tempo at which the current MIDI resource should be played. May be sl@0: called whether playback is in progress or not. The tempo is independent sl@0: from the playback rate, i.e., the resulting playback speed will be affected by both. sl@0: sl@0: @param aMicroBeatsPerMinute sl@0: Tempo in microbeats per minute (BPM*1000000) to set. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetTempo(TInt aMicroBeatsPerMinute) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iTempo = aMicroBeatsPerMinute; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetTempo, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the pitch shift in use for the currently open MIDI resource. sl@0: sl@0: @param aPitch sl@0: Shift in cents, i.e. semitones * 100. One octave equals 1200 cents. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::PitchTranspositionCents(TInt& aPitch) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPitch, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aPitch = configPackage().iPitch; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Sets the pitch shift to apply to the currently open MIDI resource. sl@0: May be called during playback. sl@0: sl@0: @param aCents sl@0: Pitch shift in cents, i.e. semitones * 100. One octave equals 1200 cents. sl@0: @param aCentsApplied sl@0: Actual pitch shift applied - may differ from the requested value due to sl@0: limitations of the MIDI engine. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetPitchTransposition(TInt aCents, TInt& aCentsApplied) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iPitch = aCents; sl@0: TInt err = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetPitch, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: aCentsApplied = configPackage().iPitch; sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: Gets the length of the currently open MIDI resource in micro-beats. sl@0: sl@0: @param aDuration sl@0: Duration in microbeats (beats * 1000000). sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::DurationMicroBeats(TInt64& aDuration) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerDurationMicroBeats, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aDuration = configPackage().iDurationMicroBeats; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Gets the number of tracks present in the currently open MIDI resource. sl@0: sl@0: @param aTracks sl@0: Number of tracks. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::NumTracks(TInt& aTracks) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerNumTracks, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aTracks = configPackage().iNumTracks; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Mutes or unmutes a particular track. sl@0: sl@0: @param aTrack sl@0: Index of the track to mute - 0 <= aTrack < NumTracksL(). sl@0: @param aMuted sl@0: ETrue to mute the track, EFalse to unmute it. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetTrackMute(TInt aTrack, TBool aMuted) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iTrack = aTrack; sl@0: configPackage().iMuted = aMuted; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetTrackMute, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the MIME type of the MIDI resource currently open. sl@0: sl@0: @param aMimeType sl@0: Descriptor containing the MIDI mime type. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MimeType(TDes8& aMimeType) const sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMimeType, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: aMimeType); sl@0: } sl@0: sl@0: /** sl@0: Sets the frequency at which MMIDIClientUtilityObserver::MmcuoSyncUpdateL() is called sl@0: to allow other components to synchronise with playback of this MIDI resource. sl@0: sl@0: @param aMicroSeconds sl@0: Temporal interval to callback at. Used in preference to aMicroBeats if both are set. sl@0: @param aMicroBeats sl@0: Metrical interval to callback at. Set both parameters to zero to cancel. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetSyncUpdateCallbackInterval(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iCallbackIntervalMicroSeconds = aMicroSeconds; sl@0: configPackage().iCallbackIntervalMicroBeats = aMicroBeats; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetSyncUpdateCallbackInterval, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Sends a single MIDI message to the MIDI engine. sl@0: sl@0: @param aMidiMessage sl@0: Descriptor containing the MIDI message data. If there are several sl@0: MIDI messages in the buffer, only the first one is processed. sl@0: @param aBytes sl@0: Number of bytes of the message buffer actually processed. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage, TInt& aBytes) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iMidiMessage = &aMidiMessage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSendMessage, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBytes = configPackage().iBytesProcessed; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Sends a single MIDI message, with time stamp, to the MIDI engine. sl@0: sl@0: @param aMidiMessage sl@0: Descriptor containing the MIDI message data. If there are several sl@0: MIDI messages in the buffer, only the first one is processed. sl@0: @param aTime sl@0: The time at which to execute the message, relative to the MIDI resource playing sl@0: time or the time elapsed since Play() was called if no resource is present. sl@0: @param aBytes sl@0: Number of bytes of the message buffer actually processed. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SendMessage(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iMidiMessage = &aMidiMessage; sl@0: configPackage().iTimeStamp = aTime; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSendMessageWithTimeStamp, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBytes = configPackage().iBytesProcessed; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Sends a mip message to the MIDI engine. This is a convenience function, sl@0: because the same functionality could be achieved with the SendMessage() function. sl@0: sl@0: @param aEntry sl@0: Array of logical {channel, MIP} value pairs to send, highest priority first. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SendMipMessage(const RArray& aEntry) sl@0: { sl@0: TPckgBuf configPackage; sl@0: TArray mipMessage(aEntry.Array()); sl@0: configPackage().iMipMessage = &mipMessage; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSendMipMessage, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the number of standard or custom sound banks currently available. sl@0: sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aNumBanks sl@0: Number of custom or standard sound banks available. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::NumberOfBanks(TBool aCustom, TInt& aNumBanks) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iCustom = aCustom; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerNumberOfBanks, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aNumBanks = configPackage().iNumBanks; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Gets the identifier of a sound bank. Bank identifier (aka bank number) is a sl@0: 14-bit value consisting of MIDI bank MSB and LSB values. sl@0: sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aBankIndex sl@0: Index of sound bank where 0 <= aBankIndex < NumberOfBanks(). sl@0: @param aBankId sl@0: Identifier of the specified bank occupying, at most, 14 bits. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::GetBankId(TBool aCustom, TInt aBankIndex, TInt& aBankId) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iCustom = aCustom; sl@0: configPackage().iBankIndex = aBankIndex; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerGetBankId, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBankId = configPackage().iBankId; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Loads one or more custom sound banks from a file into memory for use. sl@0: If several banks are loaded with consequent LoadCustomBanks() function calls, sl@0: the banks are combined if the bank sets have conflicting bank numbers. sl@0: sl@0: @param aFileName sl@0: Name of the file containing the custom sound bank. sl@0: @param aBankCollectionIndex sl@0: Identifier of the custom sound bank loaded, occupying no more than 14 bits. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBank(const TDesC& aFileName,TInt& aBankCollectionIndex) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iFileName = &aFileName; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerLoadCustomBank, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBankCollectionIndex = configPackage().iBankId; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Loads one or more custom sound banks from a descriptor into memory for use. sl@0: If several banks are loaded with consequent LoadCustomBanks() function calls, sl@0: the banks are combined if the bank sets have conflicting bank numbers. sl@0: sl@0: @param aBankData sl@0: Descriptor containing the custom sound bank. sl@0: @param aBankCollectionIndex sl@0: Identifier of the custom sound bank loaded, occupying no more than 14 bits. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomBankData(const TDesC8& aBankData,TInt& aBankCollectionIndex) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankData = &aBankData; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerLoadCustomBankData, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBankCollectionIndex = configPackage().iBankId; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Removes a custom sound bank from memory. Only valid for sound banks previously sl@0: loaded from file. Once unloaded the custom sound bank is no longer available for use. sl@0: sl@0: @param aBankCollectionIndex sl@0: Identifier of the custom sound bank to unload,occupying no more than 14 bits. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomBank(TInt aBankCollectionIndex) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId= aBankCollectionIndex; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerUnloadCustomBank, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Query if a bank has been loaded to the memory. sl@0: sl@0: @param aBankCollectionIndex sl@0: Identifier of the custom sound bank to check if it's in memory or not. sl@0: @param aBankLoaded sl@0: ETrue if the specified bank is in memory, EFalse otherwise. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::CustomBankLoaded(TInt aBankCollectionIndex, TBool& aBankLoaded) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId= aBankCollectionIndex; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerCustomBankLoaded, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBankLoaded = configPackage().iBankLoaded; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Removes all custom sound banks from memory. sl@0: sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::UnloadAllCustomBanks() sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerUnloadAllCustomBanks, sl@0: KNullDesC8, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the number of instruments available in a given sound bank. sl@0: sl@0: @param aBankId sl@0: Identifier of sound bank to reference, occupying no more than 14 bits. sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aNumInstruments sl@0: Count of the number of instruments available for the specified sound bank. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::NumberOfInstruments(TInt aBankId, TBool aCustom, TInt& aNumInstruments) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId = aBankId; sl@0: configPackage().iCustom = aCustom; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerNumberOfInstruments, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aNumInstruments = configPackage().iNumInstruments; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the identifier of an instrument. sl@0: sl@0: @param aBankId sl@0: Identifier of the sound bank to reference, occupying no more than 14 bits. sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aInstrumentIndex sl@0: Index of the instrument to reference where 0 <= aInstrumentIndex < NumberOfInstruments(). sl@0: @param aInstrumentId sl@0: Identifier of specified instrument. This may differ from the index since the index sl@0: simply enumerates the instruments, whereas identifiers may not be contiguous, sl@0: especially where certain instruments correspond to General MIDI-defined instruments sl@0: but not all instruments are present. Instrument identifiers are between 0 and 127 inclusive. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::GetInstrumentId(TInt aBankId, TBool aCustom, TInt aInstrumentIndex, TInt& aInstrumentId) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId = aBankId; sl@0: configPackage().iCustom = aCustom; sl@0: configPackage().iInstrumentIndex = aInstrumentIndex; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerGetInstrumentId, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aInstrumentId = configPackage().iInstrumentId; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the name of the given instrument. sl@0: sl@0: @param aBankId sl@0: Identifier of the bank that the instrument belongs to, occupying no more than 14 bits. sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aInstrumentId sl@0: Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127. sl@0: @return Buffer containing the name of the specified instrument. If it has no name sl@0: then an empty descriptor is returned. sl@0: */ sl@0: EXPORT_C HBufC* RMidiControllerCustomCommands::InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const sl@0: { sl@0: // First, get the size of the instrument name so we can create a descriptor big enough to hold it sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId = aBankId; sl@0: configPackage().iCustom = aCustom; sl@0: configPackage().iInstrumentId = aInstrumentId; sl@0: TPckgBuf descriptorSizePckg; sl@0: User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerInstrumentName, sl@0: configPackage, sl@0: KNullDesC8, sl@0: descriptorSizePckg)); sl@0: sl@0: // Now create a descriptor of appropriate size and get the server to copy the data into it sl@0: HBufC8* instrumentNameBuffer = HBufC8::NewLC(descriptorSizePckg()); sl@0: TPtr8 instrumentNameBufferPtr = instrumentNameBuffer->Des(); sl@0: User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerCopyInstrumentName, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: instrumentNameBufferPtr)); sl@0: sl@0: // Stream data out of the 8bit descriptor into a 16bit descriptor sl@0: RDesReadStream stream; sl@0: stream.Open(*instrumentNameBuffer); sl@0: CleanupClosePushL(stream); sl@0: sl@0: HBufC* instrumentName = HBufC::NewL(stream, KMaxTInt); sl@0: sl@0: CleanupStack::PopAndDestroy();//stream sl@0: CleanupStack::PopAndDestroy(instrumentNameBuffer); sl@0: sl@0: return instrumentName; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets a logical channel to use the given instrument. sl@0: sl@0: @param aChannel sl@0: Logical channel to set the instrument for. 0 <= aChannel <= 15. sl@0: @param aBankId sl@0: Identifier of the bank that the instrument belongs to, occupying no more than 14 bits. sl@0: The bank ID is a concatenation of MIDI bank MSB and LSB values. sl@0: @param aInstrumentId sl@0: Identifier of the instrument under scrutiny. 0 <= aInstrumentId <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetInstrument(TInt aChannel,TInt aBankId,TInt aInstrumentId) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iBankId = aBankId; sl@0: configPackage().iInstrumentId = aInstrumentId; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetInstrument, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Loads an individual instrument from file into custom sound bank memory for use. sl@0: The bank and instrument id given in the file can be mapped into different bank sl@0: and instrument id in memory. sl@0: sl@0: @param aFileName sl@0: Name of the file containing the instrument. sl@0: @param aFileBankId sl@0: Identifier of the bank in the file from which to load the instrument, sl@0: occupying no more than 14 bits. sl@0: @param aFileInstrumentId sl@0: Identifier of the instrument to load. 0 <= aInstrumentId <= 127. sl@0: @param aMemoryBankId sl@0: Identifier of the custom bank in memory to load the instrument into, sl@0: occupying no more than 14 bits. sl@0: @param aMemoryInstrumentId sl@0: Identifier of the instrument in memory to load the new instrument into. sl@0: 0 <= aInstrumentId <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrument(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iFileName = &aFileName; sl@0: configPackage().iBankId = aFileBankId; sl@0: configPackage().iInstrumentId = aFileInstrumentId; sl@0: configPackage().iMemoryBankId = aMemoryBankId; sl@0: configPackage().iMemoryInstrumentId = aMemoryInstrumentId; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerLoadCustomInstrument, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Loads an individual instrument from descriptor into custom sound bank memory for use. sl@0: The bank and instrument id given in the descriptor can be mapped into different bank sl@0: and instrument id in memory. sl@0: sl@0: @param aInstrumentData sl@0: Descriptor containing the instrument. sl@0: @param aBankDataId sl@0: Identifier of the bank in the descriptor from which to load the instrument, sl@0: occupying no more than 14 bits. sl@0: @param aInstrumentDataId sl@0: Identifier of the instrument to load. 0 <= aInstrumentId <= 127. sl@0: @param aMemoryBankId sl@0: Identifier of the custom bank in memory to load the instrument into, sl@0: occupying no more than 14 bits. sl@0: @param aMemoryInstrumentId sl@0: Identifier of the instrument in memory to load the new instrument into. sl@0: 0 <= aInstrumentId <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::LoadCustomInstrumentData(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iInstrumentData = &aInstrumentData; sl@0: configPackage().iBankId = aBankDataId; sl@0: configPackage().iInstrumentId = aInstrumentDataId; sl@0: configPackage().iMemoryBankId = aMemoryBankId; sl@0: configPackage().iMemoryInstrumentId = aMemoryInstrumentId; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerLoadCustomInstrumentData, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Removes an instrument from custom sound bank memory. Only valid for sl@0: instruments previously loaded from file. Once unloaded the instrument sl@0: is no longer available for use. sl@0: sl@0: @param aCustomBankId sl@0: Identifier of the custom sound bank containing the instrument to unload, sl@0: occupying no more than 14 bits. sl@0: @param aInstrumentId sl@0: Identifier of the instrument to unload. 0 <= aInstrumentId <= 127. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::UnloadCustomInstrument(TInt aCustomBankId,TInt aInstrumentId) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBankId = aCustomBankId; sl@0: configPackage().iInstrumentId = aInstrumentId; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerUnloadCustomInstrument, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the name of a particular percussion key corresponding to a given note. sl@0: sl@0: @param aNote sl@0: Note to query. 0 <= aNote <= 127. sl@0: @param aBankId sl@0: Identifier of the bank that the instrument belongs to, occupying no more than 14 bits. sl@0: The bank ID is a concatenation of MIDI bank MSB and LSB values. sl@0: @param aCustom sl@0: Specifies whether to reference a custom or standard sound bank. sl@0: @param aInstrumentId sl@0: Identifier of an instrument. sl@0: @return Descriptor containing the name of the percussion key. If the key sl@0: does not have a name then an empty descriptor is returned. sl@0: */ sl@0: EXPORT_C HBufC* RMidiControllerCustomCommands::PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const sl@0: { sl@0: // First, get the size of the percussion key name so we can create a descriptor big enough to hold it sl@0: TPckgBuf configPackage; sl@0: configPackage().iNote = aNote; sl@0: configPackage().iBankId = aBankId; sl@0: configPackage().iCustom = aCustom; sl@0: configPackage().iInstrumentId = aInstrumentId; sl@0: TPckgBuf descriptorSizePckg; sl@0: User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPercussionKeyName, sl@0: configPackage, sl@0: KNullDesC8, sl@0: descriptorSizePckg)); sl@0: sl@0: // Now create a descriptor of appropriate size and get the server to copy the data into it sl@0: HBufC8* keyNameBuffer = HBufC8::NewLC(descriptorSizePckg()); sl@0: TPtr8 keyNameBufferPtr = keyNameBuffer->Des(); sl@0: User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerCopyPercussionKeyName, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: keyNameBufferPtr)); sl@0: sl@0: // Stream data out of the 8bit descriptor into a 16bit descriptor sl@0: RDesReadStream stream; sl@0: stream.Open(*keyNameBuffer); sl@0: CleanupClosePushL(stream); sl@0: sl@0: HBufC* keyName = HBufC::NewL(stream, KMaxTInt); sl@0: sl@0: CleanupStack::PopAndDestroy();//stream sl@0: CleanupStack::PopAndDestroy(keyNameBuffer); sl@0: sl@0: return keyName; sl@0: } sl@0: sl@0: /** sl@0: Get the stop time currently set for the MIDI resource. sl@0: sl@0: @param aStopTime sl@0: Time at which playback will stop, relative to the start of the resource. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::StopTime(TTimeIntervalMicroSeconds& aStopTime) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerStopTime, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aStopTime = configPackage().iStopTime; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the stop time to use for the currently open MIDI resource sl@0: sl@0: @param aStopTime sl@0: Time at which playback will stop, relative to the start of the resource. sl@0: Clamped to 0 and the duration of the resource. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetStopTime(const TTimeIntervalMicroSeconds& aStopTime) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iStopTime = aStopTime; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetStopTime, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the polyphony of the MIDI engine. sl@0: sl@0: @param aNumNotes sl@0: The number of currently active voices. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::Polyphony(TInt& aNumNotes) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerPolyphony, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aNumNotes = configPackage().iNumNotes; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the current maximum number of notes the engine can handle sl@0: This can be greater than the value returned by RMidiControllerCustomCommands::Polyphony sl@0: sl@0: @param aNumNotes sl@0: The maximum number of notes the engine can handle sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MaxPolyphony(TInt& aMaxNotes) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMaxPolyphony, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMaxNotes = configPackage().iMaxNotes; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Get the maximum number of logical channels supported by the MIDI engine. sl@0: sl@0: @param aChannels sl@0: The maximum number of logical channels that the MIDI engine supports, sl@0: 0 <= aChannels <=15. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::ChannelsSupported(TInt& aChannels) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerChannelsSupported, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aChannels = configPackage().iChannel; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Get the current volume setting of a logical channel. sl@0: sl@0: @param aChannel sl@0: Logical channel to query. 0 <= aChannel <= 15. sl@0: @param aChannelVol sl@0: Volume currently set on the specified channel in decibels. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::ChannelVolume(TInt aChannel, TReal32& aChannelVol) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerChannelVolume, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aChannelVol = configPackage().iChannelVol; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Gets the Maximum volume setting that may be applied to a logical channel. sl@0: sl@0: @param aMaxVol sl@0: Maximum volume setting. Minimum value is -infinity dB, which is the sl@0: smallest possible value that TReal32 supports. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MaxChannelVolume(TReal32& aMaxVol) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMaxChannelVolume, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMaxVol = configPackage().iMaxChannelVol; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Set the volume of a channel. sl@0: sl@0: @param aChannel sl@0: Logical channel to set the volume on. 0 <= aChannel <= 15. sl@0: @param aVolume sl@0: The channel volume can be set within a range. The minimum sl@0: channel volume is -infinity dB, which is the smallest possible sl@0: value that TReal32 supports while the maximum channel volume sl@0: is set via MaxVolumeL() which represents the volume level in dB sl@0: corresponding to the MIDI Channel Volume controller. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetChannelVolume(TInt aChannel,TReal32 aVolume) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iChannelVol = aVolume; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetChannelVolume, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Set the muting state of a channel without changing its volume setting. sl@0: When unmuted the channel goes back to its previous volume setting. sl@0: sl@0: @param aChannel sl@0: Logical channel to set the mute state of. 0 <= aChannel <= 15. sl@0: @param aMuted sl@0: ETrue to mute the channel, EFalse to unmute it. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetChannelMute(TInt aChannel,TBool aMuted) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: configPackage().iMuted = aMuted; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetChannelMute, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the overall volume of the MIDI client. sl@0: sl@0: @param aVolume sl@0: The current overall volume setting. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::Volume(TInt& aVolume) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerVolume, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aVolume = configPackage().iVolume; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Maximum volume setting that may be applied overall. sl@0: sl@0: @param aMaxVolume sl@0: Maximum volume setting. Minimum value is always zero which is silent. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::MaxVolume(TInt& aMaxVolume) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerMaxVolume, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aMaxVolume = configPackage().iMaxVolume; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Set the overall volume of the MIDI client. sl@0: This setting scales all channel volumes respectively so the actual volume sl@0: that a channel is played at is (overall volume * channel volume / max volume). sl@0: sl@0: @param aVolume sl@0: Overall volume setting to use. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetVolume(TInt aVolume) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iVolume = aVolume; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetVolume, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Length of time over which the volume is faded up from zero to the current setting sl@0: when playback is started. sl@0: sl@0: @param aRampDuration sl@0: Duration of the ramping period. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iRampDuration = aRampDuration; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetVolumeRamp, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Get the current stereo balance value. sl@0: sl@0: @param aBalance sl@0: Balance value ranging from KMMFBalanceMaxLeft to KMMFBalanceMaxRight. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::GetBalance(TInt& aBalance) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerGetBalance, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aBalance = configPackage().iBalance; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Set the current stereo balance value. sl@0: sl@0: @param aBalance sl@0: Balance value to set. Defaults to KMMFBalanceCenter to restore equal left-right balance. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetBalance(TInt aBalance) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iBalance = aBalance; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetBalance, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Set the max polyphony the engine can handle. sl@0: sl@0: @param aMaxNotes sl@0: Max polyphony level, 1 <= Polyphony() <= aMaxNotes. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetMaxPolyphony(TInt aMaxNotes) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iMaxNotes = aMaxNotes; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetMaxPolyphony, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the number of times the current opened resources has to be repeated. sl@0: sl@0: @param aNumRepeats sl@0: The number of times the current opened resources has to be repeated. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::GetRepeats(TInt& aNumRepeats) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerGetRepeats, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aNumRepeats = configPackage().iNumRepeats; sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Set the number of times to repeat the current MIDI resource. sl@0: After Stop() has been called, repeat number of times and the sl@0: trailing silence are reset. sl@0: sl@0: @param aRepeatNumberOfTimes sl@0: Number of times to repeat the resource during playback. This includes the first playing. sl@0: @param aTrailingSilence sl@0: Time in microseconds to pause between repeats. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) sl@0: { sl@0: sl@0: TPckgBuf configPackage; sl@0: configPackage().iRepeatNumberOfTimes = aRepeatNumberOfTimes; sl@0: configPackage().iTrailingSilence = aTrailingSilence; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetRepeats, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Tell the MIDI engine to use a custom bank or a standard bank. sl@0: sl@0: @param aCustom sl@0: If Etrue the custom bank in memory is used otherwise the standard bank sl@0: is used leaving the custom bank in memory. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::SetBank(TBool aCustom) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iCustom = aCustom; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerSetBank, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Gets the muting status of a specific track. sl@0: sl@0: @param aTrack sl@0: The track to query. sl@0: @param aTrackMute sl@0: The mute status of the track. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::IsTrackMute(TInt aTrack, TBool& aTrackMute) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iTrack = aTrack; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerIsTrackMute, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aTrackMute = configPackage().iMuted; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the muting status of a specific channel. sl@0: sl@0: @param aChannel sl@0: The channel to query. sl@0: @param aChannelMute sl@0: The mute status of the channel. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::IsChannelMute(TInt aChannel, TBool& aChannelMute) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerIsChannelMute, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: aChannelMute = configPackage().iMuted; sl@0: return error; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the instrument assigned to a specified channel. sl@0: sl@0: @param aChannel sl@0: Logical channel, 0 <= aChannel <= 15. sl@0: @param aInstrumentId sl@0: Identifier of the instrument assigned to aChannel. 0 <= aInstrumentId <= 127. sl@0: @param aBankId sl@0: Identifier of the bank that the instrument belongs to, occupying no more than 14 bits. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::GetInstrument(TInt aChannel, TInt& aInstrumentId, TInt& aBankId) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iChannel = aChannel; sl@0: TInt error = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerGetInstrument, sl@0: configPackage, sl@0: KNullDesC8, sl@0: configPackage); sl@0: if (!error) sl@0: { sl@0: aInstrumentId = configPackage().iInstrumentId; sl@0: aBankId = configPackage().iBankId; sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: /** sl@0: Closes any currently open resources, such as files, descriptors or URLs in use. sl@0: Does nothing if there is nothing currently open. sl@0: sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::Close() sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerClose, sl@0: KNullDesC8, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: /** sl@0: Stops playback of a resource but does not change the current position sl@0: or release any resources. Pauses the internal timer if no resource is open. sl@0: sl@0: @param aFadeOutDuration sl@0: Length of time over which the volume is faded out from the current setting to zero. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration) sl@0: { sl@0: TPckgBuf configPackage; sl@0: configPackage().iFadeOutDuration = aFadeOutDuration; sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerStop, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Start receiving events from the controller. This can only be called once the controller is open. sl@0: sl@0: @param aSizeOfMidiEvent sl@0: The size of the MIDI event object. sl@0: @param aStatus sl@0: Status flag belonging to an active object that will have it's RunL() called sl@0: when this request complete. sl@0: */ sl@0: EXPORT_C void RMidiControllerCustomCommands::ReceiveEvents(TPckgBuf& aSizeOfMidiEvent, TRequestStatus& aStatus) sl@0: { sl@0: iController.CustomCommandAsync(iDestinationPckg, sl@0: EMMFMidiControllerReceiveEvents, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: aSizeOfMidiEvent, sl@0: aStatus); sl@0: } sl@0: sl@0: /** sl@0: Get the MIDI event from the MIDI controller. sl@0: sl@0: @param aMidiEventPckg sl@0: MIDI event. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::RetrieveEvent(TDes8& aMidiEventPckg) sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerRetrieveEvent, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: aMidiEventPckg); sl@0: } sl@0: sl@0: /** sl@0: Stop receiving events from the MIDI controller. sl@0: sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: EXPORT_C TInt RMidiControllerCustomCommands::CancelReceiveEvents() sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFMidiControllerCancelReceiveEvents, sl@0: KNullDesC8, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: sl@0: CMidiEventReceiver* CMidiEventReceiver::NewL(const TMMFMessage& aMessage) sl@0: { sl@0: return new(ELeave) CMidiEventReceiver(aMessage); sl@0: } sl@0: sl@0: CMidiEventReceiver::~CMidiEventReceiver() sl@0: { sl@0: if (!(iMessage.IsCompleted())) sl@0: iMessage.Complete(KErrDied); sl@0: delete iEventBuf; sl@0: } sl@0: sl@0: void CMidiEventReceiver::PrepareEventL(const CMMFMidiEvent& aEvent) sl@0: { sl@0: // eventbuf should be NULL. delete it anyway though to prevent memory leaks in release mode sl@0: ASSERT(!iEventBuf); sl@0: sl@0: delete iEventBuf; sl@0: iEventBuf = NULL; sl@0: sl@0: iEventBuf = CBufFlat::NewL(32); sl@0: RBufWriteStream s; sl@0: s.Open(*iEventBuf); sl@0: CleanupClosePushL(s); sl@0: aEvent.ExternalizeL(s); sl@0: CleanupStack::PopAndDestroy();//s sl@0: // Write the size of the externalised data back to the client sl@0: TPckgBuf pckg; sl@0: pckg() = iEventBuf->Ptr(0).Length(); sl@0: TInt error = iMessage.WriteDataToClient(pckg); sl@0: iMessage.Complete(error); sl@0: } sl@0: sl@0: void CMidiEventReceiver::SendEventL(TMMFMessage& aMessage) sl@0: { sl@0: if (!iEventBuf) sl@0: { sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: else sl@0: { sl@0: aMessage.WriteDataToClientL(iEventBuf->Ptr(0)); sl@0: } sl@0: } sl@0: sl@0: TBool CMidiEventReceiver::IsWaitingToSendEvent() sl@0: { sl@0: return (iEventBuf!=NULL); sl@0: } sl@0: sl@0: CMidiEventReceiver::CMidiEventReceiver(const TMMFMessage& aMessage) : iMessage(aMessage) sl@0: { sl@0: } sl@0: sl@0: sl@0: /** sl@0: Constructor. sl@0: sl@0: @param aEventType sl@0: A UID to define the type of MIDI event. sl@0: @param aErrorCode sl@0: The error code associated with the MIDI event. sl@0: */ sl@0: EXPORT_C CMMFMidiEvent::CMMFMidiEvent(TUid aEventType, TInt aErrorCode) sl@0: : iEventType(aEventType), iErrorCode(aErrorCode) sl@0: { sl@0: ZeroMembers(); sl@0: } sl@0: sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: EXPORT_C CMMFMidiEvent::CMMFMidiEvent() sl@0: : iEventType(KNullUid), iErrorCode(KErrNone) sl@0: { sl@0: ZeroMembers(); sl@0: } sl@0: sl@0: /** sl@0: Set to default values all the data members. sl@0: */ sl@0: void CMMFMidiEvent::ZeroMembers() sl@0: { sl@0: iOldState = EMidiStateClosedDisengaged; sl@0: iNewState = EMidiStateClosedDisengaged; sl@0: iMicroSeconds = 0; sl@0: iMicroBeats = 0; sl@0: iChannel = 0; sl@0: iVolumeInDecibels = 0; sl@0: iMute = EFalse; sl@0: iMetaDataEntryId = 0; sl@0: iPolyphony = 0; sl@0: iBankId = 0; sl@0: iInstrumentId = 0; sl@0: iTempoMicroBeats = 0; sl@0: } sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: EXPORT_C CMMFMidiEvent::~CMMFMidiEvent() sl@0: { sl@0: iMipMessage.Close(); sl@0: } sl@0: sl@0: /** sl@0: Externalize the object to a stream. All the member variables will be written to the stream. sl@0: sl@0: @param aStream sl@0: The write stream object. sl@0: */ sl@0: EXPORT_C void CMMFMidiEvent::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: aStream << iEventType; sl@0: aStream.WriteInt32L(iErrorCode); sl@0: aStream.WriteInt32L(iOldState); sl@0: aStream.WriteInt32L(iNewState); sl@0: aStream << iMicroSeconds.Int64(); sl@0: aStream << iMicroBeats; sl@0: aStream.WriteInt32L(iChannel); sl@0: aStream << iVolumeInDecibels; sl@0: aStream.WriteInt32L(iMute); sl@0: aStream.WriteInt32L(iMetaDataEntryId); sl@0: sl@0: aStream.WriteInt32L(iMipMessage.Count()); sl@0: for (TInt i=0; i> iEventType; sl@0: iErrorCode = aStream.ReadInt32L(); sl@0: iOldState = STATIC_CAST(TMidiState, aStream.ReadInt32L()); sl@0: iNewState = STATIC_CAST(TMidiState, aStream.ReadInt32L()); sl@0: sl@0: TInt64 microSeconds; sl@0: aStream >> microSeconds; sl@0: iMicroSeconds = microSeconds; sl@0: sl@0: aStream >> iMicroBeats; sl@0: iChannel = aStream.ReadInt32L(); sl@0: aStream >> iVolumeInDecibels; sl@0: iMute = aStream.ReadInt32L(); sl@0: iMetaDataEntryId = aStream.ReadInt32L(); sl@0: sl@0: TInt count = aStream.ReadInt32L(); sl@0: for (TInt i=0; i