S+H outputs nil when Input is nil and Set pin is spreaded

this gave me some headache, see patch:

s+h_bug.v4p (2.9 kB)

hey tebjan,

this is not considered as a bug yet…

up to now there are two and a half modes of how S+H works:

  • if the “Set” Pin is not spreaded (“Set” has one slice):
    ** On Set the whole spread is stored and retrieved
    ** otherwise the stored spread retrieved

  • if the “Set” Pin is NULL:
    ** the stored spread is retrieved

  • if the “Set” Pin is spreaded the S+H operation is mapped onto each (“Input”, “Set”) pair. that means that if “Input” is NULL that there are no (“Input”, “Set”) pairs.
    ** Slicecount is independant of if “Set” is true. spreadmax decides how many slices are returned.
    ** if “Set” is true for a ceratin slice the corresponding “Input” slice is stored.

if you have an idea how S+H should work instead please report here.

ok understood, so i would say:

  • output stays as long as no slice of set pin was 1
  • if a slice of set pin is 1 and input is nil then output is nil
  • rest as you explained

i would look in the code myself instead of spamming the bug forum, but i’m in mid phase of a project right now…

in the example the first 3 slices are not set, the 4th slice is always set.

hm i don’t know this sounds very special. so you would be ok with the behaviour in the patch attached?

s+h_bug-2.v4p (4.1 kB)
s+h_bug-workaround.v4p (4.4 kB)

yes, the workaround patch does exactly what i expected from the S+H node. thx, that will do!

or what about this:

the output is ONLY updated, if input makes sense, means pairs for input/set exist.

but we could think about setting the output to nil if both input pins are nil.

s+h_bug-workaround2.v4p (9.3 kB)

but if input is NIL and set = {true} (one slice) then the empty spread should be sampled…

ok how about that:

  • spread is sampled if set = {true}

  • slices are sampled if set is true in one of the slices and
    ** count of set > 1
    ** count of input > 0
    ** stored spread gets a new length of spreadmax( current set count, current input count )
    *** if sampled spread grows by that action new slices copy values of input slices if set is true for that slice
    *** otherwise a default value is sampled (for new slices which are not set)

  • in all other cases the stored spread is retrieved (length of spread will not be influenced by the input spread lengths)