基于51单片机音乐播放仿真 乐谱制作软件 音乐资料.rar
(668.85 KB, 售价: 1 E币)
- 单片机源程序如下:
- #include <REG52.H>
- #include "MusicBox.h"
- /*********************代码说明**************************
- 音乐驱动参考部分网上代码,感谢原作者
- T0,T1用于翁鸣器频率计时和控制
- 使用P1.0口控制翁鸣器,高电平导通
- 使用外部中断0,实现曲目控制。设置中断0为最高优先级
- 在开发板上调试使用STC89C51芯片,4K flash
- 在手工焊板上使用STC89C52芯片,8K flash,能放置更多歌曲文件
- ********************************************/
- #define MSC_NUM 5 //总曲目数
- unsigned char play_num = 0; //当前播放曲目号
- unsigned char play_state = 1;
- unsigned char code Music_SummerNut[]; //盛夏的果实
- unsigned char code Music_leftTrouble[]; //忘忧草
- unsigned char code Music_moonHeart[]; //月亮代表我的心
- unsigned char code Music_JiXiang[]; //吉祥三宝
- unsigned char code Music_twoButterFly[]; //两只蝴蝶
- //定义歌曲播放指针数组
- unsigned char* pMusic[] = {Music_SummerNut, Music_leftTrouble, Music_twoButterFly, Music_moonHeart, Music_JiXiang};
- void main(void)
- {
- unsigned char degree = 3; //设定播放音调,升八度
- unsigned int play_speed = 300; //设定播放速度,默认为300
- InitialSound();
- while(1)
- {
- //调用歌曲播放函数
- Play(pMusic[play_num], 0, degree, play_speed);
- //单曲完毕后,延时1S
- Delay1ms(1000);
-
- //重设播放状态为1
- play_state = 1;
- }
- }
- void Delay1ms(unsigned int count) //延时,ms级
- {
- unsigned int i,j;
- for(i=0; i<count; i++)
- for(j=0; j<120; j++);
- }
- void Int_1(void) interrupt 2 //中断1,累加全局变量,暂停当前歌曲播放,曲目跳转
- {
- EA = 0;
- //设置为不播放状态
- play_state = 0;
- P0 = 0x80;
- //曲目号累加
- play_num++;
- if(play_num >= MSC_NUM){ //若当前播放曲目为最后一条,则回零播放
- play_num = 0;
- }
- EA = 1;
- }
- //***********************************Music files**************************************************
- //吉祥三宝,一遍,后段转换不成功,未加入
- unsigned char code Music_JiXiang[] = { 0x17,0x03, 0x19,0x17, 0x19,0x16, 0x19,0x02, 0x19,0x0D,
- 0x19,0x03, 0x19,0x0D, 0x19,0x03, 0x17,0x03, 0x16,0x03,
- 0x17,0x03, 0x19,0x17, 0x19,0x02, 0x19,0x0D, 0x19,0x03,
- 0x19,0x0D, 0x19,0x03, 0x17,0x03, 0x16,0x03, 0x17,0x03,
- 0x16,0x17, 0x15,0x02, 0x15,0x0D, 0x15,0x03, 0x15,0x0D,
- 0x15,0x03, 0x10,0x03, 0x0F,0x03, 0x17,0x03, 0x16,0x17,
- 0x16,0x03, 0x16,0x03, 0x16,0x03, 0x17,0x03, 0x16,0x0D,
- 0x15,0x03, 0x10,0x0D, 0x0F,0x03, 0x19,0x01, 0x18,0x01,
- 0x17,0x01, 0x17,0x01, 0x00,0x00 };
- //盛夏的果实
- unsigned char code Music_SummerNut[] = { 0x17,0x02, 0x17,0x03, 0x16,0x03, 0x16,0x16, 0x10,0x03,
- 0x15,0x02, 0x15,0x03, 0x16,0x03, 0x16,0x02, 0x15,0x03,
- 0x11,0x03, 0x10,0x02, 0x15,0x02, 0x16,0x03, 0x16,0x03,
- 0x15,0x03, 0x16,0x03, 0x17,0x02, 0x17,0x03, 0x16,0x03,
- 0x16,0x01, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x19,0x03,
- 0x19,0x16, 0x19,0x03, 0x1A,0x03, 0x17,0x03, 0x17,0x03,
- 0x16,0x03, 0x17,0x01, 0x17,0x03, 0x17,0x03, 0x17,0x03,
- 0x19,0x03, 0x19,0x03, 0x19,0x03, 0x19,0x03, 0x1A,0x03,
- 0x17,0x03, 0x17,0x03, 0x17,0x16, 0x17,0x03, 0x16,0x03,
- 0x15,0x03, 0x10,0x03, 0x15,0x03, 0x17,0x04, 0x16,0x04,
- 0x16,0x02, 0x15,0x03, 0x16,0x03, 0x17,0x02, 0x19,0x67,
- 0x1A,0x04, 0x1A,0x02, 0x17,0x03, 0x16,0x03, 0x15,0x02,
- 0x15,0x03, 0x17,0x03, 0x16,0x02, 0x15,0x03, 0x10,0x03,
- 0x10,0x14, 0x16,0x66, 0x16,0x03, 0x15,0x66, 0x17,0x03,
- 0x19,0x03, 0x17,0x03, 0x17,0x15, 0x16,0x15, 0x15,0x03,
- 0x11,0x03, 0x10,0x03, 0x10,0x14, 0x16,0x66, 0x16,0x03,
- 0x15,0x02, 0x16,0x02, 0x17,0x02, 0x19,0x67, 0x1A,0x04,
- 0x1A,0x16, 0x1F,0x03, 0x1F,0x66, 0x1B,0x03, 0x1B,0x66,
- 0x1F,0x03, 0x1B,0x03, 0x1A,0x03, 0x1A,0x02, 0x17,0x02,
- 0x17,0x03, 0x16,0x03, 0x16,0x16, 0x10,0x03, 0x15,0x02,
- 0x15,0x03, 0x16,0x03, 0x16,0x02, 0x15,0x03, 0x11,0x03,
- 0x10,0x02, 0x15,0x02, 0x16,0x03, 0x16,0x03, 0x15,0x03,
- 0x16,0x03, 0x17,0x02, 0x17,0x03, 0x16,0x03, 0x16,0x01,
- 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x19,0x03, 0x19,0x16,
- 0x19,0x03, 0x1A,0x03, 0x17,0x03, 0x17,0x03, 0x16,0x03,
- 0x17,0x01, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x19,0x03,
- 0x19,0x03, 0x19,0x03, 0x19,0x03, 0x1A,0x03, 0x17,0x03,
- 0x17,0x03, 0x17,0x16, 0x17,0x03, 0x16,0x03, 0x15,0x03,
- 0x10,0x03, 0x15,0x03, 0x17,0x04, 0x16,0x04, 0x16,0x02,
- 0x15,0x03, 0x16,0x03, 0x17,0x02, 0x19,0x67, 0x1A,0x04,
- 0x1A,0x02, 0x17,0x03, 0x16,0x03, 0x15,0x02, 0x15,0x03,
- 0x17,0x03, 0x16,0x02, 0x15,0x03, 0x11,0x03, 0x10,0x14,
- 0x16,0x66, 0x15,0x66, 0x17,0x03, 0x19,0x03, 0x17,0x03,
- 0x17,0x15, 0x16,0x15, 0x15,0x03, 0x11,0x03, 0x10,0x03,
- 0x10,0x14, 0x16,0x66, 0x16,0x03, 0x15,0x02, 0x16,0x02,
- 0x17,0x02, 0x19,0x03, 0x1A,0x03, 0x1A,0x16, 0x1A,0x03,
- 0x1F,0x01, 0x1B,0x66, 0x1F,0x03, 0x1A,0x03, 0x1A,0x03,
- 0x1A,0x00, 0x00,0x00 };
- //忘忧草
- unsigned char code Music_leftTrouble[] = { 0x15,0x66, 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x02,
- 0x17,0x03, 0x19,0x02, 0x1A,0x03, 0x19,0x16, 0x1A,0x66,
- 0x1F,0x03, 0x1A,0x03, 0x19,0x03, 0x17,0x03, 0x1A,0x03,
- 0x19,0x03, 0x19,0x02, 0x17,0x03, 0x16,0x16, 0x17,0x66,
- 0x19,0x03, 0x1A,0x0D, 0x19,0x03, 0x17,0x03, 0x16,0x03,
- 0x16,0x03, 0x16,0x02, 0x15,0x03, 0x15,0x16, 0x10,0x66,
- 0x15,0x03, 0x16,0x03, 0x17,0x02, 0x16,0x04, 0x15,0x0E,
- 0x15,0x04, 0x15,0x71, 0x15,0x01, 0x15,0x03, 0x16,0x03,
- 0x17,0x66, 0x19,0x03, 0x1A,0x03, 0x19,0x03, 0x17,0x02,
- 0x1A,0x03, 0x19,0x03, 0x17,0x03, 0x1A,0x03, 0x19,0x16,
- 0x1A,0x66, 0x1F,0x03, 0x1A,0x03, 0x19,0x03, 0x17,0x03,
- 0x1A,0x0D, 0x19,0x03, 0x19,0x0D, 0x19,0x16, 0x17,0x66,
- 0x19,0x03, 0x1A,0x0D, 0x19,0x03, 0x17,0x03, 0x16,0x03,
- 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x15,0x02,
- 0x10,0x03, 0x0F,0x03, 0x15,0x02, 0x16,0x03, 0x17,0x03,
- 0x16,0x03, 0x15,0x0D, 0x15,0x17, 0x10,0x04, 0x15,0x03,
- 0x15,0x0D, 0x15,0x16, 0x17,0x03, 0x19,0x03, 0x19,0x66,
- 0x17,0x03, 0x19,0x16, 0x19,0x03, 0x1A,0x66, 0x1F,0x03,
- 0x1F,0x0D, 0x1A,0x0D, 0x1A,0x02, 0x1A,0x66, 0x1F,0x03,
- 0x20,0x03, 0x1F,0x03, 0x1A,0x03, 0x19,0x03, 0x19,0x66,
- 0x1A,0x04, 0x19,0x04, 0x17,0x0D, 0x16,0x03, 0x16,0x02,
- 0x17,0x66, 0x19,0x03, 0x19,0x02, 0x17,0x03, 0x16,0x03,
- 0x16,0x02, 0x16,0x03, 0x15,0x03, 0x15,0x02, 0x10,0x03,
- 0x0F,0x03, 0x15,0x02, 0x16,0x03, 0x17,0x03, 0x16,0x03,
- 0x15,0x03, 0x10,0x03, 0x15,0x03, 0x15,0x01, 0x17,0x02,
- 0x19,0x02, 0x1A,0x15, 0x1A,0x03, 0x1F,0x66, 0x1A,0x03,
- 0x19,0x16, 0x1A,0x66, 0x1F,0x03, 0x20,0x66, 0x21,0x0D,
- 0x20,0x03, 0x20,0x0D, 0x20,0x16, 0x1F,0x03, 0x20,0x03,
- 0x21,0x66, 0x23,0x03, 0x21,0x66, 0x21,0x03, 0x20,0x66,
- 0x1F,0x03, 0x1F,0x16, 0x1A,0x66, 0x1F,0x03, 0x20,0x03,
- 0x1F,0x03, 0x1A,0x03, 0x19,0x03, 0x19,0x66, 0x1A,0x04,
- 0x19,0x04, 0x17,0x0D, 0x16,0x03, 0x16,0x02, 0x15,0x66,
- 0x16,0x03, 0x17,0x02, 0x1F,0x0D, 0x1A,0x03, 0x1A,0x15,
- 0x19,0x03, 0x1A,0x16, 0x1F,0x03, 0x20,0x02, 0x20,0x03,
- 0x1F,0x0D, 0x1F,0x17, 0x1F,0x16, 0x00,0x00 };
- //两只蝴蝶
- unsigned char code Music_twoButterFly[] = { 0x17,0x03, 0x16,0x03, 0x17,0x0C, 0x17,0x03, 0x16,0x03,
- 0x17,0x03, 0x16,0x03, 0x15,0x01, 0x10,0x03, 0x15,0x03,
- 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03,
- 0x10,0x03, 0x15,0x03, 0x0F,0x01, 0x17,0x03, 0x16,0x03,
- 0x17,0x0B, 0x17,0x03, 0x16,0x03, 0x17,0x03, 0x16,0x03,
- 0x15,0x01, 0x10,0x03, 0x15,0x03, 0x16,0x02, 0x16,0x0D,
- 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03, 0x15,0x03,
- 0x16,0x01, 0x17,0x03, 0x16,0x03, 0x17,0x0B, 0x17,0x03,
- 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x01, 0x10,0x03,
- 0x15,0x03, 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03,
- 0x15,0x03, 0x10,0x03, 0x15,0x03, 0x19,0x01, 0x17,0x03,
- 0x19,0x03, 0x19,0x0B, 0x19,0x03, 0x19,0x03, 0x1A,0x03,
- 0x19,0x03, 0x17,0x01, 0x16,0x03, 0x17,0x03, 0x16,0x02,
- 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03,
- 0x10,0x0E, 0x15,0x0E, 0x15,0x03, 0x15,0x0D, 0x15,0x79,
- 0x19,0x03, 0x19,0x03, 0x1A,0x03, 0x1F,0x03, 0x1B,0x03,
- 0x1B,0x03, 0x1A,0x03, 0x17,0x03, 0x16,0x0D, 0x16,0x03,
- 0x17,0x0D, 0x17,0x15, 0x17,0x03, 0x17,0x03, 0x19,0x03,
- 0x1A,0x02, 0x1A,0x66, 0x10,0x03, 0x17,0x0D, 0x16,0x03,
- 0x16,0x01, 0x17,0x03, 0x19,0x03, 0x19,0x03, 0x17,0x03,
- 0x19,0x16, 0x1F,0x02, 0x1B,0x03, 0x1A,0x03, 0x1B,0x03,
- 0x17,0x16, 0x1A,0x03, 0x1A,0x03, 0x1B,0x03, 0x1A,0x03,
- 0x19,0x03, 0x17,0x03, 0x16,0x02, 0x17,0x0D, 0x16,0x03,
- 0x17,0x03, 0x19,0x02, 0x00,0x00 };
- //月亮代表我的心
- unsigned char code Music_moonHeart[] ={ 0x0F,0x03, 0x15,0x66, 0x17,0x03, 0x19,0x66, 0x15,0x03,
- 0x11,0x66, 0x17,0x03, 0x19,0x16, 0x19,0x03, 0x1A,0x03,
- 0x1B,0x02, 0x1F,0x66, 0x1A,0x03, 0x1A,0x03, 0x19,0x0D,
- 0x19,0x02, 0x17,0x03, 0x16,0x03, 0x15,0x66, 0x15,0x03,
- 0x15,0x02, 0x17,0x03, 0x16,0x03, 0x15,0x66, 0x15,0x03,
- 0x15,0x02, 0x16,0x03, 0x17,0x03, 0x16,0x02, 0x15,0x03,
- 0x10,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x15, 0x0F,0x03,
- 0x17,0x0D, 0x19,0x03, 0x17,0x66, 0x16,0x03, 0x15,0x02,
- 0x19,0x02, 0x11,0x01, 0x10,0x03, 0x11,0x03, 0x10,0x02,
- 0x11,0x03, 0x10,0x02, 0x0F,0x02, 0x17,0x01, 0x19,0x02,
- 0x17,0x66, 0x16,0x03, 0x15,0x02, 0x19,0x02, 0x11,0x01,
- 0x10,0x03, 0x11,0x03, 0x15,0x66, 0x15,0x03, 0x15,0x02,
- 0x16,0x0D, 0x17,0x03, 0x16,0x15, 0x0F,0x03, 0x15,0x66,
- 0x17,0x03, 0x19,0x66, 0x15,0x03, 0x11,0x66, 0x17,0x03,
- 0x19,0x66, 0x19,0x03, 0x1A,0x66, 0x1B,0x03, 0x1F,0x66,
- 0x1A,0x03, 0x1A,0x03, 0x19,0x0D, 0x19,0x02, 0x17,0x03,
- 0x16,0x03, 0x15,0x66, 0x15,0x03, 0x15,0x02, 0x17,0x03,
- 0x16,0x03, 0x15,0x66, 0x15,0x03, 0x15,0x02, 0x16,0x03,
- 0x17,0x03, 0x16,0x66, 0x10,0x03, 0x11,0x02, 0x15,0x0D,
- 0x16,0x03, 0x15,0x15, 0x00,0x00 };
复制代码
【必读】版权免责声明
1、本主题所有言论和内容纯属会员个人意见,与本论坛立场无关。2、本站对所发内容真实性、客观性、可用性不做任何保证也不负任何责任,网友之间仅出于学习目的进行交流。3、对提供的数字内容不拥有任何权利,其版权归原著者拥有。请勿将该数字内容进行商业交易、转载等行为,该内容只为学习所提供,使用后发生的一切问题与本站无关。 4、本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。 5、本网站所有软件和资料均为网友推荐收集整理而来,仅供学习用途使用,请务必下载后两小时内删除,禁止商用。6、如有侵犯你版权的,请及时联系我们(电子邮箱1370723259@qq.com)指出,本站将立即改正。
|