;;;; Somehow became 012.lisp

(require :cl-buchberger)
(require :mcclim)
(asdf:oos 'asdf:load-op :lispusers/tfw/high/turntable)

(in-package :lispusers/tfw/high/turntable)
(use-package :cl-buchberger)

(defun lambdaise (poly)
 (let* ((variables (cl-buchberger::variables
                    (cl-buchberger::base-ring poly)))
        (terms (cl-buchberger::terms->list poly)))
  `(lambda (,@variables)
    (+
     ,@(loop for term in terms
	for co = (cl-buchberger::coefficient term)
	for mo = (cl-buchberger::monomial term) collect
	`(* ,co
	    ,@(loop for m across mo for v in variables collect
	       `(expt ,v ,m))))))))

(setq *p*
 (ring* (make-polynomial (* 200 1/50 100/22050))
	(make-polynomial '(* 1 (expt x 2)))))
                   
(setq *l* (lambdaise *p*))
(setf (symbol-function '*l*) (eval *l*))
(setf (repeats *frame*) 10)

;; Some iterations of this. I got my equation math wrong, but just
;; Wandered around it a bit.

(loop for n from -100 to 100 by 5
      for wl = (+ 100 (*l* n 0 0)) do
      (setf (wavelength/2 *frame*) (truncate wl 2))
      (append-note *frame*))