Skip to content

Instantly share code, notes, and snippets.

@samaaron
Forked from deltam/core.clj
Created December 11, 2011 00:04
Show Gist options
  • Save samaaron/1457193 to your computer and use it in GitHub Desktop.
Save samaaron/1457193 to your computer and use it in GitHub Desktop.
Overtone jingle bells
(ns overtone-chrismas.core
(:use [overtone.live]))
(definst beep [freq 440]
(let [env (env-gen (perc 0.1 0.2) :action FREE)]
(* env (sin-osc freq))))
; ドレミの周波数を定義
(def doremi {:none 0
:do :c3
:re :d3
:mi :e3
:fa :f3
:so :g3
:ra :a3
:si :b3
:do2 :c4
:re2 :d4
:mi2 :e4
:fa2 :f4
:so2 :g4
:ra2 :a4})
(def jingle-bells
[
:so :mi2 :re2 :do2 :so :none ;; Dashing through the snow, in a
:so :mi2 :re2 :do2 :ra :none ;; one horse open sleigh
:ra :fa2 :mi2 :re2 :si :none ;; Through the fields we go
:so2 :so2 :fa2 :re2 :mi2 :none ;; Laughing all the way
:so :mi2 :re2 :do2 :so :none ;; Bells on bob tails ring
:so :mi2 :re2 :do2 :ra :none ;; Making spirits bright
:ra :fa2 :mi2 :re2 :so2 :so2 :so2 ;; What fun it is to laugh and sing
:so2 :ra2 :so2 :fa2 :re2 :do2 :none ;; A sleighing song tonight
:so2 :none ;; Oh,
:mi2 :mi2 :mi2 :none :mi2 :mi2 :mi2 :none ;; Jingle bells, jingle bells
:mi2 :so2 :do2 :re2 :mi2 :none :none ;; Jingle all the way
:fa2 :fa2 :fa2 :fa2 :fa2 :mi2 :mi2 :mi2 ;; Oh, what fun it is to ride
:mi2 :re2 :re2 :mi2 :re2 :none ;; In a one horse open sleigh
:so2 :none ;; Oh,
:mi2 :mi2 :mi2 :none :mi2 :mi2 :mi2 :none ;; Jingle bells, jingle bells
:mi2 :so2 :do2 :re2 :mi2 :none :none ;; Jingle all the way
:fa2 :fa2 :fa2 :fa2 :fa2 :mi2 :mi2 :mi2 ;; Oh, what fun it is to ride
:so2 :so2 :fa2 :re2 :do2 :none ;; In a one horse open sleigh
])
(def jingle-bells-freqs (map #(midi->hz (note (doremi %))) jingle-bells))
(defn play-notes
"Play all notes by passing each note (expected to be a freq in hz) to the beep
instrument and sleeping for 200ms between each note"
[notes]
(dorun (map #(do (beep %) (Thread/sleep 200))
notes)))
;;ジングルベル
;;(play-notes jingle-bells-freqs)
(defproject overtone-chrismas "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[overtone "0.5.0"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment