//---------------------------------------------------------------------------

#pragma hdrstop

#include "Instruments.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

char *GM_GROUP[] = {
	"钢琴",
	"音阶打击乐器",
	"风琴",
	"吉他",
	"贝司",
	"弦乐",
	"合奏/合唱",
	"铜管",
	"簧管",
	"木管",
	"合成主音",
	"合成背景",
	"合成效果",
	"民间乐器",
	"打击乐器",
	"声音效果"
};

char * GM_INSTRUMENT[] = {
//钢琴组
  "大钢琴"
,"明亮钢琴"
,"电钢琴"
,"酒吧钢琴"
,"柔和电钢琴"
,"合唱电钢琴"
,"拨弦古钢琴"
,"击弦古钢琴"

//打击乐器组
,"钢片琴"
,"钟琴"
,"八音盒"
,"颤音琴"
,"马林巴"
,"木琴"
,"管钟"
,"杨琴"

//风琴组
,"击杆风琴"
,"打击式风琴"
,"摇滚风琴"
,"教堂风琴"
,"簧管风琴"
,"手风琴"
,"口琴"
,"探戈手风琴"

//吉他组
,"尼龙弦吉他"
,"钢弦吉他"
,"爵士电吉他"
,"清音电吉他"
,"闷音电吉他"
,"过激电吉他"
,"失真电吉他"
,"吉他泛音"

//贝司组
,"原音贝司"
,"指弹电贝司"
,"拨片电贝司"
,"无品贝司"
,"掌击贝司1"
,"掌击贝司2"
,"合成贝司1"
,"合成贝司2"

//提琴组
,"小提琴"
,"中提琴"
,"大提琴"
,"低音大提琴"
,"颤音弦乐组"
,"拨奏弦乐组"
,"竖琴"
,"定音鼓"

//合奏/合唱组
,"弦乐合奏1"
,"弦乐合奏2"
,"合成弦乐合奏1"
,"合成弦乐合奏2"
,"人声合唱(啊)"
,"人声合唱(嘟)"
,"合成人声"
,"管弦乐齐奏"

//铜管乐器组
,"小号"
,"长号"
,"大号"
,"弱音小号"
,"圆号"
,"铜管组"
,"合成铜管1"
,"合成铜管2"

//簧片乐器组
,"高音萨克斯"
,"中音萨克斯"
,"次中音萨克斯"
,"低音萨克斯"
,"双簧管"
,"英国管"
,"巴松(大管)"
,"单簧管(黑管)"

//木管乐器组
,"短笛"
,"长笛"
,"竖笛"
,"排箫"
,"吹瓶"
,"日本尺八"
,"口哨声"
,"陶笛(洋埙)"

//合成主音组
,"合成主音1(方波)"
,"合成主音2(锯齿波)"
,"合成主音3"
,"合成主音4"
,"合成主音5"
,"合成主音6(人声)"
,"合成主音7(平行五度)"
,"合成主音8(贝司与主音)"

//合成背景组
,"合成背景1(新时代)"
,"合成背景2(温暖)"
,"合成背景3"
,"合成背景4(合唱)"
,"合成背景5(弓弦)"
,"合成背景6(金属)"
,"合成背景7(光环)"
,"合成背景8"

//合成效果组
,"效果(雨声)"
,"效果(音轨)"
,"效果(水晶)"
,"效果(大气)"
,"效果(明亮)"
,"效果(诡异)"
,"效果(回声)"
,"效果(科幻)"

//民族乐器组
,"西塔尔"
,"班卓琴"
,"三昧线"
,"十三弦筝"
,"卡林巴"
,"风笛"
,"民族提琴"
,"山奈"

//打击乐器组
,"叮当铃"
,"阿果果"
,"钢鼓"
,"木鱼"
,"太鼓"
,"通通鼓"
,"合成鼓"
,"钢钹"

//特殊音效组
,"吉他换把杂音"
,"呼吸声"
,"海浪声"
,"鸟鸣"
,"电话铃"
,"直升飞机"
,"鼓掌声"
,"枪声"
};

