let bgm1file = GetCurrentScriptDirectory ~ "./bgm/bgm1.ogg";
let bgm2file = GetCurrentScriptDirectory ~ "./bgm/bgm2.ogg";
let bgmfiles = [bgm1file,bgm2file];

@Initialize{
	
	BGM;
	SetCommonData("musicswap",0);
	
}
@MainLoop{
	yield;
}

task BGM{
	
	let a = ObjSound_Create;
	let b = ObjSound_Create;
	let bgm = [a,b];
	ascent(i in 0..2){ObjSound_Load(bgm[i],bgmfiles[i]); ObjSound_SetLoopEnable(bgm[i],true); ObjSound_SetVolumeRate(bgm[i],100);}
	ObjSound_SetLoopSampleCount(bgm[0],1265545,10352088);
	ObjSound_SetLoopSampleCount(bgm[1],305760,7424736);
	ObjSound_Play(bgm[0]);
	while(GetCommonData("musicswap",0) < 1){yield;}
	descent(i in 0..100){ObjSound_SetVolumeRate(bgm[0],i); yield;}
	ObjSound_Stop(bgm[0]);
	while(GetCommonData("musicswap",0) < 2){yield;}
	ObjSound_Play(bgm[1]);
	
}

//bgm1 1265545 to 10352088
//bgm2 305760 to 7424736