-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f420b8d
Showing
7 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data_readers.clj | ||
hs_err_pid*.log | ||
pom.xml | ||
pom.xml.asc | ||
**/gen | ||
**/target | ||
.* | ||
!.gitignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Introduction | ||
|
||
A Clojure library that wraps [Alda](https://github.com/alda-lang/alda) so you can write musical scores as edn data. | ||
|
||
## Usage | ||
|
||
You can include this library in your project dependencies using the version number in the badge above. | ||
|
||
To experiment with this library in a REPL, you can use [the Clojure CLI tool](https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools). In this directory, run `clj` to start a Clojure REPL. When the REPL is up, enter the main namespace with `(require 'edna.core) (in-ns 'edna.core)`. | ||
|
||
## Licensing | ||
|
||
All files that originate from this project are dedicated to the public domain. I would love pull requests, and will assume that they are also dedicated to the public domain. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BOOT_CLOJURE_VERSION=1.9.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(defn read-deps-edn [aliases-to-include] | ||
(let [{:keys [paths deps aliases]} (-> "deps.edn" slurp clojure.edn/read-string) | ||
deps (->> (select-keys aliases aliases-to-include) | ||
vals | ||
(mapcat :extra-deps) | ||
(into deps) | ||
(reduce | ||
(fn [deps [artifact info]] | ||
(if-let [version (:mvn/version info)] | ||
(conj deps | ||
(transduce cat conj [artifact version] | ||
(select-keys info [:scope :exclusions]))) | ||
deps)) | ||
[]))] | ||
{:dependencies deps | ||
:source-paths (set paths) | ||
:resource-paths (set paths)})) | ||
|
||
(let [{:keys [source-paths resource-paths dependencies]} (read-deps-edn [])] | ||
(set-env! | ||
:source-paths source-paths | ||
:resource-paths resource-paths | ||
:dependencies (into '[[nightlight "RELEASE" :scope "test"]] | ||
dependencies) | ||
:repositories (conj (get-env :repositories) | ||
["clojars" {:url "https://clojars.org/repo/" | ||
:username (System/getenv "CLOJARS_USER") | ||
:password (System/getenv "CLOJARS_PASS")}]))) | ||
|
||
(require | ||
'[nightlight.boot :refer [nightlight]]) | ||
|
||
(task-options! | ||
pom {:project 'edna | ||
:version "1.0.0-SNAPSHOT" | ||
:description "A library for writing Alda scores as edn data" | ||
:url "https://github.com/oakes/edna" | ||
:license {"Public Domain" "http://unlicense.org/UNLICENSE"}} | ||
push {:repo "clojars"}) | ||
|
||
(deftask run [] | ||
(comp | ||
(wait) | ||
(nightlight :port 4000))) | ||
|
||
(deftask local [] | ||
(comp (pom) (jar) (install))) | ||
|
||
(deftask deploy [] | ||
(comp (pom) (jar) (push))) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:paths ["src"] | ||
:deps {org.clojure/clojure {:mvn/version "1.9.0" :scope "provided"} | ||
alda/core {:mvn/version "0.3.10"} | ||
alda/sound-engine-clj {:mvn/version "0.3.2"}}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
(ns edna.core | ||
(:require [clojure.spec.alpha :as s] | ||
[alda.lisp.instruments.midi] | ||
[alda.lisp.model.instrument :refer [*stock-instruments*]])) | ||
|
||
(def dueling-banjos | ||
[[:guitar | ||
{:octave 3 :length 1/8} :b > :c | ||
{:length 1/4} :d < :b > :c < :a :b :g :a] | ||
[:banjo | ||
{:octave 3 :length 1/8} :b > :c | ||
{:length 1/4} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1/8} :b > :c | ||
{:length 1/4} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1} :d | ||
{:length 1/4} :g :g :a :b :g :b | ||
{:length 1} :a] | ||
|
||
[:banjo | ||
{:octave 3 :length 1/4} :g :g :a :b | ||
{:length 1} :g] | ||
|
||
[:guitar | ||
{:octave 2 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
[:banjo | ||
{:octave 3 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
[:guitar | ||
{:octave 2 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
[:banjo | ||
{:octave 3 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
[:guitar | ||
{:octave 3 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
[:banjo | ||
{:octave 3 :length 1/8} :g :g | ||
{:length 1/4} :g :a :b > :c :d :c < | ||
{:length 1} :b] | ||
|
||
[:guitar | ||
{:octave 4 :length 1/8} #{:d :<b :<g} #{:d :<b :<g} | ||
{:length 1/4} #{:d :<b :<g} #{:e :c :<g} #{:d :<b :<g}] | ||
[:banjo | ||
{:octave 4 :length 1/8} #{:d :<b :<g} #{:d :<b :<g} | ||
{:length 1/4} #{:d :<b :<g} #{:e :c :<g} #{:d :<b :<g}] | ||
[:guitar | ||
{:octave 4 :length 1/8} #{:d :<b :<g} #{:d :<b :<g} | ||
{:length 1/4} #{:d :<b :<g} #{:e :c :<g} #{:d :<b :<g}] | ||
[:banjo | ||
{:octave 4 :length 1/8} #{:d :<b :<g} #{:d :<b :<g} | ||
{:length 1/4} #{:d :<b :<g} #{:e :c :<g} #{:d :<b :<g}] | ||
|
||
[:guitar | ||
{:octave 2 :length 1/8} :b > :c | ||
{:length 1/4} :d < :b > :c < :a :b :g :a] | ||
[:banjo | ||
{:octave 3 :length 1/8} :b > :c | ||
{:length 1/4} :d < :b > :c < :a :b :g :a] | ||
|
||
#{[:banjo | ||
{:octave 3 :length 1/16} :b > :c | ||
{:length 1/8} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1/16} :r :r | ||
{:length 1/8} :g :r :d :r :g :g :d]} | ||
#{[:banjo | ||
{:octave 3 :length 1/16} :b > :c | ||
{:length 1/8} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1/16} :r :r | ||
{:length 1/8} :g :r :d :r :g :g :d]} | ||
#{[:banjo | ||
{:octave 3 :length 1/16} :b > :c | ||
{:length 1/8} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1/4} :g | ||
{:length 1/8} :a :b | ||
{:length 1/4} :g | ||
{:length 1/8} :a :d]} | ||
#{[:banjo | ||
{:octave 3 :length 1/16} :b > :c | ||
{:length 1/8} :d < :b > :c < :a :b :g :a] | ||
[:guitar | ||
{:octave 3 :length 1/4} :g | ||
{:length 1/8} :a :b | ||
{:length 1/4} :g | ||
{:length 1/8} #{:f :<a} :b | ||
{:length 1/4} :c]}]) | ||
|
||
(def instruments (->> *stock-instruments* keys (map keyword) set)) | ||
|
||
(def octaves #{\< \>}) | ||
|
||
(def notes #{\c \d \e \f \g \a \b}) | ||
|
||
(def pitches #{\+ \-}) | ||
|
||
(s/def ::note (s/cat | ||
:octaves (s/* octaves) | ||
:note notes | ||
:pitch (s/? pitches))) | ||
|
||
(defn parse-note [note] | ||
(if-not (keyword? note) | ||
:clojure.spec.alpha/invalid | ||
(s/conform ::note (seq (name note))))) | ||
|
||
(defn note? [x] | ||
(not= :clojure.spec.alpha/invalid (parse-note x))) | ||
|
||
(s/def ::chord (s/coll-of note? :kind set?)) | ||
|
||
(s/def ::octave number?) | ||
(s/def ::length number?) | ||
(s/def ::attrs (s/keys :opt-un [::octave ::length])) | ||
|
||
(s/def ::parts (s/* (s/alt | ||
:note note? | ||
:rest #{:r} | ||
:octave #{< >} | ||
:attrs ::attrs | ||
:chord ::chord | ||
:subsection (s/spec (s/cat | ||
:instrument (s/? instruments) | ||
:parts ::parts))))) | ||
|
||
(s/def ::section (s/cat | ||
:instrument instruments | ||
:parts ::parts)) | ||
|
||
(s/def ::concurrent-sections (s/coll-of ::section :kind set?)) | ||
|
||
(s/def ::sections | ||
(s/coll-of (s/or | ||
:single ::section | ||
:concurrent ::concurrent-sections))) | ||
|
||
(s/conform ::sections dueling-banjos) | ||
|