> teletype: grid # code exchange

teletype

#145

Yes and 20 characters.


#146

ah yeah, i understand your question better now. when sharing scripts you don’t really need to include #P (pattern data) and #G (grid data) parts. teletype will read a scene fine without those, it’ll just initialize pattern values and grid button/fader states to 0.

you can save/load to/from USB multiple times without powering down teletype (huge thanks to @sam for making that possible)

we really need a proper section on USB saving/loading in the manual…


#147

I’ve named this one Pillar. It is two Euclidean trigger sequencers, and one turtle-based note/gate sequencer. Zip file contains the scene and a PDF manual. You’ll probably want to load it from USB disk and take my defaults for pattern values - It won’tl work properly with #P full of zeros.

This is coded to send signals to the ER-301 over i2c, but should be easy enough to mod to use the CV and TR outs on Teletype.

Would appreciate any ideas for improvement, particularly any code optimizations you see. I’m not out of ideas, but I am out of characters!

Pillar.zip (843.7 KB)

PILLAR
TURTLE NOTE SEQUENCER
2X EUCLIDIAN TRIGGER SEQ
SEE PDF FOR INSTRUCTIONS



#1
X G.BTNX; Y ADD 8 G.BTNY
G.FDR.N 1 PN X Y
Y ADD 16 G.BTNY
Z SCALE 0 100 0 7 PN X Y
G.FDR.N 2 Z
$ 4

#2
X G.BTNX; Y G.BTNY
Z SCALE 0 16320 0 7 G.FDR.V 1
IF EQ G.FDRI 1: PN X ADD 8 Y Z
Z SCALE 0 16320 0 99 G.FDR.V 2
Y ADD G.BTNY 16
$ 3

#3
IF EQ G.FDRI 2: PN X Y Z
Y ADD G.BTNY 12
Z SCALE 0 16320 1 8 G.FDR.V 3
IF EQ G.FDRI 3: PN X Y Z
$ 5

#4
Y ADD 12 G.BTNY
G.FDR.N 3 SUB PN G.BTNX Y 1
Y ADD 20 G.BTNY
G.FDR.N 4 SUB PN G.BTNX Y 1
C ADD 7 G.BTNI
L 0 2: G.FDR.N + 5 I PN I C

#5
Y ADD G.BTNY 20
Z SCALE 0 16320 1 8 G.FDR.V 4
IF EQ G.FDRI 4: PN X Y Z
IF LT G.BTNI 17: BREAK
Y ADD G.BTNY 23
L 0 2: PN I Y G.FDR.N ADD 5 I

#6
Q PN 1 24
Z ER PN 0 24 PN 2 24 SUB T Q
IF Z: SC.TR.P 2
Q PN 2 25
Z ER PN 0 25 PN 2 25 SUB T Q
IF Z: SC.TR.P 3

#7
SC.CV 1 N PN 0 PN @X ADD 8 @Y
A PN @X ADD 16 @Y
PROB A: SC.TR.P 1

#8
G.LED @X @Y 3
@MOVE RRAND -1 1 RRAND -1 1
G.LED @X @Y 15
A MUL M PN @X ADD @Y 20
SC.TR.TIME 1 A
$ 7

#M
B PN @X ADD 12 @Y
T ADD 1 T
EVERY B: $ 8
$ 6
D SCALE 0 16320 40 200 PARAM
M BPM MUL 4 D; TR.P 4

#I
G.BTX 1 0 0 1 1 0 3 1 4 4
G.FDX 1 8 0 8 1 0 3 2 1 4
@F 0 0 3 3; @WRAP 1
@X 0; @Y 0; T 0
G.BTX 17 5 1 1 1 0 3 1 1 2
G.FDX 5 0 5 16 1 0 3 2 1 3

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

0	0	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
12	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
0	0	0	0
1	1	1	1
1	1	1	1
1	1	1	1
1	1	1	1
99	99	99	99
99	99	99	99
99	99	99	99
99	99	99	99
1	1	1	1
1	1	1	1
1	1	1	1
1	1	1	1
0	0	8	0
0	0	8	0
2	4	5	0
1	1	1	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

