Skip to content

Commit

Permalink
merging fabians stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rosejn committed Mar 13, 2010
2 parents 775f906 + b2f2b18 commit 78dd924
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 46 deletions.
2 changes: 0 additions & 2 deletions .gitignore
@@ -1,9 +1,7 @@
*.swp
*.swo
*.lck
*.class
*.scsyndef
.overtone-log
session
samples
autodoc/**
Expand Down
54 changes: 15 additions & 39 deletions README.md
Expand Up @@ -36,50 +36,30 @@ Download and install leiningen wherever you local executables go:
mv lein ~/bin
lein self-install

Now get Overtone and its submodules:
Now get Overtone:

git clone git://github.com/rosejn/overtone.git
$ git clone git://github.com/mozinator/overtone.git

cd overtone

git submodule init

git submodule update

lein deps
$ cd overtone

; In Linux you will need to create a .jackdrc file that holds the command
; that will be used to automatically start the jack server. On my
; laptop it looks like this:
;
; /usr/bin/jackd -R -dalsa -dhw:0 -r44100 -p1024 -n3

lein repl

(use 'overtone.live)
(refer-ugens)
(boot)

(synth (sin-osc 440)) ; define an anonymous synth
(*1) ; play it... returns a node-id
(kill <node-id>) ; put the number returned from above

;; Define a simple synth with a saw wave that has
;; a vibrato effect and a percussive style envelope.
(defsynth foo [freq 220, lfo 8, depth 20,
rise 0.05, fall 0.6]
(* (env-gen (perc rise fall) 1 1 0 1 :free)
(saw (+ freq (* 10 (sin-osc:kr lfo))))))

; Call with none or some arguments and it uses the defaults
(foo)
(foo 220)
(foo 220 10)

; Or call with keyword style args
(foo :rise 0.1 :fall 2.0)

(quit)
$ lein deps
$ lein repl

user=> (use 'overtone.live)
user=> (refer-ugens)
user=> (boot)
user=> (server-log) ; check for errors
user=> (synth (sin-osc 440)) ; define an anonymous synth
user=> (*1) ; play it... returns a node-id
user=> (kill <node-id>) ; put the number returned from above

user=> (quit)

### General Setup:

Expand All @@ -95,10 +75,6 @@ Install:
* Linux users will need a working Jackd setup, as well as the jack\_lsp, and
jack\_connect utilities (jack-tools package in Ubuntu).

Beyond those requirements, you can run "ant deps" to retrieve the necessary jar
files, which are currently about 5 megs. The footprint will go down
substantially soon though.

At this point you have enough to write musical scripts and make noise, but you
won't be able to do any livecoding unless you have an interactive Clojure
environment setup. I use the vimclojure plugin for vim, but it should be
Expand Down
6 changes: 3 additions & 3 deletions project.clj
@@ -1,17 +1,17 @@
(defproject overtone "0.1"
:description "An audio/musical experiment."
:repositories [["java.net" "http://download.java.net/maven/2/"]]
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[net.java.dev.scenegraph/scenegraph "svn"]
[net.java.dev.scenegraph/scenegraph "git"]
[org.clojars.rosejn/jvi "0.7.1"]
[org.clojars.rosejn/jsyntaxpane "0.9.5-b27"]
[jfree/jfreechart "1.0.12"]
[vijual "0.1.0-SNAPSHOT"]
[jline "0.9.94"]
[osc-clj "0.1"]
[byte-spec "0.1"]
[midi-clj "0.1"]]
[midi-clj "0.1"]
[clj-repl "0.1"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
[autodoc "0.7.0"]
[jline "0.9.94"]
Expand Down
2 changes: 1 addition & 1 deletion src/lib/midi-clj
Submodule midi-clj updated 1 files
+2 −1 src/midi.clj
3 changes: 2 additions & 1 deletion src/overtone/app/main.clj
Expand Up @@ -7,7 +7,7 @@
(javax.swing JFrame JPanel)
(com.sun.scenario.scenegraph JSGPanel SGText SGShape SGGroup SGAbstractShape$Mode SGComponent
SGTransform)
(com.sun.scenario.scenegraph.event SGMouseAdapter)
(com.sun.scenario.scenegraph.event SGMouseAdapter)
(com.sun.scenario.scenegraph.fx FXShape))
(:use (overtone.app editor)
(overtone.core sc)))
Expand Down Expand Up @@ -108,3 +108,4 @@
(.add main-panel)
(.pack)
(.setVisible true))))

127 changes: 127 additions & 0 deletions src/overtone/app/repl.clj
@@ -0,0 +1,127 @@
(ns overtone.app.repl
(:import
(javax.swing JFrame JEditorPane JScrollPane JPanel JTextField SwingUtilities JButton)
(java.io StringReader PushbackReader OutputStreamWriter PrintWriter)
(java.util.concurrent LinkedBlockingQueue)
(jsyntaxpane DefaultSyntaxKit)
(java.awt Dimension BorderLayout))

(:use [hiredman.hydra :only [hydra]])
(:require [clj-repl :as r]))

;; Swing macros

(defmacro EDT
"runs body on the Event-Dispatch-Thread (Swing)"
[& body]
`(SwingUtilities/invokeLater (fn [] ~@body)))

(defmacro action-performed [component event & body]
`(. ~component addActionListener
(proxy [java.awt.event.ActionListener] []
(actionPerformed [~event] ~@body))))

(defn -main []
(EDT
(let [frame (JFrame.)
content (.getContentPane frame)
editor (JEditorPane.)
scroll (JScrollPane. editor)
panel (JPanel.)
prompt (JTextField.)
text-field (JTextField.)

toolbar (JPanel.)
tb-init (JButton. "1. init")
tb-boot (JButton. "2. boot")
tb-quit (JButton. "5. quit")
tb-mn (JButton. "4. make noise")
tb-slog (JButton. "3. server log")
queue (hydra)]

(DefaultSyntaxKit/initKit)

(doto tb-init
(action-performed event (do
(r/send-to-repl queue "(use 'overtone.live)(refer-ugens)")
(r/send-to-repl queue "(refer-ugens)")
(EDT (let [ doc (.getDocument editor)
length (.getLength doc)]
(.insertString doc length ";; Make sure jackd is started" nil)))
)))

(doto tb-boot
(action-performed event (r/send-to-repl queue "(boot)")))

(doto tb-quit
(action-performed event (r/send-to-repl queue "(quit)")))

(doto tb-mn
(action-performed event (do

(r/send-to-repl queue "(defsynth foo (sin-osc 440))")
(r/send-to-repl queue "(foo)")

)))

(doto tb-slog
(action-performed event (do
(r/send-to-repl queue "(print-server-log)")
(EDT (let [ doc (.getDocument editor)
length (.getLength doc)]
(.insertString doc length ";; No errors ? Now connect your jack ports and start transport and get ready to make some noise !" nil)))
)))

(doto toolbar
(.add tb-init)
(.add tb-boot)
(.add tb-slog)
(.add tb-mn)
(.add tb-quit))

(doto queue
(r/start-repl-thread (fn [q itm] (EDT
(let [ doc (.getDocument editor)
length (.getLength doc)]
(.insertString doc length itm nil))))

(fn [q ns] (EDT
(.setText prompt (str ns))))))

(doto prompt
(.setEditable false)
(.setPreferredSize (Dimension. 150 20)))

(doto text-field
(action-performed event
(EDT
(r/send-to-repl queue (.getText text-field))
(.setText text-field "")))
(.setPreferredSize (Dimension. 300 20)))

(doto panel
(.setPreferredSize (Dimension. 300 30))
(.add prompt)
(.add text-field)
(.doLayout))

(doto editor
(.setContentType "text/clojure")
(.setEditable false))

(doto content
(.setLayout (BorderLayout.))
(.add scroll (BorderLayout/CENTER))
(.add panel (BorderLayout/SOUTH))
(.add toolbar (BorderLayout/NORTH)))

(doto frame
(.pack)
(.setVisible true)
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE))

(doto text-field
(.requestFocus)))))

(comment
(-main))

0 comments on commit 78dd924

Please sign in to comment.