Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Last active October 16, 2019 11:17
Show Gist options
  • Save pbalduino/cf7cdd5b2231e90efb62fc35b3fcd2cb to your computer and use it in GitHub Desktop.
Save pbalduino/cf7cdd5b2231e90efb62fc35b3fcd2cb to your computer and use it in GitHub Desktop.
;; :dependencies [[org.clojure/clojure "1.10.1"]
;; [overtone/overtone "0.10.6"]
;; [leipzig "0.10.0"]]
;; Reference: https://musescore.com/user/5715836/scores/2665176
(ns jukebox.megalovania
(:require [overtone.live :refer :all]
[leipzig.melody :refer [all bpm is phrase tempo then times where with]]
[leipzig.live :as live]
[overtone.inst.drum :as drum]
[overtone.inst.synth :as synth]
[overtone.inst.piano :as piano]
[leipzig.scale :as scale])
(:gen-class))
(def P nil)
(def F4 6)
(def E4 5)
(def D4 4)
(def C4 3)
(def B4 2)
(def A4 1)
(def G3 0)
(def F3 -1)
(def E3 -2)
(def D3 -3)
(def C3 -4)
(def B3 -5)
(def A3 -6)
(def G2 -7)
(def F2 -8)
(def E2 -9)
(def D2 -10)
(def C2 -11)
(def B2 -12)
(definst beep [freq 440 dur 1.0]
(-> freq
saw
(* (env-gen (adsr 0.01 0.1 0.5 0.3 -2)
(line:kr 1.0 0.0 dur)
:action FREE))
pan2))
(defmethod live/play-note :default [{midi :pitch seconds :duration :as note}]
(println note)
(when midi
(-> midi midi->hz (beep seconds))))
(def verse1 (phrase [1/8 1/8 1/8 1/8 1/4 1/8 1/4 1/4 1/4 1/8 1/8 1/8]
[D3 D3 D4 P A4 nil 0.5 G3 F3 D3 F3 0]))
(def verse2 (phrase [1/8 1/8 1/8 1/8 1/4 1/8 1/4 1/4 1/4 1/8 1/8 1/8]
[-4 -4 D4 nil A4 nil 0.5 G3 F3 D3 F3 0]))
(def verse3 (phrase [1/8 1/8 1/8 1/8 1/4 1/8 1/4 1/4 1/4 1/8 1/8 1/8]
[-4.5 -4.5 D4 nil A4 P 0.5 0 -1 D3 -1 0]))
(def verse4 (phrase [1/8 1/8 1/8 1/8 1/4 1/8 1/4 1/4 1/4 1/8 1/8 1/8]
[-5 -5 D4 nil 1 nil 0.5 0 -1 D3 -1 0]))
(def bass1 (phrase [2]
[D2]))
(def bass2 (phrase [2]
[C2]))
(def bass3 (phrase [2]
[B2]))
(def bass4 (phrase [3/4 1/8 1 1/8]
[B2 B2 C2 C2]))
(def bass5 (phrase [1/4 1/4 1/4 1/8 1/4 1/8 1/8 1/8 1/8 1/8 1/4]
[D2 D3 D2 D3 D2 E2 E2 E3 E2 E2 E3]))
(def bass6 (phrase [1/4 1/4 1/4 1/8 1/4 1/8 1/8 1/8 1/8 1/8 1/4]
[C2 C3 C2 C3 C2 D2 D2 D3 D2 D2 D3]))
(def bass7 (phrase [1/4 1/4 1/4 1/8 1/4 1/8 1/8 1/8 1/8 1/8 1/4]
[B2 B3 B2 B3 B2 C2 C2 C3 C2 C2 C3]))
(def bass8 (phrase [1/4 1/4 1/4 1/8 1/4 1/8 1/8 1/8 1/8 1/8 1/4]
[B2 B3 B2 B3 C2 C2 C2 D3 C2 C2 D3]))
(def part1 (->> verse1
(then verse2)
(then verse3)
(then verse4)))
(def part3 (->> (with verse1 bass5)
(then (with verse2 bass6))
(then (with verse3 bass7))
(then (with verse4 bass8))))
(def part3 (->> bass5
(then bass6)
(then bass7)
(then bass8)))
(def part2 (->> (with verse1 bass1)
(then (with verse2 bass2))
(then (with verse3 bass3))
(then (with verse4 bass4))))
(def intro (->> part2
; (then part2)
(then (times 2 part3))))
(def outro-melody (phrase [1/4 1/8 1/4 1/4 1/4 1/4 1/2 1/8]
[F4 F4 F4 F4 F4 D4 D4 P]))
(def outro-bass bass6)
(def main (with outro-melody outro-bass))
@(->> intro
(then main)
(tempo (bpm 60))
(where :pitch (comp scale/G scale/minor))
(live/play))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment