TELETYPE - First-order Markov chain melody generator

UPDATE 2: Final version (jump to the 9th message…)


UPDATE: I wrote an optimised code (it only take 3 pages now…), to see it just go to the 8th message. :relaxed:

Hi,

I started working on a first-order Markov chain melody generator on my Teletype, that’s where i am at the moment:

PROBABILITY N SEQ

IN 1 : TRIG IN
OUT 1 : N OUT
OUT A : TRIG OUT
PARAM : TRANSPOSE



#1
PROB 70 : SCRIPT 2

#2
IF EQ Y 0 : SCRIPT 3
IF EQ Y 1 : SCRIPT 4
IF EQ Y 2 : SCRIPT 5
IF EQ Y 3 : SCRIPT 6
IF EQ Y 4 : SCRIPT 7
SCRIPT 8

#3
PROB 100 : P.I 0
PROB 40 : P.I 1
PROB 25 : P.I 2
PROB 10 : P.I 3
PROB 3 : P.I 4

#4
PROB 100 : P.I 1
PROB 40 : P.I 2
PROB 25 : P.I 3
PROB 10 : P.I 4
PROB 3 : P.I 0

#5
PROB 100 : P.I 2
PROB 40 : P.I 3
PROB 25 : P.I 4
PROB 10 : P.I 0
PROB 3 : P.I 1

#6
PROB 100 : P.I 3
PROB 40 : P.I 4
PROB 25 : P.I 0
PROB 10 : P.I 1
PROB 3 : P.I 2

#7
PROB 100 : P.I 4
PROB 40 : P.I 0
PROB 25 : P.I 1
PROB 10 : P.I 2
PROB 3 : P.I 3

#8
X RSH PARAM 10
CV 1 N ADD P.HERE X
TR.PULSE 1
Y P.I

#M

#I
TR.TIME 1 10
Y 0
P.N 0

#P
5	8	8	8
1	1	1	1
0	0	0	0
5	7	7	7

0	0	0	0
2	0	0	0
3	0	0	0
7	0	0	0
10	0	0	0

I did something very simple with the different notes probabilities in order to test the scene. This is just a starting point so if anyone gots better coding solutions or ideas to improve this thing you are welcome.

@tehn
Maybe is there something that could be implemented in V2 in order to simplify this type of operations ???

4 Likes

Nobody ? :disappointed_relieved:

I tried it but I had an error I couldn’t debug. I had the triggering and the param transpose but couldn’t get the sequencer running. Probably user error but I like the idea.

this looks cool, definitely a lot of typing for what i think it does. if i get this right-- it’s basically a linear sequence, but with probabilities on each step to cut to a different step. is this how you’d explain it?

oh that is strange as i exported the scene from my teletype… Maybe try to move P.N 0 to script 1 instead of script I

yeah, this allow to create more controlled random melodies. With that thing the sequences will sound more “human” written because there will be a sort of a logic in the notes chaining. It gives a very unique personality to each random melodies depending of the probability parameters you input.

Right now there is 2 things I really want to improve:

  1. this code I can’t use more than 6 notes and I need 7 of them for major or minor scales.
  2. As you said it is a lot of tapping for what it does but I can’t find anything shorter

So I m searching on leads on how to do that :blush:

Ok here i am now, just trying to work with 4 different notes:

F.O. Markov chain mel gen

#1
O 0
SCRIPT 2
P.N 0
CV 1 N P.HERE
TR.PULSE 1
X P.I => Actual note Analysis

#2
P.N 1
P.I MUL X 4 => Jump to the right set of PROB (group of 4)
L 0 3 : SCRIPT 3 => Read PROB amount for each note

#3
P.N 1
Y P.I
Z P.HERE
P.N 0
PROB Z : P.I ADD 0 O
O => Go to next PROB on next loop passage

#I
O 0

#P
64 64 64 64
0 0 0 0
0 0 0 0
63 63 63 63

0 40 0 0
4 10 0 0
7 10 0 0
9 40 0 0
0 10 0 0
0 30 0 0
0 20 0 0
0 50 0 0
0 20 0 0
0 5 0 0
0 40 0 0
0 10 0 0
0 50 0 0
0 30 0 0
0 10 0 0
0 10 0 0

P.N 0 => notes
P.N 1 => PROBs notes (groups of 4)

This code isn’t working thought… Now i need help figuring out why. I thinks it’s related to the
L 0 4 : SCRIPT 3 or the SCRIPT 2 at the beginning (really got a problem with the SCRIPT command priority and the use of LOOP PRE with it)

Ok i finished optimizing the code :sunglasses:, it now only takes 3 pages (and works) and you can play with a maximum of 8 notes (but here just 4…):

MARKOV SEQ
IN 1 = TRIG IN
CV A = NOTES
TR 1 = TRIG OUT


#1
P.N 0
SCRIPT 2
CV 1 N P.HERE
TR.PULSE 1
X P.I
O 0

#2
P.N 1
P.I MUL X 4
L 1 4 : SCRIPT 3

#3
P.N 1
Y O
Z P.HERE
IF GT Y 0 : P.I ADD P.I 1
P.N 0
PROB Z : P.I SUB Y 1

#4

#5

#6

#7

#8

#M

#I
O 0
O.MIN 0
O.MAX 4

#P
4	16	0	0
1	1	1	1
0	0	0	0
63	63	63	63

0	100	0	0
3	20	0	0
7	0	0	0
8	20	0	0
0	100	0	0
0	0	0	0
0	50	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	50	0	0
0	0	0	0
0	60	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0

About the tracker, it works like this:

• First bank is the note container, so put whatever you want here (right now you can just input 4 different notes)
• Second bank is the PROB sections for each note. It works by groups of 4 probabilities. From P.I 0 to 3 you can set the PROBs for the first note , from 4 to 7 are the PROBs for the second one etc… It’s like a percentage of chance to take 1 of the 4 possible paths.

4 Likes

Ok last version, this a solid base for more complex stuff, maybe a second order Markov chain.

MARKOV MEL GEN 7 NOTES

O.MAX ? - L 1 ? - MUL X ? :
? = NUMBER OF NOTES 

ALSO SET 100 EACH ? IN P.N 0

IN 1 : TRIG 

TR 1 : TRIG OUT
CV 1 : NOTE OUT



#1
P.N 0
SCRIPT 2
CV 1 N P.HERE
TR.PULSE 1
X P.I

#2
P.N 1
P.I MUL X 7
L 1 7 : SCRIPT 3
O 0

#3
P.N 1
Y O
Z P.HERE
IF GT Y 0 : P.I ADD P.I 1
P.N 0
PROB Z : P.I SUB Y 1

#4

#5

#6

#7

#8

#M

#I
O 0
O.MIN 0
O.MAX 7

#P
8	64	0	0
1	1	1	1
0	0	0	0
63	63	63	63

0	100	0	0
2	0	0	0
4	0	0	0
5	0	0	0
7	0	0	0
9	0	0	0
11	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	100	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
6 Likes