We try to keep all the documentation up to date. Anyone is welcome to make contributions to the docs repo, or if you post here about errors then someone will try and fix them. What post are you referring to that mentioned errors in the studies?

The post in this Topic a the beginning, so basically 3 years ago :

" I did become stuck when trying to complete the Teletype Studies because they were written for a much earlier firmware (I forget which study exactly caused me to give up). One solution to this would be to attempt the studies with v1.0 before upgrading. " …

I was curious about that.

Hi everyone, I hope this is the right Topic to explain that.
Well, I’m starting to understand the underlying logic, but yet I feel a bit uncomfortable on optimizing the scripts.
So, I’m here to you, to ask for a help on a Preset I’m working on, so that I can sink into the language of the beloved tt.
(Sorry if I will copy the preset by hand, but I need to practice… and sorry for my bad English too)

M:
T LAST 1 // takes into account the duration between the last triggers received by script 1 (external clock) and associates it to the variable T
M * T 2 // used to halve the tempo
EVERY RRAND 8 32: $ 2 // execute the script 2 in a random way

I:
L 1 4: TR.TIME I 1 // set the trigger outputs to 1 ms
L 2 3: PN.L I 64 // set the length of patterns 2 and 3 to 64 step
P.N 3 // set 3 as working pattern
L 0 63: P I 0 // set all the values of the working pattern 3 to 0
P.N 2 // set 2 as new working pattern
L 0 63: P I 0 // set all the values of the working pattern 2 to 0

So, every time I hit Fn10 I call a “full reset” of the patterns 3 and 4, that are used as trigger recorders

1: // executed via external clock (16th)
TR.P 1; J RRAND 0 6; $ 4; $ 3 // pulse out on trigger 1; set the J var; execute scripts 3 and 4
PROB 20: TR.TOG 1 // I don’t know if this is the correct way, but I’m trying to randomly toggle the value of the trigger output 1, anyway it’s working the right way listening to it
PROB 33: K 12
PROB 33: K 7
PROB 33: K 0 // I imagine, I know, this last three can be enclosed is a single line, but how?
CV 1 N.S K 1 J // generate CVs picked up from a natural minor scale but with random changes on root note and degrees

This is mainly used to quasi-randomly play a Plaits

2: // executed randomly by script M
J RRAND 4 32; K RRAND 8 15 // set the J and K vars
DEL.X J K: TR.P 1 // output random repetition of triggers on trigger output 1, kind of random ratcheting

3: // executed by script 1 (external clock, 16th)
P.N 2; T 1 // set 2 as working pattern; I forgot why I wrote T 1, wtf… :D
P.NEXT // go ahead on steps
IF EQ P.HERE 1: TR.P 3 // pulse on trigger 3 when the value of the step of the working pattern is 1, used to trigger an envelope generator

4: // executed by script 1 (external clock, 16th), everything as above, but on pattern 3 and trigger 4
P.N 3; T 1
P.NEXT
IF EQ P.HERE 1: TR.P 4

7: // executed on manual external trigger, write 1s on the pattern 2 and produce a pulse on trigger output 3
PN.HERE 2 1
TR.P 3

8 // same as above, but on pattern 3 and trigger output 4
PN.HERE 3 1
TR.P 4

This last two scripts are used as a triggers recorder for pattern 2 and 3

That’s all. Any idea on how optimizing this preset?
Thank you so much!

1 Like

Cool, first reaction, it it works and fits in your tt, why bother?

But here are some (more constructive) input:

  1. As far as I can see, you’re not reading T anywhere, so you can remove it entirely with this line replacing your first two lines of #M:

    M * 2 LAST 1

  2. Regarding #1, seems like you’re trying to have a 33% chance of K being 12, 7 and 0, however those lines will not give you that. Something like this (untested) should be similar (will have 33% chance of each of 0, 7 and 12):

    K * TOSS 12; K ? RND 2 K 7

Hope that helps :slight_smile:

2 Likes

Yes, on TT everything works fine, but I would love to learn more and to be more elegant while coding :slight_smile:

  1. You’re right. Still, I can’t understand why t f I wrote those T 1 on $ 3 and $ 4
  2. Yes, that is what I’m trying to have on $ 1. I will try the ternary if, BUT just to understand what you wrote:
  • K can be 0 or 12 at every trigger
  • then you wrote K is (? RND 2 K 7), and RND 2 can be 0, 1 or 2, so
    if K is 0 or 12, and RND is 0, then K is always 7
    if K is 0, and RND is 1 or 2, then K is always 0
    if K is 12, and RND is 1 or 2, then K is always 12
    But still I can’t perfectly master the logic… I think I can’t write nothing similar at this moment. Sorry but the ternary if drives me crazy :exploding_head:
    :smiley:

First, let’s put it on two lines (as you know semicolon separates commands on the same line):

K * TOSS 12
K ? RND 2 K 7

TOSS is randomly 1 or 0 (basically the same as RND 1), multiply by 12 and you get either 0 or 12, so after the first line, K is either 0 or 12 (50/50 chance).

The second line possibly overwrites K, possibly keeps it’s current value (either 0 or 12, from the first line). RND 2 returns either 0, 1 or 2, and since true in tt is non-zero, RND 2 has 66% chance of being true. If it’s true it put’s K in K (keeps K’s value of either 0 or 12), the other 33% of the time it puts 7 into K. These 33% of the time will “eat” equally into the 50/50 of the previous value of either 0 or 12, effectively reducing the chance of K being 0 from 50% to 33%, same with the chance of K being 12. So K will end up with a 33% chance of being 0, 12 or 7.

