Saturday, September 1, 2012

My first meeting with Closure

I got inspired by video of life music hacking jam session http://www.youtube.com/watch?v=WXovdAEV_mI&hd=1
so that I wanted to try Overtone project myself.
First you need to install Lein which is a kind of depency managet for Clojure.
You can follow with instructions at https://github.com/technomancy/leiningen/#installation
What I did on Windows was downloading lein.bat from https://raw.github.com/technomancy/leiningen/preview/bin/lein.bat and stand-alone jar from https://github.com/technomancy/leiningen/downloads
Then I had to set env. variable LEIN_HOME to my local dir, e.g.: c:/tools/lein and put the stand-alone jar in
c:/tools/lein/self-installs
and add LEIN_HOME to PATH system variable so that lein.bat could be found globally in system.

Then when I typed
lein
in system console it downloaded missing Clojure dependencies and welcomed me with message:


Leiningen is a tool for working with Clojure projects.
Several tasks are available:
check               Check syntax and warn on reflection.
classpath           Write the classpath of the current project to output-file.
clean               Remove all files from project's target-path.
compile             Compile Clojure source into .class files.
deploy              Build jar and deploy to remote repository.
deps                Show details about dependencies.
do                  Higher-order task to perform other tasks in succession.
help                Display a list of tasks or help for a given task.
install             Install current project to the local repository.
jar                 Package up all the project's files into a jar file.
javac               Compile Java source files.
new                 Generate project scaffolding based on a template.
plugin              DEPRECATED. Please use the :user profile instead.
pom                 Write a pom.xml file to disk for Maven interoperability.
repl                Start a repl session either with the current project or standalone.
retest              Run only the test namespaces which failed last time around.
run                 Run the project's -main function.
search              Search remote maven repositories for matching jars.
show-profiles       List all available profiles or display one if given an argument.
test                Run the project's tests.
trampoline          Run a task without nesting the project's JVM inside Leiningen's.
uberjar             Package up the project files and all dependencies into a jar file.
upgrade             Upgrade Leiningen to specified version or latest stable.
version             Print version for Leiningen and the current JVM.
with-profile        Apply the given task with the profile(s) specified.
Run lein help $TASK for details.
See also: readme, faq, tutorial, news, sample, profiles,
deploying and copying.

Now I can start playing with Overtone...
Then you download sources from github:

git clone git://github.com/overtone/overtone.git

and build project with

lein deps

Now launch REPL and follow according to steps at Overtone github:


The quickest way to get started is to launch a clojure repl using lein. In the overtone project directory....
$ lein repl
Then make some noise :)
user> (use 'overtone.live)
   ...wait a bit...
user> (demo (sin-osc))
For a better experience try Overtone in emacs or Overtone in vim.
Unfortunately that ain't that easy and first command: (use 'overtone.livebrought me to error message:
--> Loading Overtone...
UnsatisfiedLinkError Unable to load library 'scsynth': Nie mo┐na odnalečŠ okreťlonego modu│u.
  com.sun.jna.NativeLibrary.loadLibrary (NativeLibrary.java:169)
I wish you were more lucky, I will come back to resolve it in a while..stay tuned...



Soo.. after a while I'm back with a different approach.
I followed the following steps:
From command line execute:
lein new tutorial
cd tutorial 

edit project.clj generated in folder tutorial and add dependency:

(defproject tutorial "1.0"
  :dependencies [ [org.clojure/clojure "1.3.0"]
                  [overtone "0.7.1"] ])

Then type:
lein deps
Install SuperCollider (http://sourceforge.net/projects/supercollider/files/Windows/) - during installation enter installation folder name as SuperCollider, without version number. I'm not sure if otherwise Overtune will locate scsynth.exe correctly.

Start REPL (https://github.com/overtone/overtone/wiki/Starting-a-REPL)

lein repl
Type commands:

(use 'overtone.core)
(boot-external-server)

and start playing... (https://github.com/overtone/overtone/wiki/Getting-Started)

No comments:

Post a Comment