#G
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000

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

#148

this is great - and thanks for a detailed video! i’ll take a look at the script when i get a chance and see how it can be optimized.


#149

Here’s a fun little toy/sequencer - Pachinko.

Pressing the left-most edge of buttons releases a ball from that position. Pressing any other button will place a ‘pin’. Sending a clock into Input 5 will automatically release a ball.

When a ball hits a pin, it sends a trig out of TR 1 and a pitch (dependent on pin position) out of CV 1.

pachinko.txt (1.9 KB)

PACHINKO



#1
IF EZ G.BTNV: BREAK
PN.PUSH 1 0; PN.PUSH 2 G.BTNY
PN.PUSH 3 15

#2
X PN 1 I; Y PN 2 I; Z PN 3 I
IF < G.LED X Y 9: G.LED X Y -3
IF EZ PN 3 I: $ 3; BREAK
G.LED PN 1 I PN 2 I 4
PN.- 3 I 1

#3
X + 1 PN 1 I; Y PN 2 I
B G.LED X Y
IF LTE B 1: PN.+ 1 I 1
IF LTE B 1: PN 3 I - 15 X
ELSE: $ 4

#4
A * 4 Y; A + A X; CV 1 N A
Y ? TOSS + Y 1 - Y 1
IF > G.LED PN 1 I Y 1:
ELSE: PN 2 I Y; TR.P 1
PN 3 I 15

#5
G.BTN.PR 3 1; G.BTN.PR 3 0

#6


#7
IF GTE PN 1 I 16: PN.RM 3 I
IF GTE PN 1 I 16: PN.RM 2 I
IF GTE PN 1 I 16: PN.RM 1 I

#8
IF EZ G.BTNV: D -3
ELSE: D 9
G.LED G.BTNX G.BTNY D

#M
M! PARAM; TR.TIME / M 2
IF EZ PN.L 1: BREAK
L 0 - PN.L 1 1: $ 2
L 0 - PN.L 1 1: $ 7

#I
INIT.P.ALL; INIT.DATA; G.RST
PARAM.SCALE 4 50
G.BTX 0 0 0 1 1 0 0 1 1 8
G.BTX 100 1 0 1 1 1 0 8 15 8

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

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

#G
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000

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

There are several ways the Scene could be adapted. Balls could wrap at the edges. There could be different kinds of pins (eg some get hit once and then disappear, others move…etc). The In port could dictate the ball’s y-pos when it is created by a trigger into 5. Proper scales could be selected as opposed to the basic way I have handled pitch cv.

Here’s an explanation of the code, line by line. If you have any suggestions for improving it - please let me know, I’m a relative beginner with Teletype and especially the Grid ops.

Init Script #I:
1 Reset the pattern page, variables and grid
2 Scale the Param knob between 4 and 50 (this will be used to set Metro).
3 Create 8 buttons down the left edge which trigger Script #1
4 Create 120 buttons which trigger Script #8

Script #1:
1 Break if the button is being released, otherwise create a ‘ball’
2 Push a new pattern entry with the ball’s x position to Pattern 1; Push a new pattern entry with the ball’s y position to Pattern 2
3 Push a new pattern entry with the ball’s timer to Pattern 3

Script #2:
1 Get the ball’s x pos, y pos and speed and put into X,Y,Z
2 Clear the LED layer for the ball’s position
3 If the ball’s timer reaches zero (it is ready to move right) run Script 3 and break.
4 Otherwise draw the ball on the LED layer
5 Decrease the ball’s timer by 1 (using the new PN.- op)

Script #3:
1 Set X and Y to the position in front of the ball (ie cell to the right)
2 Set B to the brightness of this cell
3 If the cell is empty, move the ball right (increase the ball’s x pos)
4 If the cell is empty, reset the ball’s timer to 15 - X.
5 Otherwise (the cell to the right is not empty) run Script #4

Script #4: (the ball has collided with a pin)
1 Set CV 1 to a pitch based on the pin’s position
2 Set Y to the cell above or below the ball, depending on a coin TOSS
3 If this potential position is not empty, do nothing
4 Otherwise, move the ball to the position and send a Trigger out of TR 1
5 Reset the ball’s timer to 15

