epoc32/include/midiclientutility.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef __MIDICLIENTUTILITY_H__
williamr@2
    17
#define __MIDICLIENTUTILITY_H__
williamr@2
    18
williamr@2
    19
#include <e32std.h>
williamr@2
    20
#include <e32base.h>
williamr@2
    21
#include <bamdesca.h> 
williamr@2
    22
#include <mmf/common/mmfcontroller.h>
williamr@2
    23
#include <mmf/common/mmfstandardcustomcommands.h>
williamr@2
    24
#include <mmf/common/mmfdrmcustomcommands.h>
williamr@2
    25
#include <mmf/common/mmfmididatacommon.h>
williamr@2
    26
williamr@2
    27
williamr@2
    28
/**
williamr@2
    29
General utility class to hold instrument information.
williamr@2
    30
williamr@2
    31
@publishedAll
williamr@2
    32
@released
williamr@2
    33
*/
williamr@2
    34
class TInstrumentInfo
williamr@2
    35
	{
williamr@2
    36
public:
williamr@2
    37
	/**
williamr@2
    38
	 *Identifier of sound bank to reference.
williamr@2
    39
	 */
williamr@2
    40
	TInt iBankId;
williamr@2
    41
williamr@2
    42
	/**
williamr@2
    43
	 * Specifies whether to reference a custom or standard sound bank.
williamr@2
    44
	 */
williamr@2
    45
	TBool iCustom;
williamr@2
    46
williamr@2
    47
	/**
williamr@2
    48
	 * Identifier of specified instrument.
williamr@2
    49
	 */
williamr@2
    50
	TInt iInstrumentId;
williamr@2
    51
	};
williamr@2
    52
williamr@2
    53
/**
williamr@2
    54
Defines the state of the MIDI client utility with regard to the MIDI resource.
williamr@2
    55
williamr@2
    56
@publishedAll
williamr@2
    57
@released
williamr@2
    58
*/
williamr@2
    59
enum TMidiState
williamr@2
    60
	{
williamr@2
    61
	/**
williamr@2
    62
	 * No MIDI resource is currently open. 
williamr@2
    63
	 * The MIDI engine is not processing midi events.
williamr@2
    64
	 */
williamr@2
    65
	EMidiStateClosedDisengaged,  
williamr@2
    66
williamr@2
    67
williamr@2
    68
	/**
williamr@2
    69
	 * A MIDI resource is open and primed but not playing.
williamr@2
    70
	 * The MIDI engine is not processing midi events.
williamr@2
    71
	 */
williamr@2
    72
	EMidiStateOpenDisengaged,
williamr@2
    73
williamr@2
    74
	/**
williamr@2
    75
	 * A MIDI resource is open and currently playing.
williamr@2
    76
	 * The MIDI engine is currently processing midi events.
williamr@2
    77
	 */
williamr@2
    78
	EMidiStateOpenPlaying,  
williamr@2
    79
williamr@2
    80
	/**
williamr@2
    81
	 * Not able to play full SP-MIDI or DLS content, but attempting best-effort playback.
williamr@2
    82
	 */
williamr@2
    83
	EMidiStatePlaybackIncompatible,
williamr@2
    84
williamr@2
    85
	/**
williamr@2
    86
	 * Due to system resource constraints and SP-MIDI content constraints,
williamr@2
    87
	 * there is no audible MIDI content during playback currently.
williamr@2
    88
	 * The situation may change if resources are freed later.
williamr@2
    89
	 */
williamr@2
    90
	EMidiStatePlaybackSilent,
williamr@2
    91
		
williamr@2
    92
	/**
williamr@2
    93
	 * No MIDI resource is currently open. 
williamr@2
    94
	 * The MIDI engine is currently processing midi events. 
williamr@2
    95
	 */
williamr@2
    96
	EMidiStateClosedEngaged, 
williamr@2
    97
	
williamr@2
    98
	/**
williamr@2
    99
	 * A MIDI resource is open and primed but not playing. 
williamr@2
   100
	 * The MIDI engine is currently processing MIDI events. 
williamr@2
   101
	 * The transition to this state is only possible from EMidiStateOpenPlaying state, 
williamr@2
   102
	 * when the 'playback head' reaches the end of media data or the playback
williamr@2
   103
	 * stops due to stop time set.
williamr@2
   104
	 */
williamr@2
   105
	EMidiStateOpenEngaged,
williamr@2
   106
	};
williamr@2
   107
williamr@2
   108
/**
williamr@2
   109
Active object utility class to allow MIDI events to be signalled asynchronously.
williamr@2
   110
@see CMidiClientUtility::NewL().
williamr@2
   111
williamr@2
   112
@publishedAll
williamr@2
   113
@released
williamr@2
   114
*/
williamr@2
   115
class MMidiClientUtilityObserver
williamr@2
   116
	{
williamr@2
   117
public:
williamr@2
   118
    /**
williamr@2
   119
    A state change has occurred in the MIDI client utility.
williamr@2
   120
	
williamr@2
   121
    @param aOldState 
williamr@2
   122
	       Old state.
williamr@2
   123
    @param aNewState 
williamr@2
   124
	       New state.	 
williamr@2
   125
    @param aTime 
williamr@2
   126
	       The time in microseconds at which playback stopped relative to the start of the MIDI resource.	
williamr@2
   127
    @param aError	
williamr@2
   128
	       Error code.
williamr@2
   129
    */
williamr@2
   130
	virtual void MmcuoStateChanged(TMidiState aOldState,TMidiState aNewState,const TTimeIntervalMicroSeconds& aTime,TInt aError) = 0;
williamr@2
   131
    /**
williamr@2
   132
    The MIDI resource has encountered a tempo change message in the MIDI data stream.
williamr@2
   133
	
williamr@2
   134
    @param aMicroBeatsPerMinute 
williamr@2
   135
	       New tempo value in micro beats per minute (BPM*1000000).
williamr@2
   136
    */
williamr@2
   137
	virtual void MmcuoTempoChanged(TInt aMicroBeatsPerMinute) = 0;
williamr@2
   138
    /**
williamr@2
   139
    The MIDI resource has encountered a volume change message in the MIDI data stream.
williamr@2
   140
	
williamr@2
   141
    @param aChannel 
williamr@2
   142
	       Logical channel to which the message applies. 0 <= aChannel < ChannelsSupportedL().
williamr@2
   143
    @param aVolumeInDecibels 
williamr@2
   144
	       New volume setting being used.
williamr@2
   145
    */
williamr@2
   146
	virtual void MmcuoVolumeChanged(TInt aChannel,TReal32 aVolumeInDecibels) = 0;
williamr@2
   147
    /**
williamr@2
   148
    The MIDI resource has encountered a mute message in the MIDI data stream.
williamr@2
   149
	
williamr@2
   150
    @param aChannel
williamr@2
   151
	       Logical channel to which the message applies. 0 <= aChannel < ChannelsSupportedL().
williamr@2
   152
    @param aMuted 
williamr@2
   153
	       New muting state of the channel - ETrue is muted, EFalse is unmuted.
williamr@2
   154
    */
williamr@2
   155
	virtual void MmcuoMuteChanged(TInt aChannel,TBool aMuted) = 0;
williamr@2
   156
    /**
williamr@2
   157
    Callback in response to a call to CMIDIClientUtility::SetSyncUpdateCallbackIntervalL().
williamr@2
   158
	By default there are no callbacks. Otherwise the callback is called at an interval set by the client. 
williamr@2
   159
	
williamr@2
   160
    @param aMicroSeconds 
williamr@2
   161
	       Position in microseconds relative to the start of the resource - only set if 
williamr@2
   162
	       the sync update set function was called with the microseconds parameter set.
williamr@2
   163
    @param aMicroBeats 
williamr@2
   164
	       Position in microbeats relative to the start of the resource - only set if
williamr@2
   165
	       the sync update set function was called with the microbeats parameter set and
williamr@2
   166
	       the microseconds parameter set to 0.
williamr@2
   167
    */
williamr@2
   168
	virtual void MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats) = 0;
williamr@2
   169
    /**
williamr@2
   170
    A timed meta data entry has been found in the MIDI data stream, eg a timed song lyric in an SMF file.
williamr@2
   171
	
williamr@2
   172
    @param aMetaDataEntryId 
williamr@2
   173
	       Index of the meta data entry - if this entry has not been encountere before,
williamr@2
   174
	       it will be added to the list of meta data entries. Previously encountered timed 
williamr@2
   175
		   entries still generate this callback. 
williamr@2
   176
    @param aPosition
williamr@2
   177
	       Position in microseconds relative to the start of the MIDI resource that the MIDI
williamr@2
   178
	       meta data entry was found at.
williamr@2
   179
    */
williamr@2
   180
	virtual void MmcuoMetaDataEntryFound(const TInt aMetaDataEntryId,const TTimeIntervalMicroSeconds& aPosition) = 0;
williamr@2
   181
    /**
williamr@2
   182
    A MIP message has been found in the MIDI data stream.
williamr@2
   183
	
williamr@2
   184
    @param aMessage 
williamr@2
   185
	       Reference to an array of MIP message entries (logical {channel, MIP} value pairs) 
williamr@2
   186
	       contained in the message.
williamr@2
   187
    */
williamr@2
   188
	virtual void MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& aMessage) = 0;
williamr@2
   189
    /**
williamr@2
   190
    The polyphony of the MIDI engine has changed.
williamr@2
   191
	
williamr@2
   192
    @param aNewPolyphony 
williamr@2
   193
	       The new polyphony value.
williamr@2
   194
    */
williamr@2
   195
	virtual void MmcuoPolyphonyChanged(TInt aNewPolyphony) = 0;
williamr@2
   196
    /**
williamr@2
   197
    An instrument has been changed on a channel.
williamr@2
   198
	
williamr@2
   199
    @param aChannel 
williamr@2
   200
	       Channel where the change of instrument occurred. 0 <= aChannel < ChannelsSupportedL().
williamr@2
   201
    @param aBankId 
williamr@2
   202
	       Identifier of the bank that the instrument belongs to, occupying no more than 14 bits. 
williamr@2
   203
	       The bank ID is a concatenation of MIDI bank MSB and LSB values.
williamr@2
   204
    @param aInstrumentId 
williamr@2
   205
	       Identifier of the instrument that has been changed. 0 <= aInstrumentId <= 127.
williamr@2
   206
    */
williamr@2
   207
	virtual void MmcuoInstrumentChanged(TInt aChannel,TInt aBankId,TInt aInstrumentId) = 0;
williamr@2
   208
	};
williamr@2
   209
williamr@2
   210
williamr@2
   211
/**
williamr@2
   212
Utility class to provide a standard client interface to a MIDI controller.
williamr@2
   213
williamr@2
   214
@publishedAll
williamr@2
   215
@released
williamr@2
   216
*/
williamr@2
   217
class CMidiClientUtility : public CBase
williamr@2
   218
	{
williamr@2
   219
	class CBody;
williamr@2
   220
public:
williamr@2
   221
	IMPORT_C static CMidiClientUtility* NewL(MMidiClientUtilityObserver& aObserver,
williamr@2
   222
											 TInt aPriority = EMdaPriorityNormal,
williamr@4
   223
											 TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
williamr@2
   224
	
williamr@2
   225
	// alternative NewL for selecting shared/separate controller heap(s)
williamr@2
   226
	IMPORT_C static CMidiClientUtility* NewL(MMidiClientUtilityObserver& aObserver,
williamr@2
   227
											 TInt aPriority,
williamr@4
   228
											 TInt aPref,
williamr@2
   229
											 TBool aUseSharedHeap);
williamr@2
   230
williamr@2
   231
	/**	Destructor */
williamr@2
   232
	virtual ~CMidiClientUtility();
williamr@2
   233
	IMPORT_C TMidiState State() const;
williamr@2
   234
	IMPORT_C void OpenFile(const TDesC& aFileName);
williamr@2
   235
	IMPORT_C void OpenFile(const RFile& aFile);
williamr@2
   236
williamr@2
   237
	IMPORT_C void OpenFile(const TMMSource& aSource);
williamr@2
   238
williamr@2
   239
	IMPORT_C void OpenDes(const TDesC8& aDescriptor);
williamr@2
   240
	IMPORT_C void OpenUrl(const TDesC& aUrl,TInt aIapId = KUseDefaultIap,const TDesC8& aMimeType=KNullDesC8);
williamr@2
   241
	IMPORT_C void Close();
williamr@2
   242
	IMPORT_C void Play();
williamr@2
   243
	IMPORT_C void Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration);
williamr@2
   244
	IMPORT_C void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
williamr@2
   245
	IMPORT_C void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
williamr@2
   246
	IMPORT_C void StopNotes(TInt aChannel);
williamr@2
   247
	IMPORT_C void NoteOnL(TInt aChannel,TInt aNote,TInt aVelocity);
williamr@2
   248
	IMPORT_C void NoteOffL(TInt aChannel,TInt aNote,TInt aVelocity);
williamr@2
   249
	IMPORT_C TInt PlaybackRateL() const;
williamr@2
   250
	IMPORT_C void SetPlaybackRateL(TInt aRate);
williamr@2
   251
	IMPORT_C TInt MaxPlaybackRateL() const;
williamr@2
   252
	IMPORT_C TInt MinPlaybackRateL() const;
williamr@2
   253
	IMPORT_C TInt TempoMicroBeatsPerMinuteL() const;
williamr@2
   254
	IMPORT_C void SetTempoL(TInt aMicroBeatsPerMinute);
williamr@2
   255
	IMPORT_C TInt PitchTranspositionCentsL() const;
williamr@2
   256
	IMPORT_C TInt SetPitchTranspositionL(TInt aCents);
williamr@2
   257
	IMPORT_C TTimeIntervalMicroSeconds DurationMicroSecondsL() const;
williamr@2
   258
	IMPORT_C TInt64 DurationMicroBeatsL() const;
williamr@2
   259
	IMPORT_C TInt NumTracksL() const;
williamr@2
   260
	IMPORT_C void SetTrackMuteL(TInt aTrack,TBool aMuted) const;
williamr@2
   261
	IMPORT_C const TDesC8& MimeTypeL();
williamr@2
   262
	IMPORT_C TTimeIntervalMicroSeconds PositionMicroSecondsL() const;
williamr@2
   263
	IMPORT_C void SetPositionMicroSecondsL(const TTimeIntervalMicroSeconds& aPosition);
williamr@2
   264
	IMPORT_C TInt64 PositionMicroBeatsL() const;
williamr@2
   265
	IMPORT_C void SetPositionMicroBeatsL(TInt64 aMicroBeats);
williamr@2
   266
	IMPORT_C void SetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds, TInt64 aMicroBeats=0);		
williamr@2
   267
	IMPORT_C TInt SendMessageL(const TDesC8& aMidiMessage);
williamr@2
   268
	IMPORT_C TInt SendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime);
williamr@2
   269
	IMPORT_C void SendMipMessageL(const RArray<TMipMessageEntry>& aEntry);
williamr@2
   270
	IMPORT_C TInt NumberOfBanksL(TBool aCustom) const;
williamr@2
   271
	IMPORT_C TInt GetBankIdL(TBool aCustom,TInt aBankIndex) const;
williamr@2
   272
	IMPORT_C void LoadCustomBankL(const TDesC& aFileName,TInt& aBankCollectionIndex);
williamr@2
   273
	IMPORT_C void LoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankCollectionIndex);
williamr@2
   274
	IMPORT_C void UnloadCustomBankL(TInt aBankCollectionIndex);
williamr@2
   275
	IMPORT_C TBool CustomBankLoadedL(TInt aBankCollectionIndex) const;
williamr@2
   276
	IMPORT_C void UnloadAllCustomBanksL();
williamr@2
   277
	IMPORT_C TInt NumberOfInstrumentsL(TInt aBankId,TBool aCustom) const;
williamr@2
   278
	IMPORT_C TInt GetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex) const;
williamr@2
   279
	IMPORT_C HBufC* InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const;
williamr@2
   280
	IMPORT_C void GetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId);
williamr@2
   281
	IMPORT_C void SetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId);
williamr@2
   282
	IMPORT_C void LoadCustomInstrumentL(const TDesC& aFileName,TInt aFileBankId,TInt aFileInstrumentId,TInt aMemoryBankId,TInt aMemoryInstrumentId);
williamr@2
   283
	IMPORT_C void LoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId);
williamr@2
   284
	IMPORT_C void UnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId);
williamr@2
   285
	IMPORT_C HBufC* PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const;
williamr@2
   286
	IMPORT_C void StopTimeL(TTimeIntervalMicroSeconds& aStopTime) const;
williamr@2
   287
	IMPORT_C void SetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime);
williamr@2
   288
	IMPORT_C void SetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
williamr@2
   289
	IMPORT_C TInt GetRepeats() const;
williamr@2
   290
	IMPORT_C TInt PolyphonyL() const;
williamr@2
   291
	IMPORT_C void SetMaxPolyphonyL(TInt aMaxNotes);
williamr@2
   292
	IMPORT_C TInt ChannelsSupportedL() const;
williamr@2
   293
	IMPORT_C TReal32 ChannelVolumeL(TInt aChannel) const;
williamr@2
   294
	IMPORT_C TReal32 MaxChannelVolumeL() const;
williamr@2
   295
	IMPORT_C void SetChannelVolumeL(TInt aChannel,TReal32 aVolumeInDecibels);
williamr@2
   296
	IMPORT_C void SetChannelMuteL(TInt aChannel,TBool aMuted);
williamr@2
   297
	IMPORT_C TInt VolumeL() const;
williamr@2
   298
	IMPORT_C TInt MaxVolumeL() const;
williamr@2
   299
	IMPORT_C void SetVolumeL(TInt aVolume);
williamr@2
   300
	IMPORT_C void SetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
williamr@2
   301
	IMPORT_C TInt GetBalanceL() const;
williamr@2
   302
	IMPORT_C void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
williamr@4
   303
	IMPORT_C void SetPriorityL(TInt aPriority, TInt aPref);
williamr@2
   304
	IMPORT_C TInt NumberOfMetaDataEntriesL() const;
williamr@2
   305
	IMPORT_C CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex) const;
williamr@2
   306
/**
williamr@2
   307
 * @deprecated SetBankL is deprecated due to Mobile XMF specification requirement that user instruments (custom instruments) override standard instruments.
williamr@2
   308
 */
williamr@2
   309
	IMPORT_C void SetBankL(TBool aCustom);
williamr@2
   310
	IMPORT_C TBool IsTrackMuteL(TInt aTrack) const;
williamr@2
   311
	IMPORT_C TBool IsChannelMuteL(TInt aChannel) const;
williamr@2
   312
	IMPORT_C void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
williamr@2
   313
	IMPORT_C void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
williamr@2
   314
	IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
williamr@2
   315
	IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
williamr@2
   316
	IMPORT_C TInt MaxPolyphonyL() const;
williamr@2
   317
williamr@2
   318
	IMPORT_C MMMFDRMCustomCommand* GetDRMCustomCommand();
williamr@2
   319
	
williamr@2
   320
private:
williamr@2
   321
	/**
williamr@2
   322
	 * a pointer to the implementation.
williamr@2
   323
	 */
williamr@2
   324
	CBody* iBody;	
williamr@2
   325
	friend class CBody;
williamr@2
   326
	}; 
williamr@2
   327
williamr@2
   328
#endif