Liking cljdoc? Tell your friends :D

Functions

This explains the main functions in detail. For a tutorial covering their interplay, see the Tutorial.

Back to Index

Table of Contents

User-Facing Functions
FunctionInputOutputSource
pdhiccup or nodenodesparse.clj#221
outlethiccup or node
inlethiccup or node
otherreference
write-patchhiccup or nodesfile
write-patch-reloadhiccup or nodesfile
startupone or more filenames
load-patchesone or more filenames
reload-all-patches
open-pd
import-image
Internal Functions
FunctionInputOutput
linesnodeslines
patchlinespatch
writepatchfile

PD

(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

Outlet

Inlet

Other

Write-Patch

Write-Patch-Reload

Startup

Load-Patches

Reload-All-Patches

Open-Pd

Attempts to start PureData and open OSC channel for communication.

Lines

Patch

Write

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close