[PD] [list /], [list -]?

Mathieu Bouchard matju at sympatico.ca
Fri Jan 9 21:27:27 CET 2004


On Fri, 9 Jan 2004 stephaniebrodeur at rogers.com wrote:

> We are working on getting values from an image to a pd array. We are
> using maxlib's [tabset] to write the values to an array but the values
> are ints ranging from 0-255 and we'd like to get floats from -1 to 1.
> Since gridflow deals only with ints currently, are operations on lists
> possible in pd?

GF got float support in last April (0.7.2) but you have to specify it
explicitly, because GF doesn't know which you want, and assumes integers
because of compatibility with all previous GF patches.

You can do what you want to do like this:

[@cast float32]
 |
[@ / ( float32 # 127.5 )]
 |
[@ - ( float32 # 1 )]
 |
[@export_list]


Alternatively, you can also build equivalents to jMax's [list+] and such
(it's not spelt [list +] !) using Ruby code like this:

class ListPlus < GridFlow::FObject
  def _0_initialize(*right) @right=right end
  def _1_list(*right) @right=right end
  def _0_list(*left)
    send_out 0, :list, *(0...left.length).map{|i| left[i] + @right[i] }
  end
  install "list+", 2, 1
end

And likewise for the other ones.

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju





More information about the Pd-list mailing list