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
(ns overtunes.songs.at-all | |
(:use | |
[overtone.live :only [at now]] | |
[overtone.inst.sampled-piano :only [sampled-piano]])) | |
(defn bpm [beats-per-minute] | |
(let [start (now) | |
ms-per-minute (* 60 1000) | |
ms-per-beat (/ ms-per-minute beats-per-minute)] | |
#(+ start (* ms-per-beat %)))) |
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
(ns overtunes.songs.row-row-row-your-boat | |
(:use | |
[overtone.live])) | |
(definst harpsichord [freq 440] | |
(let [duration 1] | |
(* | |
(line:kr 1 1 duration FREE) | |
(pluck (* (white-noise) (env-gen (perc 0.001 5) :action FREE)) | |
1 1 (/ 1 freq) (* duration 2) 0.25)))) |
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
# So the problem is inserting data into neo using the batch API. So we have a bunch of people and we want to put them into the graph and also | |
# add to to the index so that we can search for them. | |
# The way the batch API works is that you can refer to previous commands by referencing their index in the list of commands (zero indexed) | |
# e.g. if I want to reference the person added in the first command I would reference that node as {0} | |
# You should be able to see how that works in the code below. | |
neo_people_to_load = | |
[{ :name => "Mark Needham", :id => 1 }, | |
{ :name => "Jenn Smith", :id => 2 }, | |
{ :name => "Chris Ford", :id => 3 }] |
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
(definst bell# [frequency 440 duration 4.0] | |
(let [harmonic-decay [1.0 0.5 0.25 0.125] | |
partials (map-indexed | |
(fn [harmonic proportion] | |
(let [envelope (env-gen (perc 0.01 (* duration proportion))) | |
overtone (* (inc harmonic) frequency)] | |
(* envelope proportion (sin-osc overtone)))) | |
harmonic-decay)] | |
(detect-silence (first partials) :action FREE) | |
partials)) |
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
(definst bell# [frequency 440 duration 4.0] | |
(let [harmonic-decay [1.0 0.5 0.25 0.125] | |
ring (reduce + (map-indexed | |
(fn [harmonic proportion] | |
(let [envelope (env-gen (perc 0.01 (* duration proportion))) | |
overtone (* (inc harmonic) frequency)] | |
(* envelope proportion (sin-osc overtone)))) | |
harmonic-decay))] | |
(detect-silence ring :action FREE) | |
ring)) |
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
(definst bell [frequency 300 duration 20.0 h0 1.0 h1 0.5 h2 0.4 h3 0.25 h4 0.20 h5 0.125] | |
(let [harmonic-decay [h0 h1 h2 h3 h4 h5] | |
proportional-partial | |
(fn [harmonic proportion] | |
(let [envelope (env-gen (perc 0.01 (* duration proportion))) | |
overtone (* (inc harmonic) frequency)] | |
(* envelope proportion (sin-osc overtone)))) | |
partials (map-indexed proportional-partial harmonic-decay) | |
whole (mix partials)] | |
(detect-silence whole :action FREE) |
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
(ns anarchy.core) | |
(def plurality {}) | |
(defmacro defplural [method resolver] | |
`(def ~method (fn ~method [& args#] (~resolver (plurality ~method) args#)))) | |
(defmacro defimplementation [method implementation] | |
`(def plurality (update-in plurality [~method] #(conj % ~implementation)))) |
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
### Week 01 ### | |
0.upto(10) { |i| | |
print " " * (10 - i) | |
puts "*" * (2 * i + 1) | |
} | |
9.downto(0) { |i| | |
print " " * (10 - i) | |
puts "*" * (2 * i + 1) |
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
# Hashes connect keys to values: | |
companies = {"third_floor" => "ThoughtWorks", | |
"fourth_floor" => "Outbox"} | |
#> companies["third_floor"] | |
# You can use hashes to create a complex thing with multiple parts: | |
john = | |
{"first_name" => "John", | |
"second_name" => "Smith", |
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
# First, you need to install ruby. This will be different for Windows, Linux and Mac. | |
# You're probably best googling instructions for your operating system. | |
# | |
# Once you've got it installed, there are two ways of running ruby code: | |
# | |
# 1) Type "irb" on your command-line, and start typing in expressions that | |
# will be immediately evaluated. | |
# 2) Save some ruby in a file ending with .rb, and then run it with the ruby | |
# command, e.g. "ruby my_code.rb". This will run everything in the file | |
# at once. |
OlderNewer