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: #ifndef __MIDISTANDARDCUSTOMCOMMANDS_H__ sl@0: #define __MIDISTANDARDCUSTOMCOMMANDS_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Interface UID for the Midi Controller API. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TUid KUidInterfaceMidi = { 0x101F945C }; sl@0: sl@0: /** sl@0: Describe a MIDI event. sl@0: Contains a UID to define the actual event type, and an integer to define the event code. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CMMFMidiEvent: public CBase sl@0: { sl@0: public: sl@0: IMPORT_C CMMFMidiEvent(TUid aEventType, TInt aErrorCode); sl@0: IMPORT_C CMMFMidiEvent(); sl@0: IMPORT_C ~CMMFMidiEvent(); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void CopyL(const CMMFMidiEvent& aOther); sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: void ZeroMembers(); sl@0: public: sl@0: /** sl@0: * A UID to define the type of MIDI event. sl@0: */ sl@0: TUid iEventType; sl@0: /** sl@0: * The error code associated with the MIDI event. sl@0: */ sl@0: TInt iErrorCode; sl@0: /** sl@0: * Old state of the MIDI client utility object. sl@0: */ sl@0: TMidiState iOldState; sl@0: /** sl@0: * Current state of the MIDI client utility object. sl@0: */ sl@0: TMidiState iNewState; sl@0: /** sl@0: * General purpose time stamp in microseconds. sl@0: */ sl@0: TTimeIntervalMicroSeconds iMicroSeconds; sl@0: /** sl@0: * General purpose time stamp in micro beats per minute. sl@0: */ sl@0: TInt64 iMicroBeats; sl@0: /** sl@0: * Channel sl@0: */ sl@0: TInt iChannel; sl@0: /** sl@0: * Volume in decibel of a logical channel. sl@0: */ sl@0: TReal32 iVolumeInDecibels; sl@0: /** sl@0: * Mute state of a track or of a channel. sl@0: */ sl@0: TBool iMute; sl@0: /** sl@0: * Meta data entry. sl@0: * Client will retrieve meta data entry by calling GetMetaDataEntryL() sl@0: * using this TInt to indicate which meta data entry to retrieve. sl@0: */ sl@0: TInt iMetaDataEntryId; sl@0: /** sl@0: * Array of logical {channel, MIP} value pairs. sl@0: */ sl@0: RArray iMipMessage; sl@0: /** sl@0: * Polyphony of the MIDI engine. sl@0: */ sl@0: TInt iPolyphony; sl@0: /** sl@0: * Identifier of a bank occupying, at most, 14 bits. sl@0: */ sl@0: TInt iBankId; sl@0: /** sl@0: * Identifier of a specific instrument. sl@0: */ sl@0: TInt iInstrumentId; sl@0: /** sl@0: * Tempo value in micro beats per minute. sl@0: */ sl@0: TInt iTempoMicroBeats; sl@0: }; sl@0: sl@0: /** sl@0: Client class to access functionality specific to a MIDI controller. sl@0: The class uses the custom command function of the controller plugin, and removes the necessity sl@0: for the client to formulate the custom commands. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class RMidiControllerCustomCommands : public RMMFCustomCommandsBase sl@0: { sl@0: public: sl@0: IMPORT_C RMidiControllerCustomCommands(RMMFController& aController); sl@0: IMPORT_C TInt SetPositionMicroBeats(TInt64 aMicroBeats) const; sl@0: IMPORT_C TInt PositionMicroBeats(TInt64& aMicroBeats) const; sl@0: IMPORT_C TInt PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity); sl@0: IMPORT_C TInt PlayNote(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity); sl@0: IMPORT_C TInt StopNotes(TInt aChannel); sl@0: IMPORT_C TInt NoteOn(TInt aChannel,TInt aNote,TInt aVelocity); sl@0: IMPORT_C TInt NoteOff(TInt aChannel,TInt aNote,TInt aVelocity); sl@0: IMPORT_C TInt PlaybackRate(TInt& aPlayBackRate) const; sl@0: IMPORT_C TInt SetPlaybackRate(TInt aPlayBackRate); sl@0: IMPORT_C TInt MaxPlaybackRate(TInt& aMaxRate) const; sl@0: IMPORT_C TInt MinPlaybackRate(TInt& aMinRate) const; sl@0: IMPORT_C TInt TempoMicroBeatsPerMinute(TInt& aMicroBeatsPerMinute) const; sl@0: IMPORT_C TInt SetTempo(TInt aMicroBeatsPerMinute); sl@0: IMPORT_C TInt PitchTranspositionCents(TInt& aPitch) const; sl@0: IMPORT_C TInt SetPitchTransposition(TInt aCents, TInt& aCentsApplied); sl@0: IMPORT_C TInt DurationMicroBeats(TInt64& aDuration) const; sl@0: IMPORT_C TInt NumTracks(TInt& aTracks) const; sl@0: IMPORT_C TInt SetTrackMute(TInt aTrack, TBool aMuted) const; sl@0: IMPORT_C TInt MimeType(TDes8& aMimeType) const; sl@0: IMPORT_C TInt SetSyncUpdateCallbackInterval(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats=0); sl@0: IMPORT_C TInt SendMessage(const TDesC8& aMidiMessage, TInt& aBytes); sl@0: IMPORT_C TInt SendMessage(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes); sl@0: IMPORT_C TInt SendMipMessage(const RArray& aEntry); sl@0: IMPORT_C TInt NumberOfBanks(TBool aCustom, TInt& aNumBanks) const; sl@0: IMPORT_C TInt GetBankId(TBool aCustom, TInt aBankIndex, TInt& aBankId) const; sl@0: IMPORT_C TInt LoadCustomBank(const TDesC& aFileName,TInt& aBankId); sl@0: IMPORT_C TInt LoadCustomBankData(const TDesC8& aBankData,TInt& aBankId); sl@0: IMPORT_C TInt UnloadCustomBank(TInt aBankId); sl@0: IMPORT_C TInt CustomBankLoaded(TInt aBankId, TBool& aBankLoaded) const; sl@0: IMPORT_C TInt UnloadAllCustomBanks(); sl@0: IMPORT_C TInt NumberOfInstruments(TInt aBankId, TBool aCustom, TInt& aNumInstruments) const; sl@0: IMPORT_C TInt GetInstrumentId(TInt aBankId,TBool aCustom,TInt aInstrumentIndex, TInt& aInstrumentId) const; sl@0: IMPORT_C HBufC* InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const; sl@0: IMPORT_C TInt SetInstrument(TInt aChannel,TInt aBankId,TInt aInstrumentId); sl@0: IMPORT_C TInt LoadCustomInstrument(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId); sl@0: IMPORT_C TInt LoadCustomInstrumentData(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId); sl@0: IMPORT_C TInt UnloadCustomInstrument(TInt aCustomBankId,TInt aInstrumentId); sl@0: IMPORT_C HBufC* PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const; sl@0: IMPORT_C TInt StopTime(TTimeIntervalMicroSeconds& aStopTime) const; sl@0: IMPORT_C TInt SetStopTime(const TTimeIntervalMicroSeconds& aStopTime) const; sl@0: IMPORT_C TInt Polyphony(TInt& aNumNotes) const; sl@0: IMPORT_C TInt ChannelsSupported(TInt& aChannels) const; sl@0: IMPORT_C TInt ChannelVolume(TInt aChannel, TReal32& aChannelVol) const; sl@0: IMPORT_C TInt MaxChannelVolume(TReal32& aMaxVol) const; sl@0: IMPORT_C TInt SetChannelVolume(TInt aChannel,TReal32 aVolume); sl@0: IMPORT_C TInt SetChannelMute(TInt aChannel,TBool aMuted); sl@0: IMPORT_C TInt Volume(TInt& aVolume) const; sl@0: IMPORT_C TInt MaxVolume(TInt& aMaxVolume) const; sl@0: IMPORT_C TInt SetVolume(TInt aVolume); sl@0: IMPORT_C TInt SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); sl@0: IMPORT_C TInt GetBalance(TInt& aBalance) const; sl@0: IMPORT_C TInt SetBalance(TInt aBalance); sl@0: IMPORT_C TInt SetMaxPolyphony(TInt aMaxNotes); sl@0: IMPORT_C TInt GetRepeats(TInt& aNumRepeats) const; sl@0: IMPORT_C TInt SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); sl@0: IMPORT_C TInt SetBank(TBool aCustom); sl@0: IMPORT_C TInt IsTrackMute(TInt aTrack, TBool& aTrackMute) const; sl@0: IMPORT_C TInt IsChannelMute(TInt aChannel, TBool& aChannelMute) const; sl@0: IMPORT_C TInt GetInstrument(TInt aChannel, TInt& aInstrumentId, TInt& aBankId); sl@0: IMPORT_C TInt Close(); sl@0: IMPORT_C TInt Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration); sl@0: IMPORT_C void ReceiveEvents(TPckgBuf& aEventSize, TRequestStatus& aStatus); sl@0: IMPORT_C TInt RetrieveEvent(TDes8& aMidiEventPckg); sl@0: IMPORT_C TInt CancelReceiveEvents(); sl@0: IMPORT_C TInt MaxPolyphony(TInt& aNumNotes) const; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Mixin class to be derived from by controller plugins wishing sl@0: to support the MIDI controller custom commands. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MMidiCustomCommandImplementor sl@0: { sl@0: public: 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: */ sl@0: virtual void MmcSetPositionMicroBeatsL(TInt64 aMicroBeats) = 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: */ sl@0: virtual void MmcPositionMicroBeatsL(TInt64& aMicroBeats) = 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: */ sl@0: virtual void MmcPlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity) = 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 to the MIDI sl@0: resource playing time or the time elapsed since Play() 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: */ sl@0: virtual void MmcPlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity) = 0; sl@0: /** sl@0: Stops the playback of all notes on the given channel, sl@0: 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: */ sl@0: virtual void MmcStopNotesL(TInt aChannel) = 0; sl@0: /** sl@0: Synchronous function to commence playback of a note. sl@0: Multiple calls to this 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 sl@0: is 0 <= aVelocity <= 127, but the value zero actually causes the sl@0: message to be interpreted as a Note Off message instead of a Note On. sl@0: */ sl@0: virtual void MmcNoteOnL(TInt aChannel,TInt aNote,TInt aVelocity) = 0; sl@0: /** sl@0: Synchronous function to terminate playback of a note. sl@0: If no corresponding note 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. sl@0: There is no standard behaviour corresponding with note off velocity. sl@0: */ sl@0: virtual void MmcNoteOffL(TInt aChannel,TInt aNote,TInt aVelocity) = 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, sl@0: i.e., it can be used to give 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: */ sl@0: virtual void MmcPlaybackRateL(TInt& aPlayBackRate) = 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, sl@0: i.e., it can be used to give an overall speed factor for playback. sl@0: May be called whether playback is in progress or not. sl@0: sl@0: @param aPlayBackRate sl@0: Playback rate in percent times 1000, i.e., 100000 means original playback speed, sl@0: 200000 means double speed, and 50000 means half speed playback. sl@0: */ sl@0: virtual void MmcSetPlaybackRateL(TInt aPlayBackRate) = 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: */ sl@0: virtual void MmcMaxPlaybackRateL(TInt& aMaxRate) = 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: */ sl@0: virtual void MmcMinPlaybackRateL(TInt& aMinRate) = 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: */ sl@0: virtual void MmcTempoMicroBeatsPerMinuteL(TInt& aMicroBeatsPerMinute) = 0; sl@0: /** sl@0: Sets the tempo at which the current MIDI resource should be played. sl@0: May be called whether playback is in progress or not. The tempo is sl@0: independent from the playback rate, i.e., the resulting playback speed sl@0: will be affected by both. sl@0: sl@0: @param aMicroBeatsPerMinute sl@0: Tempo in microbeats per minute (BPM*1000000) to set. sl@0: */ sl@0: virtual void MmcSetTempoL(TInt aMicroBeatsPerMinute) = 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: virtual void MmcPitchTranspositionCentsL(TInt& aPitch) = 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 sl@0: to limitations of the MIDI engine. sl@0: */ sl@0: virtual void MmcSetPitchTranspositionL(TInt aCents, TInt& aCentsApplied) = 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: */ sl@0: virtual void MmcDurationMicroBeatsL(TInt64& aDuration) = 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: */ sl@0: virtual void MmcNumTracksL(TInt& aTracks) = 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 < NumTracks(). sl@0: @param aMuted sl@0: ETrue to mute the track, EFalse to unmute it. sl@0: */ sl@0: virtual void MmcSetTrackMuteL(TInt aTrack, TBool aMuted) = 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: */ sl@0: virtual void MmcMimeTypeL(TDes8& aMimeType) = 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: */ sl@0: virtual void MmcSetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats=0) = 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: */ sl@0: virtual void MmcSendMessageL(const TDesC8& aMidiMessage, TInt& aBytes) = 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: */ sl@0: virtual void MmcSendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes) = 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: */ sl@0: virtual void MmcSendMipMessageL(const TArray& aEntry) = 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: */ sl@0: virtual void MmcNumberOfBanksL(TBool aCustom, TInt& aNumBanks) = 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: */ sl@0: virtual void MmcGetBankIdL(TBool aCustom, TInt aBankIndex, TInt& aBankId) = 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 LoadCustomBanksL() 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 aBankId sl@0: Identifier of the custom sound bank loaded, occupying no more than 14 bits. sl@0: */ sl@0: virtual void MmcLoadCustomBankL(const TDesC& aFileName,TInt& aBankId) = 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 LoadCustomBanksL() 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 aBankId sl@0: Identifier of the custom sound bank loaded, occupying no more than 14 bits. sl@0: */ sl@0: virtual void MmcLoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankId) = 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 aBankId sl@0: Identifier of the custom sound bank to unload,occupying no more than 14 bits. sl@0: */ sl@0: virtual void MmcUnloadCustomBankL(TInt aBankId) = 0; sl@0: /** sl@0: Query if a bank has been loaded to the memory. sl@0: sl@0: @param aBankId 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: */ sl@0: virtual void MmcCustomBankLoadedL(TInt aBankId, TBool& aBankLoaded) = 0; sl@0: /** sl@0: Removes all custom sound banks from memory. sl@0: */ sl@0: virtual void MmcUnloadAllCustomBanksL() = 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: */ sl@0: virtual void MmcNumberOfInstrumentsL(TInt aBankId, TBool aCustom, TInt& aNumInstruments) = 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 < NumberOfInstrumentsL(). sl@0: @param aInstrumentId sl@0: Identifier of specified instrument. This may differ from the index since the sl@0: index simply enumerates the instruments, whereas identifiers may not be sl@0: contiguous, especially where certain instruments correspond to General MIDI-defined sl@0: instruments but not all instruments are present. Instrument identifiers are sl@0: between 0 and 127 inclusive. sl@0: */ sl@0: virtual void MmcGetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex, TInt& aInstrumentId) = 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. sl@0: If it has no name then an empty descriptor is returned. sl@0: */ sl@0: virtual const TDesC& MmcInstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) = 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: */ sl@0: virtual void MmcSetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId) = 0; sl@0: /** sl@0: Loads an individual instrument from file into custom sound bank memory for use. sl@0: The bank and instrument ids given in the file can be mapped into different bank sl@0: and instrument ids 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: */ sl@0: virtual void MmcLoadCustomInstrumentL(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId) = 0; sl@0: /** sl@0: Loads an individual instrument from descriptor into custom sound bank memory for use. sl@0: The bank and instrument ids given in the descriptor can be mapped into different bank sl@0: and instrument ids 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: */ sl@0: virtual void MmcLoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId) = 0; sl@0: /** sl@0: Removes an instrument from custom sound bank memory. sl@0: Only valid for instruments previously loaded from file. sl@0: Once unloaded the instrument is no longer available for use. sl@0: sl@0: @param aCustomBankId sl@0: Identifier of the custom sound bank containing the instrument sl@0: to unload, occupying no more than 14 bits. sl@0: @param aInstrumentId sl@0: Identifier of the instrument to unload. 0 <= aInstrumentId <= 127. sl@0: */ sl@0: virtual void MmcUnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId) = 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. sl@0: If the key does not have a name then an empty descriptor is returned. sl@0: */ sl@0: virtual const TDesC& MmcPercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) = 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 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: virtual void MmcStopTimeL(TTimeIntervalMicroSeconds& aStopTime) = 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: */ sl@0: virtual void MmcSetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime) = 0; sl@0: /** sl@0: Gets the number of currently active voices. sl@0: sl@0: @param aNumNotes sl@0: The number of currently active voices. sl@0: */ sl@0: virtual void MmcPolyphonyL(TInt& aNumNotes) = 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, 0 <= aChannels <=15. sl@0: */ sl@0: virtual void MmcChannelsSupportedL(TInt& aChannels) = 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: */ sl@0: virtual void MmcChannelVolumeL(TInt aChannel, TReal32& aChannelVol) = 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 sl@0: the smallest possible value that TReal32 supports. sl@0: */ sl@0: virtual void MmcMaxChannelVolumeL(TReal32& aMaxVol) = 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 channel sl@0: volume is -infinity dB, which is the smallest possible value that sl@0: TReal32 supports while the maximum channel volume is set via MaxVolumeL() sl@0: which represents the volume level in dB corresponding to the MIDI Channel sl@0: Volume controller. sl@0: */ sl@0: virtual void MmcSetChannelVolumeL(TInt aChannel,TReal32 aVolume) = 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: */ sl@0: virtual void MmcSetChannelMuteL(TInt aChannel,TBool aMuted) = 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: */ sl@0: virtual void MmcVolumeL(TInt& aVolume) = 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: */ sl@0: virtual void MmcMaxVolumeL(TInt& aMaxVolume) = 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 becomes (overall volume * channel volume / max volume). sl@0: sl@0: @param aVolume Overall volume setting to use. sl@0: */ sl@0: virtual void MmcSetVolumeL(TInt aVolume) = 0; sl@0: /** sl@0: Length of time over which the volume is faded up from zero to the current settings sl@0: when playback is started. sl@0: sl@0: @param aRampDuration sl@0: Duration of the ramping period. sl@0: */ sl@0: virtual void MmcSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration) = 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: */ sl@0: virtual void MmcGetBalanceL(TInt& aBalance) = 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: */ sl@0: virtual void MmcSetBalanceL(TInt aBalance) = 0; sl@0: /** sl@0: Set the max polyphony level the engine can handle. sl@0: sl@0: @param aMaxNotes sl@0: Max polyphony level, 0 <= PolyphonyL() <= aMaxNotes. sl@0: */ sl@0: virtual void MmcSetMaxPolyphonyL(TInt aMaxNotes) = 0; sl@0: /** sl@0: Gets the number of times the current opened resources have to be repeated. sl@0: sl@0: @param aNumRepeats sl@0: The number of time the current opened resources have to be repeated. sl@0: */ sl@0: virtual void MmcGetRepeatsL(TInt& aNumRepeats) = 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 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: */ sl@0: virtual void MmcSetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) = 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: */ sl@0: virtual void MmcSetBankL(TBool aCustom) = 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: */ sl@0: virtual void MmcIsTrackMuteL(TInt aTrack, TBool& aTrackMute) = 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: */ sl@0: virtual void MmcIsChannelMuteL(TInt aChannel, TBool& aChannelMute) = 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: */ sl@0: virtual void MmcGetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId) = 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: virtual void MmcCloseL() = 0; sl@0: /** sl@0: Stops playback of a resource but does not change the current position or release any resources. sl@0: 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 settings to zero. sl@0: */ sl@0: virtual void MmcStopL(const TTimeIntervalMicroSeconds& aFadeOutDuration) = 0; sl@0: /** sl@0: Gets the max polyphony level the engine can handle. sl@0: sl@0: @param aNumNotes sl@0: Max polyphony level, PolyphonyL() <= aMaxNotes. sl@0: */ sl@0: virtual void MmcMaxPolyphonyL(TInt& aMaxNotes) = 0; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Mixin class to define an object capable of handling a MIDI event within the controller framework. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MMidiEventHandler sl@0: { sl@0: public: sl@0: /** sl@0: Send an event to the client. sl@0: sl@0: @param aEvent sl@0: The MIDI event. sl@0: @return One of the system-wide error codes. sl@0: */ sl@0: virtual TInt SendMidiEventToClient(const CMMFMidiEvent& aEvent) = 0; sl@0: }; sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: class CMidiEventReceiver; sl@0: sl@0: /** sl@0: Custom command parser class to be used by controller plugins wishing to support sl@0: MIDI controller commands. sl@0: The controller plugin must be derived from MMidiCustomCommandImplementor sl@0: to use this class. The controller plugin should create an object of this type and add sl@0: it to the list of custom command parsers in the controller framework. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CMidiCustomCommandParser : public CMMFCustomCommandParserBase, sl@0: public MMidiEventHandler sl@0: { sl@0: public: sl@0: IMPORT_C static CMidiCustomCommandParser* NewL(MMidiCustomCommandImplementor& aImplementor); sl@0: IMPORT_C ~CMidiCustomCommandParser(); sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: void HandleRequest(TMMFMessage& aMessage); sl@0: virtual TInt SendMidiEventToClient(const CMMFMidiEvent& aEvent); sl@0: private: sl@0: CMidiCustomCommandParser(MMidiCustomCommandImplementor& aImplementor); sl@0: // Internal request handling methods. sl@0: void DoHandleRequestL(TMMFMessage& aMessage); sl@0: sl@0: TBool DoSetPositionMicroBeatsL(TMMFMessage& aMessage); sl@0: TBool DoPositionMicroBeatsL(TMMFMessage& aMessage); sl@0: TBool DoPlayNoteL(TMMFMessage& aMessage); sl@0: TBool DoPlayNoteWithStartTimeL(TMMFMessage& aMessage); sl@0: TBool DoStopNotesL(TMMFMessage& aMessage); sl@0: TBool DoNoteOnL(TMMFMessage& aMessage); sl@0: TBool DoNoteOffL(TMMFMessage& aMessage); sl@0: TBool DoPlaybackRateL(TMMFMessage& aMessage); sl@0: TBool DoSetPlaybackRateL(TMMFMessage& aMessage); sl@0: TBool DoMaxPlaybackRateL(TMMFMessage& aMessage); sl@0: TBool DoMinPlaybackRateL(TMMFMessage& aMessage); sl@0: TBool DoTempoMicroBeatsPerMinuteL(TMMFMessage& aMessage); sl@0: TBool DoSetTempoL(TMMFMessage& aMessage); sl@0: TBool DoPitchTranspositionCentsL(TMMFMessage& aMessage); sl@0: TBool DoSetPitchTranspositionL(TMMFMessage& aMessage); sl@0: TBool DoDurationMicroBeatsL(TMMFMessage& aMessage); sl@0: TBool DoNumTracksL(TMMFMessage& aMessage); sl@0: TBool DoSetTrackMuteL(TMMFMessage& aMessage); sl@0: TBool DoMimeTypeL(TMMFMessage& aMessage); sl@0: TBool DoSetSyncUpdateCallbackIntervalL(TMMFMessage& aMessage); sl@0: TBool DoSendMessageL(TMMFMessage& aMessage); sl@0: TBool DoSendMessageWithTimeStampL(TMMFMessage& aMessage); sl@0: TBool DoSendMipMessageL(TMMFMessage& aMessage); sl@0: TBool DoNumberOfBanksL(TMMFMessage& aMessage); sl@0: TBool DoGetBankIdL(TMMFMessage& aMessage); sl@0: TBool DoLoadCustomBankL(TMMFMessage& aMessage); sl@0: TBool DoLoadCustomBankDataL(TMMFMessage& aMessage); sl@0: TBool DoUnloadCustomBankL(TMMFMessage& aMessage); sl@0: TBool DoCustomBankLoadedL(TMMFMessage& aMessage); sl@0: TBool DoUnloadAllCustomBanksL(TMMFMessage& aMessage); sl@0: TBool DoNumberOfInstrumentsL(TMMFMessage& aMessage); sl@0: TBool DoGetInstrumentIdL(TMMFMessage& aMessage); sl@0: TBool DoInstrumentNameL(TMMFMessage& aMessage); sl@0: TBool DoCopyInstrumentNameL(TMMFMessage& aMessage); sl@0: TBool DoSetInstrumentL(TMMFMessage& aMessage); sl@0: TBool DoLoadCustomInstrumentL(TMMFMessage& aMessage); sl@0: TBool DoLoadCustomInstrumentDataL(TMMFMessage& aMessage); sl@0: TBool DoUnloadCustomInstrumentL(TMMFMessage& aMessage); sl@0: TBool DoPercussionKeyNameL(TMMFMessage& aMessage); sl@0: TBool DoCopyPercussionKeyNameL(TMMFMessage& aMessage); sl@0: TBool DoStopTimeL(TMMFMessage& aMessage); sl@0: TBool DoSetStopTimeL(TMMFMessage& aMessage); sl@0: TBool DoPolyphonyL(TMMFMessage& aMessage); sl@0: TBool DoChannelsSupportedL(TMMFMessage& aMessage); sl@0: TBool DoChannelVolumeL(TMMFMessage& aMessage); sl@0: TBool DoMaxChannelVolumeL(TMMFMessage& aMessage); sl@0: TBool DoSetChannelVolumeL(TMMFMessage& aMessage); sl@0: TBool DoSetChannelMuteL(TMMFMessage& aMessage); sl@0: TBool DoVolumeL(TMMFMessage& aMessage); sl@0: TBool DoMaxVolumeL(TMMFMessage& aMessage); sl@0: TBool DoSetVolumeL(TMMFMessage& aMessage); sl@0: TBool DoSetVolumeRampL(TMMFMessage& aMessage); sl@0: TBool DoGetBalanceL(TMMFMessage& aMessage); sl@0: TBool DoSetBalanceL(TMMFMessage& aMessage); sl@0: TBool DoSetMaxPolyphonyL(TMMFMessage& aMessage); sl@0: TBool DoGetRepeatsL(TMMFMessage& aMessage); sl@0: TBool DoSetRepeatsL(TMMFMessage& aMessage); sl@0: TBool DoSetBankL(TMMFMessage& aMessage); sl@0: TBool DoIsTrackMuteL(TMMFMessage& aMessage); sl@0: TBool DoIsChannelMuteL(TMMFMessage& aMessage); sl@0: TBool DoGetInstrumentL(TMMFMessage& aMessage); sl@0: TBool DoCloseL(TMMFMessage& aMessage); sl@0: TBool DoStopL(TMMFMessage& aMessage); sl@0: TBool DoReceiveEventsL(TMMFMessage& aMessage); sl@0: TBool DoRetrieveEventL(TMMFMessage& aMessage); sl@0: TBool DoCancelReceiveEventsL(TMMFMessage& aMessage); sl@0: sl@0: void DoCreateBufFromUintArrayL(RArray& aArray); sl@0: void DoCreateBufFromFourCCArrayL(RArray& aArray); sl@0: TBool DoMaxPolyphonyL(TMMFMessage& aMessage); sl@0: private: sl@0: /** The object that implements the MIDI controller interface */ sl@0: MMidiCustomCommandImplementor& iImplementor; sl@0: sl@0: CMidiEventReceiver* iMidiEventReceiver; sl@0: /** The events waiting to be sent to the client.*/ sl@0: RPointerArray iMidiEvents; sl@0: sl@0: // variable length data waiting to be copied back to the client sl@0: CBufFlat* iInstrumentName; sl@0: CBufFlat* iPercussionKeyName; sl@0: }; sl@0: sl@0: #endif