# > teletype : code exchange

I’m studying Teletype and as a small exercise, I’ve built a simple euclidean sequencer.
I’m using the tracker to store the values required by ER, as explained here, but instead of using 1 column per trigger output and row 0 for fill, row 1 for length etc, I’m using P0 for fill P1 for length and P2 for rotation. And I’d like to use P3 for the probability.

So, for example on row 0, I have :
`4 16 0 100`

In a script, I wrote :

``````Z + 0 A
X PN 2 Z
Y ER PN 0 Z PN 1 Z - T X
Y && Y LT RAND 100 PN 4 Z
IF Y: SC.TR.P 1
``````

I use the variable A as an offset, it gives me the possibility to quickly jump to another euclidean sequence/ another row in the tracker.

The problem is that even if the probability is set to 100 in the tracker, some triggers are not sent, very few of them, but it happens sometimes, so I’m wondering if there’s a better way to write multiple conditions, to combine If and Probability. Is there a problem with the syntax of this script or the order of execution ?

Thanks.

The trouble is this line: `Y && Y LT RAND 100 PN 4 Z`. Let’s talk through it. we’re saying set `Y` to be `AND` of `Y` (which is 1 or 0) and `LT RAND 100 PN 4 Z`. But the problem, is that if `RAND 100` rolls 100 and `PN 4 Z` IS 100, the answer to “is `RAND 100` less than `PN 4 Z`?” is no, because 100 is not strictly less than itself. The fix is easy! Replace `LT` by `LTE`, which means less-than-or-equal, and has nothing to do with cell phones.

4 Likes

Oh, great ! I understand, and it’s working as exepcted now. Thanks a lot !

1 Like

I’d try this:

``````B PN 1 A
O.MAX B
Y ER PN 0 A B - O PN 2 A
PROB PN 3 A: SC.TR.P Y
``````

(Assuming “SC.TR.P 0” does nothing, as “TR.P 0” does.)

Or instead of relying on O, which I inevitably want to reference on another line every time I use it,
`T WRAP + 1 T 0 B`

1 Like

Thank you.

It’s in script 2

``````T ADD 1 T
SCRIPT 3
SCRIPT 4
``````

And script 1 only contains the reset, maybe that’s not particularly great.
`T 0`

I’m not familiar with the syntax yet, it takes me some time to read the script that you’re suggesting, sorry. I think I understand your code and I will try it but at the end there is:
`PROB PN 3 A: SC.TR.P Y`
I imagine that SC.TR.P 0 does nothing indeed but I plan to use many similar scripts,multiple euclidean sequences in my scene, SC.TR.P 2, SC.TR.P 3 etc, I should have mentioned that. So I’m not sure I can write the last line like that.

2 Likes

I did kind of write it more for conciseness than readability. I expect `PROB PN 3 A: SC.TR.P * Y 3` would work if it fits on a line, your way is clearer as long as you have the lines to spare

I’ve noticed that depending on Euclidean pattern length, sometimes variables wind up resetting out of sync with the pattern when they hit their maximum or overflow to 0, so I usually wrap them to some multiple of the pattern length. For instance, if the same counter is going to drive a length 8 pattern and a length 12 pattern, I’ll reset it at 24 (or use a separate counter for each pattern).

1 Like

Ah yes, I get it, yes I think that would work
thanks !

Edit :

I’ve modified your code and tried :

``````Z + A 0
B PN 1 Z; O.MAX B
Y ER PN 0 Z B - O PN 2 Z
PROB PN 3 Z: SC.TR.P * Y 1
``````

the first line sets variable Z —> row + offset so I can type A 4 in live mode to jump to another “sequence” for example. I’ve also added `O 0` in another script (I don’t know if I need to reset the counter). For some reason, it’s not working as expected, I’m testing with a simple `8 16 0` sequence but the beat is not regular. It would be very useful to use this counter / O variable , especially if they can be independent, I didn’t know that. Is it a global variable or is it “one per script” ?

I ended up using the following script, I can have many euclidean seq with probability.

#1

`T 0`

#2

