# Emphasis on 1 in a 4/4 time signature of random patterns?

Hello, I was thinking to make an accent on every ‘one’ of a random 4/4 drum pattern. I’m showing a simple percussion in my code. the pattern ‘a’ is predetermined and gives a accent on the 1 of the 4/4 time signature. The random pattern gives the accent on the first iteration, but then the accent becomes randomly. How can i tie the accent also to the 1 of the 4/4 pattern, no matter what randomness is generated in the \dur key?

I hope i managed to describe the problem appropriately, however here is the code, maybe it becomes clearer what I’m trying to archive. I guess its not a very difficult task. Thank you!

SynthDef(\noise,{|amp=1,freq=440| Out.ar(0,amp*BPF.ar(WhiteNoise.ar(Line.kr(1,0,0.2,doneAction:2)**3),freq,0.2))}).add

(
a.stop;
b.stop;
a = Pbind(
\instrument, \noise,
\freq, 440,
\dur, 0.25,
\amp, Pseq([1]++(0.25!3),inf),
).play;
b = Pbind(
\instrument, \noise,
\freq, 2200,
\dur, Prand([Pseq([0.125],2),0.25],inf),
\amp, Pseq([1]++(0.25!3),inf),// this amp should be 1 at the same time as a, and 0.25 otherwise. basically on the first stroke of the 4/4 time pattern
).play
)


PS: I used emphasis in the title, not sure if that is the right word, in German I’ve meant ‘Betonung’.

Hi,

You could use Pstep with a total duration of one bar. Here I have an initial duration of 0.125 which is the minimum note length of the pattern. This could also be developed to make other accents throughout the bar.

b = Pbind(
\instrument, \noise,
\freq, 2200,
\dur, Prand([Pseq([0.125],2),0.25],inf),
\amp, Pstep([1, 0.25], [0.125, 0.875], inf) //0.125 + 0.875 = 1
).play

2 Likes

Hi,
First remark, I think there is something wrong in your 2nd \amp pattern.

This will results in having the 1st tick of 4 at an amp of 1, while having the 3 next at 0.25. While your \dur pattern may results of having more that 4 ticks by beat. E.g. the \dur and \amp patterns could result in having [0.125,1] [0.125, 0.25] [0.125, 0.25] [0.125, 0.25] [0.25, 1] … And you have your next emphasis at 0.5 and not one 1.

So I would suggest you to write that 2nd Pbind like this:

b = Pbind(
\instrument, \noise,
\freq, 2200,
\dur, Pn(Pconst(1,Prand([Pseq([0.125],2),0.25],inf)),inf,\bar).trace,
\amp, Pfunc({|evt|
(evt.bar?false).and({0.5.coin}).if({1},{0.25})}).trace
).play


The Pn(Pconst,\bar) for \dur ensures that you have a \bar marker at true when all your ticks duration have reached a some of 1 (=1 full beat). It will be at nil in the other cases. So whith that \bar marker youu know you are on the beat.

The (evt.bar?false).and({0.5.coin}).if({1},{0.25})}) tells that whenever you are on the beat and with 50% chances the amp will be at 1, in all other cases it will be at 0.25.

3 Likes

Thank you very much, this is a good solution. So many Pattern methods yet to be discovered ^^

Hey ,yes there is something wrong in my code, this is for demonstrative purposes, because I didn’t know how to implement it.
But you solved it too, thank you very much. Actually your solution is very helpful, I didn’t know you can refer to the |evt| argument in the Pfunc{} in the way, you are doing. That’s actually pretty great. Thank you!

1 Like