tcopy

copy the elements of a table from table 'src' to table 'dst' the length of the area to copy is defined by 'range', the read offset is defined by inlet'src' and the write offset by 'dst' 'speed' sets the copying speed in terms of audio-rate (16 is really fast!) if 'splat' is enabled,tcopy will preserve the original contents of the destination table. if 'clear' is enabled,tcopy will clear the contents of the table.
Author: Robert Schirmer
License: BSD
Github: rbrt/data/tcopy.axo

Inlets

bool32.rising start copying

bool32 splat

bool32 clear

int32 source start

int32 destination start

int32 length of the area to copy

Outlets

bool32.pulse operation done.

Parameters

int32 src

int32 dst

int32 range

bool32.tgl add to src contents

bool32.tgl clear dst

Attributes

objref name of the source -table

objref name of the destination - table

spinner speed

Declaration
uint32_t pos;
bool doit;
bool trig;
bool splat;
bool clear;

int speed;
uint32_t src;
uint32_t dst;
uint32_t range;
uint32_t blocksize;
Control Rate
outlet_done = 0;

if (inlet_trig && !trig) {
  speed = attr_speed << 4;
  src = param_src + inlet_src;
  dst = param_dst + inlet_dst;
  range = param_range + inlet_range;
  blocksize = range - (range % speed);
  splat = param_splat || inlet_splat;
  clear = !(param_clear || inlet_clear);
  trig = 1;
  pos = 0;
  doit = 1;
}
if (!inlet_trig && !doit)
  trig = 0;

// copy n chunks of size 'blocksize'
if (doit) {
  if (pos < blocksize) {
    {
      int ii;
      for (ii = 0; ii < speed; ii++) {
        int spos = pos + ii + src;
        int dpos = pos + ii + dst;
        attr_dst.array[dpos] =
            (attr_src.array[spos] + (attr_dst.array[dpos] * splat)) * clear;
      }
    }
    pos += speed;
  }
  // copy what's left
  else {
    int ii;
    for (ii = pos; ii < range; ii++) {
      int spos = ii + src;
      int dpos = ii + dst;
      attr_dst.array[dpos] =
          (attr_src.array[spos] + (attr_dst.array[dpos] * splat)) * clear;
    }
    doit = 0;
    outlet_done = 1;
  }
}

Privacy

© 2024 Zrna Research