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


Monday, April 8, 2013

Quick intro to git

Here are some quick steps to setup a project under git - Say, you have a project called project at /path/to/project

1. Initialize the git repository
    cd /path/to/project
    git init

   This will create a directory called .git at /path/to/project

2. git add file1 file2 ...
    Add the files that you'd like to be tracked

3. git commit -m "comments for commit"
    This will "commit the changes

After that, you can make changes to the file and then do a "git diff" to see the changes

Unlike other repositories, you need to do "git add" each time

Say, you make changes to file - f1 - to put the changes into the repository, you need to do

git add f1
git commit -m "comment"