This explains the main functions in detail. For a tutorial covering their interplay, see the Tutorial.
Function | Input | Output | Source |
---|---|---|---|
pd | hiccup or node | nodes | parse.clj#221 |
outlet | hiccup or node | ||
inlet | hiccup or node | ||
other | reference | ||
write-patch | hiccup or nodes | file | |
write-patch-reload | hiccup or nodes | file | |
startup | one or more filenames | ||
load-patches | one or more filenames | ||
reload-all-patches | |||
open-pd | |||
import-image |
Function | Input | Output |
---|---|---|
lines | nodes | lines |
patch | lines | patch |
write | patch | file |
(pd hiccup-vector*) -> hash-map
(pd [hiccup-vector*]) -> [hash-map*]
pd
converts hiccup syntax into Nodes. If pd
encounters a Node during parsing, it will be passed along unchanged.
pd
is implicitly called by write-patch
and write-patch-reload
.
Nodes are assigned unique ids by pd
, and clj-puredata
takes care to avoid duplicate nodes.
Call it explicitly when generating nodes in functions, or to re-use nodes. (Another way to reuse nodes is other
.)
;; supports hiccup
(pd [:float]) => {:type :node, :op "float", :unique-id 121, :options {}, :args []}
;; passes along nodes unchanged
(pd (pd [:float]) => {:type :node, :op "float", :unique-id 122, :options {}, :args []}
;; supports nested structures
(pd [:+ [:-]])
=> {:type :node,
:op "+",
:unique-id 122,
:options {},
:args [{:type :node, :op "-", :unique-id 123, :options {}, :args []}]}
(defn count-number-of-nodes [x]
(->> x lines (filter #(-> % :type (= :node))) count))
;; each node is only used once
(->> (let [a (pd [:msg 1])]
(pd [:+ a a]))
count-number-of-nodes)
=> 2
;; identical hiccup is still evaluated twice
(->> (let [b [:msg 1]]
(pd [:+ b b]))
count-number-of-nodes)
=> 3
Attempts to start PureData and open OSC channel for communication.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close