Wednesday, January 15, 2014

midi in clojure

It was a pleasant surprise for me to learn that core java ships with midi support. Mix that with clojure and one can have some music up and running really quickly


(ns music.core)

(import 'javax.sound.midi.MidiSystem)

(def synth (. MidiSystem getSynthesizer))

(. synth open)

(def mc (. synth getChannels))

(def instr (. (. synth getDefaultSoundbank) getInstruments))


(def yy (. synth loadInstrument (aget instr 0)))

(defn dhun [c f] (. (aget mc c) noteOn f 40))

(defn tune [f]
  (new Thread (fn [] (loop [] (f) (recur)))))


(def beats (tune (fn [] (dhun 9 40) (Thread/sleep 500))))

(def lead (tune (fn [] (dhun 0 40) (Thread/sleep 500))))

Monday, January 13, 2014

Emacs24 on ubuntu 12.04 LTS

http://devajava.blogspot.in/2012/08/emacs-24-on-ubuntu-1204.html


To add this PPA:
$ sudo add-apt-repository ppa:cassou/emacs
$ sudo apt-get update
Then, for emacs-snapshot:
$ sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot
*Or*, for emacs24:
$ sudo apt-get install emacs24 emacs24-el

Friday, January 10, 2014

Getting started with clojure on emacs


I found this link to be the most useful -
http://www.kedrovsky.com/blog/clojure-emacs-nrepl-and-leiningen

You need the following things installed -


  1. leiningen - http://leiningen.org/
  2. emacs - http://ftp.gnu.org/gnu/emacs/windows/

(require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (package-initialize) (when (not package-archive-contents) (package-refresh-contents)) (defvar my-packages '(clojure-mode nrepl)) (dolist (p my-packages) (when (not (package-installed-p p)) (package-install p)))

And after that
M-x nrepl-jack-in