• Stars
    star
    187
  • Rank 206,464 (Top 5 %)
  • Language
    Clojure
  • License
    The Unlicense
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Clojure data -> music library

Introduction

A Clojure library for making music with edn data. It uses Alda underneath. There are probably bugs...or maybe your music just sounds bad. It could be that. Think about it.

Try the playable examples!

In addition to playing music, you can export to mp3, wav, or midi files, or even export to a data URI for playing on the web. With that, you can embed music in a ClojureScript game and the music will rebuild automatically when you edit it.

NOTE: OpenJDK 11 is required! Newer versions of the JDK removed the com.sun.media.sound.* classes.

You may be interested in a very similar library I made for Nim called paramidi.

Getting Started

You can generate a new project with the Clojure CLI Tool:

clj -Sdeps "{:deps {leiningen/leiningen {:mvn/version \""2.9.0\""}}}" -M -m leiningen.core.main new edna my-music

It will contain a README with all the commands you need to use.

Documentation

; first hit middle c on the piano
[:piano :c]

; hit all twelve notes
[:piano :c :c# :d :d# :e :f :f# :g :g# :a :a# :b]

; by default you're on the 4th octave, but you can change it
[:piano {:octave 3} :c :d :e :f]

; maps let you change attributes for anything that comes after it
[:piano {:octave 3} :c :d {:octave 4} :e :f]

; notes are 1/4 length by default, but you can change that too
[:piano {:octave 3} :c :d {:octave 4, :length 1/2} :e :f]

; you have to change note lengths often so here's a shorthand
[:piano {:octave 3} :c :d {:octave 4} 1/2 :e :f]

; you can change individual notes' relative octave with + or - inside the keyword
[:piano {:octave 3} :c :d 1/2 :+e :+f]

; a number following the + or - changes it by that many octaves
[:piano {:octave 3} :c :d 1/2 :+2e :+2f]

; if there is no + or - before the number, it sets the note's absolute octave
[:piano {:octave 3} :c :d 1/2 :2e :2f]

; with all that, we can write the first line of dueling banjos
[:guitar {:octave 3} 1/8 :b :+c 1/4 :+d :b :+c :a :b :g :a]

; chords are just notes in a set
[:piano #{:c :e}]

; you can change the length of chords just like single notes
[:guitar {:octave 4}
  1/8 #{:d :-b :-g} #{:d :-b :-g}
  1/4 #{:d :-b :-g} #{:e :c :-g} #{:d :-b :-g}]

; to play two instruments simultaneously, put them in a set!
#{[:banjo {:octave 3} 1/16 :b :+c 1/8 :+d :b :+c :a :b :g :a]
  [:guitar {:octave 3} 1/16 :r :r 1/8 :g :r :d :r :g :g :d]} ; the :r means rest

The keyword at the beginning of your vector has to coorespond with something from Alda's list of instruments. After that, you can mix and match notes, chords, note lengths, and so on.

Development

  • Install the Clojure CLI tool
  • To develop with figwheel: clj -M:dev
  • To install the release version: clj -M:prod install

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.

More Repositories

1

vim_cubed

Vim rendered on a cube for no reason
Nim
2,709
star
2

Nightcode

An IDE for Clojure
Clojure
1,403
star
3

play-clj

A Clojure game library
Clojure
939
star
4

SolidOak

An IDE for Rust
Rust
893
star
5

Nightlight

An embedded editor for Clojure
Clojure
789
star
6

play-cljc

A Clojure and ClojureScript game library
Clojure
537
star
7

odoyle-rules

A rules engine for Clojure(Script)
Clojure
535
star
8

Nightweb

An anonymous P2P social network in Clojure
Clojure
497
star
9

PixelJihad

A JavaScript steganography tool
JavaScript
306
star
10

play-cljs

A ClojureScript game library
Clojure
290
star
11

Lightmod

An all-in-one tool for full stack Clojure
Clojure
275
star
12

Dynadoc

Dynamic documentation for Clojure(Script)
Clojure
217
star
13

Nightmod

A tool for making live-moddable games in Clojure
Clojure
192
star
14

Paravim

A Vim-based editor for Clojure
Clojure
181
star
15

paren-soup

A browser-based editor for ClojureScript
Clojure
153
star
16

full-stack-clj-example

A sample Clojure CLI project containing Clojure and ClojureScript
Clojure
115
star
17

play-clj-examples

Example projects using play-clj
Clojure
113
star
18

Nightcoders

A cloud IDE for ClojureScript
Clojure
75
star
19

odoyle-rum

Clojure
71
star
20

play-cljc-examples

Clojure
58
star
21

full-stack-boot-example

A sample Boot project containing Clojure and ClojureScript
Clojure
51
star
22

neovim-rs

A Neovim wrapper for Rust
Rust
47
star
23

iglu

A Clojure data -> GLSL library
Clojure
40
star
24

clarax

A new coat of paint for clara rules
Clojure
37
star
25

libgdx-examples

Java
29
star
26

tile-soup

A Clojure(Script) library to parse tiled maps
Clojure
27
star
27

libvim-clj

Vim as a Clojure library
Clojure
25
star
28

clojure-conj-2014

Making Games at Runtime with Clojure
Clojure
24
star
29

play-cljs-examples

Example projects using play-cljs
Clojure
20
star
30

parinferish

A library for parsing Clojure and optionally applying parinfer(ish)
Clojure
18
star
31

learn-clojure

Clojure
16
star
32

eval-soup

A library that makes it easy to eval Clojure(Script) code
Clojure
14
star
33

cross-parinfer

A library that wraps Parinfer for Clojure and ClojureScript
Clojure
11
star
34

Russian101

An Android app for learning Russian
Java
11
star
35

zachlisp.nim

Nim
11
star
36

zachlisp.cpp

C++
10
star
37

mistakes-were-made

An undo/redo system for Clojure and ClojureScript
Clojure
10
star
38

defexample

A macro for defining code examples
Clojure
9
star
39

dynadoc-examples

Example projects using Dynadoc
Clojure
9
star
40

odoyle-rum-todo

Clojure
7
star
41

play-clj.net

A networking library for play-clj games
Clojure
6
star
42

SeeJay

A console program in C demonstrating key generation and encrypted connections
C
5
star
43

html-soup

A library that adds HTML tags to Clojure(Script) code
Clojure
5
star
44

play-cljc.text

Render text with play-cljc
Clojure
5
star
45

nimconf-2021

4
star
46

clojure-assignments

Clojure
4
star
47

tag-soup

A library to parse code into descriptive maps
Clojure
4
star
48

functional-game-dev

Clojure
4
star
49

clojured-lightning-talk

Clojure
3
star
50

bay-area-odoyle

Clojure
3
star
51

java-assignments

Java
3
star
52

FireSteg

A stego tool I made in college
Java
2
star
53

HighSchoolFinal

A mock operating system UI I made in high school
Java
1
star
54

Jumpman

Simple JavaScript game for teaching coding
JavaScript
1
star
55

imgui_nim

Nim
1
star
56

BabaRam

A dashcam app for Android in Java
Java
1
star
57

vulkan_triangle_nim

Nim
1
star