Source: midimountain/mcTrack.h


Annotated List
Files
Globals
Hierarchy
Index
//=============================================================================
//  TMidiTrack Class Definition
//============================================================================
// Author  : Adrian Meyer
// Version : 0.2.2
// Log     :
//=============================================================================
// 18.02.2000 building class
// 20.02.2000 added track name, instrument name
// 23.02.2000 added lists: lyric, text, channel prefix
// 25.02.2000 added compiler switch DEBUG_OUTPUT
//						added TMidiEvent list
// 29.02.2000 corrected AddEvent for inserting event
// 27.03.2000 added preffered channel number
// 28.03.2000 added selected flag
// 05.04.2000 read track index
// 06.04.2000 read owner
// 28.08.2000 corrected destructor
//						added message system
// 03.09.2000	instrument patch added
// 04.09.2000 deleting events and referenced events
// 09.09.2000 allocating char* with lenth + 1
// 11.09.2000 track create and track destroy message moved to sequence
// 19.04.2001 changing to TMidiList for events
// 01.05.2001 adding port
//============================================================================
// to do:
// add sysex list
//=============================================================================

#include <mcEvent.h>

#ifndef __MCTRACK__
#define __MCTRACK__

#include <mcSequence.h>
#include <mcList.h>
#include <mcBase.h>

// messages for track
const long cMMTrackSelect               = cMCTrack << 16 | 0x0001;
const long cMMTrackEventListChanged     = cMCTrack << 16 | 0x0002;
const long cMMTrackSetName              = cMCTrack << 16 | 0x0003;
const long cMMTrackSetInstrumentName    = cMCTrack << 16 | 0x0004;
const long cMMTrackSetChannel           = cMCTrack << 16 | 0x0005;
const long cMMTrackAddLyric             = cMCTrack << 16 | 0x0006;
const long cMMTrackRenameLyric          = cMCTrack << 16 | 0x0007;
const long cMMTrackDeleteLyric          = cMCTrack << 16 | 0x0008;
const long cMMTrackAddText              = cMCTrack << 16 | 0x0009;
const long cMMTrackRenameText           = cMCTrack << 16 | 0x000A;
const long cMMTrackDeleteText           = cMCTrack << 16 | 0x000B;
const long cMMTrackAddChannelPrefix     = cMCTrack << 16 | 0x000C;
const long cMMTrackDeleteChannelPrefix  = cMCTrack << 16 | 0x000D;
const long cMMTrackSetIntrumentPatch    = cMCTrack << 16 | 0x000E;
const long cMMTrackSetPort              = cMCTrack << 16 | 0x000F;

// structures for lists
struct sLyricList																			// lyric list
{
  char* Lyric;																				// lyric piece
  long Offset;	  																		// offset of lyric
  long ID;																						// id of lyric
  sLyricList* Next;																		// next lyric
};

struct sTextList																			// text list
{
  char* Text;																					// text piece
  long Offset;	  																		// offset of text
  long ID;																						// id of text
  sTextList* Next;																		// next text
};

struct sChannelPrefixList															// channel prefix list
{
  short ChannelPrefix;																// channel prefix
  long Offset;	  																		// offset of lyric
  long ID;																						// id of lyric
  sChannelPrefixList* Next;														// next channel prefix
};

class TMidiEvent;

	// in midi file "MTrk nnnnnnnn" n for chunk length
	// end of track "FF 2F 00"
class TMidiTrack : public TMidiBase
	{

  private:
		TMidiSequence* fOwner;														// owned by this sequence
		TMidiList* fEventList;														// list with events;
		short fChannel;																		// prefered midi channel
		bool fSelected;																		// selection flag
		
    // if first event is patch change, else -1
    short fInstrumentPatch;														// patch of channel
		
 		// in midi file as "FF 03 len text" offset 0
	  char* fTrackName;																	// name of track

 		// in midi file as "FF 04 len text" offset 0
		char* fInstrumentName;														// name of instrument

    // port information from META tag
    short fPort;                                      // port information

		// in midi file as "FF 05 len text"
		sLyricList* fLyricList;														// list with lyrics

		// in midi file as "FF 01 len text"
		sTextList* fTextList;															// list with text

		// in midi file as "FF 20 01 cc"
    sChannelPrefixList* fChannelPrefixList;						// list  with channel prefix

	public:
		TMidiTrack( TMidiSequence* aOwner );
     ~TMidiTrack( void );

		int GetIndex( void );															// read the tracks index
		TMidiSequence* GetOwner( void );									// read owner
		
		bool GetSelected();																// read selected flag
		void SetSelected( bool aSelected );								// write selected flag

		TMidiEvent* AddEvent( long aOffset );							// add midi event
		TMidiEvent* AddEventEnd( long aOffset );					// add midi event at end
		TMidiEvent* GetEvent( long aID );									// read event
		long GetEventCount( void );												// read event counter
		void SetEventOffset( TMidiEvent* aMidiEvent, long aOffset );		// set new offset
		void DeleteEvent( TMidiEvent* aMidiEvent );				// delete event

		void SetTrackName( char *aTrackName );						// write track name
		char* GetTrackName( void );												// read track name
		void SetInstrumentName( char *aInstrumentName );	// write instrument name
		char* GetInstrumentName( void );									// read instrument name
		void SetChannel( short aChannel );								// write channel
		short GetChannel( void );													// read channel
		void SetInstrumentPatch( short aInstrumentPatch );// set instrument patch #
		short GetInstrumentPatch( void );									// read instrument patch
    void SetPort( short aPort );                      // set port
    short GetPort( void );                            // read port

		void AddLyric( char* aLyric, long aOffset );			// add lyric
		void RenameLyric( char* aLyric, long aID );				// rename lyric
    void DeleteLyric( long aID );											// delete a lyric
    sLyricList* GetLyric( long aID );									// list lyric list
		long GetLyricCount( void );       								// read lyric count

		void AddText( char* aText, long aOffset );				// add text
		void RenameText( char* aText, long aID );					// rename text
    void DeleteText( long aID );											// delete a text
    sTextList* GetText( long aID );										// list text list
		long GetTextCount( void );       									// read text count

																											// add channel prefix
		void AddChannelPrefix( short aChannelPrefix, long aOffset );	
    void DeleteChannelPrefix( long aID );							// delete a ChannelPrefix
    sChannelPrefixList* GetChannelPrefix( long aID );	// list ChannelPrefix list
		long GetChannelPrefixCount( void );       				// read ChannelPrefix count
  };

#endif

Generated by: root@castle on Fri Jul 20 00:33:17 2001, using kdoc 2.0a36.