亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mp3_play.c

?? mega64 + VS1003 + SD卡
?? C
?? 第 1 頁 / 共 2 頁
字號:



#include"sys_config.h"
#include"lrc/lrc.h"

extern struct LrcStructHead_s LrcStructHead;	/* Gloable struct variable to record the lyric info */

/* Use to record the time tag info */
extern uint8 lrcbuffer[sizeof(struct LrcStruct_s) * MAXITEM];

/* Use to record the lyric data */
extern uint8 lrcdatbuf[MAXLRCDATSIZE];

extern volatile uint8 key_value;

/* enum for ICON */
enum IconTag
{
	Playing,Pause,RepetAll,RepetOne,Shuffle,Time,Music,Speaker
};

/* Long name buffer and flag */
extern unsigned char LongNameBuffer[MAX_LONG_NAME_SIZE];
extern unsigned char LongNameFlag;

/* indicate if the file system is FAT32 , ortherwise it is FAT16, note FAT12 is not supported */
extern BYTE FAT32_Enable;

extern WORD SectorsPerClust;//每簇扇區數
extern WORD FirstDataSector;//第一個數據扇區數

//struct FileInfoStruct FileInfo;//文件信息

struct direntry MusicInfo;	/* Music file information, 32Bytes short directory record, contain the short name and others */


//void (*BootLoaderEntry)(void) = 0xf800;	/* boot loader entry, bootloader size: 2048Bytes */

uint16 totalsongs;	/* total number of songs*/
uint8 type;			/* current song's file type, mp3 wma mid or wav */
extern uint8 lrc;			/* Gloable variable to indicate wether the songs has a lyric file, 1 means have */
extern uint8 HanziEnable;	/* Gloable variable to indicate wether the firmware are exist, and 1 means exist */


uint8 Volume_Table[32] PROGMEM = \
{
255,225,206,188,161,145,130,116,103,91,80,70,61,53,46,40,35,30,26,22,19,16,13,11,9,7,5,4,3,2,1,0
};

uint8 track[128];			/* stroe the information of songs (bit set indicate songs has been played) */

void ClearTrackInfo()		/* cleare the array track[128] */
{
	uint8 i;
	for(i=0;i<128;i++)track[i] = 0;
}

uint8 SetTrack(uint16 songs)/* set the track bit, return 1 means the song has been played */
{
	uint8 byte_offset;
	uint8 bit_offset;
	songs--;
	byte_offset = songs/8;
	bit_offset = songs%8;
	if(track[byte_offset] & (1<<bit_offset))return 1;
	else
	{
		track[byte_offset] |= 1<<bit_offset;
		return 0;
	}
}

/*void nextline()
{
	USART_putchar(0x0d);
	USART_putchar(0x0a);
}*/

void Delay(uint16 n)//延時
{
	while(n--)asm("nop");
}


uint8 PlayMusicwithKey()//播放音樂函數,一旦執行不會退出
{
	uint16 count;			//數據計數			//data counting
	uint8 i;				//循環變量			//loop variable
	uint16 j;				//循環變量			//loop variable
	DWORD p;				//簇指示值			//cluster
	DWORD totalsect;		//文件擁有的扇區數	//cotain the total sector number of a file
	uint16 leftbytes;		//剩余字節			//cotain the left bytes number of a file //the last cluster usually not fully occupied by the file
	uint8 *buffer;			//緩沖				//buffer
	DWORD sector;			//扇區				//recor the current sector to judge the end sector
	uint8 flag;				//播放/暫停標志		//flag of pause
	uint16 vol= DEFAULT_VOLUME;//初始音量,應與vs1003函數里的初始音量相同	//default volume
	uint8 vol_temp;
	uint16 songs=1;			//默認放第一首歌	//play the fist songs by default
	uint16 songs_cnt = 0;					//how many songs have been played
	uint8 mode=0;			//單曲重復			//repet all by default
	unsigned long rand_val;
	
	uint8 total[6];	/* for total songs indication */
	uint8 current[12];	/* Current songs number */
	uint16 temp = totalsongs;

	uint8 time[6];
	uint16 decodetime;

	uint8 volume[3];
	uint8 min,sec;
      
	struct LrcStruct_s * LrcStruct_pp;
	uint16 lrcaddr;

	/* the display buffer (characters) */
	#define MAX_LRC_DISP 52
	uint8 lrcdata[MAX_LRC_DISP];
	uint8 lrcDisFlag = 0;	/* indicate if it need display lyric on the lcd */
	uint8 lrcCnt = 0;		/* lrcdata buffer count */

	ClearTrackInfo();

      
	//printf_P(PSTR("\r\nCurrent mode : "));
	/*switch(mode)
	{
		case REPET_ALL: printf_P(PSTR("repet all"));break;
		case REPET_ONE:printf_P(PSTR("repet one"));break;
		case RANDOM:printf_P(PSTR("shuffle"));break;
	}*/

	if(totalsongs==0)//如果沒有歌曲則異常退出	//if no music file return
	{
		lcdClrDisBuf();
		LCD_print12_P(0,20,PSTR("File not found!"));
		lcdUpdateDisplay();
		return;
	}
	
/**********************************************/
	for(i=0;i<5;i++)
	{
		total[4-i] = temp%10;
		temp /= 10;
	}
	for(i=0;i<5;i++)
	{
		if(total[i])break;
	}
	for(j=0;j<5-i;j++)
	{
		total[j] = total[j+i] + 0x30;
	}
	total[j] = 0;
/**********************************************/
	vol_temp = 15;
	volume[0] = vol_temp/10 + 0x30;
	volume[1] = vol_temp%10 +0x30;    
	volume[2] = '\0'; 
/**********************************************/

	//Timer1_Initial();//啟動定時器,用于產生隨機函數的種子	//initialize the timer
next://下一首歌的起始地方						//label for "goto"
	if(mode==RANDOM)//隨機播放歌曲 				//if the mode is shuffle the songs
	{
		songs_cnt++;
		if(songs_cnt == totalsongs && totalsongs<1025)
		{
			ClearTrackInfo();
			songs_cnt = 0;
		}
		rand_val = TCNT1;
		Delay((random() && 0x00ff));
		rand_val <<= 16;
		rand_val += TCNT1;
		srandom(rand_val);
		if(totalsongs>1024)
		{
			songs = (uint16)(((random()/214749)*(uint32)totalsongs)/10000)+1;//隨機產生歌曲序號	//create random song number
		}
		while(totalsongs<1025)
		{
			songs = (uint16)(((random()/214749)*(uint32)totalsongs)/10000)+1;//隨機產生歌曲序號	//create random song number
			if(SetTrack(songs) == 0)break;
		}	
	}
	count=0;//清基數	//clear count
	flag=1;
	if(type != MID)VS1003B_Fill2048Zero();

	lrcDisFlag = 0;	/* clear the flag in case some lyric is not displayed of last songs */
	lrcCnt = 0;		/* clear the lrc count, maybe more lyric will display on one screen, for sometimes cpu do not have time to display the last one */
	//decodetime = -1;	
	//lcdInit();	/* the connection of the 3310lcd is not stable, so we reinitialize it every time */
	VS1003B_SoftReset();//soft reset //in case of playing wma files//軟件復位

#if FIX_DIRECTORY
	Search((unsigned char *)(MUSIC_PATH),&MusicInfo,&songs,&type);		//找到相應的文件		//find the file
#else
	Search(&lrcaddr,&MusicInfo,&songs,&type);		//找到相應的文件		//find the file
#endif

	/* here we use lrcaddr to get the record address in the eeprom which the file placed */

	for(j=0;j<MAX_LONG_NAME_SIZE/2;j++)			/* cut off the extension, only leave the name*/
	{
		if(((unsigned int*)LongNameBuffer)[j] == 0)
		{
			((unsigned int*)LongNameBuffer)[j-4] = 0;
			break;
		}
	}
/****************************************************/
	time[0] = '0';
	time[1] = '0';
	time[2] = ':';
	time[3] = '0';
	time[4] = '0';
	time[5] = '\0';
	decodetime = -1;	/* for display the lyric which is at time 00:00 */
/******************************************************/
	temp = songs;
	for(i=0;i<5;i++)
	{
		current[4-i] = temp%10;
		temp /= 10;
	}
	for(i=0;i<5;i++)
	{
		if(current[i])break;
	}
	for(j=0;j<5-i;j++)
	{
		current[j] = current[j+i] + 0x30;
	}
	current[j++] = '/';
	for(i=0;i<6;i++)
	{
		current[j+i] = total[i];
	}
	
/********************************************************/	
	lcdClrDisBuf();
	switch(type)
	{
		case MP3:LCD_print12_P(0,0,PSTR("mp3"));break;
		case WMA:LCD_print12_P(0,0,PSTR("wma"));break;
		case MID:LCD_print12_P(0,0,PSTR("mid"));break;
		case WAV:LCD_print12_P(0,0,PSTR("wav"));break;
		default:break;
	}
	Print_ICON_12(18,0,Playing);
	LCD_print12(30,0,current);
	switch(mode)
	{
		case REPET_ALL:Print_ICON_12(72,0,RepetAll);break;
		case REPET_ONE:Print_ICON_12(72,0,RepetOne);break;
		case RANDOM   :Print_ICON_12(72,0,Shuffle);break;
		default:break;
	}
/*****************************************************/
	//LCD_print12(30,36,time);
	//LCD_print12(72,36,volume);
	//Print_ICON_12(60,36,Speaker);
	//Print_ICON_12(0,12,Music);	
/******************************************************/
	if(LongNameFlag)
	{
		if(HanziEnable)	/* if HanziEnable, convert the long name from unicode to GBK */
		{
			buffer = malloc(MAX_LONG_NAME_SIZE);
			if(buffer == 0)return 1;
			i = 0;
			j=0;
			while(1)
			{
				temp = ((unsigned int *)LongNameBuffer)[i++];

				/*  you may confused about following code, because at previous we set "." to 0 for lry search*/
				if(temp == 0 )
				{
					buffer[j++] = '.';
					while(1)	/*copy the extention */
					{
						temp = ((unsigned int *)LongNameBuffer)[i++];
						if(temp == 0)break;	/* end */
						buffer[j++] = (uint8)temp;
					}
					break;
				}
				else if (temp<0x80)
				{
					buffer[j++]=(uint8)temp;
				}
				else if(temp<0x4e00)
				{
					*((unsigned int*)&(buffer[j])) = "?";
					j+=2;
				}
				else if(temp<0x9fa6)
				{
					if(Unicode_to_GBK((unsigned char *)&temp))return 1;
					*((unsigned int*)&(buffer[j])) = temp;
					j+=2;                                
				}
				else
				{
					*((unsigned int*)&(buffer[j])) = "?";
					j+=2;
				}
			}
			buffer[j] = 0;
			LCD_print12(12,12,buffer);
			//LCD_print_unicode12(12,12,(unsigned int *)LongNameBuffer);
		}
		else
		{
			LCD_print12_P(0,12,PSTR("-- --By bozai\nFirmware lost!"));
		}
	}
	else 	/* short name */
	{
		for(j=0;j<8;j++)
		{
			if(MusicInfo.deName[j]==0x20)break;
			LongNameBuffer[j]=MusicInfo.deName[j];
		}
		//LongNameBuffer[j++]='\0';
		LongNameBuffer[j++]='.';
		count = j+3;
		for(count=0;count<3;count++)LongNameBuffer[j+count]=MusicInfo.deExtension[count];
		LongNameBuffer[j+count]='\0';
		if(HanziEnable)LCD_print12(12,12,LongNameBuffer);
		else
		{
			LCD_print12_P(0,12,PSTR(" --By Michael Firmware lost!"));
		}
	} 
/*************************************************************/
	LCD_print12(30,36,time);
	LCD_print12(72,36,volume);
	Print_ICON_12(60,36,Speaker);
	Print_ICON_12(0,12,Music);	
	lcdUpdateDisplay();
/**************************************************************/

//	printf_P(PSTR("\r\nNow playing "));
//	printf_P(PSTR("%s :"),current);
	if(LongNameFlag && HanziEnable)
	{
	//	printf_P(PSTR("%s"),buffer);
		free(buffer);
	}
	else
	{
		for(j=0;j<8;j++)
		{
			if(MusicInfo.deName[j]==0x20)break;
			USART_putchar(MusicInfo.deName[j]);
		}
        
		USART_putchar('.');
		for(j=0;j<3;j++)
		{
			//if(MusicInfo.deName[j]==0x20)break;
			USART_putchar(MusicInfo.deExtension[j]);
		}
	}

/**************************************************************/
#if FIX_DIRECTORY
	LrcProc(LongNameBuffer,LongNameFlag);
#else
	LrcProc(LongNameBuffer,lrcaddr,LongNameFlag);			/* search lyc file */
											/* lrcaddr indicate the record address of eeprom */
											/* first search the current folder then the default */
#endif											
	LrcStruct_pp = LrcStructHead.header;

/**************************************************************/

	p     = MusicInfo.deStartCluster+(((unsigned long)MusicInfo.deHighClust)<<16);//讀文件首簇	//the first cluster of the file
		
	totalsect = MusicInfo.deFileSize/512; //計算扇區數			//calculate the total sectors
	leftbytes = MusicInfo.deFileSize%512; //計算剩余的字節數	//calculate the left bytes	
	i=0;
	sector=0;

	if(lrc && HanziEnable)		/* clear the previous time area */
	{
		if(LrcStruct_pp->time/1000 == 0 && LrcStruct_pp != 0)/* see if it has lyric at time 00:00 */
		{
			
			decodetime = -1;	/* for display the lyric which is at time 00:00 */
		}
		else
		{
			decodetime = 0;		/* otherwise, it will not flush screen when 00:00, then you can see the filename and other info for 1 second */
		}
		LCD_print12_P(36,36,PSTR("    "));
		lcdClrDisBuf(); 
	}
    
	while(1)
	{
		for(;i<SectorsPerClust;i++)		//一個簇	//a cluster
		{
			buffer=malloc(512);
			FAT_LoadPartCluster(p,i,buffer);//讀一個扇區	//read a sector
			count=0;
			while(count<512)
			{

				if(VS1003B_NeedData() && flag)	//根據需要送數據  //send data  honoring DREQ
				{
					VS1003B_Write32B(&buffer[count]);
					count += 32;
					if(sector == totalsect && count >= leftbytes)		//如果文件已結束		//if this is the end of the file
					{
						if(type == MID)//waiting the midi file was decoded
							VS1003B_Fill2048Zero();
						i=SectorsPerClust;
						break;
					}//文件結束			//file ended
					if(count == 511){break;}//512字節送完跳出		//break if a sector was sent
				}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
捆绑紧缚一区二区三区视频| 欧美日韩在线播放三区| 久久久久久久精| 亚洲精品国产一区二区三区四区在线| 国产成人激情av| 欧美经典三级视频一区二区三区| 丰满少妇在线播放bd日韩电影| 老司机精品视频一区二区三区| 一本色道久久综合亚洲aⅴ蜜桃 | 国产精品中文欧美| 欧美一区二区免费| 成人免费黄色在线| 美女精品自拍一二三四| 一区二区欧美视频| 91精品国产综合久久久久| 国产在线精品不卡| 亚洲精品ww久久久久久p站| 日韩一级完整毛片| 一本久道久久综合中文字幕 | 欧美亚一区二区| 美女视频免费一区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 精品999在线播放| 国产三级欧美三级| 亚洲美女屁股眼交3| 欧美熟乱第一页| 成人动漫一区二区在线| 美日韩黄色大片| 亚洲成人午夜影院| 亚洲精品成人a在线观看| 欧美一区二区三区在线| 日韩美女视频一区二区在线观看| 中文av一区二区| 久久精品国产精品亚洲精品| 色婷婷久久久久swag精品| 国产精品久久久久久妇女6080 | 欧美视频精品在线| 亚洲免费在线视频| 91久久精品日日躁夜夜躁欧美| 国产精品传媒在线| 色综合久久综合网97色综合| 亚洲九九爱视频| 欧美亚洲动漫制服丝袜| 午夜不卡av免费| 日韩欧美在线1卡| 韩国欧美国产一区| 国产精品久久久久三级| 色偷偷88欧美精品久久久| 一卡二卡欧美日韩| 91精品在线麻豆| 久久成人18免费观看| 国产欧美日产一区| 色一情一伦一子一伦一区| 一级女性全黄久久生活片免费| 欧美性高清videossexo| 亚洲chinese男男1069| 欧美电影免费观看高清完整版在线| 久久国产剧场电影| 国产精品久久精品日日| 欧美在线观看视频一区二区三区 | 一本大道久久a久久精二百| 一区二区三区免费看视频| 欧美日韩中文字幕一区| 免费成人美女在线观看| 久久嫩草精品久久久精品一| 99精品久久只有精品| 天堂精品中文字幕在线| 国产三级一区二区三区| 亚洲图片另类小说| 中文字幕一区av| 日韩一级视频免费观看在线| 风间由美性色一区二区三区| 亚洲综合免费观看高清完整版| 欧美一级视频精品观看| 成人av在线影院| 蜜臀久久99精品久久久久宅男| 日本一区二区三区电影| 3d成人h动漫网站入口| 国产69精品久久99不卡| 午夜电影网一区| 国产欧美一区二区精品秋霞影院| 欧美色网站导航| 风间由美中文字幕在线看视频国产欧美| 亚洲精品国产一区二区三区四区在线 | 欧美丰满一区二区免费视频| 国内精品国产三级国产a久久| 亚洲欧美日韩国产成人精品影院 | 免费看黄色91| 一区二区三区影院| 国产精品蜜臀av| 久久网站最新地址| 欧美另类高清zo欧美| 91美女片黄在线| 国产成人av电影在线| 老司机免费视频一区二区| 亚洲国产日韩av| 一区二区三区在线视频观看58| 久久精品日产第一区二区三区高清版| 欧美日韩国产中文| 日本韩国一区二区三区视频| 黑人巨大精品欧美黑白配亚洲| 亚洲图片欧美视频| 亚洲精品乱码久久久久久 | 一区在线观看免费| 久久久亚洲精品石原莉奈| 欧美日韩一二三| 99麻豆久久久国产精品免费| 国产一区二三区好的| 日韩电影在线观看一区| 午夜在线成人av| 一区二区三区欧美在线观看| 亚洲丝袜自拍清纯另类| 亚洲人成在线观看一区二区| 国产精品女人毛片| 国产精品天天看| 中日韩免费视频中文字幕| 日本一区二区三区久久久久久久久不 | 国产精品短视频| 国产精品国产三级国产普通话99| 国产蜜臀av在线一区二区三区| 久久久亚洲国产美女国产盗摄 | 亚洲一区二区五区| 亚洲欧美偷拍另类a∨色屁股| 国产日韩精品一区| 国产精品欧美一区二区三区| 日本一区免费视频| 国产精品久久久久桃色tv| 亚洲男人电影天堂| 亚洲黄色小视频| 一区二区三区四区在线播放| 亚洲综合免费观看高清完整版| 亚洲一区二三区| 日本 国产 欧美色综合| 日本不卡一二三| 韩国成人精品a∨在线观看| 久久精品久久综合| 成人综合婷婷国产精品久久 | 一区二区成人在线| 午夜视频久久久久久| 亚洲自拍偷拍欧美| 三级精品在线观看| 激情伊人五月天久久综合| 国v精品久久久网| 91黄色小视频| 欧美成人艳星乳罩| 中文字幕一区av| 亚洲动漫第一页| 国产一区二区三区四区五区入口| 成人小视频在线观看| 欧美午夜精品久久久久久超碰| 欧美一区二区福利在线| 欧美激情一区二区三区四区| 国产精品乱码人人做人人爱| 亚洲免费观看高清完整版在线| 亚洲国产精品天堂| 精品一区二区三区免费毛片爱| 国产精品国产三级国产专播品爱网| 成人丝袜高跟foot| 青青草国产精品亚洲专区无| 亚洲精品视频在线| 蜜桃久久久久久久| 91免费观看在线| 26uuu久久综合| 图片区小说区区亚洲影院| 国产精品911| 国产精品白丝jk白祙喷水网站| 丁香六月综合激情| 91麻豆精品国产自产在线观看一区| 国产无遮挡一区二区三区毛片日本 | 亚洲欧洲成人自拍| 免费在线看成人av| 欧美怡红院视频| 欧美激情一区在线| 国产美女一区二区| 欧美一级理论片| 一区二区不卡在线视频 午夜欧美不卡在| 国产综合久久久久影院| 69堂亚洲精品首页| 亚洲自拍偷拍欧美| 色婷婷综合久久久久中文| 国产亚洲综合在线| 久久99精品久久久久久国产越南| 91福利视频久久久久| 国产精品二三区| 成人性生交大片免费看中文网站| 欧美日韩极品在线观看一区| 中文字幕乱码一区二区免费| 天天色天天操综合| 麻豆成人在线观看| 色婷婷激情久久| 国产精品女人毛片| 久久精品99国产精品日本| 欧美高清精品3d| 婷婷丁香激情综合| 色综合久久久久久久| 欧美激情在线一区二区| 国产风韵犹存在线视精品| 日韩一区二区在线观看| 三级不卡在线观看| 日韩视频一区二区三区在线播放|