Skip to content

Commit

Permalink
Merge branch 'vedderb:master' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinbeing authored Dec 29, 2023
2 parents d53c41c + 58a6d82 commit 234e591
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions QCodeEditor/resources/languages/lisp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@
<name>set-pos</name>
<name>foc-openloop</name>
<name>foc-beep</name>
<name>foc-play-tone</name>
<name>foc-play-stop</name>
<name>get-current</name>
<name>get-current-dir</name>
<name>get-current-in</name>
Expand Down
61 changes: 61 additions & 0 deletions res/Lisp/Examples/foc_melody.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
(def pause '(246.942 . 0))
(def h '(246.942 . 1.0))
(def c '(261.626 . 1.0))
(def d '(293.665 . 1.0))
(def e '(329.628 . 1.0))
(def f '(349.228 . 1.0))
(def fs '(369.994 . 1.0))
(def g '(391.995 . 1.0))
(def a '(440 . 1.0))
(def h1 '(493.883 . 1.0))
(def c1 '(523.251 . 1.0))

(def quarter 0.5)
(def eight 0.25)

(def melody (list
`(,quarter . ,g) `(,eight . ,g) `(,eight . ,a) `(,quarter . ,g)
`(,quarter . ,e) `(,eight . ,e) `(,eight . ,f) `(,quarter . ,e)
`(,quarter . ,d) `(,eight . ,d) `(,eight . ,e) `(,eight . ,d)
`(,eight . ,h)
`(,eight . ,c) `(,eight . ,d) `(,eight . ,e) `(,eight . ,f)
`(,quarter . ,g)
`(,quarter . ,g) `(,eight . ,g) `(,eight . ,a) `(,quarter . ,g)
`(,quarter . ,d) `(,eight . ,g) `(,eight . ,a) `(,quarter . ,h1)
`(,quarter . ,c1) `(,quarter . ,e) `(,quarter . ,fs)
`(,quarter . ,g) `(,quarter . ,pause) `(,quarter . ,pause)
`(,eight . ,c) `(,eight . ,c)
`(,eight . ,c) `(,eight . ,d) `(,eight . ,e) `(,eight . ,d)
`(,eight . ,c) `(,eight . ,d) `(,quarter . ,e) `(,quarter . ,c)
`(,eight . ,d) `(,eight . ,d) `(,eight . ,d) `(,eight . ,e)
`(,eight . ,f) `(,eight . ,d)
`(,eight . ,d) `(,eight . ,e) `(,quarter . ,f) `(,quarter . ,d)
`(,eight . ,e) `(,eight . ,f) `(,quarter . ,g) `(,eight . ,f)
`(,eight . ,e)
`(,eight . ,f) `(,eight . ,g) `(,quarter . ,a) `(,eight . ,g)
`(,eight . ,f)
`(,eight . ,g) `(,eight . ,a) `(,quarter . ,h1) `(,eight . ,a)
`(,eight . ,g)
`(,quarter . ,c1) `(,quarter . ,c1) `(,quarter . ,pause)
))

; Play tone with exponential decay
(defun play-tone (ch freq time vol) {
(looprange i 0 30 {
(setq vol (* vol 0.93))
(foc-play-tone ch freq vol)
(sleep (/ time 30.0))
})
})

(defun play (x)
(loopforeach ls x {
(var time (car ls))
(var freq (car (cdr ls)))
(var vol (* (cdr (cdr ls)) 1.2))

(play-tone 0 freq time vol)
(sleep 0.05)
}))

(play melody)
1 change: 1 addition & 0 deletions res_lisp.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
<file>res/Lisp/Examples/lbm_update.lisp</file>
<file>res/Lisp/Examples/sort_test1.lisp</file>
<file>res/Lisp/Examples/sort_test2.lisp</file>
<file>res/Lisp/Examples/foc_melody.lisp</file>
</qresource>
</RCC>

0 comments on commit 234e591

Please sign in to comment.