-
-
Save jbclements/7489591 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
(require rsound) | |
;a note is | |
;(make-note number number number) | |
(define-struct note (pitch time duration)) | |
;a list-of-notes is one of: | |
;-empty, or | |
;-(cons note list-nof-notes) | |
;list-of-notes -> list-of-notes | |
;takes in a list of notes and produces a list of notes containing only those that end in the first 10 seconds | |
(define (note-filter lon) | |
(cond[(empty? lon) empty] | |
[else (if (> (* 10 44100) (+ (note-duration (first lon)) (note-time (first lon)))) | |
(cons (first lon) (note-filter (rest lon))) | |
(note-filter (rest lon)))])) | |
(check-expect (note-filter (cons (make-note 100 10000 44100)(cons (make-note 100 10000 (* 11 44100)) (cons (make-note 100 441001 44100) empty)))) | |
(cons (make-note 100 10000 44100) empty)) | |
(check-expect (note-filter (cons (make-note 100 10000 44100)(cons (make-note 100 10000 (* 9 44100)) (cons (make-note 100 441001 44100) empty)))) | |
(cons (make-note 100 10000 44100) (cons (make-note 100 10000 (* 9 44100)) empty))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment