大疆社区
标题:
#S1歌舞大赛#勃拉姆斯的摇篮曲--乐谱简易录入方法
[打印本页]
作者:
老妖怪
时间:
2019-10-26
标题:
#S1歌舞大赛#勃拉姆斯的摇篮曲--乐谱简易录入方法
本帖最后由 老妖怪 于 2019-10-26 21:57 编辑
[{"nameindex":"_1_1","type":1,"url":"","desc":"\u5b69\u5b50\u5c0f\u65f6\u5019\uff0c\u6211\u54fc\u5f97\u6700\u591a\u7684\u66f2\u5b50\uff0c\u6700\u591a\u4e09\u904d\uff0c\u4e00\u5b9a\u7761\u7740\r\n\r\nS1\u65b0\u52a0\u5165\u4e86\u64ad\u653e\u97f3\u7b26\u7684\u529f\u80fd\uff0c\u770b\u4e86\u4e00\u4e9b\u673a\u53cb\u7684\u89c6\u9891\uff0c\u5927\u5bb6\u90fd\u7528scratch\u5199\u7684\u5427\uff0c\u9010\u4e2a\u97f3\u7b26\u8f93\u5165\u5f88\u7d2f\u5427\u3002\r\n\u672c\u7a0b\u5e8f\u7528python\u7f16\u5199\uff0c\u91c7\u7528\u4e86\u4e00\u4e9b\u6280\u672f\u624b\u6bb5\uff0c\u53ef\u4ee5\u628a\u4f60\u4ece\u7e41\u7410\u7684\u8f93\u5165\u4e2d\u89e3\u653e\u51fa\u6765\uff0c\u8f7b\u8f7b\u677e\u677e\u64ad\u653e\u5404\u79cd\u66f2\u5b50\r\n\r\n\u9996\u5148\uff0c\u90a3\u4e2a\u957f\u957f\u7684define\u975e\u5e38\u4e0d\u53cb\u597d\uff0crm_define.media_sound_solmization_1C\uff0c\u4e00\u4e2a\u97f3\u7b26\u5c31\u8fd9\u4e48\u957f\uff0c\u6572\u952e\u76d8\u8981\u6572\u591a\u4e45\u554a\u3002\u90a3\u4e2a1C\uff0c\u8981\u60f3\u4e00\u60f3\u624d\u77e5\u9053\u662f\u4f4e\u97f31\u3002\u8981\u662f\u770b\u7b80\u8c31\u5f55\u5165\uff0c\u4f60\u8fd8\u662f\u8981\u53cd\u5e94\u4e00\u4e0b\uff0c\u7528scratch\u7684\u8bdd\uff0c\u4f60\u8fd8\u8981\u4eba\u5de5\u505a\u5531\u540d\u5230\u94a2\u7434\u952e\u4e4b\u95f4\u7684\u6620\u5c04\uff0c\u592a\u9ebb\u70e6\u4e86\r\n\r\n\u5176\u6b21\uff0c\u4e00\u53e5\u4e00\u53e5\u5730\u5199media_ctrl.play_sound()\uff0c\u592a\u7d2f\u4e86\uff0c\u7528scratch\u7684\u8bdd\uff0c\u4e00\u4e2a\u4e00\u4e2a\u8c03\u7528\u64ad\u653e\u97f3\u7b26\u6a21\u5757\uff0c\u540c\u6837\u592a\u7d2f\u4e86\uff0c\u8981\u662f\u8f93\u9519\u4e86\u4e00\u4e2a\u97f3\u7b26\uff0c\u4f60\u5c31\u6162\u6162\u627e\u5427\r\n\r\n\u4e8e\u662f\uff0c\u6211\u5148\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7f16\u7801\uff0c11-17\u8868\u793a\u4f4e\u97f31-7\uff0c21-27\u8868\u793a\u4e2d\u97f31-7\uff0c31-37\u8868\u793a\u9ad8\u97f31-7\uff0c\u81f3\u4e8e\u5347\u534a\u97f3\uff0c\u90a3\u5c31\u52a00.5\uff0c\u6bd4\u598223.5\u8868\u793a\u4e2d\u97f33#\uff0c\u7279\u522b\u5730\uff0c0\u8868\u793a\u4f11\u6b62\u7b26\u3002\u4ee3\u7801\u5982\u4e0b\r\n\r\nglobal note\r\nnote = [\\\r\nrm_define.media_sound_solmization_1C,rm_define.media_sound_solmization_1CSharp,\\\r\nrm_define.media_sound_solmization_1D,rm_define.media_sound_solmization_1DSharp,\\\r\nrm_define.media_sound_solmization_1E,\\\r\nrm_define.media_sound_solmization_1F,rm_define.media_sound_solmization_1FSharp,\\\r\nrm_define.media_sound_solmization_1G,rm_define.media_sound_solmization_1GSharp,\\\r\nrm_define.media_sound_solmization_1A,rm_define.media_sound_solmization_1ASharp,\\\r\nrm_define.media_sound_solmization_1B,\\\r\nrm_define.media_sound_solmization_2C,rm_define.media_sound_solmization_2CSharp,\\\r\nrm_define.media_sound_solmization_2D,rm_define.media_sound_solmization_2DSharp,\\\r\nrm_define.media_sound_solmization_2E,\\\r\nrm_define.media_sound_solmization_2F,rm_define.media_sound_solmization_2FSharp,\\\r\nrm_define.media_sound_solmization_2G,rm_define.media_sound_solmization_2GSharp,\\\r\nrm_define.media_sound_solmization_2A,rm_define.media_sound_solmization_2ASharp,\\\r\nrm_define.media_sound_solmization_2B,\\\r\nrm_define.media_sound_solmization_3C,rm_define.media_sound_solmization_3CSharp,\\\r\nrm_define.media_sound_solmization_3D,rm_define.media_sound_solmization_3DSharp,\\\r\nrm_define.media_sound_solmization_3E,\\\r\nrm_define.media_sound_solmization_3F,rm_define.media_sound_solmization_3FSharp,\\\r\nrm_define.media_sound_solmization_3G,rm_define.media_sound_solmization_3GSharp,\\\r\nrm_define.media_sound_solmization_3A,rm_define.media_sound_solmization_3ASharp,\\\r\nrm_define.media_sound_solmization_3B]\r\n\u200b\r\ndef play_note(x):\r\n a = x \/\/ 10 - 1\r\n b = x * 2 % 20 - 2\r\n if b > 5:\r\n b -= 1\r\n n = int(a * 12 + b)\r\n if x != 0:\r\n media_ctrl.play_sound(note[n])\r\n\u51fd\u6570play_note(x) \u76f4\u63a5\u64ad\u653e\u6211\u5b9a\u4e49\u7684\u7f16\u7801\u5bf9\u5e94\u7684\u97f3\u7b26\uff0c\u81f3\u4e8e\u8fd9\u4e2a\u51fd\u6570\u600e\u4e48\u5199\u7684\uff0c\u6bd4\u8f83\u96be\u8bf4\u660e\u767d\uff0c\u5927\u5bb6\u5f53\u9ed1\u5323\u5b50\u5c31\u597d\r\n\r\n\u7136\u540e\uff0c\u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4\uff0c\u7528\u4e24\u4e2a\u6570\u8868\u793a\u4e00\u4e2a\u97f3\uff0c\u7b2c\u4e00\u4e2a\u6570\u5c31\u662f\u4e0a\u8ff0\u7f16\u7801\uff0c\u7b2c\u4e8c\u4e2a\u6570\u662f\u97f3\u957f\uff0c\u7b80\u5355\u7c97\u66b4\u4e00\u70b9\uff0c1\u8868\u793a\u56db\u5206\u97f3\u7b26\uff0c0.5\u8868\u793a\u516b\u5206\u97f3\u7b26\uff0c0.25\u8868\u793a\u5341\u516d\u5206\u97f3\u7b26\uff0c1.5\u8868\u793a\u9644\u70b9\u56db\u5206\u97f3\u7b26\uff0c\u5475\u5475\uff0c\u603b\u4e4b\u5c31\u662f1\u4ee3\u88681\u62cd\uff0c\u5bf9\u5e94\u5b9e\u9645\u65f6\u95f41\u79d2\u3002\u6bd4\u5982\u52c3\u62c9\u59c6\u65af\u7684\u6447\u7bee\u66f2\uff0c\u4ee3\u7801\u5982\u4e0b\uff0c\u76f4\u63a5\u7167\u7740\u7b80\u8c31\u6284\uff0c\u7ae5\u53df\u65e0\u6b3a\uff1a\r\nmusic = [\\\r\n23,0.5, 23,0.5, 25,1.5, 23,0.5, 23,1, 25,1, 0,1, 23,0.5, 25,0.5, 31,1, 27,1.5, 26,0.5, 26,1, 25,1, 22,0.5, 23,0.5,\\\r\n24,1, 22,1, 22,0.5, 23,0.5, 24,1, 0,1, 22,0.5, 24,0.5, 27,0.5, 26,0.5, 25,1, 27,1, 31,1, 0,1, 21,0.5, 21,0.5,\\\r\n31,2, 26,0.5, 24,0.5, 25,2, 23,0.5, 21,0.5, 24,1, 25,1, 26,1, 23,0.25, 25,1.75, 21,0.5, 21,0.5,\\\r\n31,2, 26,0.5, 24,0.5, 25,2, 23,0.5, 21,0.5, 24,0.5, 25,0.25, 24,0.25, 23,1, 22,1, 21,2]\r\n\u6211\u5199\u7684\u65f6\u5019\uff0c\u6545\u610f\u628a\u4e24\u4e2a\u6570\u5199\u5f97\u7d27\u51d1\uff0c\u800c\u6bcf\u4e24\u4e2a\u6570\u4e4b\u95f4\u52a0\u4e86\u4e00\u4e2a\u7a7a\u683c\uff0c\u8fd9\u6837\u6709\u4ec0\u4e48\u95ee\u9898\u597d\u67e5\r\n\r\n\u64ad\u653e\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u4e00\u4e2a\u5faa\u73af\uff0c\u8bfb\u6570\u7ec4\uff0c\u64ad\u97f3\u7b26\uff0cover\r\ndef start():\r\n global note\r\n global music \r\n for i in range(0,len(music)\/\/2):\r\n play_note(music[2*i])\r\n time.sleep(music[2*i+1])\r\n\u7b80\u5355\u5427\uff0c\u8981\u64ad\u653e\u5176\u4ed6\u97f3\u4e50\uff0c\u6362music\u6570\u7ec4\u5c31\u597d\uff0c\u7a0b\u5e8f\u4e0d\u52a8\uff0c\u52a8\u7684\u53ea\u662f\u6570\u636e\r\nDJI\u8981\u662f\u518d\u652f\u6301\u6587\u4ef6\u8bfb\u5199\u5c31\u66f4\u723d\u4e86\uff0c\u97f3\u4e50\u5199\u5728\u6587\u4ef6\u91cc\uff0c\u8bfb\u6587\u4ef6\u64ad\u653e\uff0c\u6e90\u4ee3\u7801\u90fd\u53ef\u4ee5\u4e0d\u52a8\r\n\r\n\u64ad\u653e\u97f3\u4e50\u641e\u5b9a\u4e86\uff0c\u73b0\u5728\u8981\u52a0\u4e0a\u52a8\u4f5c\uff0c\u600e\u4e48\u52a0\u5462\uff1f\u5f88\u9057\u61be\uff0cDJI\u8fd8\u6ca1\u6709\u652f\u6301\u591a\u7ebf\u7a0b\uff0c\u9700\u8981\u6709\u4e00\u4e2a\u53d8\u901a\u7684\u529e\u6cd5\r\n\r\n\u600e\u4e48\u505a\u5462\uff1f\u5c31\u662f\u5728\u4e0a\u9762time.sleep()\u51fd\u6570\u8fd9\u91cc\u505a\u6587\u7ae0\u3002\u6211\u73a9\u8fc7\u5f88\u591a\u79cd\u673a\u5668\u4eba\uff0c\u5bf9\u4e8e\u51e0\u4e4e\u6240\u6709\u7684\u673a\u5668\u4eba\uff0csleep\uff0cwait\u4e4b\u7c7b\u7684\u51fd\u6570\u90fd\u975e\u5e38\u5751\u7239\uff0c\u8981\u60f3\u7f16\u51fa\u9ad8\u7ea7\u7a0b\u5e8f\uff0c\u5fc5\u987b\u653e\u5f03\u8fd9\u4e00\u7c7b\u51fd\u6570\r\n\r\n\u5177\u4f53\u505a\u6cd5\uff0c\u7528\u8ba1\u65f6\u5668\uff0c\u4ee3\u7801\u6846\u67b6\u662f\u8fd9\u6837\u7684\r\n for i in range(0,len(music)\/\/2):\r\n play_note(music[2*i])\r\n t0 = tools.timer_current()\r\n t = t0\r\n while t < t0 + music[2*i+1]:\r\n t = tools.timer_current()\r\n #\u8fd9\u91cc\u63d2\u5165\u4f60\u8981\u505a\u7684\u4e8b\u60c5\r\n\u64ad\u653e\u97f3\u7b26\u662f\u4e00\u4e2a\u975e\u963b\u585e\u529f\u80fd\uff0c\u6267\u884c\u4e86\u4e4b\u540e\uff0c\u540e\u53f0\u5c31\u64ad\u653e\u53bb\u4e86\uff0c\u524d\u53f0\u4ea4\u5230\u4f60\u624b\u91cc\r\n\u8fd9\u65f6\uff0c\u7528\u53d8\u91cft0\u8bb0\u5f55\u5f53\u524d\u65f6\u95f4\uff0c\u518d\u7528\u5faa\u73af\u53cd\u590d\u68c0\u67e5\uff08\u5f53\u524d\u65f6\u95f4-t0\uff09\u6709\u6ca1\u6709\u8fbe\u5230\u4f60\u671f\u671b\u7684\u5ef6\u8fdf\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0sleep\u51fd\u6570\u7684\u6548\u679c\uff0c\u4f46\u662f\u4f60\u83b7\u5f97\u4e86\u505a\u4f60\u81ea\u5df1\u7684\u4e8b\u60c5\u7684\u673a\u4f1a\r\n\r\n\u5177\u4f53\u5230\u8fd9\u4e2a\u66f2\u5b50\uff0c\u65e2\u7136\u662f\u6447\u7bee\u66f2\uff0c\u90a3\u5c31\u6a21\u62df\u6447\u6447\u7bee\u7684\u52a8\u4f5c\u5427\uff0c\u7528\u4e00\u4e2a\u5468\u671f\u51fd\u6570\u63a7\u5236\u901f\u5ea6\uff0c\u505a\u4e00\u4e2a\u5706\u5f27\u8fd0\u52a8\u5c31\u597d\u3002\u4ee3\u7801\u5982\u4e0b\uff1a\r\n for i in range(0,len(music)\/\/2):\r\n play_note(music[2*i])\r\n t0 = tools.timer_current()\r\n t = t0\r\n while t < t0 + music[2*i+1]:\r\n t = tools.timer_current()\r\n v = 0.5*math.cos(t*1.5)\r\n chassis_ctrl.move_with_speed(v,0,v\/math.pi*180) \r\n chassis_ctrl.stop()\r\n\r\n\u518d\u914d\u5408\u4e00\u4e0b\u706f\u6548\uff0c\u7528\u547c\u5438\u706f\u3002\u53ef\u60dc\u547c\u5438\u706f\u4e0d\u80fd\u8c03\u5468\u671f\uff0c\u6ca1\u6cd5\u4e0e\u97f3\u4e50\u878d\u4e3a\u4e00\u4f53\uff0c\u662f\u4e2a\u9057\u61be\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_all, 69, 215, 255, rm_define.effect_breath) \r\n led_ctrl.set_top_led(rm_define.armor_top_all, 69, 215, 255, rm_define.effect_breath)\r\n\r\n\u518d\u8ba9\u4e91\u53f0\u6446\u4e2a\u59ff\u52bf\uff0c\u5c31\u5f53\u662f\u4e00\u4f4d\u7236\u4eb2\u62b1\u7740\u5c0f\u5b9d\u5b9d\uff0c\u54fc\u7740\u6447\u7bee\u66f2\uff0c\u8f7b\u8f7b\u6447\u52a8
\r\n robot_ctrl.set_mode(rm_define.robot_mode_free)\r\n gimbal_ctrl.set_rotate_speed(270)\r\n gimbal_ctrl.angle_ctrl(90, -15)\r\n\r\n\u89c6\u9891\u5982\u4e0b\uff1a\r\n","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_3_1","type":3,"url":"http:\/\/player.youku.com\/embed\/XNDQxNDMyMjY5Ng","desc":"","imgsrc":"static\/image\/video.jpg"},{"nameindex":"_1_2","type":1,"url":"","desc":"\u8fd9\u662f\u5b8c\u6574\u7684\u4ee3\u7801\uff1a\r\nglobal note\r\nnote = [\\\r\nrm_define.media_sound_solmization_1C,rm_define.media_sound_solmization_1CSharp,\\\r\nrm_define.media_sound_solmization_1D,rm_define.media_sound_solmization_1DSharp,\\\r\nrm_define.media_sound_solmization_1E,\\\r\nrm_define.media_sound_solmization_1F,rm_define.media_sound_solmization_1FSharp,\\\r\nrm_define.media_sound_solmization_1G,rm_define.media_sound_solmization_1GSharp,\\\r\nrm_define.media_sound_solmization_1A,rm_define.media_sound_solmization_1ASharp,\\\r\nrm_define.media_sound_solmization_1B,\\\r\nrm_define.media_sound_solmization_2C,rm_define.media_sound_solmization_2CSharp,\\\r\nrm_define.media_sound_solmization_2D,rm_define.media_sound_solmization_2DSharp,\\\r\nrm_define.media_sound_solmization_2E,\\\r\nrm_define.media_sound_solmization_2F,rm_define.media_sound_solmization_2FSharp,\\\r\nrm_define.media_sound_solmization_2G,rm_define.media_sound_solmization_2GSharp,\\\r\nrm_define.media_sound_solmization_2A,rm_define.media_sound_solmization_2ASharp,\\\r\nrm_define.media_sound_solmization_2B,\\\r\nrm_define.media_sound_solmization_3C,rm_define.media_sound_solmization_3CSharp,\\\r\nrm_define.media_sound_solmization_3D,rm_define.media_sound_solmization_3DSharp,\\\r\nrm_define.media_sound_solmization_3E,\\\r\nrm_define.media_sound_solmization_3F,rm_define.media_sound_solmization_3FSharp,\\\r\nrm_define.media_sound_solmization_3G,rm_define.media_sound_solmization_3GSharp,\\\r\nrm_define.media_sound_solmization_3A,rm_define.media_sound_solmization_3ASharp,\\\r\nrm_define.media_sound_solmization_3B]\r\n\u200b\r\ndef play_note(x):\r\n a = x \/\/ 10 - 1\r\n b = x * 2 % 20 - 2\r\n if b > 5:\r\n b -= 1\r\n n = int(a * 12 + b)\r\n if x != 0:\r\n media_ctrl.play_sound(note[n])\r\n\u200b\r\nmusic = [\\\r\n23,0.5, 23,0.5, 25,1.5, 23,0.5, 23,1, 25,1, 0,1, 23,0.5, 25,0.5, 31,1, 27,1.5, 26,0.5, 26,1, 25,1, 22,0.5, 23,0.5,\\\r\n24,1, 22,1, 22,0.5, 23,0.5, 24,1, 0,1, 22,0.5, 24,0.5, 27,0.5, 26,0.5, 25,1, 27,1, 31,1, 0,1, 21,0.5, 21,0.5,\\\r\n31,2, 26,0.5, 24,0.5, 25,2, 23,0.5, 21,0.5, 24,1, 25,1, 26,1, 23,0.25, 25,1.75, 21,0.5, 21,0.5,\\\r\n31,2, 26,0.5, 24,0.5, 25,2, 23,0.5, 21,0.5, 24,0.5, 25,0.25, 24,0.25, 23,1, 22,1, 21,2]\r\ndef start():\r\n robot_ctrl.set_mode(rm_define.robot_mode_free)\r\n gimbal_ctrl.set_rotate_speed(270)\r\n gimbal_ctrl.angle_ctrl(90, -15)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_all, 69, 215, 255, rm_define.effect_breath) \r\n led_ctrl.set_top_led(rm_define.armor_top_all, 69, 215, 255, rm_define.effect_breath)\r\n tools.timer_ctrl(rm_define.timer_start)\r\n global note\r\n global music \r\n for i in range(0,len(music)\/\/2):\r\n play_note(music[2*i])\r\n t0 = tools.timer_current()\r\n t = t0\r\n while t < t0 + music[2*i+1]:\r\n t = tools.timer_current()\r\n v = 0.5*math.cos(t*1.5)\r\n chassis_ctrl.move_with_speed(v,0,v\/math.pi*180) \r\n chassis_ctrl.stop()\r\n\r\nS1\u5982\u6447\u7bee\u4e00\u822c\u7f13\u7f13\u6447\u52a8\uff0c\u914d\u5408\u547c\u5438\u706f\uff0c\u8f7b\u8f7b\u5730\u54fc\u7740\u52c3\u62c9\u59c6\u65af\u6447\u7bee\u66f2\uff0c\u4eb2\u7231\u7684\u5404\u4f4d\u5c0f\u670b\u53cb\u548c\u5927\u670b\u53cb\uff0c\u8be5\u7761\u89c9\u4e86","imgsrc":"static\/image\/text.jpg"}]
作者:
jatgz020
时间:
2019-10-26
哈~,s1的编程越来越有意思了,歌曲可以带节奏了,一个个音符输入且带节拍,可能要码字一天吧?一个函数自定义一下,就可以少输入好多行命令?有意思了,有些看头,再搞多些函数自定义出来,看是否可以动作与声音结合起来做更多的复杂的表现?或者更智能地识别一些规程?赞一个!
作者:
星空创客吴老师
时间:
2019-10-29
其实我提的建议就是直接播放MP3文档,或者录制弹奏的音符进行播放。
作者:
王生
时间:
2019-11-12
楼主真神人也!!
作者:
总督
时间:
2019-11-19
这个文章写的好啊,必须点赞
作者:
阿阿阿阿阿默
时间:
2019-11-21
看完觉得SCRATCH真的太弱了
想把S1玩通透真得要学PYTHON啊
作者:
小灰机小谷
时间:
2019-12-8
才19点,睡啥呀
欢迎光临 大疆社区 (https://bbs.dji.com/)
Powered by Discuz! X3.2