Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
fix minification problem
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Nov 5, 2018
1 parent 2efd741 commit 54335d7
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 67 deletions.
40 changes: 20 additions & 20 deletions release/browser/csound-wasm-browser.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions release/browser/csound-wasm-worklet-processor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/browser/main.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions release/node/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/node/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:output-dir "release/browser"
:asset-path "./"
:compiler-options {:optimizations :advanced
:infer-externs :auto
:source-map true
:output-wrapper true
:output-to "release/browser/csound-wasm-browser.js"}
Expand All @@ -46,6 +47,7 @@
:output-dir "release/browser"
:asset-path "./"
:compiler-options {
:infer-externs :auto
:optimizations :advanced
:elide-strict false
:output-wrapper true
Expand Down
6 changes: 3 additions & 3 deletions src/csound_wasm/browser.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
audio-process-node (.createScriptProcessor
audio-context
buffer-size input-count output-count)
_ (do (set! (.-inputCount audio-process-node) input-count)
(set! (.-outputCount audio-process-node) output-count))
_ (do (set! (.-inputCount ^js audio-process-node) input-count)
(set! (.-outputCount ^js audio-process-node) output-count))
buffer-size (.-bufferSize audio-process-node)
frame-len (* ksmps output-count)
output-pointer ((libcsound.cwrap
"CsoundObj_getOutputBuffer"
#js ["number"] #js ["number"])
csound-instance)
output-buffer (new js/Float64Array (.-buffer (.-HEAP8 libcsound))
output-buffer (new js/Float64Array (.-buffer (.-HEAP8 ^js libcsound))
^js output-pointer frame-len)
;; TODO add microphone input buffer
zerodbfs ((libcsound.cwrap
Expand Down
44 changes: 22 additions & 22 deletions src/csound_wasm/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@
(defn prepareRT []
(if-let [awn @audio-worklet-node]
((:post awn) #js ["prepareRT"]))
(((.-cwrap @libcsound) "CsoundObj_prepareRT"
(((.-cwrap ^js @libcsound) "CsoundObj_prepareRT"
nil #js ["number"]) @csound-instance))

(defn set-option [option]
(if-let [awn @audio-worklet-node]
((:post awn) #js ["setOption" option])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_setOption" nil #js ["number" "string"])
(((.-cwrap ^js @libcsound) "CsoundObj_setOption" nil #js ["number" "string"])
@csound-instance option)
(swap! event-queue conj #(set-option option)))))

(defn compile-orc [orc]
(if-let [awn @audio-worklet-node]
((:post awn) #js ["compileOrc" orc])
(if @wasm-loaded?
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_compileOrc"
"number" #js ["number" "string"])
@csound-instance orc)
Expand All @@ -104,15 +104,15 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["evalCode" orc])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_evaluateCode" "number" #js ["number" "string"])
(((.-cwrap ^js @libcsound) "CsoundObj_evaluateCode" "number" #js ["number" "string"])
@csound-instance orc)
(swap! event-queue conj #(eval-code orc)))))

(defn input-message [sco]
(if-let [awn @audio-worklet-node]
((:post awn) #js ["inputMessage" sco])
(if @wasm-loaded?
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_inputMessage"
"number" #js ["number" "string"])
@csound-instance sco)
Expand Down Expand Up @@ -147,7 +147,7 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["readScore" sco])
(if @wasm-loaded?
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_readScore"
"number" #js ["number" "string"])
@csound-instance sco)
Expand All @@ -157,7 +157,7 @@
(if @audio-worklet-node
(wrap-ipc-promise #js ["getControlChannel" ctrl-channel])
(let [callback (fn []
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_getControlChannel"
#js ["number"] #js ["number" "string"])
@csound-instance ctrl-channel)
Expand All @@ -168,7 +168,7 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["setControlChannel" #js [ctrl-channel val]])
(if @wasm-loaded?
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_setControlChannel"
nil #js ["number" "string" "number"])
@csound-instance ctrl-channel val)
Expand All @@ -178,7 +178,7 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["setStringChannel" #js [string-channel string]])
(if @wasm-loaded?
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_setStringChannel"
nil #js ["number" "string" "string"])
@csound-instance string-channel string)
Expand All @@ -189,7 +189,7 @@
(wrap-ipc-promise #js ["getScoreTime"])
(let [callback
(fn []
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_getScoreTime"
nil #js ["number"])
@csound-instance))]
Expand Down Expand Up @@ -217,15 +217,15 @@
((:post awn) #js ["reset"])
(if @wasm-loaded?
(do (reset! csound-running? :reset)
(((.-cwrap @libcsound) "CsoundObj_reset" nil #js ["number"])
(((.-cwrap ^js @libcsound) "CsoundObj_reset" nil #js ["number"])
@csound-instance))
(swap! event-queue conj #(reset)))))

(defn destroy []
(if-let [awn @audio-worklet-node]
((:post awn) #js ["destroy"])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_destroy" nil #js ["number"])
(((.-cwrap ^js @libcsound) "CsoundObj_destroy" nil #js ["number"])
@csound-instance)
(swap! event-queue conj #(destroy)))))

Expand All @@ -234,7 +234,7 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["compileCSD" csd])
(if @wasm-loaded?
(do (((.-cwrap @libcsound) "CsoundObj_compileCSD" nil #js ["number" "string"])
(do (((.-cwrap ^js @libcsound) "CsoundObj_compileCSD" nil #js ["number" "string"])
@csound-instance csd)
(dispatch-event "csoundReady" nil))
(swap! event-queue conj #(compile-csd csd)))))
Expand All @@ -244,15 +244,15 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["setTable" table-num index val])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_setTable" nil #js ["number" "number" "number" "number"])
(((.-cwrap ^js @libcsound) "CsoundObj_setTable" nil #js ["number" "number" "number" "number"])
@csound-instance table-num index val)
(swap! event-queue conj #(set-table table-num index val)))))

(defn get-table-length [table-num]
(if @audio-worklet-node
(wrap-ipc-promise #js ["getTableLength" table-num])
(let [callback (fn []
(((.-cwrap @libcsound) "CsoundObj_getTableLength"
(((.-cwrap ^js @libcsound) "CsoundObj_getTableLength"
#js ["number"] #js ["number" "number"])
@csound-instance table-num))]
(wrap-promise callback))))
Expand All @@ -262,26 +262,26 @@
(wrap-ipc-promise #js ["getTable" table-num])
(wrap-promise
(fn []
(let [buf (((.-cwrap @libcsound)
(let [buf (((.-cwrap ^js @libcsound)
"CsoundObj_getTable"
#js ["number"] #js ["number" "number"])
@csound-instance table-num)
len (((.-cwrap @libcsound) "CsoundObj_getTableLength"
len (((.-cwrap ^js @libcsound) "CsoundObj_getTableLength"
#js ["number"] #js ["number" "number"])
@csound-instance table-num)]
(if (= -1 len)
(.error js/console (str "Error: table number " table-num
" doesn't exist, or hasn't been compiled yet."))
(let [src (new js/Float64Array
(.-buffer (.-HEAP8 @libcsound)) buf len)
(.-buffer (.-HEAP8 ^js @libcsound)) buf len)
ret (new js/Float32Array src)]
ret)))))))

(defn get-ksmps []
(if @audio-worklet-node
(wrap-ipc-promise #js ["getKsmps"])
(let [callback (fn []
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_getKsmps"
#js ["number"] #js ["number"])
@csound-instance))]
Expand All @@ -291,7 +291,7 @@
(if @audio-worklet-node
(wrap-ipc-promise #js ["get0dbfs"])
(let [callback (fn []
(((.-cwrap @libcsound)
(((.-cwrap ^js @libcsound)
"CsoundObj_getZerodBFS"
#js ["number"] #js ["number"])
@csound-instance))]
Expand All @@ -301,15 +301,15 @@
(if-let [awn @audio-worklet-node]
((:post awn) #js ["setMidiCallbacks"])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_setMidiCallbacks" nil #js ["number"])
(((.-cwrap ^js @libcsound) "CsoundObj_setMidiCallbacks" nil #js ["number"])
@csound-instance)
(swap! event-queue conj #(set-midi-callbacks)))))

(defn push-midi-message [byte1 byte2 byte3]
(if-let [awn @audio-worklet-node]
((:post awn) #js ["pushMidiMessage" byte1 byte2 byte3])
(if @wasm-loaded?
(((.-cwrap @libcsound) "CsoundObj_pushMidiMessage" nil #js ["number" "number" "number" "number"])
(((.-cwrap ^js @libcsound) "CsoundObj_pushMidiMessage" nil #js ["number" "number" "number" "number"])
@csound-instance byte1 byte2 byte3)
(swap! event-queue conj #(push-midi-message byte1 byte2 byte3)))))

Expand Down
4 changes: 2 additions & 2 deletions src/csound_wasm/macros.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
(defmacro wrap-ipc-promise [message]
`(js/Promise.
(fn [resolve# reject#]
(let [promise-id# (.-str (gensym))]
(let [promise-id# ^js/String (.-str (gensym))]
(swap! csound-wasm.core/ipc-promise-queue
assoc promise-id# [resolve# reject#])
((:post (deref csound-wasm.core/audio-worklet-node))
(.concat (js/Array "promise" promise-id#) ~message))))))
(.concat (js/Array "promise" promise-id#) ^js ~message))))))

(defmacro wrap-promise [callback]
`(if @csound-wasm.core/audio-worklet-processor
Expand Down
2 changes: 1 addition & 1 deletion src/csound_wasm/worklet_processor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
;; range-output-cnt (range output-count)
perform-ksmps-fn
(fn []
(let [res ((.cwrap @public/libcsound
(let [res ((.cwrap ^js @public/libcsound
"CsoundObj_performKsmps"
#js ["number"] #js ["number"])
csound-instance)]
Expand Down

0 comments on commit 54335d7

Please sign in to comment.