Skip to content

Instantly share code, notes, and snippets.

@jbclements
jbclements / class-code.rkt
Created October 23, 2013 18:23
code from class 2011-10-23
(require rsound)
(require 2htdp/universe)
(require 2htdp/image)
(define SR 44100.0)
(define (s sec) (* sec SR))
;(define beat-frames (round (/ (* SR 60) 128)))
;(define (beat b) (* beat-frames b))
(define LEAD-FRAMES (s 1/14))
@jbclements
jbclements / two-sliders.rkt
Created October 21, 2013 18:20
code from class 2011-10-21 morning section
(require rsound)
(require 2htdp/universe)
(require 2htdp/image)
(define SR 44100)
(define (s sec) (* sec SR))
(define beat-frames (round (/ (* SR 60) 128)))
(define (beat b) (* beat-frames b))
(define LEAD-FRAMES (beat 0.5))
@jbclements
jbclements / reverse-sound.rkt
Created October 14, 2013 23:47
code from class, 2013-10-14
(require rsound)
;; the sample rate
(define SR 44100)
;; a helper function to simplify specifying the number of seconds
(define (s seconds) (* seconds SR))
;; read in a clip of a sound
(define samp
(rs-read/clip "/path/to/your/sound.wav"
@jbclements
jbclements / random-piano-notes.rkt
Created October 12, 2013 00:21
code from class, 2013-10-11. Requires today's version of rsound at least, to include piano sounds.
(require rsound)
(require rsound/piano-tones)
(require 2htdp/universe)
(require 2htdp/image)
;(play (piano-tone 62))
(define (both a b) b)
@jbclements
jbclements / eli-wxme-to-text.rkt
Created October 5, 2013 22:11
Eli's code to convert WXME code to text
#!/bin/sh
#| -*- scheme -*-
exec gracket -tm "$0" "$@"
|#
#lang racket/gui
;; ===========================================================================
(define (insert-to-editor editor . xs)
@jbclements
jbclements / mouse-tone-player.rkt
Created October 4, 2013 23:27
a simple big-bang program that plays notes depending on the x-position of the mouse
(require 2htdp/image)
(require 2htdp/universe)
(require rsound)
;; a world is an integer.
;; rep. the "x" position of the mouse
(define SCREENWIDTH 400)
;; draw the world
#lang typed/racket
(: fir-filter ((Listof (List Nonnegative-Fixnum Real)) -> Any))
(define (fir-filter params)
(match params
[`((,delays ,amplitudes) ...)
(+ 1 (apply max delays))]
[other (error 'ouch)]))
@jbclements
jbclements / typed-match.rkt
Created September 12, 2013 20:16
I claim this used to type-check....
#lang typed/racket
(: fir-filter ((Listof (List Nonnegative-Fixnum Real)) -> Any))
(define (fir-filter params)
(match params
[`((,delays ,amplitudes) ...)
(: max-delay Index)
(+ 1 (apply max delays))]
[other (error 'ouch)]))
@jbclements
jbclements / scoped-macro.rs
Created September 12, 2013 18:06
trying to use a macro that's out of scope
fn f() -> int {
macro_rules! a (() => (3));
return a!();
}
fn main() {
a!();
}
@jbclements
jbclements / gist:6460010
Created September 6, 2013 05:50
codegen test failure
run codegen [x86_64-apple-darwin]: x86_64-apple-darwin/stage2/bin/compiletest
running 9 tests
test [codegen] codegen/iterate-over-array.rs ...
error: extracting 'test' function failed
command: /Users/clements/rust/build/x86_64-apple-darwin/llvm/Release+Asserts/bin/llvm-extract -func=test -o=x86_64-apple-darwin/test/codegen/iterate-over-array-clang-extract.bc x86_64-apple-darwin/test/codegen/iterate-over-array-clang.bc
stdout:
------------------------------------------
------------------------------------------