明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: highflybird

[【高飞鸟】] 用Beep演奏一段音乐--LISP的卖弄神器

    [复制链接]
发表于 2022-8-9 12:47:53 | 显示全部楼层
本帖最后由 tigcat 于 2022-8-9 14:17 编辑


;帖子来源https://blog.csdn.net/v1t1p9hvbd/article/details/71523218?
;天空之城
(defun c:tkzc ()
  (princ "\n开始为你播放生日歌:")
  (setq qdo 262 )
(setq qre 294)
(setq qmi 330)
(setq qfa 349)
(setq qso 392)
(setq qla 440)
(setq qsi 494)
(setq do 523)
(setq re 578)
(setq mi 659)
(setq fa 698)
(setq so 784)
(setq la 880)
(setq si 988)
(setq do1 1046)
(setq re1 1175)
(setq mi1 1318)
(setq fa1 1480)
(setq so1 1568)
(setq la1 1760)
(setq si1 1976)
(setq sqdo 277)
(setq sqre 311)
(setq sqfa 370)
(setq sqso 415)
(setq sqla 466)
(setq sdo 554)
(setq sre 622)
(setq sfa 740)
(setq sso 831)
(setq sla 932)
(setq sdo1 1046)
(setq sre1 1245)
(setq sfa1 1480)
(setq sso1 1661)
(setq sla1 1865)

(setq pai 400 ban 200 ting 128)

(command  "delay" 1000)

(Beep la ban)
(Beep si ban)
(command  "delay" ting)

(Beep do1 (+ ban pai))
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)

(Beep si (* 3 pai))
(command  "delay" ting)
(Beep mi ban)
(Beep mi ban)

(Beep la (+ ban pai))
(Beep so ban)
(command  "delay" ting)
(Beep la pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep so (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep mi ban)
(command  "delay" (/ ting 2))
(Beep mi ban)
(command  "delay" (/ ting 2))

(Beep fa (+ ban pai))
(Beep mi ban)
(command  "delay" ting)
(Beep fa ban)
(Beep do1 (+ ban pai))
(command  "delay" ting)

(Beep mi (* 2 pai))
(command  "delay" ting)
(command  "delay" ban)
(Beep do1 ban)
(command  "delay" (/ ting 2))
(Beep do1 ban)
(command  "delay" (/ ting 2))
(Beep do1 ban)
(command  "delay" (/ ting 2))

(Beep si (+ ban pai))
(Beep sfa ban)
(command  "delay" ting)
(Beep sfa pai)
(Beep si pai)
(command  "delay" ting)

(Beep si (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep la ban)
(Beep si ban)
(command  "delay" ting)

(Beep do1 (+ ban pai))
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)

(Beep si (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep mi ban)
(command  "delay" 20)
(Beep mi ban)
(command  "delay" ting)

(Beep la (+ ban pai))
(Beep so ban)
(command  "delay" ting)
(Beep la pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep so (* 3 pai))
(command  "delay" (+ ting ban))
(Beep mi ban)
(command  "delay" (/ ting 2))

(Beep fa pai)
(command  "delay" ting)
(Beep do1 ban)
(Beep si ban)
(command  "delay" 20)
(Beep si pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep re1 ban)
(command  "delay" 20)
(Beep re1 ban)
(command  "delay" 20)
(Beep mi1 ban)
(command  "delay" (/ ting 2))
(Beep do1 pai)
(command  "delay" (+ ting pai))

(Beep do1 pai)
(Beep si ban)
(command  "delay" ting)
(Beep la ban)
(command  "delay" 20)
(Beep la ban)
(command  "delay" ting)
(Beep si pai)
(command  "delay" ting)
(Beep sso pai)
(command  "delay" ting)

(Beep sso (* 2 pai))
(command  "delay" (+ ting pai))
(Beep do1 ban)
(Beep re1 ban)
(command  "delay" ting)

(Beep mi1 (+ ban pai))
(Beep re1 ban)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)
(Beep fa1 pai)
(command  "delay" ting)

(Beep re1 (* 2 pai))
(command  "delay" (+ ting pai))
(Beep so ban)
(command  "delay" 20)
(Beep so ban)
(command  "delay" ting)

(Beep do1 ban)
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)

(Beep mi1 (* 2 pai))
(command  "delay" ting+(* 2 pai))

(Beep la ban)
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep si pai)
(command  "delay" ting)
(Beep re1 ban)
(command  "delay" 20)
(Beep re1 ban)
(command  "delay" ting)

(Beep do1 (+ ban pai))
(Beep so ban)
(command  "delay" 20)
(Beep so pai)
(command  "delay" (+ ting pai))

(Beep fa1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)
(Beep re1 pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep mi1 (* 4 pai))

(Beep mi1 (* 2 pai))
(command  "delay" (+ ting pai))
(Beep mi1 pai)
(command  "delay" ting)

(Beep la1 (* 2 pai))
(command  "delay" ting)
(Beep so1 pai)
(command  "delay" ting)
(Beep so1 pai)
(command  "delay" ting)

(Beep mi1 ban)
(command  "delay" (/ ting 2))
(Beep re1 ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" (+ ting ban))
(Beep do1 ban)
(command  "delay" ting)

(Beep re1 pai)
(command  "delay" ting)
(Beep do1 ban)
(Beep re1 ban)
(command  "delay" 20)
(Beep re1 ban)
(command  "delay" ting)
(Beep so1 pai)
(command  "delay" ting)

(Beep mi1 (* 2 pai))
(command  "delay" (+ ting pai))
(Beep mi pai)
(command  "delay" ting)

(Beep la1 (* 2 pai))
(command  "delay" ting)
(Beep so1 (* 2 pai))
(command  "delay" ting)

(Beep mi1 ban)
(Beep re1 ban)
(command  "delay" ting)
(Beep do1 (* 2 pai))
(command  "delay" (+ ting ban))
(Beep do1 ban)
(command  "delay" ting)

(Beep re1 pai)
(command  "delay" ting)
(Beep do1 ban)
(Beep re1 ban)
(command  "delay" 20)
(Beep re1 ban)
(command  "delay" ting)
(Beep si pai)
(command  "delay" ting)

(Beep la (* 2 pai))
(command  "delay" ting)
(Beep la ban)
(Beep si ban)

(Beep do1 (+ ban pai))
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)

(Beep si (* 3 pai))
(command  "delay" ting)
(Beep mi ban)
(Beep mi ban)

(Beep la (+ ban pai))
(Beep so ban)
(command  "delay" ting)
(Beep la pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep so (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep mi ban)
(command  "delay" (/ ting 2))
(Beep mi ban)
(command  "delay" (/ ting 2))

(Beep fa (+ ban pai))
(Beep mi ban)
(command  "delay" ting)
(Beep fa ban)
(Beep do1 (+ ban pai))
(command  "delay" ting)

(Beep mi (* 2 pai))
(command  "delay" ting)
(command  "delay" ban)
(Beep do1 ban)
(command  "delay" (/ ting 2))
(Beep do1 ban)
(command  "delay" (/ ting 2))
(Beep do1 ban)
(command  "delay" (/ ting 2))

(Beep si (+ ban pai))
(Beep sfa ban)
(command  "delay" ting)
(Beep sfa pai)
(Beep si pai)
(command  "delay" ting)

(Beep si (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep la ban)
(Beep si ban)
(command  "delay" ting)

(Beep do1 (+ ban pai))
(Beep si ban)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)
(Beep mi1 pai)
(command  "delay" ting)

(Beep si (* 2 pai))
(command  "delay" ting)
(command  "delay" pai)
(Beep mi ban)
(command  "delay" 20)
(Beep mi ban)
(command  "delay" ting)

(Beep la (+ ban pai))
(Beep so ban)
(command  "delay" ting)
(Beep la pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep so (* 3 pai))
(command  "delay" (+ ting ban))
(Beep mi ban)
(command  "delay" (/ ting 2))

(Beep fa pai)
(command  "delay" ting)
(Beep do1 ban)
(Beep si ban)
(command  "delay" 20)
(Beep si pai)
(command  "delay" ting)
(Beep do1 pai)
(command  "delay" ting)

(Beep re1 ban)
(command  "delay" 20)
(Beep re1 ban)
(command  "delay" 20)
(Beep mi1 ban)
(command  "delay" (/ ting 2))
(Beep do1 pai)
(command  "delay" (+ ting pai))

(Beep la (* 4 pai))

(command  "delay" 1000)

  (princ "\n播放完毕!")
  (princ)
)

