Awesome work! I’ve used binary patterns and bit shifting for rhythmic patterns but never realized that they could also be used for quantization. Can’t wait to try this one out!

Also, I was unaware of the fact that you can mount the TT upside down. Might be an option for my current setup, although it would probably take a while to memorize the fliüüed layout of the inputs/outputs.

1 Like

I believe when you DEVICE.FLIP it reorders these so that the jack ordering remains the same left-to-right.

1 Like

yep, it will reorder inputs/outputs accordingly.

2 Likes

Perfect! I saw DEVICE.FLIP being mentioned in the changelog but didn’t have any idea what it does. I feel like I’m discovering something new about the Teletype on an almost daily basis, thanks to this forum and all the talented people involved in the firmware development :slightly_smiling_face:

Now I just have to figure out if it’s really worth flipping the TT and thus having to re-connect all the fiddly i2c stuff again :sweat_smile:

Flip your teletype! It’s so much better for anything other that a flat-on-the-table setup. I don’t know why you’d have it any other way. Though sometimes I feel like I’m the only one rocking it flipped!

(I should say, it takes a bit of getting used to having the param knob upside down… I probably ought to realign mine so the marker points where I’m expecting it to.)

2 Likes

I’ve been working to fully wrap my head around this and have another question about the second line.

Let’s say that X equals 3. My mind is telling me that the result of 3 being run through line two would be “0000 0000 0100” EXCEPT that the zero in “BSET 0” is tripping me up. Why is that value zero and not 1?

Also, would you be willing to offer an explanation of the “K ? BGET J I I K” line?

Apologies if this is obnoxious, I fundamentally understand what’s going on here but am just uncertain on the specifics of what certain pieces of the code are doing. Thank you!

1 Like

Excellent questions! BSET takes two values. The first is the number to be changed, and the second one is the bit of the first number that is to be set to 1. So, for example, BSET 2 3 takes the number 2 (binary: 10), and sets its third bit to change it into 6 (binary: 110). So, the reason the first number is 0 is because we want all the other bits to be 0 (other than the one being set).

Turning to your second question… The line in the loop is a bit cunning :-).

L 0 11: K ? BGET J I I K

I needed a loop that counted through the binary number bit by bit until it found the one that was set to 1. Normally we’d do that with a while loop or something, or a loop that would break out when it found a 1, but you can’t do that with the teletype language syntax because you can only have one statement inside the loop. So, this line goes through every bit in J. We want K to end up being the index of the “hot” bit in J. We start with K equal to zero. If the current bit in J that we’re looking at is 1 then we want to set K to the loop counter (that is, I) otherwise we leave K alone. (So, if we haven’t hit the right bit yet, K will be zero, if it’s after the right bit, K will stay at that index number.) So, let’s unpack that line…

The ? operator is a so-called “ternary if” statement. The first part is the condition part: “BGET J I”. If that is 1, this operator returns the next part “I”. If it is 0, then it returns the third part “K”. The result of this ternary if is what updates the value of K. (This would all be unnecessary if we had log base two in Teletype :slight_smile: )

Phew… hope this makes sense! Sorry for going on a bit about such a wee piece of code :slight_smile:

6 Likes

Thank you so much for the detailed reply! I think that after a little bit of digestion that I will totally get this.

@SimonKirby I was noticing last night that changing A can drastically affect the execution time (maybe in the W loop?). Seems like it should only have to right-shift 11 times maximum… Have you experienced this?

Woah… you’re absolutely right! I didn’t notice that with the metro rate (and A values) I was using, but now I’ve gone back and tried some testing and it can get really slow. That’s extremely puzzling. As you say, as long as at least some of the first 12 bits of A are on, then the while loop should terminate quickly, but I’m finding it can basically make the teletype pretty unresponsive for sparse bit patterns. This is very very odd. I’ve tested big while loops and for loops in the metro script and you can have them looping into the thousands without much in the way of delay.

Can anyone else round here figure out what the problem is?

1 Like

I was getting some pretty sick grooves last night just running a sequence while manually toggling between A 137 and A 1412 and letting the lag do its thing :laughing:

But the Teletype was basically locked up :face_with_raised_eyebrow:

OK - I’ve got it! The issue is that I was always assuming that you’d have the root note of the scale active. This is equivalent to having the first bit set to 1. Sure enough, it’s fine for any odd number of A. Even numbers can cause the bug because you might end up having the target note lower than any note in the scale… the teletype shifts that down and eventually hits zero and presumably keeps shifting pointlessly until it gives up at some point!

To put it another way, this quantiser is looking for the note in the scale lower than the one you’re quantising. If there is no such thing it locks up!

3 Likes

Oh I think I figured it out! And damn you just beat me to it lol

Someone was talking about adding ring-shift OPs to carry the bits that fall off the bottom back to the top…

1 Like

Incidentally, I’m kind of regretting not making the first line of the haiku:

PARAM.SCALE 0 48; X PARAM.

It’s surprisingly expressive playing that teletype dial like it’s a harp! (You’ll probably want a reasonably fast metro rate for this.)

7 Likes

W has a hard limit of 10000 repetitions to prevent accidentally causing infinite loops. depending what’s in the loop it can still cause slowness or unresponsiveness.

1 Like
Summary

I’m curious, loking this over, I’m wondering if there are other pages to this whole set up… I’m REALLY new to the teletype and am a bit confused. I’ve tried implementing your code and x only bounces between two numbers instead of a scale.

Now that I have used my teletype a bit further, I’m concerned something might be wrong with it. As I impliment some of this code, I get only flickers between two notes at all times… Is there something I’m missing? Here is an image of the M page:

Here’s a quick video do X is returning based upon A’s value:

https://llllllll.co/uploads/default/original/3X/8/8/885c13e926f2bd06fdfbe34de9dad8609be6ce2f.MOV

Having done some more testing, it is odd, but specifically this line seems to lock up my teletype:

X WRAP CHAOS 0 36

If I change this number, I begin to get greater range of scales. Any thoughts on why this might be locking it up?

Hi! The chaos operator in Teletype generates series of numbers based on one of several mathematical procedures and a parameter that changes the way the procedure works. Depending on the algorithm used and the parameter, the sequence of numbers can be more or less random and sometimes go round in shorter or longer cycles. You can change the algorithm using CHAOS.ALG and the parameter using CHAOS.R

I don’t have my teletype to hand right now but you could try (at the live coding prompt) typing CHAOS.ALG 2 and CHAOS.R 5000 and see what happens…

Also remember to play around with different values of A for different scales (you need to make sure they are always odd numbers by the way). E.g.: A 1709

Another fun thing to try is to replace this line with: PARAM.SCALE 0 48; X PARAM and play the scales using the knob on the teletype. It’s best to do this with a fast metronome. E.g. M 100

3 Likes

Ok, amazing, thank you! I was totally unclear with CHAOS and was scratching my head why I was unable to achieve a similar result. Thanks for the response!

I’ve taken an interest in this wonderfully crafted code and for the whole idea of using binary in TT which I hadn’t yet got around to.
I was trying to work out a table for the decimal of various modes and chords and found this resource that I thought I would share. Its too much detail for me to work through completely now but I can confirm to others that the blue numbers for each scale are the decimal values (at least I have found the ones that I can calculate to confirm).
https://ianring.com/musictheory/scales/

5 Likes

Ooooh! Good find! I’m going to take some time out this weekend from grieving over my country’s election results to share some tables for scales and chord numbers to use with the haiku quantiser.

5 Likes