``````L 0  7 : \$ 3
T + 1 T
``````

#3

``````Z + I A; X PN 2 Z
Y ER PN 0 Z PN 1 Z - T X
PROB PN 3 Z: SC.TR.P * Y + I 1
``````

and `A` is the offset variable for the tracker that I can optionally use to jump to another sequence.

hey, i had a question on your marbles script, specifically clock jitter. if i wanted to isolate just the bit that reads a knob position to determine how much jitter, if any, is applied to the `M` clock, where would i look? what needs to be modified in the script?

i can use either `LV.CV` for an arc encoder, or the `PARAM` knob on teletype itself; i don’t have the `TI` expander.

i’ve managed to get kria’s clock jittering wildly, but i can’t seem to limit it or affect it with an arc encoder at all. kria never settles back down to its base regular clock at `M 220` when the jitter knob is zeroed out.

i’m looking to get a regular kria clock tempo at `M 220`, no jitter, when the knob is fully CCW. and then at max jitter when the knob is fully clockwise, but only within a small range of possibilities, so jitter shouldn’t vary by more than, say, 40. i don’t want to adjust tempo at all–ideally, the same knob should set it back to `220` when jitter is back to `0`.

here’s what i have so far (using variable D; the others are taken):

``````#7
D RSH LV.CV 1 7
PROB D: Y RAND - X / X 9
PROB - 100 D: Y 0

#M
LIM LV.CV 1 0 12850
X >> PRM 4; M X
SCRIPT 7
KR.CLK 0

#I
M 220; M.ACT 1
``````

Wanted to check this with you after seeing this post as I have been trying this out, the Kria+JF.vox control. I seem to be getting sync problems, it can run ok for awhile then it would start dropping beats. And when the pattern on Kria changes, it also drops. Does this happen to you?

weird, i have never had any issues like that no. very, very solid. maybe firmware? not sure how to check just friends (prob the most recent) but my TT is 3.0.0 22D6CE8

You’re right, it is most likely the order of my code that is causing that.

I think the `KR.POS` OP is fast on its way to becoming my favorite.

1 Like

if you have too much connected to teletype i2c or if just friends is a fair distance away from teletype it could be an i2c related problem. try testing with an empty scene and one i2c op that is easy to validate sonically or visually and use it in metro script, and see if it still skips. if it does you might need to unplug something from i2c or use a powered i2c backpack.

There is only ansible and jf connected to TT. When it’s just some ops, it doesn’t skip. Only started skipping when trying to control jf with ansible. I have moved the order of the code, will check again later when I’m at the modular to see, thanks!

Experimenting with making a swung clock output and came up with a simple solution:

M
EVERY 2: TR.P 1
OTHER: SCRIPT 1

1
DEL DIV M X: TR.P 1

The delay equation is kinda limited because the resolution of the delay time isn’t incredibly fine, but the result allows for “musical” ratios quite easily. Lots of fun to be had tweaking little bits of this, definitely experiment!

This works for swing (with the latest beta):

M:
`DEL.R 2 / * M 2 3: TR.P 1`

6 Likes

That’s a nice single line solution without tying up another script, thank you! I’m going to experiment more with that tomorrow

EDIT: tried the turing machine script as mentioned earlier in this thread and on the codex, and not getting the behavior I expect- any chance it is outdated with Teletype 3.0 syntax?

While scanning through some of the old posts I became really fascinated by the idea of storing pages of grid buttons states and trig patterns as binary. Not coming from a computer science background binary is still a little cryptic to me. After a lot of frustration about how to actually use BSET/BCLR I slimmed the code down to 2 scripts and documented it all here because writing things out helps me a lot.

``````#I
G.BTX 0 0 0 1 1 1 3 8 16 6
G.FDR 0 0 7 8 1 2 3 8

#8
J + G.BTNY A; K G.BTNX
IF G.BTNV: P J BSET P J K
ELSE: P J BCLR P J K
A * G.FDRN 6
L 0 95: \$ 7

#7
K + A / I 16
G.BTN.V I BGET P K WRP I 0 15``````
4 Likes