Skip to content

Instantly share code, notes, and snippets.

@rogerallen
rogerallen / music.clj
Created December 26, 2012 15:39
snippet for use in overtone issue #203
(def SCALE
(let [ionian-sequence [2 2 1 2 2 2 1]
pentatonic-sequence [3 2 2 3 2]
rotate (fn [scale-sequence offset]
(take (count scale-sequence)
(drop offset (cycle scale-sequence))))]
{:diatonic ionian-sequence
:ionian (rotate ionian-sequence 0)
:major (rotate ionian-sequence 0)
:dorian (rotate ionian-sequence 1)
@rogerallen
rogerallen / stringed.clj
Created January 10, 2013 21:44
Gist for a macro expansion question on the Overtone email list. The interesting problem is in the area that does (if free-on-silence ...). I want that "%" to make it through the macro. Alternatively, if I could figure out how to put the if only around :action FREE, that is another way to do things, but I get a nil from the if statement in the fa…
;; A Stringed Synth Generator Macro & Guitar Example Instrument
;;
;; See overtone/examples/instruments/guitar_synth.clj for example usage.
;;
;; Other instruments (like bass-guitar, ukelele, mandolin, etc.) may
;; use the same basic instrument. Watch this space...
(ns overtone.synth.stringed
^{:doc "A Stringed Synth Generator Macro & Guitar Instrument"
:author "Roger Allen"}
(:use [overtone.music pitch time]
@rogerallen
rogerallen / leipzig_poly_player.clj
Created February 7, 2013 04:19
Leipzig poly-player. Translate live midi playing in one key into another key entirely. Allows you to play "the white keys" on a keyboard and hear a different key without breaking your brain on manual transposition.
(ns explore-overtone.leipzig-poly-player
(:use
leipzig.melody
leipzig.scale
leipzig.canon)
(:require [overtone.live :as o]
[overtone.inst.sampled-piano :as p]))
;; "un-scale" -- the inverse translations to go from raw pitches 60,
;; 62, etc. to scale indices 0, 1, etc. Then, you can "re-scale" in
@rogerallen
rogerallen / core.clj
Created March 1, 2013 04:32
Ray-Tracing in Clojure Bugfix
(ns onlrt.core
(:gen-class))
;; Ray-Tracing in Clojure from
;; http://nakkaya.com/2010/12/26/ray-tracing-in-clojure/
(defstruct v3d-struct :x :y :z)
(defn v3d [x y z]
(struct v3d-struct x y z))
@rogerallen
rogerallen / leip_polyrhythm.clj
Created April 30, 2013 15:57
Fun with Leipzig/Overtone & Polyrhythms
(ns explore-overtone.leip-polyrhythm
(:require [overtone.live :as o]
[leipzig.live :as ll]
[leipzig.melody :as lm]))
(def snare (o/sample (o/freesound-path 26903)))
(def kick (o/sample (o/freesound-path 2086)))
(def close-hihat (o/sample (o/freesound-path 802)))
(def open-hihat (o/sample (o/freesound-path 26657)))
(def clap (o/sample (o/freesound-path 48310)))
@rogerallen
rogerallen / red-frik-130511.clj
Last active December 17, 2015 06:18
an attempt to translate https://twitter.com/redFrik/status/333317729073381377 play{a=LFSaw;mean({|i|Ringz.ar(Blip.ar(a.ar(i+1/[3,4])>(a.ar(i+1/8)+1)*25+50,i+[2,3])*a.ar(i+1/50,i/25),i+1*99,0.1)}!50)/5} to Overtone
;; an attempt to translate
;; https://twitter.com/redFrik/status/333317729073381377
;; play{a=LFSaw;mean({|i|Ringz.ar(Blip.ar(a.ar(i+1/[3,4])>(a.ar(i+1/8)+1)*25+50,i+[2,3])*a.ar(i+1/50,i/25),i+1*99,0.1)}!50)/5}
;; to Overtone
;;
;; play {
;; a=LFSaw;
;; mean(
;; { |i|
;; Ringz.ar(
@rogerallen
rogerallen / vihart_braid.clj
Last active December 18, 2015 15:19
Overtone Translation of Vi Hart's Sound Braid. See http://www.youtube.com/watch?v=VB6a4nI0BPA
;; Overtone Translation of Vi Hart's Sound Braid by Roger Allen
;; http://www.youtube.com/watch?v=VB6a4nI0BPA
;;
;; Listen to what this sounds like here: http://goo.gl/HSzgM
;;
(ns vihart-braid
(:require [overtone.live :as o]
[overtone.synth.stringed :as strings]
[leipzig.canon :as lc]
[leipzig.live :as ll]
@rogerallen
rogerallen / sonogram.glsl
Last active December 19, 2015 05:49
A sonogram for Shadertone
// Sonogram.glsl for Shadertone
//
// Now with explicit commentary...feel free to ask questions!
//
// Use a call like this to start the window from Clojure & Shadertone.
// See similar code in https://github.com/overtone/shadertone/tree/master/examples
// (t/start "examples/sonogram.glsl"
// :width 1024 :height 512 ;; note width matches WIN_WIDTH, height is 1:1 with FFT data
// :textures [ :overtone-audio :previous-frame ]) ;; this puts the FFT data in iChannel0 and
// ;; a texture of the previous frame in iChannel1
;; play{a=LFTri;l=LocalBuf(b=600,9).clear;BufWr.ar(a.ar(c=(3..11)*3.5),l,a.ar(9/c,c/99)*b);Splay.ar(PlayBuf.ar(9,l,loop:1)/2)}
;;
;; play{
;; a=LFTri;
;; l=LocalBuf(b=600,9).clear;
;; BufWr.ar(
;; a.ar(
;; c=(3..11)*3.5
;; ),
;; l,
(ns explore-overtone.violin
(:use [overtone.live]))
;; From the second article in the 4-part series...
;; http://www.soundonsound.com/sos/may03/articles/synthsecrets49.asp
;; See Image 5/Figure 4 as a good orientation point.
;;
;; 1) we used the synth to generate a sawtooth wave, and filtered it
;; using the internal low-pass and high-pass filters.
;;