/*
 * This code is released under the Microsoft Public License (MS-PL). See License.txt, below.
 */
#pragma once

typedef struct _INTERNAL_MUSIC {
	DWORD nSeqIdx;
	DWORD nVhIdx;
	LPDWORD nSeqOfs;
	LPDWORD nVhOfs;
	LPDWORD nSeqSize;
	LPDWORD nVhSize;
	LPDWORD isSeq;
	LPDWORD isVh;
	LPDWORD isVb;
	_TCHAR pszSeqExt[6];
	_TCHAR pszVhExt[6];
} INTERNAL_MUSIC, *PINTERNAL_MUSIC;

#pragma pack(1)
__declspec(align(1)) typedef struct _SEQ_HDR {
	DWORD form;
	DWORD id;
	WORD resolution;
	BYTE tempo[3];
	WORD rhythm;
} SEQ_HDR, *PSEQ_HDR;
# pragma pack ()

typedef struct _VH {
	LONG form;
	LONG ver;
	LONG id;
	DWORD fsize;
	WORD reserved0;
	WORD TotalNumOfPrograms;
	WORD TotalNumOfTones;
	WORD TotalNumOfVags;
	BYTE MasterVolume;
	BYTE MasterPan;
	BYTE BankAttribute1;
	BYTE BankAttribute2;
	DWORD SystemReserved2;
} VH, *PVH;

typedef struct _PROG_ATTR {
	BYTE tones;      /* # of tones */
	BYTE mvol;       /* program volume */
	BYTE prior;      /* program priority */
	BYTE mode;       /* program mode */
	BYTE mpan;       /* program pan */
	CHAR reserved0;  /* system reserved */
	SHORT attr;      /* program attribute */
	DWORD reserved1; /* system reserved */
	DWORD reserved2; /* system reserved */
} PROG_ATTR, *PPROG_ATTR;

typedef struct _TONE_ATTR {
	BYTE prior;        /* tone priority */
	BYTE mode;         /* play mode */
	BYTE vol;          /* tone volume*/
	BYTE pan;          /* tone panning */
	BYTE center;       /* center note */
	BYTE shift;        /* center note fine tune */
	BYTE min;          /* minimam note limit */
	BYTE max;          /* maximam note limit */
	BYTE vibW;         /* vibrate depth */
	BYTE vibT;         /* vibrate duration */
	BYTE porW;         /* portamento depth */
	BYTE porT;         /* portamento duration */
	BYTE pbmin;        /* under pitch bend max */
	BYTE pbmax;        /* upper pitch bend max */
	BYTE reserved1;    /* system reserved */
	BYTE reserved2;    /* system reserved */
	WORD adsr1;        /* adsr1 */
	WORD adsr2;        /* adsr2 */
	SHORT prog;        /* parent program*/
	SHORT vag;         /* vag reference */
	SHORT reserved[4]; /* system reserved */
} TONE_ATTR, *PTONE_ATTR;

#define MAX_SEQ_SIZE (65536)
#define MAX_SEQ_IN_SEP (16)
#define PROG_ATTR_NUM (128)
#define MAX_PROG_ATTR_SIZE (sizeof(PROG_ATTR) * PROG_ATTR_NUM)
#define TONE_ATTR_NUM (16)
#define MIN_TONE_ATTR_SIZE (sizeof(TONE_ATTR) * TONE_ATTR_NUM)
#define VAG_SIZE_TBL_NUM (256)
#define VAG_SIZE_TBL_SIZE (512)
