Skip to content

Instantly share code, notes, and snippets.

@jbclements
jbclements / s16vec-play-testing.rkt
Created October 12, 2012 15:38
testing sound playing under windows for rsound
#lang racket
(require ffi/vector
ffi/unsafe
(rename-in racket/contract [-> c->])
(planet clements/portaudio/portaudio)
(planet clements/portaudio/callback-support))
;; this module provides a function that plays a sound.
JSONOBJECT = {code : CODE, trace : TRACE}
TRACE = {ordered_globals : VARARRAY,
stdout : STDOUT,
}
@jbclements
jbclements / sliders.rkt
Created October 24, 2012 22:02
A simple example of using Racket and 2htdp/universe to create a bunch of sliders on the screen
(require 2htdp/universe)
(require 2htdp/image)
; Copyright 2012, John Clements ([email protected])
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
#lang racket
(require net/url
#;html
(planet neil/htmlprag))
#;(string->url "https://dev.twitter.com/oauth/request_token")
(define the-port
(post-pure-port
@jbclements
jbclements / katy-sliders.rkt
Created October 31, 2012 18:33
sliders controlling katy perry sample
(require 2htdp/universe)
(require 2htdp/image)
; Copyright 2012, John Clements ([email protected])
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
@jbclements
jbclements / tap-examples.rkt
Created November 3, 2012 00:21
code from class, 2012-11-01
(require (planet clements/rsound:4:3))
(define SONG (rs-read "/tmp/wenceslas.wav"))
(define my-ding (rs-append ding (silence (* 4 44100))))
(define (looper sound)
(local [(define len (rs-frames sound))]
(network ()
[ctr ((loop-ctr len 1))]
@jbclements
jbclements / tempo-sliders.rkt
Created November 5, 2012 20:28
five sliders, the first controls the tempo of the ding
(require 2htdp/universe)
(require 2htdp/image)
; Copyright 2012, John Clements ([email protected])
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
@jbclements
jbclements / class-code-2012-11-05.rkt
Created November 6, 2012 00:12
Code from class, 2012-11-05
(require (planet clements/rsound:4:3))
(require (planet clements/rsound:4:3/filter))
(define SONG (rs-read "/tmp/bette-davis-eyes.wav"))
(define (looper sound)
(local [(define len (rs-frames sound))]
(network ()
[ctr ((loop-ctr len 1))]
[out (/ (+ (rs-ith/left sound ctr)
@jbclements
jbclements / sliders-with-colors.rkt
Created November 9, 2012 19:55
Code from class, 2012-11-09
(require 2htdp/universe)
(require 2htdp/image)
; Copyright 2012, John Clements ([email protected])
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
@jbclements
jbclements / tiny-envelope.rkt
Created November 15, 2012 00:41
Code from class, 2012-11-14
(require (planet clements/rsound:4))
(require "event-channel.rkt")
(require 2htdp/image)
(require 2htdp/universe)
(define ec (make-event-channel))
(send-event ec 400)
;; an event is either