Periodic pattern of intervals in melody

a = PWalk (max = 7, step = [1, 2])
p1 >> pluck (a, dur = 2)

Hello community.
Could someone help me with this problem?

what happens to me is the following: I am needing to make every 4 pulses change interval; that is to say, that the first four pulses are intervals of 2nd and the following 4 pulses are of 3rd and then another 4 of 2nd and so on. I use “PWalk” because I need the melodic line to be “makeshift” and randomize the intervals.
I am trying to make possible what I need using “step [ ]” but I am unable to achieve the goal.
With the command “step = [1, 2]” it is output randomly, but not the pattern that I need 4 pulses, examp:

a = PWalk (max = 7, step = [1, 2])
Print (a) >> [1,2,1,2,3,4,6,5,7,6,8,6,4,2,3,4,6,7,5 …] -> There is no here 4 pulse pattern. The 3rd and 2nd intervals come out randomly

What I need is this: >> [1,2,1,7 ‘, 1,3,5,7’, 2,1,2,1 ‘, 2,4,6,4’, …] -> 4Int 2nd ', 4Int 3rd ‘, 4Int 2nd’, 4 Int 3rd ', … etc

I have tried to modify the command like this: “step [1,1,1,1,2,2,2,2]”, but the pattern I need does not work either. because the intervals keep appearing randomly.

Hmm looking at the source code it looks like when you provide a list for step then it does just choose it at random, which is… interesting! I’m not sure that should be correct behaviour - you should supply a PRand if you want it to be random. So I will make a change and update FoxDot this week. In the mean time here is a horrible hacky way to achieve what you what:

a = Pattern()
[a.extend(PWalk(step=n + 1)[:4]) for n in range(4)]
print(a)
>>> P[0, 1, 0, -1, 0, 2, 4, 2, 0, 3, 6, 9, 0, -4, 0, 4]

When I make the update, however, the code you’ll want to use is just this:

PWalk(step=P[2, 3, 4].stutter(4))

Thanks for bringing this up - good catch!

1 Like
  1. The following happens with this command.

a = Pattern ()
[a.extend (PWalk (step = n + 1) [: 4]) for n in range (4)]

The melodic line performs first a fragment of melody with intervals of 2 °, then 3 ° and then 4 ° … etc. But the problem is that the line is not improvised, because there is always a movement pattern on the melodic line.

  1. That is, the melodic line that is presented is this:

(1-0-1-2 - 1-6-1-3 - 1-5-1-4 - 1-4-1-5 …)

The movement pattern of the melodic line would be this:

(Neutral-down-neutral-up)

and it is necessary that the melodic line does not have a “movement pattern”, but that it does have a “pattern in the intervals”. The following melodic line does not have a movement pattern, but it does have a pattern in the intervals:

(1-2-3-2 - 4-6-1-3 - 2-1-7-1 - 3-5-3-5 - 4-3-2-1 - 3-1-3-5. …)
(2nd-3rd-2nd-3rd-2nd-3rd …)

  1. Now, it will also be necessary for me to regulate the jumps that will result in the melodic line, as in the case of the command “(step = [1, 2])”; Well, there I want the only intervals included in the melodic line to be 2nd and 3rd:
    (step = [1, 2])

1 = 2nd interval
2 = 3rd interval

What comes closest to what I need is the command “PWalk (max = 7, step = [1, 2])”. Only I need that every 4 pulses, are intervals of 2nd and the following 4 pulses are 2nd and 3rd.

In short, the task sought would be this, but remember that there should be no movement pattern:

111111111111

  1. In this command, there is no movement pattern, that means the line is improvised, that is a plus point. But the intervals continue to appear randomly, without an “interval skip pattern” every 4 pulses.

PWalk(step=P[2, 3, 4].stutter(4))

EDIT: I’ve pushed changes to FoxDot so you can update by running pip install FoxDot --upgrade or through your other method of installation. It should work as you’re expecting :+1:

1 Like

I really thank you very much for creating this project, since it is a very interesting tool to create music and also has unique properties, from which you can do many things. Thanks a lot for everything.

1 Like

Sorry if I’m suddenly a bit insistent, this help is really important, as it is necessary for a project that I have. Your help is really very valuable, I greatly appreciate it, with these commands, because the truth is I can’t find another tool that can do this, I really appreciate your help.

Is it possible that I can do this ?, since this would be the point I want to get to.

How could we do to make the following happen?
Where each certain number of pulses we can add an interval or intervals. Let’s look at the following example:

An improvised melody where every 4 beats has the following patterns:

  1. 4 pulses where there may be 2nd intervals (as in the “PWalk” command before the update).
  2. 4 pulses where there may be 2nd and 3rd intervals (as in the “PWalk” command before the update).

Could be like this?:
PWalk (step = P [[1], [1,2]]. Stutter (4))?

1111111

And so on, if I want to put into play other intervals like 4th, 5th, 6th … etc. The approach would be the following with intervals of up to 5th:

An improvised melody where every 4 beats has the following patterns:

  1. 4 pulses where there can be 2nd, 3rd and 4th intervals (as in the “PWalk” command before the update).
  2. 4 pulses where there can be 2nd, 3rd, 4th and 5th intervals (as in the “PWalk” command before the update).

Could be like this?:
PWalk (step = P ([1,2,3], [1,2,3,4]) .stutter (4))?

2222222

The larger interval exposes the jump range, since not all the intervals will have to be in the 4 pulses, as in the previous example:

33333

You’ve raised some interesting points and prompted me to make a change I had wanted to do for a while, which was fix how stutter worked when a pattern contains a generator pattern. I’ve added a strict keyword argument for backward compatibility but with the new update here is how you would implement the following:

data = PWalk(step=P[1, PRand([1, 2])].stutter(4))

So to continue this you might do something like so:

l = []    
for N in P[2:6]:
    intervals = P[1:N]
    l.append(PRand(intervals))
data = PWalk(Pattern(l).stutter(4))

Or in one nested line:

data = PWalk(step=Pattern([PRand(P[1:N]) for N in P[2:6]]).stutter(4))

I’m not sure if that’s exactly what you’re asking as you lost me a bit in the last part. If you want to use all the values in a Pattern but in a random order, have a look at the shuffle() method too.

Hope this helps