点评

sleep就是 delay  发表于 2022-8-9 12:49
发表于 2022-8-9 12:57:03 | 显示全部楼层
tigcat 发表于 2022-8-9 12:47
;抄了一个天空之城的,c语言中有sleep函数,不知道含义,直接屏蔽了
(defun c:tkzc ()
  (princ "\n开始为 ...

好,回头有时间我补充下,办公室电脑没有耳机,听不到声音。
上次这么有趣的帖子是在命令行显示诗词。
发表于 2022-8-9 13:09:16 | 显示全部楼层
有点儿意思,在此奉上“粉刷匠”:

  1. (defun c:fsj()
  2.   (setq jp'(53 53 53 11 24 32 55 53 53 53 11 24 32 11 22 44 31 55 24 32 55 53 53 53 11 24 32 11))
  3.   (setq keys(list (list 1 (* 262 2))(list 2 (* 294 2))(list 3 (* 330 2))(list 4 (* 349 2))(list 5 (* 392 2))(list 6 (* 440 2))(list 7 (* 494 2))))
  4.   (setq play nil)
  5.   (foreach x jp
  6.     (setq strj(itoa x))
  7.     (if (=(substr strj 1 1) (substr strj 2 1))
  8.       (setq play (append play (list(list (cadr(assoc (atoi (substr strj 1 1)) keys)) 600))))
  9.       (setq play (append play (list (list (cadr(assoc (atoi (substr strj 1 1)) keys)) 300)
  10.             (list (cadr(assoc (atoi (substr strj 2 1)) keys)) 300))))
  11.       )
  12.     )
  13.   (foreach x play
  14.     (beep (car x )(cadr x))
  15.     )
  16.   )


点评

当我看《爱情公寓》这段时,笑疯了!  发表于 2022-8-9 16:26
发表于 2022-8-9 13:14:59 | 显示全部楼层
copy这个网址的天空之城上半段,太长了难得改成lisp。
https://blog.csdn.net/weixin_45697774/article/details/106868403
  1. ;q前缀为低音,1后缀为高音,s前缀为半音阶
  2. (setq  qdo 262 )
  3. (setq  qre 294)
  4. (setq  qmi 330)
  5. (setq  qfa 349)
  6. (setq  qso 392)
  7. (setq  qla 440)
  8. (setq  qsi 494)
  9. (setq  do 523)
  10. (setq  re 578)
  11. (setq  mi 659)
  12. (setq  fa 698)
  13. (setq  so 784)
  14. (setq  la 880)
  15. (setq  si 988)
  16. (setq  do1 1046)
  17. (setq  re1 1175)
  18. (setq  mi1 1318)
  19. (setq  fa1 1480)
  20. (setq  so1 1568)
  21. (setq  la1 1760)
  22. (setq  si1 1976)
  23. (setq  sqdo 277)
  24. (setq  sqre 311)
  25. (setq  sqfa 370)
  26. (setq  sqso 415)
  27. (setq  sqla 466)
  28. (setq  sdo 554)
  29. (setq  sre 622)
  30. (setq  sfa 740)
  31. (setq  sso 831)
  32. (setq  sla 932)
  33. (setq  sdo1 1046)
  34. (setq  sre1 1245)
  35. (setq  sfa1 1480)
  36. (setq  sso1 1661)
  37. (setq  sla1 1865)
  38. (setq  pai 400 ban 200 ting 128)
  39. (Beep la ban)
  40. (Beep si ban)
  41. (Beep 0 ting)
  42. (Beep do1 (+ pai ban))
  43. (Beep si ban)
  44. (Beep 0 ting)
  45. (Beep do1 pai)
  46. (Beep 0 ting)
  47. (Beep mi1 pai)
  48. (Beep 0 ting)
  49. (Beep si (* 3 pai))
  50. (Beep 0 ting)
  51. (Beep mi ban)
  52. (Beep mi ban)
  53. (Beep la (+ ban pai))
  54. (Beep so ban)
  55. (Beep 0 ting)
  56. (Beep la pai)
  57. (Beep 0 ting)
  58. (Beep do1 pai)
  59. (Beep 0 ting)
  60. (Beep so (* 2 pai))
  61. (Beep 0 ting)
  62. (Beep 0 pai)
  63. (Beep mi ban)
  64. (Beep 0 (* 0.5 ting))
  65. (Beep mi ban)
  66. (Beep 0 (* 0.5 ting))
  67. (Beep fa (+ pai ban))
  68. (Beep mi ban)
  69. (Beep 0 ting)
  70. (Beep fa ban)
  71. (Beep do1 (+ pai ban))
  72. (Beep 0 ting)
  73. (Beep mi (* 2 pai))
  74. (Beep 0 ting)
  75. (Beep 0 ban)
  76. (Beep do1 ban)
  77. (Beep 0 (* 0.5 ting))
  78. (Beep do1 ban)
  79. (Beep 0 (* 0.5 ting))
  80. (Beep do1 ban)
  81. (Beep 0 (* 0.5 ting))
  82. (Beep si ban+pai)
  83. (Beep sfa ban)
  84. (Beep 0 ting)
  85. (Beep sfa pai)
  86. (Beep si pai)
  87. (Beep 0 ting)
  88. (Beep si 2*pai)
  89. (Beep 0 ting)
  90. (Beep 0 pai)
  91. (Beep la ban)
  92. (Beep si ban)
  93. (Beep 0 ting)
  94. (Beep do1 (+ pai ban))
  95. (Beep si ban)
  96. (Beep 0 ting)
  97. (Beep do1 pai)
  98. (Beep 0 ting)
  99. (Beep mi1 pai)
  100. (Beep 0 ting)
  101. (Beep si (* 2 pai))
  102. (Beep 0 ting)
  103. (Beep 0 pai)
  104. (Beep mi ban)
  105. (Beep 0 20)
  106. (Beep mi ban)
  107. (Beep 0 ting)
  108. (Beep la (+ pai ban))
  109. (Beep so ban)
  110. (Beep 0 ting)
  111. (Beep la pai)
  112. (Beep 0 ting)
  113. (Beep do1 pai)
  114. (Beep 0 ting)
  115. (Beep so (* pai 3))
  116. (Beep 0 (+ ting ban)
  117. (Beep mi ban)
  118. (Beep 0 (fix (* 0.5 ting)))
  119. (Beep fa pai)
  120. (Beep 0 ting)
  121. (Beep do1 ban)
  122. (Beep si ban)
  123. (Beep 0 20)
  124. (Beep si pai)
  125. (Beep 0 ting)
  126. (Beep do1 pai)
  127. (Beep 0 ting)
  128. (Beep re1 ban)
  129. (Beep 0 20)
  130. (Beep re1 ban)
  131. (Beep 0 20)
  132. (Beep mi1 ban)
  133. (Beep 0 (* 0.5 ting))
  134. (Beep do1 pai)
  135. ;;OK

发表于 2022-8-9 13:19:45 | 显示全部楼层
向大师学习学习
发表于 2022-8-9 13:47:18 | 显示全部楼层
拜读大师,感谢分享
发表于 2022-8-9 15:11:33 | 显示全部楼层
向高飞大神学习
发表于 2022-8-9 15:28:50 | 显示全部楼层
都是人才啊!!
发表于 2022-8-9 16:00:14 | 显示全部楼层
陨落 发表于 2022-8-9 13:09
有点儿意思,在此奉上“粉刷匠”:

嗯   你这个粉刷匠很流畅  不错!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-22 23:05 , Processed in 0.192609 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表