1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/MIDI/inc/midiclientutility.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,328 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MIDICLIENTUTILITY_H__
1.20 +#define __MIDICLIENTUTILITY_H__
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <e32base.h>
1.24 +#include <bamdesca.h>
1.25 +#include <mmf/common/mmfcontroller.h>
1.26 +#include <mmf/common/mmfstandardcustomcommands.h>
1.27 +#include <mmf/common/mmfdrmcustomcommands.h>
1.28 +#include <mmf/common/mmfmididatacommon.h>
1.29 +
1.30 +
1.31 +/**
1.32 +General utility class to hold instrument information.
1.33 +
1.34 +@publishedAll
1.35 +@released
1.36 +*/
1.37 +class TInstrumentInfo
1.38 + {
1.39 +public:
1.40 + /**
1.41 + *Identifier of sound bank to reference.
1.42 + */
1.43 + TInt iBankId;
1.44 +
1.45 + /**
1.46 + * Specifies whether to reference a custom or standard sound bank.
1.47 + */
1.48 + TBool iCustom;
1.49 +
1.50 + /**
1.51 + * Identifier of specified instrument.
1.52 + */
1.53 + TInt iInstrumentId;
1.54 + };
1.55 +
1.56 +/**
1.57 +Defines the state of the MIDI client utility with regard to the MIDI resource.
1.58 +
1.59 +@publishedAll
1.60 +@released
1.61 +*/
1.62 +enum TMidiState
1.63 + {
1.64 + /**
1.65 + * No MIDI resource is currently open.
1.66 + * The MIDI engine is not processing midi events.
1.67 + */
1.68 + EMidiStateClosedDisengaged,
1.69 +
1.70 +
1.71 + /**
1.72 + * A MIDI resource is open and primed but not playing.
1.73 + * The MIDI engine is not processing midi events.
1.74 + */
1.75 + EMidiStateOpenDisengaged,
1.76 +
1.77 + /**
1.78 + * A MIDI resource is open and currently playing.
1.79 + * The MIDI engine is currently processing midi events.
1.80 + */
1.81 + EMidiStateOpenPlaying,
1.82 +
1.83 + /**
1.84 + * Not able to play full SP-MIDI or DLS content, but attempting best-effort playback.
1.85 + */
1.86 + EMidiStatePlaybackIncompatible,
1.87 +
1.88 + /**
1.89 + * Due to system resource constraints and SP-MIDI content constraints,
1.90 + * there is no audible MIDI content during playback currently.
1.91 + * The situation may change if resources are freed later.
1.92 + */
1.93 + EMidiStatePlaybackSilent,
1.94 +
1.95 + /**
1.96 + * No MIDI resource is currently open.
1.97 + * The MIDI engine is currently processing midi events.
1.98 + */
1.99 + EMidiStateClosedEngaged,
1.100 +
1.101 + /**
1.102 + * A MIDI resource is open and primed but not playing.
1.103 + * The MIDI engine is currently processing MIDI events.
1.104 + * The transition to this state is only possible from EMidiStateOpenPlaying state,
1.105 + * when the 'playback head' reaches the end of media data or the playback
1.106 + * stops due to stop time set.
1.107 + */
1.108 + EMidiStateOpenEngaged,
1.109 + };
1.110 +
1.111 +/**
1.112 +Active object utility class to allow MIDI events to be signalled asynchronously.
1.113 +@see CMidiClientUtility::NewL().
1.114 +
1.115 +@publishedAll
1.116 +@released
1.117 +*/
1.118 +class MMidiClientUtilityObserver
1.119 + {
1.120 +public:
1.121 + /**
1.122 + A state change has occurred in the MIDI client utility.
1.123 +
1.124 + @param aOldState
1.125 + Old state.
1.126 + @param aNewState
1.127 + New state.
1.128 + @param aTime
1.129 + The time in microseconds at which playback stopped relative to the start of the MIDI resource.
1.130 + @param aError
1.131 + Error code.
1.132 + */
1.133 + virtual void MmcuoStateChanged(TMidiState aOldState,TMidiState aNewState,const TTimeIntervalMicroSeconds& aTime,TInt aError) = 0;
1.134 + /**
1.135 + The MIDI resource has encountered a tempo change message in the MIDI data stream.
1.136 +
1.137 + @param aMicroBeatsPerMinute
1.138 + New tempo value in micro beats per minute (BPM*1000000).
1.139 + */
1.140 + virtual void MmcuoTempoChanged(TInt aMicroBeatsPerMinute) = 0;
1.141 + /**
1.142 + The MIDI resource has encountered a volume change message in the MIDI data stream.
1.143 +
1.144 + @param aChannel
1.145 + Logical channel to which the message applies. 0 <= aChannel < ChannelsSupportedL().
1.146 + @param aVolumeInDecibels
1.147 + New volume setting being used.
1.148 + */
1.149 + virtual void MmcuoVolumeChanged(TInt aChannel,TReal32 aVolumeInDecibels) = 0;
1.150 + /**
1.151 + The MIDI resource has encountered a mute message in the MIDI data stream.
1.152 +
1.153 + @param aChannel
1.154 + Logical channel to which the message applies. 0 <= aChannel < ChannelsSupportedL().
1.155 + @param aMuted
1.156 + New muting state of the channel - ETrue is muted, EFalse is unmuted.
1.157 + */
1.158 + virtual void MmcuoMuteChanged(TInt aChannel,TBool aMuted) = 0;
1.159 + /**
1.160 + Callback in response to a call to CMIDIClientUtility::SetSyncUpdateCallbackIntervalL().
1.161 + By default there are no callbacks. Otherwise the callback is called at an interval set by the client.
1.162 +
1.163 + @param aMicroSeconds
1.164 + Position in microseconds relative to the start of the resource - only set if
1.165 + the sync update set function was called with the microseconds parameter set.
1.166 + @param aMicroBeats
1.167 + Position in microbeats relative to the start of the resource - only set if
1.168 + the sync update set function was called with the microbeats parameter set and
1.169 + the microseconds parameter set to 0.
1.170 + */
1.171 + virtual void MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats) = 0;
1.172 + /**
1.173 + A timed meta data entry has been found in the MIDI data stream, eg a timed song lyric in an SMF file.
1.174 +
1.175 + @param aMetaDataEntryId
1.176 + Index of the meta data entry - if this entry has not been encountere before,
1.177 + it will be added to the list of meta data entries. Previously encountered timed
1.178 + entries still generate this callback.
1.179 + @param aPosition
1.180 + Position in microseconds relative to the start of the MIDI resource that the MIDI
1.181 + meta data entry was found at.
1.182 + */
1.183 + virtual void MmcuoMetaDataEntryFound(const TInt aMetaDataEntryId,const TTimeIntervalMicroSeconds& aPosition) = 0;
1.184 + /**
1.185 + A MIP message has been found in the MIDI data stream.
1.186 +
1.187 + @param aMessage
1.188 + Reference to an array of MIP message entries (logical {channel, MIP} value pairs)
1.189 + contained in the message.
1.190 + */
1.191 + virtual void MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& aMessage) = 0;
1.192 + /**
1.193 + The polyphony of the MIDI engine has changed.
1.194 +
1.195 + @param aNewPolyphony
1.196 + The new polyphony value.
1.197 + */
1.198 + virtual void MmcuoPolyphonyChanged(TInt aNewPolyphony) = 0;
1.199 + /**
1.200 + An instrument has been changed on a channel.
1.201 +
1.202 + @param aChannel
1.203 + Channel where the change of instrument occurred. 0 <= aChannel < ChannelsSupportedL().
1.204 + @param aBankId
1.205 + Identifier of the bank that the instrument belongs to, occupying no more than 14 bits.
1.206 + The bank ID is a concatenation of MIDI bank MSB and LSB values.
1.207 + @param aInstrumentId
1.208 + Identifier of the instrument that has been changed. 0 <= aInstrumentId <= 127.
1.209 + */
1.210 + virtual void MmcuoInstrumentChanged(TInt aChannel,TInt aBankId,TInt aInstrumentId) = 0;
1.211 + };
1.212 +
1.213 +
1.214 +/**
1.215 +Utility class to provide a standard client interface to a MIDI controller.
1.216 +
1.217 +@publishedAll
1.218 +@released
1.219 +*/
1.220 +class CMidiClientUtility : public CBase
1.221 + {
1.222 + class CBody;
1.223 +public:
1.224 + IMPORT_C static CMidiClientUtility* NewL(MMidiClientUtilityObserver& aObserver,
1.225 + TInt aPriority = EMdaPriorityNormal,
1.226 + TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
1.227 +
1.228 + // alternative NewL for selecting shared/separate controller heap(s)
1.229 + IMPORT_C static CMidiClientUtility* NewL(MMidiClientUtilityObserver& aObserver,
1.230 + TInt aPriority,
1.231 + TInt aPref,
1.232 + TBool aUseSharedHeap);
1.233 +
1.234 + /** Destructor */
1.235 + virtual ~CMidiClientUtility();
1.236 + IMPORT_C TMidiState State() const;
1.237 + IMPORT_C void OpenFile(const TDesC& aFileName);
1.238 + IMPORT_C void OpenFile(const RFile& aFile);
1.239 +
1.240 + IMPORT_C void OpenFile(const TMMSource& aSource);
1.241 +
1.242 + IMPORT_C void OpenDes(const TDesC8& aDescriptor);
1.243 + IMPORT_C void OpenUrl(const TDesC& aUrl,TInt aIapId = KUseDefaultIap,const TDesC8& aMimeType=KNullDesC8);
1.244 + IMPORT_C void Close();
1.245 + IMPORT_C void Play();
1.246 + IMPORT_C void Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration);
1.247 + IMPORT_C void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
1.248 + IMPORT_C void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
1.249 + IMPORT_C void StopNotes(TInt aChannel);
1.250 + IMPORT_C void NoteOnL(TInt aChannel,TInt aNote,TInt aVelocity);
1.251 + IMPORT_C void NoteOffL(TInt aChannel,TInt aNote,TInt aVelocity);
1.252 + IMPORT_C TInt PlaybackRateL() const;
1.253 + IMPORT_C void SetPlaybackRateL(TInt aRate);
1.254 + IMPORT_C TInt MaxPlaybackRateL() const;
1.255 + IMPORT_C TInt MinPlaybackRateL() const;
1.256 + IMPORT_C TInt TempoMicroBeatsPerMinuteL() const;
1.257 + IMPORT_C void SetTempoL(TInt aMicroBeatsPerMinute);
1.258 + IMPORT_C TInt PitchTranspositionCentsL() const;
1.259 + IMPORT_C TInt SetPitchTranspositionL(TInt aCents);
1.260 + IMPORT_C TTimeIntervalMicroSeconds DurationMicroSecondsL() const;
1.261 + IMPORT_C TInt64 DurationMicroBeatsL() const;
1.262 + IMPORT_C TInt NumTracksL() const;
1.263 + IMPORT_C void SetTrackMuteL(TInt aTrack,TBool aMuted) const;
1.264 + IMPORT_C const TDesC8& MimeTypeL();
1.265 + IMPORT_C TTimeIntervalMicroSeconds PositionMicroSecondsL() const;
1.266 + IMPORT_C void SetPositionMicroSecondsL(const TTimeIntervalMicroSeconds& aPosition);
1.267 + IMPORT_C TInt64 PositionMicroBeatsL() const;
1.268 + IMPORT_C void SetPositionMicroBeatsL(TInt64 aMicroBeats);
1.269 + IMPORT_C void SetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds, TInt64 aMicroBeats=0);
1.270 + IMPORT_C TInt SendMessageL(const TDesC8& aMidiMessage);
1.271 + IMPORT_C TInt SendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime);
1.272 + IMPORT_C void SendMipMessageL(const RArray<TMipMessageEntry>& aEntry);
1.273 + IMPORT_C TInt NumberOfBanksL(TBool aCustom) const;
1.274 + IMPORT_C TInt GetBankIdL(TBool aCustom,TInt aBankIndex) const;
1.275 + IMPORT_C void LoadCustomBankL(const TDesC& aFileName,TInt& aBankCollectionIndex);
1.276 + IMPORT_C void LoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankCollectionIndex);
1.277 + IMPORT_C void UnloadCustomBankL(TInt aBankCollectionIndex);
1.278 + IMPORT_C TBool CustomBankLoadedL(TInt aBankCollectionIndex) const;
1.279 + IMPORT_C void UnloadAllCustomBanksL();
1.280 + IMPORT_C TInt NumberOfInstrumentsL(TInt aBankId,TBool aCustom) const;
1.281 + IMPORT_C TInt GetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex) const;
1.282 + IMPORT_C HBufC* InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const;
1.283 + IMPORT_C void GetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId);
1.284 + IMPORT_C void SetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId);
1.285 + IMPORT_C void LoadCustomInstrumentL(const TDesC& aFileName,TInt aFileBankId,TInt aFileInstrumentId,TInt aMemoryBankId,TInt aMemoryInstrumentId);
1.286 + IMPORT_C void LoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId);
1.287 + IMPORT_C void UnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId);
1.288 + IMPORT_C HBufC* PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const;
1.289 + IMPORT_C void StopTimeL(TTimeIntervalMicroSeconds& aStopTime) const;
1.290 + IMPORT_C void SetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime);
1.291 + IMPORT_C void SetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
1.292 + IMPORT_C TInt GetRepeats() const;
1.293 + IMPORT_C TInt PolyphonyL() const;
1.294 + IMPORT_C void SetMaxPolyphonyL(TInt aMaxNotes);
1.295 + IMPORT_C TInt ChannelsSupportedL() const;
1.296 + IMPORT_C TReal32 ChannelVolumeL(TInt aChannel) const;
1.297 + IMPORT_C TReal32 MaxChannelVolumeL() const;
1.298 + IMPORT_C void SetChannelVolumeL(TInt aChannel,TReal32 aVolumeInDecibels);
1.299 + IMPORT_C void SetChannelMuteL(TInt aChannel,TBool aMuted);
1.300 + IMPORT_C TInt VolumeL() const;
1.301 + IMPORT_C TInt MaxVolumeL() const;
1.302 + IMPORT_C void SetVolumeL(TInt aVolume);
1.303 + IMPORT_C void SetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
1.304 + IMPORT_C TInt GetBalanceL() const;
1.305 + IMPORT_C void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
1.306 + IMPORT_C void SetPriorityL(TInt aPriority, TInt aPref);
1.307 + IMPORT_C TInt NumberOfMetaDataEntriesL() const;
1.308 + IMPORT_C CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex) const;
1.309 +/**
1.310 + * @deprecated SetBankL is deprecated due to Mobile XMF specification requirement that user instruments (custom instruments) override standard instruments.
1.311 + */
1.312 + IMPORT_C void SetBankL(TBool aCustom);
1.313 + IMPORT_C TBool IsTrackMuteL(TInt aTrack) const;
1.314 + IMPORT_C TBool IsChannelMuteL(TInt aChannel) const;
1.315 + IMPORT_C void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
1.316 + IMPORT_C void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
1.317 + IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
1.318 + IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
1.319 + IMPORT_C TInt MaxPolyphonyL() const;
1.320 +
1.321 + IMPORT_C MMMFDRMCustomCommand* GetDRMCustomCommand();
1.322 +
1.323 +private:
1.324 + /**
1.325 + * a pointer to the implementation.
1.326 + */
1.327 + CBody* iBody;
1.328 + friend class CBody;
1.329 + };
1.330 +
1.331 +#endif