char * LSZ_STYLTYPES[24] =
{
"流行",
"民谣",
"摇滚",
"舞曲",
"爵士",
"蓝调",
"桑巴",
"古典",
"圆舞曲",
"独立",
"乡村",
"R&B",
"电子",
"小夜曲",
"进行曲",
"叙事曲",
"说唱",
"拉丁",
"曼波",
"雷鬼",
"萨尔萨",
"摇摆",
"波萨",
"FUNKY"
} ;

char * CNS_INSTRUMENT[] = {
//吹奏类
"",
"大唢呐",
"小唢呐",
"高笙",
"曲笛",
"曲笛2",
"梆笛",
"梆笛2",
"巴乌",

//弦乐类
"二胡",
"高胡",
"京胡",
"板胡",

//弹奏类
"琵琶1",
"琵琶2",
"阮",
"三弦",
"扬琴",

"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",

//打击乐
"朝鲜鼓",
"大鼓",
"大鼓1",
"大鼓2",
"打击乐",
"大锣",
"风锣",
"京戏",
"锣",
"铙钹镲",
"排鼓",
"声波",
"象脚鼓",
"编磬",
"编钟"
};

FONTINFO::FONTINFO()
{
	memset( this, 0, sizeof(FONTINFO) );
}

FONTINFO::FONTINFO( char* strFile, char* strFont, int nInst, FONTPRESET* setInst,
											int nDrum, FONTPRESET* setDrum )
{
	strcpy(strFileName, strFile);

	if( strlen(strFont) > 0 )
		strcpy(strFontName, strFont);
	else{
		char *name = strrchr( strFile, '\\' )+1,
			*ext = strrchr( strFile, '.' );

		if( ext>name ){
			strncpy( strFontName, name, ext-name );
			strFontName[ext-name] = '\0';
		}
		else
			strcpy(strFontName, name );
	}

	nInstCount = nInst;
	if( nInst>0 ){
		aInsts = new FONTPRESET[nInst];
		memcpy( aInsts, setInst, sizeof(FONTPRESET) * nInst );
	}
	else{
		aInsts = NULL;
	}

	nDrumCount = nDrum;
	if( nDrum>0 ){
		aDrums = new FONTPRESET[nDrum];
		memcpy( aDrums, setDrum, sizeof(FONTPRESET) * nDrum );
	}
	else{
		aDrums = NULL;
	}
}

VSTINFO::VSTINFO()
{
	memset( this, 0, sizeof(VSTINFO) );
}

VSTINFO::VSTINFO( char* strFile, char* strEff, unsigned int id )
{
	uniqueID = id;
	strcpy(strFileName, strFile);

	if( strlen(strEff) > 0 && stricmp(strEff, "container") )
		strcpy(strVSTName, strEff);
	else{
		char *name = strrchr( strFile, '\\' )+1,
			*ext = strrchr( strFile, '.' );

		if( ext>name ){
			strncpy( strVSTName, name, ext-name );
			strVSTName[ext-name] = '\0';
		}
		else
			strcpy(strVSTName, name );
	}
}

VSTINFO::~VSTINFO()
{
	while( !aPlugins.empty() ){
		delete aPlugins.back();
		aPlugins.pop_back();
	}
}

char AutoTransCNS( char prog )
{
	char ret = -1;

	if( prog>=8 && prog<=15 )
		ret = 17;
	else if( prog>=16 && prog<=23 )
		ret = 9;//3;
	else if( prog>=40 && prog<=45 )
		ret = 9;
	else if( prog==46 )
		ret = 13;
	else if( prog==47 )
		ret = 31;
	else if( prog>=56 && prog<=63 )
		ret = 1;
	else if( prog>=64 && prog<=71 )
		ret = 4;
	else if( prog>=72 && prog<=79 )
		ret = 6;

	return ret;
}

