Hi there,
I’m very much a beginner when it comes to programming, so I hope that I can find some help ![]()
I’m trying to program the module BASICally to work as a sort of shift register, logic operator and gate sequencer in one.
It’s for a patch where I want to reverse incoming audio signals based on triggers from that same audio signal. All the reversing stuff is done with the Memory Ensemble by Stochastic Telegraph.
So far I have some kind of BINARY COUNTER that shifts back and forth between 0 and 1, a STORAGE ARRAY for the position values coming in from the Memory Ensemble, a sort of SHIFT REGISTER, the MATH LOGIC for calculating length in milliseconds from the positions values and two GATES that are send out with the before calculated length in milliseconds.
' --------------------------- BINARY COUNTER (trigger to IN9)
IF trigger(IN9) AND switch[1] == 0
THEN
FOR gate_ON = 0 to 1 STEP 1
switch[1] = gate_ON
NEXT
ELSEIF trigger(IN9) AND switch[1] == 1
THEN
FOR gate_OFF = 1 to 0 STEP -1
switch[1] = gate_OFF
NEXT
END IF
' OUT6 shows binary counter // 0 or 1
OUT6 = switch[1]
' --------------------------- RESET (trigger to IN7)
IF trigger(IN7) THEN switch[1] = 0 END IF
IF trigger(IN7) THEN a[1] = 0 END IF
IF trigger(IN7) THEN a[2] = 0 END IF
' --------------------------- VALUE STORAGE ARRAY for IN1 (trigger to IN8)
IF switch[1] == 0 AND trigger(IN8)
THEN
FOR value_a1 = 0 to IN1 STEP IN1[1] - 0.00001
a[1] = value_a1
NEXT
ELSEIF switch[1] == 1 AND trigger(IN8)
THEN
FOR value_a2 = 0 to IN1 STEP IN1[1] - 0.00001
a[2] = value_a2
NEXT
END IF
' ------------------------- SHIFT REGISTER
' assigning X1 & X2 in a kind of shift register
IF switch[1] == 0 THEN X1 = a[2] END IF
IF switch[1] == 0 THEN X2 = a[1] END IF
IF switch[1] == 1 THEN X1 = a[1] END IF
IF switch[1] == 1 THEN X2 = a[2] END IF
' OUT1 & OUT2 for debugging and logic understanding
OUT1 = X1
OUT2 = X2
' -------------------------- MATHI LOGIC
' calculating length in ms from X2 and X1
IF X1 != 0
THEN length_ms = X2 - X1
ELSE length_ms = 0
END IF
' for avoiding wrong length if X2 < X1
IF length_ms < 0
THEN length_ms = X2 + 10 - X1
END IF
OUT3 = length_ms
' ------------------------- GATE LENGTH
' CREATE A GATE with length in ms
ALSO
IF trigger(IN6) AND switch[1] == 1
THEN OUT4[1] = 10
WAIT length_ms * 1000
OUT4[1] = 0
END IF
END ALSO
ALSO
IF trigger(IN6) AND switch[1] == 0
THEN OUT4[2] = 10
WAIT length_ms * 1000
OUT4[2] = 0
END IF
END ALSO
Shift Register TEST_v02.vcv (2.9 KB)
BUT I need more then just two GATES to be send out simultaneously in order for the patch to be working as intended.
One idea would be to have some kind of 1 - x serial switch but I have NO IDEA how to implement this into BASICally. Already the BINARY COUNTER broke my brain somehow ![]()
Another solution that I would find more elegant is to have some kind of logic like this:
ALSO
IF trigger(IN6) AND OUT[1] == 10
THEN OUT4[3] = 10
WAIT length_ms * 1000
OUT4[3] = 0
END IF
END ALSO
ALSO
IF trigger(IN6) AND OUT[2] == 10
THEN OUT4[4] = 10
WAIT length_ms * 1000
OUT4[3] = 0
END IF
END ALSO
BUT an IF does not like to get an array like OUT1[1] as part of an condition… So BASICally shows an ERROR (Fix lamp ON) when I do it.
Is there a way around that? Or are there other ideas how to do it?