This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-24
Channels
- # announcements (8)
- # babashka (16)
- # beginners (18)
- # biff (4)
- # calva (18)
- # clj-kondo (20)
- # clojure (24)
- # clojure-brasil (1)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (3)
- # clojurescript (16)
- # core-async (50)
- # cursive (5)
- # data-science (5)
- # datalevin (5)
- # datomic (69)
- # dev-tooling (18)
- # fulcro (3)
- # gratitude (1)
- # honeysql (5)
- # hyperfiddle (4)
- # jackdaw (2)
- # jobs-discuss (24)
- # lambdaisland (7)
- # lsp (16)
- # malli (5)
- # off-topic (65)
- # overtone (16)
- # pathom (28)
- # portal (3)
- # re-frame (24)
- # releases (1)
- # shadow-cljs (101)
Just testing this, getting some “interesting” results: With this:
(
SynthDef("dusty-test",
{
|in=0, replyRate=10, peakLag=3|
SendPeakRMS.kr(Dust.ar(20))
}
).store(dir: "my-dir")
)
There’s this:
{:ugens
[{:name "Control",
:rate 1,
:n-inputs 0,
:n-outputs 3,
:special 0,
:inputs [],
:outputs [{:rate 1} {:rate 1} {:rate 1}]}
{:name "Dust",
:rate 2,
:n-inputs 1,
:n-outputs 1,
:special 0,
:inputs [{:src -1, :index 0}],
:outputs [{:rate 2}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 12,
:n-outputs 0,
:special 0,
:inputs
[{:src -1, :index 0}
{:src -1, :index 1}
{:src -1, :index 2}
{:src -1, :index 3}
{:src 1, :index 0}
{:src -1, :index 4}
{:src -1, :index 5}
{:src -1, :index 6}
{:src -1, :index 7}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 10}],
:outputs []}],
:variants [],
:n-ugens 3,
:n-variants 0,
:pnames
[{:name "in", :index 0}
{:name "replyRate", :index 1}
{:name "peakLag", :index 2}],
:name "dusty-test",
:n-constants 11,
:params [0.0 10.0 3.0],
:n-pnames 3,
:n-params 3,
:version 2,
:constants [20.0 3.0 -1.0 1.0 6.0 47.0 114.0 101.0 112.0 108.0 121.0]}
VS:
// or clj
(o/defsynth peak-rms
[in 0 reply-rate 10 peak-lag 3]
(o/send-peak-rms (o/dust 20)))
This:
{:ugens
[{:name "Control",
:rate 1,
:n-inputs 0,
:n-outputs 3,
:special 0,
:inputs [],
:outputs [{:rate 1} {:rate 1} {:rate 1}]}
{:name "Dust",
:rate 2,
:n-inputs 3,
:n-outputs 1,
:special 0,
:inputs [{:src -1, :index 4} {:src -1, :index 2} {:src -1, :index 0}],
:outputs [{:rate 2}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 11,
:n-outputs 1,
:special 0,
:inputs
[{:src 1, :index 0}
{:src -1, :index 4}
{:src -1, :index 1}
{:src -1, :index 3}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 11}
{:src -1, :index 6}
{:src -1, :index 10}
{:src -1, :index 7}
{:src -1, :index 5}],
:outputs [{:rate 1}]}],
:variants [],
:n-ugens 3,
:n-variants 0,
:pnames
[{:name "in", :index 0}
{:name "reply-rate", :index 1}
{:name "peak-lag", :index 2}],
:name "external.scratch/peak-rms",
:n-constants 12,
:params [0.0 10.0 3.0],
:n-pnames 3,
:n-params 3,
:constants [0.0 3.0 1.0 -1.0 20.0 121.0 101.0 108.0 6.0 47.0 112.0 114.0]}
However with something like this:
(
SynthDef("amp-regulator-replier",
{
|in=0, replyRate=10, peakLag=3|
((in, 4), replyRate, peakLag, "/amp-regulator")
}
).store(dir: "my-dir")
)
We get this:
{:ugens
[{:name "Control",
:rate 1,
:n-inputs 0,
:n-outputs 3,
:special 0,
:inputs [],
:outputs [{:rate 1} {:rate 1} {:rate 1}]}
{:name "In",
:rate 2,
:n-inputs 1,
:n-outputs 4,
:special 0,
:inputs [{:src 0, :index 0}],
:outputs [{:rate 2} {:rate 2} {:rate 2} {:rate 2}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 23,
:n-outputs 0,
:special 0,
:inputs
[{:src 0, :index 1}
{:src 0, :index 2}
{:src -1, :index 0}
{:src -1, :index 1}
{:src 1, :index 0}
{:src 1, :index 1}
{:src 1, :index 2}
{:src 1, :index 3}
{:src -1, :index 2}
{:src -1, :index 3}
{:src -1, :index 4}
{:src -1, :index 5}
{:src -1, :index 6}
{:src -1, :index 7}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 10}
{:src -1, :index 11}
{:src -1, :index 12}
{:src -1, :index 4}
{:src -1, :index 13}
{:src -1, :index 14}
{:src -1, :index 8}],
:outputs []}],
:variants [],
:n-ugens 3,
:n-variants 0,
:pnames
[{:name "in", :index 0}
{:name "replyRate", :index 1}
{:name "peakLag", :index 2}],
:name "amp-regulator-replier",
:n-constants 15,
:params [0.0 10.0 3.0],
:n-pnames 3,
:n-params 3,
:version 2,
:constants
[-1.0
4.0
14.0
47.0
97.0
109.0
112.0
45.0
114.0
101.0
103.0
117.0
108.0
116.0
111.0]}
VS:
(o/defsynth peak-rms
[in 0 reply-rate 10 peak-lag 3]
(o/send-peak-rms (o/in in 4) reply-rate peak-lag "/amp-regulator"))
Where we get this (notice among other divergencies, the multichannel expansion of the SendPeakRMS ugen, which doesn’t happen on the SC version):
{:ugens
[{:name "Control",
:rate 1,
:n-inputs 0,
:n-outputs 3,
:special 0,
:inputs [],
:outputs [{:rate 1} {:rate 1} {:rate 1}]}
{:name "In",
:rate 2,
:n-inputs 1,
:n-outputs 4,
:special 0,
:inputs [{:src 0, :index 0}],
:outputs [{:rate 2} {:rate 2} {:rate 2} {:rate 2}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 19,
:n-outputs 1,
:special 0,
:inputs
[{:src 1, :index 3}
{:src 0, :index 1}
{:src 0, :index 2}
{:src -1, :index 0}
{:src -1, :index 11}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 5}
{:src -1, :index 10}
{:src -1, :index 12}
{:src -1, :index 13}
{:src -1, :index 1}
{:src -1, :index 7}
{:src -1, :index 3}
{:src -1, :index 4}
{:src -1, :index 9}
{:src -1, :index 2}
{:src -1, :index 6}
{:src -1, :index 13}],
:outputs [{:rate 1}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 19,
:n-outputs 1,
:special 0,
:inputs
[{:src 1, :index 1}
{:src 0, :index 1}
{:src 0, :index 2}
{:src -1, :index 0}
{:src -1, :index 11}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 5}
{:src -1, :index 10}
{:src -1, :index 12}
{:src -1, :index 13}
{:src -1, :index 1}
{:src -1, :index 7}
{:src -1, :index 3}
{:src -1, :index 4}
{:src -1, :index 9}
{:src -1, :index 2}
{:src -1, :index 6}
{:src -1, :index 13}],
:outputs [{:rate 1}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 19,
:n-outputs 1,
:special 0,
:inputs
[{:src 1, :index 2}
{:src 0, :index 1}
{:src 0, :index 2}
{:src -1, :index 0}
{:src -1, :index 11}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 5}
{:src -1, :index 10}
{:src -1, :index 12}
{:src -1, :index 13}
{:src -1, :index 1}
{:src -1, :index 7}
{:src -1, :index 3}
{:src -1, :index 4}
{:src -1, :index 9}
{:src -1, :index 2}
{:src -1, :index 6}
{:src -1, :index 13}],
:outputs [{:rate 1}]}
{:name "SendPeakRMS",
:rate 1,
:n-inputs 19,
:n-outputs 1,
:special 0,
:inputs
[{:src 1, :index 0}
{:src 0, :index 1}
{:src 0, :index 2}
{:src -1, :index 0}
{:src -1, :index 11}
{:src -1, :index 8}
{:src -1, :index 9}
{:src -1, :index 5}
{:src -1, :index 10}
{:src -1, :index 12}
{:src -1, :index 13}
{:src -1, :index 1}
{:src -1, :index 7}
{:src -1, :index 3}
{:src -1, :index 4}
{:src -1, :index 9}
{:src -1, :index 2}
{:src -1, :index 6}
{:src -1, :index 13}],
:outputs [{:rate 1}]}],
:variants [],
:n-ugens 6,
:n-variants 0,
:pnames
[{:name "in", :index 0}
{:name "reply-rate", :index 1}
{:name "peak-lag", :index 2}],
:name "external.scratch/peak-rms",
:n-constants 14,
:params [0.0 10.0 3.0],
:n-pnames 3,
:n-params 3,
:constants
[-1.0
101.0
116.0
117.0
108.0
109.0
111.0
103.0
47.0
97.0
112.0
14.0
45.0
114.0]}
None of the two examples work on Overtone. Should we move this to a github issue @U07FP7QJ0?
On the SC source code SendPeakRMS
is quite similar to SendReply
, however send-reply
does work as expected.
sure, always good to have an issue to track this and collect findings. My bandwidth for overtone is low at the moment, but maybe I'll have a chance to poke at things over the weekend
Thanks. Opened an issue, and also updated the wiki with the snippet you shared: https://github.com/overtone/overtone/wiki/Comparing-sclang-and-Overtone-synthdefs#generating-overtone-synthdefs
BTW if you could review and merge #516
it would be much appreciated.
Should be easy to test.
@diego.vid.eco ^ this is what I use, make an overtone synth an a supercollider synth, and then compare the synthdef-read output of the overtone synth to this output
Oh I see, makes sense
I’ll try it later today
i was exploring it a bit, and found that (into {} my-synth)
also seemed to work
in the end it’s just a map right?
I’ve had similar errors trying to add other UGens (like the DX7 one), so I made this for such cases and for compatibility with other synths. I guess some people may find it useful:
(ns tieminos.sc-utils.synths.scsyndef
"Generate synths from compiled SuperCollider scsyndef files."
(:require [overtone.core :as o]
[overtone.sc.machinery.synthdef :refer [load-synthdef synthdef-read]]))
(comment
;; Example
(def sini (make-synth
{:synthdef-path "/Users/diego/Music/code/tieminos/src/tieminos/sc_utils/synths/sini.scsyndef"
:name "sini"
:params {:freq 200}}))
(sini)
(o/stop))
(defn params->synth-params
[params]
(map (fn [[name* value]]
(let [value* (float value)]
{:name (name name*) :default value* :rate :kr :value (atom value*)}))
params))
(defn synth-params->args
[synth-params]
(map :name synth-params))
(defn make-synth
[{:keys [name
synthdef-path
params]}]
(let [sdef (synthdef-read synthdef-path)
params* (params->synth-params params)
args (synth-params->args params*)
smap (with-meta
(o/map->Synth
{:name name
:sdef sdef
:args args
:params params*
:instance-fn identity})
{:overtone.live/to-string #(str (name (:type %)) ":" (:name %))})]
(load-synthdef sdef)
(o/event :new-synth :synth smap)
smap))
Just finished it but seems to work with my test synth:
(
SynthDef("sini",
{
|freq 0|
Out.ar(0, (SinOsc.ar(freq)*0.2)!2)
}
).store(dir: "/Users/diego/Music/code/tieminos/src/tieminos/habitat/extended_sections/hacia_un_nuevo_universo/scsynthdefs/")
)
It’s not perfect as the returned value for make-synth
won’t show the param names on lsp or cider. Would need a macro for that I think, but it’s 90% of the way there.