Script #5 (expects a trigger into input 5):
1 Simulate pushing button 3, which is 4 cells down on the left edge.

Script #7:
If the ball has gone off the right-hand edge, remove the ball’s x,y,timer data from the patterns.

Script #8:
1 If the pin is being removed, set D to -3
2 Otherwise (the pin is being created) set D to 9
3 Set the LED brightness to D

Metro Script #M:
1 Set M to the Param knob and the Trig time to half that.
2 Break if there is no entry on the Pattern page (ie no balls on grid)
3 Loop through all the balls, passing I to Script 2
4 Loop through all the balls, passing I to Script 7


#150

Looks really fun - looking forward to giving it a spin. Also I like the way you’ve done a line by line code to english translation. That’s helpful in understanding it!


#151

Ok, here’s my first stab at a 4-channel euclidian rhythm (ER) drum sequencer - it uses telex input (TXi) knobs to rotate the pattern per channel. There are independent mutes. If you hold the lower left button and press a row, that sets the number of spaces in the ER. If you press a row without holding the lower left button, it sets the number of pulses in the ER. You clock it by sending a clock into input 8. If you don’t have a grid, you could, of course, use the grid viewer, or else, just edit the tracker with the keyboard

I’m sure that the code isn’t optimal and could be improved - if I had a free script, I could add a reset pulse (I might still be able to find a way to shoehorn it in there). It could also probably be modified with more shift keys to just use the teletype knob to rotate the pattern of a particular channel (depending on what button you held down).

Forgive me if the code isn’t of the best quality, I am still learning :slight_smile:

EUCLIDGRID
CLOCK INPUT 8
HOLD LOWER LEFT BUTTON TO 
SET PATTERN LENGTH
PRESS ROW TO SET NUM PULSES
TURN KNOBS TO ROTATE PATTERN
VERTICAL BTNS ARE MUTES



#1
G.CLR; Z G.BTN.V 100
IF == 4 G.GRPI: BRK
B G.GRPI; A PN B 0
IF Z: PN B 0 + 1 G.BTNX; BRK
PN B 1 LIM + 1 G.BTNX 1 A
PN B 1 + 1 G.BTNX

#2
Z - I 1
TI.PRM.MAP I 1 16
PN - I 1 3 TI.PRM I

#3
PN 0 2 G.BTN.V 200
PN 1 2 G.BTN.V 201
PN 2 2 G.BTN.V 202
PN 3 2 G.BTN.V 203

#4
G.GBX 0 0 0 0 1 1 0 5 1 16 1
G.GBX 1 16 0 1 1 1 0 5 1 16 1
G.GBX 2 32 0 2 1 1 0 5 1 16 1
G.GBX 3 48 0 3 1 1 0 5 1 16 1
G.GBT 4 100 0 7 1 1 0 10 0
G.BTX 200 1 4 1 1 1 5 3 1 4

#5
D - I 1; P.N D;
X P 0; Y P 1; C P 3
L 1 X: $ 6

#6
Z ER Y X SUB I C
IF Z: G.LED - I 1 D 15

#7
P.N - I 1
G.LED % - T 1 P 0 - I 1 10
IF P 2: Z ER P 1 P 0 - T P 3
ELSE: Z 0
IF Z: TR.PULSE I

#8
T + T 1
L 1 4: $ 7

#M
G.CLR
L 1 4: $ 2
L 1 4: $ 5

#I
$ 4; T 0
L 1 4: TR.TIME I 10

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

16	16	16	16
4	3	6	4
1	1	1	1
1	14	2	3
15	15	15	15
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	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

#G
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000011110000
0000000000000000
0000000000000000
0000000000000000

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

#152

Thank you so much for posting this sketch, rikrak - I’ve liked it since I saw it on your Instagram! I am very much looking forward to drawing some inspiration from your code!


"Just Type" Beta Testers
#153

Think there are enough script lines (and space on the grid) to create some kind of grid based controls for the offset? For those who don’t have TXi yet?

Edit: to be clear I’m not necessarily asking you to do that - just wondered if you thought it could be done.


