Skip to content

Instantly share code, notes, and snippets.

@jbclements
Forked from StasisPod/gist:7493602
Created November 15, 2013 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbclements/7493701 to your computer and use it in GitHub Desktop.
Save jbclements/7493701 to your computer and use it in GitHub Desktop.
;; a note is (make-note note-num frames frames)
(define-struct note (pitch time duration))
;; number -> number
;; converts seconds to frames
(define (s f)
(* 44100 f))
(check-expect (s 10) 441000)
;; list-of-notes -> list-of-notes
;; returns all notes that end in first 10 sec
(define (ten-sec l)
(cond [(empty? l) empty]
[(<= (+ (note-duration (first l)) (note-time (first l)))
(s 10))
(cons (first l) (ten-sec (rest l)))]
[else (ten-sec (rest l))]))
(check-expect (ten-sec
(cons (make-note 60 4410000 25)
(cons (make-note 60 44000 25)
empty)))
(cons (make-note 60 44000 25)
empty))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment