-
-
Save jbclements/7493671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Nancy Truong, Mitchell Salles, Dan Stone | |
;; CPE 123 (3:00 P - 5:00 P) | |
(define (s sec) (* 44100 sec)) | |
;; a note is (make-note midi-num frames frames) | |
(define-struct note (pitch time dur)) | |
;; note -> boolean | |
(define (check-if-first-ten n) | |
(if (<= (+ (note-time n) (note-dur n)) (s 10)) true false)) | |
; list-of-notes -> list-of-notes | |
;; returns alist of notes that end in the first 10 seconds | |
(define (first-ten lon) | |
(cond [(empty? lon) empty] | |
[else | |
(if (check-if-first-ten (first lon)) | |
(cons (first lon) | |
(first-ten (rest lon))) | |
(first-ten (rest lon)))])) | |
(check-expect (first-ten (cons (make-note 40 0 (s 2)) | |
(cons (make-note 50 (s 3) (s 2)) | |
(cons (make-note 40 (s 5) (s 4)) | |
(cons (make-note 40 (s 10) (s 2)) empty))))) | |
(cons (make-note 40 0 (s 2)) | |
(cons (make-note 50 (s 3) (s 2)) | |
(cons (make-note 40 (s 5) (s 4)) empty)))) | |
(check-expect (first-ten (cons (make-note 40 (s 9) (s 2)) | |
(cons (make-note 50 (s 11) (s 2)) | |
(cons (make-note 40 (s 13) (s 4)) | |
(cons (make-note 40 (s 3) (s 2)) empty))))) | |
(cons (make-note 40 (s 3) (s 2)) empty)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment