Created
November 18, 2013 19:29
-
-
Save ekajjake/7533824 to your computer and use it in GitHub Desktop.
Recorder for final project
This file contains 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) | |
(require 2htdp/universe) | |
(require 2htdp/image) | |
(define (s sec) (* sec 44100)) | |
(define (draw-world st) | |
(empty-scene 20 20)) | |
(define (both a b)b) | |
(define RECORD-LENGTH (s 2)) | |
(define-struct recording-world (rec1 rec2 rec3)) | |
(define (player st key) | |
(cond | |
[(key=? key "1") | |
(if (string=? key "1") (make-recording-world (record-sound RECORD-LENGTH) (recording-world-rec2 st) (recording-world-rec3 st)) st)] | |
[(key=? key "2") | |
(if (string=? key "2") (make-recording-world (recording-world-rec1 st) (record-sound RECORD-LENGTH) (recording-world-rec3 st)) st)] | |
[(key=? key "3") | |
(if (string=? key "3") (make-recording-world (recording-world-rec1 st) (recording-world-rec2 st) (record-sound RECORD-LENGTH)) st)] | |
[(key=? key "4") | |
(if (string=? key "4") (both (play (recording-world-rec1 st)) st) st)] | |
[(key=? key "5") | |
(if (string=? key "5") (both (play (recording-world-rec2 st)) st) st)] | |
[(key=? key "6") | |
(if (string=? key "6") (both (play (recording-world-rec3 st)) st) st)] | |
[else st])) | |
(big-bang (make-recording-world 0 0 0) | |
[on-key player] | |
[to-draw draw-world]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment