Created
April 30, 2014 21:18
-
-
Save ab5tract/8c9e4da4c7ca00949cc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////// | |
// Pattern Store | |
///////////////////////// | |
// parameters declaration | |
const PATTERNs = 8; | |
const STEPs = 32; | |
const IOs = 4; | |
var MEMs : integer; | |
type tStep = array [0..STEPs-1] of single; | |
type stepBank = array [0..IOs-1] of tStep; | |
var patternBank : array of stepBank; | |
var memory : array [0..(PATTERNs*IOs)-1] of tParameter; | |
var stepIn : array of integer; | |
var stepOut : array of integer; | |
var store : tParameter; | |
var load : tParameter; | |
var stepNum : tParameter; | |
var current : tParameter; | |
var copy : tParameter; | |
var resetP : tParameter; | |
var resetA : tParameter; | |
var initd : tParameter; | |
var p,i,x,s : integer; | |
var cur,next : integer; | |
var firstTime : integer; | |
// initialisation : create parameters | |
procedure init; | |
begin | |
MEMs := PATTERNs * IOs; | |
setArrayLength(patternBank,PATTERNS); | |
setArrayLength(stepIn,IOs); | |
setArrayLength(stepOut,IOs); | |
store := createParam('store',ptButton); | |
setIsOutput(store,false); | |
load := createParam('load',ptDataField); | |
copy := createParam('copy',ptSwitch); | |
setIsOutput(copy,false); | |
initd := createParam('init',ptButton); | |
setIsOutput(initd,false); | |
setIsSeparator(initd,true); | |
stepNum := createParam('step num',ptDataField); | |
setIsSeparator(stepNum,true); | |
current := createParam('current',ptDataField); | |
setIsInput(current,false); | |
setIsOutput(current,false); | |
resetP := createParam('reset pattern',ptButton); | |
setIsOutput(resetP,false); | |
resetA := createParam('reset all',ptButton); | |
setIsOutput(resetA,false); | |
firstTime := 0; | |
for i := 0 to IOs-1 | |
do begin | |
stepIn[i] := createParam('seq '+inttostr(i+1),ptArray); | |
setIsOutput(stepIn[i],false); | |
setLength(stepIn[i],STEPs); | |
end; | |
setIsSeparator(stepIn[0],true); | |
for i := 0 to IOs-1 | |
do begin | |
stepOut[i] := createParam('seq '+inttostr(i+1),ptArray); | |
setIsInput(stepOut[i],false); | |
setLength(stepOut[i],STEPs); | |
end; | |
for i:=0 to MEMs-1 | |
do begin | |
memory[i] := createParam('mem '+inttostr(i+1),ptArray); | |
setIsInput(memory[i],false); | |
setIsOutput(memory[i],false); | |
setDontSave(memory[i],false); | |
setLength(memory[i],STEPs); | |
end; | |
end; | |
var choice, | |
prev, m : integer; | |
var v : single; | |
var temp : tStep; | |
// Callbackprocedure | |
Procedure Callback(N:integer); | |
begin | |
case N of | |
initd: begin | |
cur := round( getValue(current) ); | |
next := round( getValue(load) ); | |
if next = 0 | |
then begin | |
setValue( load,1 ); | |
next := 1; | |
end; | |
if cur = 0 | |
then begin | |
setValue( current,1 ); | |
cur := 1; | |
end; | |
for i:=0 to IOs-1 | |
do begin | |
x := ((next-1) * IOs) + i; | |
for s:=0 to STEPs-1 | |
do begin | |
temp[s] := getDataArrayValue(memory[x],s); | |
setDataArrayValue(stepOut[i],s,temp[s]); | |
end; | |
end; | |
end;//initd | |
resetP: begin | |
choice := round(getValue(current)); | |
setLength(stepOut[choice],STEPs); | |
setLength(memory[choice],STEPs); | |
for s:=0 to STEPs-1 | |
do begin | |
setDataArrayValue(memory[choice],s,0); | |
setDataArrayValue(stepOut[choice],s,0); | |
end; | |
end; | |
resetA: begin | |
for m:=0 to MEMs-1 | |
do begin | |
for s:=0 to STEPs-1 | |
do begin | |
setDataArrayValue(memory[m],s,0); | |
end; | |
end; | |
end; | |
store: begin | |
choice := round( getValue(load) ); | |
for i := 0 to IOs-1 | |
do begin | |
m := ((choice-1) * PATTERNs) + i; | |
setLength(stepOut[i],STEPs); | |
setLength(memory[m],STEPs); | |
for s := 0 to STEPs-1 | |
do begin | |
temp[s] := getDataArrayValue(stepIn[i],s); | |
setDataArrayValue(memory[m],s,temp[s]); | |
setDataArrayValue(stepOut[i],s,temp[s]); | |
end; | |
end; | |
end;//store | |
stepNum: begin | |
if getValue(stepNum) = STEPs-1 | |
then begin | |
next := round( getValue(load) ); | |
prev := round( getValue(current) ); | |
if next <> prev | |
then begin | |
for i:=0 to IOs-1 | |
do begin | |
x := ((next-1) * IOs) + i; | |
setLength(stepOut[i],STEPs); | |
for s:=0 to STEPs-1 | |
do begin | |
temp[s] := getDataArrayValue(memory[x],s); | |
setDataArrayValue(stepOut[i],s,temp[s]); | |
end; | |
end; | |
setValue(current,next); | |
end; | |
end; | |
end;//stepNum | |
// this case handles 'copy to new pattern' | |
load: begin | |
next := round( getValue(load) ); | |
prev := round( getValue(current) ); | |
if next <> prev | |
then begin | |
if prev > 0 | |
then begin | |
for i:=0 to IOs-1 | |
do begin | |
p := ((prev-1) * IOs) + i; | |
setLength(memory[p],STEPs); | |
setLength(stepOut[i],STEPs); | |
for s:=0 to STEPs-1 | |
do begin | |
temp[s] := getDataArrayValue(stepIn[i],s); | |
setDataArrayValue(memory[p],s,temp[s]); | |
setDataArrayValue(stepOut[i],s,temp[s]); | |
end; | |
end; | |
end; | |
end; | |
choice := round( getValue(copy) ); | |
if choice = 1 | |
then begin | |
next := round( getValue(load) ); | |
prev := round( getValue(current) ); | |
for i:=0 to IOs-1 | |
do begin | |
x := ((next-1) * IOs) + i; | |
p := ((prev-1) * IOs) + i; | |
setLength(memory[x],STEPs); | |
for s:=0 to STEPs-1 | |
do begin | |
temp[s] := getDataArrayValue(memory[p],s); | |
setDataArrayValue(memory[x],s,temp[s]); | |
end; | |
end; | |
end; | |
end; | |
end; | |
end; | |
// Global variables | |
//var loadPattern : integer; | |
//var stepPos : integer; | |
////////////////////////////// | |
// main proc | |
////////////////////////////// | |
Procedure Process; | |
begin | |
// v2 | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment