Coder Social home page Coder Social logo

edna's Introduction

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.

edna's People

Contributors

oakes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.