#154

Absolutely if you rip out the bits that are talking to the telex! I bet I could hack up an alternative version with rotation buttons!

I think you can remove the call to script 2 from the metronome script and then create a column of 4 buttons that call script 2 and in that script, increment patterns 0-3 row 3 - once I am in front of the TT I will give it a shot :slight_smile:


#155

this is great, thanks for posting it @rikrak and @giftculture! (and special thanks for the detailed breakdown).
really glad to see some of the newer ops being put to use.

@giftculture - for rotation instead of buttons could also use faders, so you’d just need to create a group of 4 faders, so 1 op, should fit in I script, and then in script 5 instead of C P 3 you could just do C + 1 G.FDR.N D, if i understand correctly.


#156

@scanner_darkly Thanks for the tips re faders - I need to get more comfortable with them so that I can use them to their full potential!

Here is a version with rotate left and rotate right buttons for each channel and a
reset when sending a trigger to trigger 3

EUCLIDGRID WITH ROTATION BTNS
CLOCK TRIG 8 RESET TRIG 3
HOLD LOWER LEFT BUTTON AND
PRESS ROW TO  SET NUM SPACES

PRESS ROW TO SET NUM PULSES

FIRST VERTICAL BTNS ARE MUTES
SECOND VERTICAL BTNS ROTATE
LEFT AND RIGHT



#1
G.CLR; Z G.BTN.V 100
IF == 4 G.GRPI: BRK
B G.GRPI; A PN B 0
IF Z: PN B 0 + 1 G.BTNX; BRK
PN B 1 LIM + 1 G.BTNX 1 A
PN B 1 + 1 G.BTNX

#2
IF EZ G.BTNV: BRK
C - G.BTNI 65; D - G.BTNI 75
A ? == G.GRPI 9 1 -1
B ? == A 1 D C
PN.+ B 3 A

#3
PN 0 2 G.BTN.V 200
PN 1 2 G.BTN.V 201
PN 2 2 G.BTN.V 202
PN 3 2 G.BTN.V 203
IF STATE 3: T 0

#4
G.GBX 0 0 0 0 1 1 0 5 1 16 1
G.GBX 1 16 0 1 1 1 0 5 1 16 1
G.GBX 2 32 0 2 1 1 0 5 1 16 1
G.GBX 3 48 0 3 1 1 0 5 1 16 1
G.GBT 4 100 0 7 1 1 0 10 0
G.BTX 200 1 4 1 1 1 5 3 1 4

#5
D - I 1; P.N D;
X P 0; Y P 1; C P 3
L 1 X: $ 6

#6
Z ER Y X SUB I C
IF Z: G.LED - I 1 D 15

#7
P.N - I 1
G.LED % - T 1 P 0 - I 1 10
IF P 2: Z ER P 1 P 0 - T P 3
ELSE: Z 0
IF Z: TR.PULSE I

#8
T + T 1
L 1 4: $ 7

#M
G.CLR
L 1 4: $ 5

#I
$ 4; T 0
L 1 4: TR.TIME I 10
G.GBX 8 65 3 4 1 1 0 15 2 1 4
G.GBX 9 75 4 4 1 1 0 15 2 1 4

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

16	16	16	16
4	3	6	4
1	1	1	1
-73	35	12	19
15	15	15	15
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	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

#G
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000011110000
0000000000000000
0000000000000000
0000000000000000

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

#157

Hey @scanner_darkly - I’d like to understand how to use Pages. The excellent grid ops documentation on github introduces the concept but I would really benefit from some example code.

Is it just a case of assigning all controls on a page the same id and then dis/enabling that group? Can controls be active on more than a single page?


#158

yep, that’s the idea. groups are basically a way to group several controls so you could update their properties at once. that includes enabling/disabling controls.

let’s say you define a group of 8 faders: G.GFX 1 0 0 0 1 8 1 4 0 8 1 - this creates a row of 8 faders and assigns them to group 1. now let’s create an 8x8 group of buttons: G.GBX 2 0 0 0 1 1 1 4 0 8 8 and assign them to group 2. both occupy an 8x8 block on the left. if we execute these 2 ops both groups of controls are active. you’ll only see the buttons as they are rendered last, but both buttons and faders will react to presses - probably not what we want (although this could be an interesting UI to work with!).

