I want to have some form of stereo instruments. This example is from the sources: (definst bar [f1 100 f2 200 f3 300 f4 400] (mix (pan2 (sin-osc [f1 f2 f3 f4]) [-1 1 -1 1]))) (bar)
great @frankleonrose! I will try this
I tried it, and it works!
I was also trying to patch the stereo mixer but i never got it working
tnx again!
finally i can listen to sine waves in stereo it sounds like eliane radigue lol!
@joakim, I suspect this is the answer: https://github.com/overtone/overtone/pull/592
but it doesnt play in stereo.
I tried different permutations, but I cant get the intended stereo effect. Any hints?
Mix merges channels into a single channel. Try splay to mix many channels into a stereo pair
like this right? i dont get the stereo feel still. (definst bar [f1 100 f2 200 f3 300 f4 400] (splay (pan2 (sin-osc [f1 f2 f3 f4]) [-1 1 -1 1]))) (bar)
sorry, this: (definst bar [f1 100 f2 200 f3 300 f4 400] (splay :spread 1 :in-array (sin-osc [f1 f2 f3 f4])))
alright, this has a stereo effect, so theres something with inst that removes the stereo: (demo (splay :spread 2 :in-array (sin-osc [100 200 300 400 500])))
for reference, this is foo2, and it unexpectedly plays in mono
this is foo which plays in stereo, also unexpectedly, because why does it make a difference if i add an out
hmm i will try
@frankleonrose i dont think i understand what you mean. Do you mean i should make an fx that just copies input to output?
Or ignores the input entirely. Just trying to come up with an effect that will show whether one or both of the stereo channels is dropped. If you made a stereo inst with sine wave on left channel and sawtooth on right, then apply an fx that halves the signal with an odd bus # and doubles the signal with even bus #, you could see in the output whether both input channels get through and are affected as intended. Basing the effect on bus # is just a strategy to do something different for the two channels, despite the fact that only the one fx is passed to inst-fx!. I’d try it myself, but AFK for a bit.
tnx
definst behaves oddly i think:
(definst foo[] (out 0 (splay :spread 2 :in-array (sin-osc [100 200 300 400 500]))))
(definst foo2[] (splay :spread 2 :in-array (sin-osc [100 200 300 400 500])))
;; plays in mono, the sines are mixed down to mono
(foo2)
;; plays in stereo, the sines are distributed between the stereo channels
(foo)
;; examine the graphs they look very similar, except the out nodes are different
(show-graphviz-synth foo2)
(show-graphviz-synth foo)my expectation was for foo to behave same as foo2
also foo doesnt work with inst-fx!
(definst foo[] (out …. doesn’t survive. I think it’s https://github.com/overtone/overtone/blob/1cfc0a06eb39c913c318f6517a161952ef322e75/src/overtone/sc/synth.clj#L385-L388 that removes the out. So it’s surprising to me that the two have different graphs.
definst routes stereo insts final ugen to the inst-bus (to merge with all notes from the inst) which then gets mixed down to master output (with pan & volume and bad values discarded and good values limited) with https://github.com/overtone/overtone/blob/master/src/overtone/studio/inst.clj#L54-L65.
Note that :spread 1 results in -1 to 1 panning of input sines, by my read of https://github.com/overtone/overtone/blob/1cfc0a06eb39c913c318f6517a161952ef322e75/src/overtone/sc/cgens/mix.clj#L36-L41. That may account for how some of it sounds different from your expectation.
what about stereo effects?
I tried this with the foo2 stereo instrument above
(defsynth fx-chorus-stereo [bus 0 rate 0.002 depth 0.01] (let [src (in bus 2) dub-depth (* 2 depth) rates [rate (+ rate 0.001)] osc (+ dub-depth (* dub-depth (sin-osc:kr rates))) dly-a (delay-l src 0.3 osc) sig (apply + src dly-a)] (replace-out bus (* 0.3 sig))))
I just added 2 to the number of channels in the (in bus 2)
im not sure what should be the correct way of doing this
Intuitively the fx-chorus should adapt to stereo if the input is stereo
if you just use the standard fx-chorus some conversion to mono is done im not sure if conversion is done by ignoring one of the stereo chonnels or if a mix happens, but it sounds more like the right channel is being ignored
The :stereo multimethod for inst-fx! looks like it should handle applying the fx to both channels:
(defmethod inst-fx! :stereo
[inst fx & args]
(ensure-node-active! inst)
(let [fx-group (:fx-group inst)
bus-l (to-sc-id (:bus inst))
bus-r (inc bus-l)
fx-ids [(apply fx [:tail fx-group] :bus bus-l args)
(apply fx [:tail fx-group] :bus bus-r args)]]
fx-ids))
What if you try an FX that just replaces the input with (dc (mod bus 2)) or some other expression that depends on bus. That way you could tell whether you’re getting two different channels of output.I did try it - seems to work fine.
(o/definst sin-saw []
(-> [(o/sin-osc 500)
(o/saw 500)]))
(def snd (sin-saw))
(o/defsynth split
[bus 0]
(let [dry (o/in bus)
selector (- (o/round-up bus 2) bus)
wet (o/select selector [(o/dc 1.0) (o/dc 0.5)])
wet (* wet dry)]
(o/replace-out bus wet)))
(o/inst-fx! sin-saw split)
Specifically, adding split fx to sin-saw halves the amplitude of just one of the channels.hmmm tnx for looking into this
how do you generate the graphs?
Start Supercollider outside of Overtone and then connect. Scope in SC works.
Credit to @diego.vid.eco https://clojurians.slack.com/archives/C053Q1QSG/p1725887285457549?thread_ts=1724846982.742359&channel=C053Q1QSG&message_ts=1725887285.457549
tnx, @frankleonrose i will have a look