Midi event type and timingoffset key

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Midi event type and timingoffset key

Bad Numbers
Hi there

For note event type patterns, we can use the \timingOffset key to provide
swing-type rhythmical variations:

// assumes clock tempo of 1
(
SynthDef(\click,
        {
                var audio = Env([1,0],[0.03]).kr(Done.freeSelf,1) * WhiteNoise.ar(0.1);
                Out.ar(0,audio);
        }
).add;
)

(
Pdef(\click,
        Pbind(
                \instrument, \click,
                \dur, 0.25,
                \timingOffset, Pseg(Pseq([0,0.05],inf),Pseq([0.25],inf),\sine,inf)
        )
).play;
)
Pdef(\click).stop;

But when I try to use the same trick with a midi event pattern, to control
an external synthesiser, there's no variation in the rhythm:

(
Pdef(\midi,
        Pbind(
                \type, \midi,
                \midicmd, \noteOn,
                \midiout, m,
                \chan, 1,
                \dur, q,
                \timingOffset, Pseg(Pseq([0,0.05],inf),Pseq([h,h],inf),\sine,inf) // I can
comment this out, and it makes no difference
        )
).play;
)
Pdef(\midi).stop;

Can anyone tell me why? I can't think of why \timingOffset can't be applied
to MIDI messages as well as OSC messages.

Thanks



--
Sent from: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/SuperCollider-Users-New-Use-this-f2676391.html

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: Midi event type and timingoffset key

daniel-mayer

Am 01.01.2018 um 12:57 schrieb [hidden email]:

> But when I try to use the same trick with a midi event pattern, to control
> an external synthesiser, there's no variation in the rhythm:
>
>

> Can anyone tell me why? I can't think of why \timingOffset can't be applied
> to MIDI messages as well as OSC messages.


Hi,

simply because it's not built in.

See the midi event type in Event.sc:

                                        midi: #{|server|
                                                var freqs, lag, dur, sustain, strum;
                                                var bndl, midiout, hasGate, midicmd;

                                                freqs = ~freq = ~detunedFreq.value;

                                                ~amp = ~amp.value;
                                                ~midinote = (freqs.cpsmidi).round(1).asInteger;
                                                strum = ~strum;
                                                lag = ~lag;
                                                sustain = ~sustain = ~sustain.value;
                                                midiout = ~midiout.value;
                                                ~uid ?? { ~uid = midiout.uid };  // mainly for sysex cmd
                                                hasGate = ~hasGate ? true;
                                                midicmd = ~midicmd;
                                                bndl = ~midiEventFunctions[midicmd].valueEnvir.asCollection;

                                                bndl = bndl.asControlInput.flop;

                                                bndl.do {|msgArgs, i|
                                                        var latency;

                                                        latency = i * strum + lag;

                                                        if(latency == 0.0) {
                                                                midiout.performList(midicmd, msgArgs)
                                                        } {
                                                                thisThread.clock.sched(latency, {
                                                                        midiout.performList(midicmd, msgArgs);
                                                                })
                                                        };
                                                        if(hasGate and: { midicmd === \noteOn }) {
                                                                thisThread.clock.sched(sustain + latency, {
                                                                        midiout.noteOff(*msgArgs)
                                                                });
                                                        };
                                                };
                                        },


But you can use lag instead which takes the delay in seconds.

A general remark: please check if examples are reproducable when posting. E.g. this one contains interpreter variables m,q, and h, people have to rewrite for testing, this is frustrating. Chances to get an answer are higher if examples are working out of the box.

Greetings and Happy 2018

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------




_______________________________________________
sc-users mailing list

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