Skip to content

Instantly share code, notes, and snippets.

View forsakendaemon's full-sized avatar

David Allen forsakendaemon

View GitHub Profile
# N.B. The following values work. Technically, you can use any s and p with p a primitive root modulo s.
# It works best if you use an s that is one more than a multiple of three. (e.g. 4, 7, 10, 13)
# It will work for any x up to 2^{s - 1} - 1
# inv calculates is the inverse of p in \mathbb{Z}_{s}.
# s p
# 1 0
# 2 1
# 3 2
# 4 3

Keybase proof

I hereby claim:

  • I am forsakendaemon on github.
  • I am forsakendaemon (https://keybase.io/forsakendaemon) on keybase.
  • I have a public key whose fingerprint is 54DA 82F1 C9B6 E61D ABF3 1065 35DA BF6E 5605 65D4

To claim this, I am signing this object:

@forsakendaemon
forsakendaemon / pitch.clj
Created January 27, 2012 12:12
Potential additions to overtone.music.pitch to match chords.
(ns overtonehacking.pitch
(:use [overtone.music.pitch]
[clojure.test]
[clojure.pprint]
)
)
; Utility function to invert a map. Thanks to amalloy on stackexchange.com for help with this!
(defn map-invert-preserving-dups [m] (apply merge-with into (for [[k v] m] {v [k]})))
@forsakendaemon
forsakendaemon / gist.clj
Created January 20, 2012 09:00
A Clojure Gist that allows you to load a Gist by id.
;requires clj-http (https://github.com/dakrone/clj-http) and clojure.data.json (https://github.com/clojure/data.json) to be available
(require '[clj-http.client :as client] '[clojure.data.json :only (read-json) :as json])
(defn getfiles [id] (get (json/read-json (get (client/get (str "https://api.github.com/gists/" id)) :body)) :files))
(defn getcontent [files] (get (get files (first (keys files))) :content))
(defn loadgist [id] (load-string (getcontent (getfiles id))))
@forsakendaemon
forsakendaemon / chords.clj
Created January 19, 2012 11:38
Simple chord analysis in overtone
(def notenames '(:C :C# :D :D# :E :F :F# :G :G# :A :A# :B))
(defn subchord [chord] (map - (rest chord) chord))
(defn complete [chord] (concat chord (list (apply - (cons 12 chord)))))
(defn rotate [list] (cons (last list) (butlast list)))
(defn match [chordlist]
(try
(if (= (first chordlist) (+ 1 (count (second chordlist)))) (throw (Exception. "Unable to Match")))
(condp = (second chordlist)
'(4 3 5) (list (first chordlist) "Major")