what we want is show one group and hide the other one. first we’ll hide group 2: G.GRP.EN 2 0. now we need a button to switch between the groups: G.GBT 0 64 15 7 1 1 0 8 1, this button needs to be assigned to a different group, so we’re using group 0 here. it’s assigned to script 1 which does the switching:

IF G.GRP.EN 1: G.GRP.EN 1 0
ELSE: G.GRP.EN 1 1
IF G.GRP.EN 2: G.GRP.EN 2 0
ELSE: G.GRP.EN 2 1

which could be shortened to:

G.GRP.EN 1 EZ G.GRP.EN 1
G.GRP.EN 2 EZ G.GRP.EN 2

you could also use G.GRP.SW op - it enables the specified group and disables all others (just remember to re-enable group 0 after this, otherwise your page button will get hidden as well!)

now the cool thing is you don’t have to use grid itself to switch - you could use something like monome walk and plug it into the trigger input 1, and now you can change pages with a footswitch! or do it with the grid but instead of having a dedicated control to switch pages use the grid control mode to execute the switching script.

it should be mentioned groups have other purposes as well, such as setting a fader range or extracting information from multiple button presses.


#159

Thanks for the explanation @scanner_darkly. I have it working - lots of potential!

There’s a small typo in $1 (ELSE G:GRP)

I hadn’t been using the logical NOT properly:

G.GRP.EN 1 ! G.GRP.EN 1 - is a great shortcut! That will come in handy.


#160

thanks, that’s what happens when i type without double checking :slight_smile: also forgot : after ELSE, fixed.

yeah, logical NOT works as well and is shorter than EZ. and of course both lines could be shortened to:
L 1 2: G.GRP.EN I ! G.GRP.EN I

(the above won’t work if you have more than 2 pages, G.GRP.SW will be likely a more compact way to do it but will require a variable to track the current page number).


#161

I think the glitching actually had to do with reading PARAM multiple times. I didn’t test very much, though. Now I save PARAM to a variable outside of the loop. A bit of tweaking and I was able to smooth things out.

I’ve edited my original post. I probably could have kept reusing script 8 from the metro, but I figured just changing button luminance in a duplicated script (7) might be more performant?


#162

could you elaborate a bit on what you are trying to do?


#163

could you elaborate a bit on what you are trying to do?

Yeah, my idea is to let the init script setup the board based on the initial value of PARAM. There’s an ugly few lines that computes whether or not a button should be a “white” or “black” key for all buttons with IDs 0-127 (script 8). After this setup, I use the metro script to resample
PARAM and recompute which buttons should be “white” or “black” (script 7).

  • I think it’s actually OK to reuse script 8 from the metro script, even without the G.RST you suggested, but I figured it doesn’t hurt to have a separate script that just updates the button’s lighting instead of redefining the button.
  • I toggle off the metro script before entering the loop. I doubt this is necessary, but I was afraid looping from 0-127 was taking too long and the metro script was re-executing.

#164

ah i see. in terms of performance there shouldn’t be much difference between initializing buttons or setting their level, so either option works. but re-initializing buttons in this case doesn’t do anything useful since you reapply script 7 after that anyway, so it’s just an unnecessary step (as a side note, you don’t need to G.RST when you reinitialize the same controls - not sure what i had in mind when i suggested adding it!).

i would change it this way: instead of script 8 you could just define the whole button block with one op: G.BTX 0 0 0 1 1 0 0 1 16 8 and then assign brightness levels as you do with script 7: L 0 127: Z I; SCRIPT 7. and then update brightness level in metro script as well. also you only need to readjust brightness levels when PARAM value changes, just add this line to the metro script: IF EQ Y PARAM: BREAK.

glitching likely was due to PARAM value changing slightly. another thing to consider would be replacing the knob with a grid fader.

edit: forgot to include number of columns and rows in G.BTX, fixed. also forgot to mention - you don’t need to use another variable anymore to pass the value of I when you call another script from a loop - just use I in the called script.