[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Make a function into a synthdef



Thanks, Daniel - this works very well for me, except for two small
concerns. Code follows below.

I'm converting scale degrees to notes. It seems that this creates some
kind of discrepancy in the ability to change \degree in real-time
within Pbindef.  I wonder if this is because I'm attempting to shut
off the \default synth playback using "\degree, Rest()".

The second concern is that it produces a fair number of "FAILURE IN
SERVER /n_set Node xxxx not found" messages. I thought that perhaps
adding some extra time to the s.latency would help, but no such luck.

In any event, thank you very much for this help. This challenge has
been bugging me for years and now I'm well on my way.

~off = { |e| s.makeBundle(e[\dur] * e[\legato] + s.latency, {
~mainCaller.(e.noteConvert, 0) }) }

d=Pbindef(
\lomp,
\degree, Rest(),
\dur, 0.2,\degree, Pseq([11, 11, 11, 11, 11], inf),
\scale, Scale.lydian,
\octave, Pseq([4, 5, 3, 6], inf), \vel, Pseq([80], inf),
\preset, Pseq([ 3022], inf),
\legato, 0.5,
\noteConvert, Pfunc { |e| e.use { ~note.value+(e.octave*12) } },
\put, Pfunc({|values|
~mainCaller.value(
values.noteConvert,
            values.vel,
values.preset)}),
\off, Pfunc(~off),
\stretch, 1);

On Mon, Dec 23, 2019 at 7:38 PM <daniel-mayer@xxxxxxxx> wrote:
>
> You could do it with an Event type, sure, but a single line Function would also do.
> See a simplified example here. The crucial point is releasing the node at correct time. Normally you'd need the current id, which is uncomfortable. Instead you can use a new Group for every event and release the group.
>
> (
> SynthDef(\sin, { |out = 0, freq = 440, gate = 1, amp = 0.5, dur = 1|
>     Out.ar(out, SinOsc.ar(freq, 0, amp) ! 2 *
> EnvGen.kr(Env.asr(0.01, 1, 0.01), gate, doneAction: 2)
> );
> }).add;
>
> ~off = { |e| s.makeBundle(e[\dur] * e[\legato] + s.latency, { e[\group].release }) }
> )
>
> (
> p = Pbind(
> \instrument, \sin,
> \group, Pfunc { Group() },
> \type, \on,
> \dur, 0.5,
> \midinote, Pseq((60..67), inf),
> \legato, 0.5,
> \off, Pfunc (~off)
> ).play
> )
>
> p.stop
>
> In your example Instead of
>
> { e[\group].release }
>
> this should do
>
> { ~mainCaller.(note, 0) }
>
> Side remark: for portability to other contexts I tend to write
>
> topEnvironment[\mainCaller]
>
> if ~mainCaller is defined in topEnvironment.
>
> Regards
>
> Daniel
>
> -----------------------------
> http://daniel-mayer.at
> -----------------------------
>

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/