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