Howdy folks, I’m realizing that I’ve spent far too much time trying to get this to work, so I’m asking for help.
What I need to happen: is simply to hit a button, start recording a table, creating a new row every frame that goes by, that includes the frame index since hitting the record button (ie starting at 1) and the numerical value of various midi knobs. So the only way I’ve known how to use variables is that ridiculous setup where you have a table with names and initial values, another table you can refer to in other dats to change the values, and an evaluate DAT to use when you want to refer to a value. So I tried just creating a table and had it change length depending on a frame value in the evaluate DAT, and tried to have each new row become the values I desired, but TD just pooped out and couldn’t handle it at all.
But then I discovered the scriptDAT, I added an LFO to one of the examples in the snippets and found that I could update the values and the number of rows in it with no problems. I’ve been trying to follow Matthew Ragan’s script example matthewragan.com/2017/03/19/scr … hdesigner/ However, I have yet to figure out exactly what it’s trying to run with the script I have. I need to setup the variable f when I hit record, set it to 0, clear the table and create a first row with just the headers for each column. Each frame, f+=1, and it needs to add another row with the value of f and the respective midi values.
Here’s what I have right now:
when I hit record:
if op(‘vars’)[8,1] == 0:
attr = {
“c”:{
“f” : 0,
“justifyv” : 1
}
}
parent().store( ‘set_up_attr’, attr )
op(‘table2’)[8,1] = 1
else:
op(‘table2’)[8,1] = 0
#the vars and table2 [8,1] is my record variable, if it’s on it turns off, if it’s off it turns on, which works properly
(I created an empty container named c just because in Matthew’s example he attributes his variables to containers for some reason.)
And then in the script callbacks associated with my final table:
pars = parent().fetch( ‘set_up_attr’ )
the record button triggers setup parameters
def setupParameters(scriptOp):
#scriptOp.appendParFloat(‘ValueA’, page=‘Custom’)
#scriptOp.appendParFloat(‘ValueB’, page=‘Custom’)
scriptOp.clear()
scriptOp.insertRow( [‘frame’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘K1’] )
return
called whenever custom pulse parameter is pushed
def onPulse(par):
return
def cook(scriptOp):
if op(‘vars’)[8,1] == 1:
pars[ ‘c’ ][ ‘f’ ] +=1
scriptOp.insertRow( [ pars[ ‘c’ ][ ‘f’ ], op(‘switch2’)[‘B1’], op(‘switch2’)[‘B2’], op(‘switch2’)[‘B3’], op(‘switch2’)[‘B4’], op(‘switch2’)[‘B5’],op(‘switch2’)[‘K1’] ],pars[ ‘c’ ][ ‘f’ ] )
return
def cook(scriptOp):
if op(‘vars’)[8,1] == 1:
pars[ ‘c’ ][ ‘f’ ] +=1
scriptOp.appendRow( [ pars[ ‘c’ ][ ‘f’ ], op(‘switch2’)[‘B1’], op(‘switch2’)[‘B2’], op(‘switch2’)[‘B3’], op(‘switch2’)[‘B4’], op(‘switch2’)[‘B5’],op(‘switch2’)[‘K1’] ],f )
return
What it actually does:
Once record is on, when I hit the midi buttons that it should be recording, I think it’s somehow triggering the ‘def cook’ portion (but only when I hit midi buttons) because it adds another row with a frame number that’s one higher than the last (despite the actual number of frames that may have passed by) with the appropriate midi info. The weird part is that when it adds a new row, it turns all the previous rows blank except for the header. Even weirder, when I initially hit record, it’s like it’s triggering the cook either 2 or 3 times, so what I’m left with after I hit record is the header, one or two blank rows, and then what would be the appropriate row for that frame number (either 2 or 3). When I hit record again, it deletes all the rows except for the header. What I’ll need it to do is copy the final table into another table and save it in a folder with a time stamp.
I guess what I need to know is when exactly each of the sections in the script callbacks are run. (I’m also curious how you set up this so called custom pulse thing), how to get it to cook once every frame, and how to get it to add to the table each time without deleting the previous rows, thanks!