#include "stdio.h"
#include "M451Series.h"
#include "NuEdu-Basic01.h"
#define PLL_CLOCK 72000000
typedef struct Tonedata{
short note;//音符:0 表示 不发音。1 2 3 4 5 6 7
short tone;//音调:1 低音,2 中
short length;//长度//1表示四分之一拍,8表2拍
}Tone,*PTone;
typedef struct SongData
{
unsigned int length;//歌曲长度
PTone pData;
} Song,*PSong;
unsigned int yinfu[22]={0,
262,294,330,349,392,315,494,
523,578,659,698,784,880,988,//中音
1046,1175,1318, 1397,1568,1780,1976
};
Tone songdata1[37]={ {6,2,8},{5,2,2},{3,2,4},{5,2,4},{1,3,4},{6,2,2},{5,2,2},{6,2,4},{0,0,4},
{3,2,4},{5,2,2},{6,2,2},{5,2,4},{3,2,2},{2,2,2},{1,2,2},{6,1,2},{5,2,2},
{3,2,2},{2,2,4},{0,0,4},{2,2,8},{3,2,2},{5,2,4},{5,2,2},{6,2,2},{3,2,8},
{2,2,2},{1,2,4},{5,2,8},{3,2,2},{2,2,2},{1,2,2},{6,1,2},{1,2,2},{5,1,4},
{0,0,4}};//《世上只有妈妈好》
Tone songdata2[65]= { {5,2,4},{3,2,2},{1,3,8},{6,2,4},{1,3,4},{5,2,8},{0,0,2},{5,2,4},
{1,2,2},{2,2,2},{3,2,4},{2,2,2},{1,2,2},{2,2,8},{0,0,8},{5,2,4},{3,2,2},
{5,2,2},{2,2,4},{1,3,6},{7,2,2},{6,2,4},{1,3,4},{5,2,8},{5,2,4},{2,2,2},
{3,2,2},{4,2,6},{7,1,2},{1,2,8},{0,0,8},{6,2,4},{1,3,4},{0,0,1},{1,3,8},
{7,2,4},{6,2,2},{7,2,2},{1,3,8},{6,2,2},{7,2,2},{1,3,2},{6,2,2},{6,2,2},
{5,2,2},{2,2,2},{1,2,2},{2,2,8},{0,0,8},{5,2,4},{3,2,2},{5,2,2},{1,3,8},
{7,2,2},{6,2,4},{1,3,4},{5,2,8},{0,0,1},{5,2,4},{2,2,2},{3,2,2},{4,2,8},
{7,1,2},{1,2,12},{0,0,4}};//《送别》-李叔同
int playspeed=1;
int playmode=1;//播放模式:1 单曲循环,2 全部循环,3 停止,4 暂停
int currentsong=0;//当前歌曲
Song songs[2];//世上只有妈妈?
int numOfsongs=2;
void PlaySong(PSong pSong)
{
int temp=playmode;
int length=pSong->length;
int oldmode=playmode;
PTone pTone=pSong->pData;
int index=0,i,j;
for(i=0;i
{
if(pTone[i].note==0)
{