Skip to content

Commit

Permalink
Rearrange music code for side by side review.. prelude to factoring o…
Browse files Browse the repository at this point in the history
…ut..
  • Loading branch information
ahefner committed Apr 30, 2015
1 parent 6add731 commit 3b1b06b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
4 changes: 3 additions & 1 deletion hacks/dollhouse.lisp
Expand Up @@ -906,7 +906,9 @@
(align 256)
(with-label music-start
(unless (= (length music-sequence) (* 128 (expt 2 log2-song-length)))
(error "Song length is ~:D, should be ~:D" (length music-sequence) (* 128 (expt 2 log2-song-length))))
(error "Song length is ~:D, should be ~:D"
(length music-sequence)
(* 128 (expt 2 log2-song-length))))
(print (list :num-unique (length (remove-duplicates music-sequence))))
;; Write the pointer table:
(mapcar #'dw (reverse music-sequence))))
Expand Down
37 changes: 7 additions & 30 deletions hacks/music-test.lisp
Expand Up @@ -84,6 +84,11 @@
(list
(noteon channel (translate-length d) freq)))))

(defun silence-channel (channel)
(ecase channel
(0 (note 0 1 1 :d 0 :cfg '(:vol 0 :loop t :env nil)))
(1 (note 1 1 1 :d 0 :cfg '(:vol 0 :loop t :env nil)))))

(defun tri (length freq &key (d length))
(check-type d (integer 0 31))
(segment length
Expand Down Expand Up @@ -118,6 +123,8 @@
(defun repeat (n &rest args)
(apply #'seq (mapcan #'copy-list (loop repeat n collect args))))

(defun rst (length) (segment length nil))

(defparameter *tuning-root* nil)

(defun get-tuning-root ()
Expand Down Expand Up @@ -157,39 +164,9 @@
(noise 1 1 1 :env nil :loop t :vol volume)
(noise 1 1 1 :env nil :vol 0))))

(defun rst (length) (segment length nil))

(defun eltmod (i seq) (elt seq (mod i (length seq))))
(defun clamp (x min max) (max (min x max) min))

(defun arp-test-2 ()
(para
(apply 'seq
(loop for i below 128
as time = (* i 3)
as freq = (et (eltmod i '(0 3 5 -2 -4)) 12)
as vol = (clamp (- 15 (ash time -3))
0
15)
as duty = (mod (ash time -2) 4)
collect
(note 0 3 freq :cfg (list :duty duty :env nil :loop t :vol vol))))
(apply 'seq
(loop for i below 128
as time = (* i 4)
as freq = (et (eltmod i '(0 2 5 -2 -4 7)) 12)
as vol = (clamp (- 15 (ash time -3))
0
15)
as duty = (mod (ash time -2) 4)
collect
(note 1 4 freq :cfg (list :duty duty :env nil :loop t :vol vol))))))

(defun silence-channel (channel)
(ecase channel
(0 (note 0 1 1 :d 0 :cfg '(:vol 0 :loop t :env nil)))
(1 (note 1 1 1 :d 0 :cfg '(:vol 0 :loop t :env nil)))))

(defun volramp (&optional (start 15) (rate -1/10))
(lambda (time)
(clamp (round (+ start (* time rate)))
Expand Down

0 comments on commit 3b1b06b

Please sign in to comment.