I tried the example, with some minor mods.
It manages to crash scsynth somehow.
;; create new id
(def uid (trig-id))
;; define a synth which uses send-trig
(defsynth foo [t-id 0 trigger 0] (send-trig:ar (k2a trigger) t-id (out [0 1](sin-osc))))
;; register a handler fn
(on-trigger uid
(fn [val] (println "trig val:" val))
::debug)
;; create a new instance of synth foo with trigger id as a param
(def tt (foo uid))
(ctl tt :trigger 1)
Arne Brasseur <arne.b...@gmail.com> writes:
> There's a way to send values back to Overtone via OSC, I've never tried it.
>
> From the CHANGELOG:
>
>> ### Synth Triggers
>>
>> It is possible to send information out of a specific synth and into
>> Overtone as an event via the `send-trig` ugen. This is now a little bit
>> easier with the new trigger handler functions. Firstly, there's
>> `trig-id` which will return you a unique id for use as a trigger id. You
>> can then feed that to your synth and also use it to register handler
>> functions to execute when data from that specific synth is received:
>>
>> ;; create new id
>> (def uid (trig-id))
>>
>> ;; define a synth which uses send-trig
>> (defsynth foo [t-id 0] (send-trig (impulse 10) t-id (sin-osc)))
>>
>> ;; register a handler fn
>> (on-trigger uid
>> (fn [val] (println "trig val:" val))
>> ::debug)
>>
>> ;; create a new instance of synth foo with trigger id as a param
>> (foo uid)
>
> On Mon, 5 Feb 2024 at 14:52, <joa...@verona.se> wrote:
>
> One more question:
>
> Is it possible to access the current value of the phasor somehow?
> That way I could mark a place to return to during playback, and the set
> the phasor to that value later.
>
> I didnt find how to do it yet
>
> Thanks for your help,
> /joakim
>
> Arne Brasseur <arne.b...@gmail.com> writes:
>
> > Sure, it's generally pretty straightforward to convert SC to overtone. Same thing different syntax.
> >
> > Instead of Phasor.ar(...) write (phasor ...). Use kebab case instead of camelcase. Instead of assigning variables
> use a
> > let, etc. Check the docs in overtone of the ugens you're using to make sure you get the params right.
> >
> > So something like
> >
> > (defsynth player [bufnum 0 offset 0]
> > (out 0 (buf-rd :bufnum bufnum :pos (+ offset (phasor :rate (buf-rate-scale bufnum) :end (buf-frames bufnum))))))
> >
> > Which bits do you need? To be able to jump back in a playing sample? Does it loop or just a one-shot?
> >
> > It's gonna take some tweaking, like what if the offset gets you before the start of after the end of the buffer?
Joakim Verona
joa...@verona.se
To view this discussion on the web visit https://groups.google.com/d/msgid/overtone/CAK2o9WKSkm6w59Mh8y%2BzaQGt6ioYzXpg2YCL6PoJN-eNsJB8aw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/overtone/87fry071im.fsf%40tanaka.verona.se.