I'm trying to set up a 'default' value for for a step sequencer such that when a switch in a separate switch sequencer is clicked, the default value will be set in the step in the same index. I was thinking to use 'mouse dwn' from the switch sequencer, but then I still don't know which step to fill in with the default value.
I can write another script probably but I was hoping there would be an easier solution (maybe it doesn't take much to add this as an output in the sequencers?).
get the index of the changed value in a sequencer
Nevermind, I've scripted it myself.
Code: Select all
//////////////////////////
// Index of Changed Array Value
/////////////////////////
// parameters declaration
var mem, arrIn, value,
index : tParameter;
var s,l : integer;
var m,x : single;
var hasRun : integer;
// initialisation : create parameters
procedure init;
begin
mem := createParam('memory',ptArray);
setIsInput(mem,false);
setIsOutput(mem,false);
arrIn := createParam('array in',ptArray);
setIsOutput(arrIn,false);
index := createParam('index',ptDatafield);
setIsInput(index,false);
value := createParam('value',ptDatafield);
setIsInput(value,false);
hasRun := 0;
end;
// Callback procedure
Procedure Callback(N:integer);
begin
case N of
arrIn: begin
if hasRun = 1
then begin
l := getLength(arrIn);
for s:=0 to l-1
do begin
x := getDataArrayValue(arrIn,s);
m := getDataArrayValue(mem,s);
if x <> m
then begin
setValue(index,s);
setValue(value,x);
end;
end;
end;
l := getLength(arrIn);
setLength(mem,l);
for s:=0 to l-1
do begin
x := getDataArrayValue(arrIn,s);
setDataArrayValue(mem,s,x);
end;
hasRun := 1;
end;
end;
end;
// Global variables
//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
begin
if hasRun = 0
then begin
l := getLength(arrIn);
setLength(mem,l);
for s:=0 to l-1
do begin
x := getDataArrayValue(arrIn,s);
setDataArrayValue(mem,s,x);
end;
hasRun := 1;
end;
end;Hi ceaseless! I was wondering too...would you not use the step-position of the switch sequence to determine the index?
I guess I don't have a good idea of your approach...but I looked at once and found the step position was not only where the sequencer "was" but the index of each button.
-S
I guess I don't have a good idea of your approach...but I looked at once and found the step position was not only where the sequencer "was" but the index of each button.
-S
"Every act of creation is first an act of destruction." -Picasso
Hi Sephult,
Indeed, it seems that it is very hard to translate patching concepts in words. Thank you for responding and trying to help! It can really mean a lot, especially as threads can go unanswered here for long stretches. That is to be expected, especially with the development pace of Holylhock, but it can still be a little demotivating.
As regards step position, yes definitely it carries the index with it (using the trunc module gets you exactly the index). This is perfectly fine for inputting new step/switch values in real-time.
However, I'm designing a drum sequencer that can also be used just with a mouse. So what I need is to get the index value of a switch that has changed. This can be 'in the future' relative to step position: step position is on the second switch, while I've just clicked to activate the 15th switch.
The script above takes care of that, I'm just starting to worry that I have so many scripts in my patch
Indeed, it seems that it is very hard to translate patching concepts in words. Thank you for responding and trying to help! It can really mean a lot, especially as threads can go unanswered here for long stretches. That is to be expected, especially with the development pace of Holylhock, but it can still be a little demotivating.
As regards step position, yes definitely it carries the index with it (using the trunc module gets you exactly the index). This is perfectly fine for inputting new step/switch values in real-time.
However, I'm designing a drum sequencer that can also be used just with a mouse. So what I need is to get the index value of a switch that has changed. This can be 'in the future' relative to step position: step position is on the second switch, while I've just clicked to activate the 15th switch.
The script above takes care of that, I'm just starting to worry that I have so many scripts in my patch
Who is online
Users browsing this forum: No registered users and 23 guests
