Note length with LFO.square > counter > sel > ad pattern


#1

How would I make a solid note length using the LFO.square > counter > sel > ad pattern?

Is there an object that holds a boolean set by trigger for specific note length?

Using an ad envelope works but I would like more control on the note length

Any ideas?


#2

look at timer/pulselength


#3

You probably need an ahd envelope instead of ad.
ad uses the start of the gate pulse as a trigger and then generates a rising and a falling slope, regardless of the duration of the gate pulse.
ahd generates a rising slope, then stays at maximum until the gate signal ends, then it generates a falling slope.
Of course you also need a gate signal with the proper duration.


#4

Thanks, I was in the train and I forgot my headphones so I had to test this using the disp/boolean object. And this worked quite well so I made a patch that has a seqencer where I can define the note length.

notelength2.axp (4.0 KB)

Now the next thing is that I would like to understand the code of this object. Is the K-rate code executed at a fixed rate? I am new to this.

if ((inlet_trig > 0) && !ntrig) {
val = 1 << 30;
ntrig = 1;
outlet_pulse = 1;
}
else {
if (!(inlet_trig > 0))
ntrig = 0;
if (val>0) {
int32_t t;
MTOF(-param_delay,t);
val -= t>>3;
if (val<=0) outlet_pulse = 0;
else outlet_pulse = 1;
} else outlet_pulse = 0;
}

Thanks!,
Bart


#5

Yes, K-rate code is executed at the k-rate of 3000Hz!

The code basically just loops through a counter based on param_delay and keeps the output positive until the counter reaches zero. For some info on MTOF and other guidellines check this


fwiw i like you solution with the and object and the clock timed pulse length but you could as well just add the pulse length object directly after the output of your sel and avoid the rest.


#6

Thanks and cool, that makes it clear, and helps me in coding some objects.

I tried putting the pulse length directly after the sel but as it didn't work I made this solution with the and object. But you are right, I used the wrong sel object. I used the
sel b 16 4t,
but should have chosen
sel b 16 4t pulse

Now it works great.

MTOF is still not clear to me. It is mapping the input to output, but what does the function do?


#7

Converts pitch to frequency.