Obviously there’s some rounding missing here (33 + 33 + 33 is not 100), so to be exact: one 3rd of the time (33.3333333333333…% chance) K will be 7, one 3rd of the time it will be 0 and one 3rd of the time it will be 12, which I imagine it even better than 33% :slight_smile:

Did that help?

6 Likes

Seems perfect! great explanation, thank you.

This saves me a lot of lines to try something is in my head: the train of incoming triggers on 1 will have its output time on tr out 1 kinda smashed, with the Param knob setting the power of the destruction of the original timing. Today I will try to work it out

1 Like

Reminds me of this example of sequential probability calculations from the Discord chat:

Prob 25: M 500; BRK
Prob 25: M 350; BRK
Prob 50: M 1000; BRK

Somewhat counterintuitively, this gives 25% chance of M 500, 18.75% chance of M 350, 28.125% chance of M 1000, and 28.125% chance no change to M. Whereas this:

PROB 50: M 1000; BRK
PROB 50: M 500; BRK
M 350

gives 50% chance M 1000, and 25% each to M 500 and M 350.

2 Likes

Here’s an approach I’ve used in the past that’s a little more generalized. The setup is this:

  • A list of weighting values in the pattern buffer, of whatever length you want N, where N is the number of different values you want to choose from randomly but weighted to suit
P.N 0; P.END 6; P.I 0; A 0          // setup, for 7 weighted values in P
L 0 P.END: A + A P I                // first, get the sum of all weighting values
B RND - A 1; A 0; O 0; P.I 0        // pick the random based on the sum, initialize for the while
W >= B A: A + A P.NEXT; O           // while random > running total, add to the total, increment O
A O                                 // here, O is the resultant weighted random choice, 0-6

So the idea is, each weighting value in P represents the relative amount of weight that value will have in the randomized result. If you’re hardcoding it, you can set them to percentage numbers, as long as they all add up to 100. But you don’t have to use percentages, you could use counts or however you want to think about it, the resultant output value will treat all of the values as 100% and choose a random value that is weighted to the degree you want, assuming the RAND function has a well distributed output.

For instance, if you take the 7-element example here, and fill the P buffer with: 1 1 1 10 1 1 1, then it should pick 3 as the result approximately 10 times as often as it picks any of the other values.

4 Likes

Is there a description somewhere for how to interpret the pattern & grid data as saved with a script exported from Teletype?

I get that the second part of the #P is the contents of patterns, and I’m guessing that the first part is pattern lengths, wrap, and start / end (?) but what’s what?

#P
0	0	0	0
1	1	1	1
0	0	0	0
63	63	63	63

The grid data under #G - I’m completely in the dark there, though. :thinking:

Edit: I’ve saved a script that has this at the bottom:

0	0	0	0	0	0	0	0	7	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

What does the “7” mean? Why is it there?

1 Like

Brilliant script. Thanks for sharing!

Hi all,

I’m having a really odd issue. I have a Teletype running firmware 3.2.0, and an Ansible running 3.0.0 (both flashed successfully this morning). I’m just getting into i2c comms and was playing with the Ansible commands from Teletype.

All of the commands work as expected (e.g. KR.PRE, ES.PRESET, ANS.G.LED), but when I try to use any of the MP commands (e.g. MP.PRE to return the current preset number) I get the UNKNOWN WORD error thrown back at me (e.g. UNKNOWN WORD: MP.PRE).

When I first hit this I thought it might have been a firmware issue or I was running an older version of something, which is why I reflashed the firmware, but it has persisted. I checked the Teletype source code to be triple-sure I was entering the right command, and it all looks to be correct.

All other i2c behavior on the bus is totally normal, all Teletype and Ansible behavior is normal, and if I put the Ansible into Teletype extender mode it all works as expected.

Any help would be greatly appreciated.

You’re looking for ME.PRE

they’re all ME according to this

1 Like

Ah! That is exactly it, thanks so much!

Turns out I was consulting https://monome.org/docs/ansible/teletype (which still lists MP as the namespace for those functions). It doesn’t look from the Ansible repo that the docs are being generated programmatically so I might ping @tehn on this one as a heads up. Happy to submit a PR if there’s an open repo with the Ansible docs in it!

if i recall, MP is the standalone meadowphysics trilogy module.

ME is meadowphysics mode on ansible.

will check on the docs.

no, the ansible docs are not programmatically generated so this is indeed a typo. fixing now.

1 Like

the grid data section stores current button states and fader values. first you have 16 lines of 16 digits each (since for buttons it’s just on/off) for 256 available buttons, followed by 4 rows of 16 values for 64 available faders. you must’ve used a grid fader in a scene - it will keep that value unless you move the fader or reset all controls with G.RST.

for patterns the first 4 rows represent:

length
wrap
start
end

1 Like

Aha! 20 characters of :bulb:
Thank you!

And yet these aren’t saved with the Scene, right? Why is that the case? I can use I to initialize my grid with specific functionality (thank you sooo much for the very helpful tutorials on GitHub, they are great) but I can’t save a pattern of buttons.

button states and fader values are definitely saved with the scene. do you mean button and fader definitions? these are not saved automatically, the idea is that you would put the ops that initialize them in your init script.