[PD] passing atoms to subroutines

Charles Henry czhenry at gmail.com
Mon Jul 10 02:05:56 CEST 2006


Hello, all,
  I've been having some trouble with a "save" subroutine.  I want to
send my external a message "save filename" and have it write to
filename.  The function is set up like so,

class_addmethod(controlfreak_tilde_class,
(t_method)controlfreak_tilde_save, gensym("save"), A_SYMBOL,0);

I've tried passing the symbol by reference and by value, but I always
have the atom_string routine say, "consistency check failed"
What am I doing wrong, here?

void controlfreak_tilde_save (t_controlfreak_tilde *x, t_atom *instr)
{
  char *filename=alloca(32*sizeof(char));
  atom_string(instr, filename, 32);
  printf(filename);
  int fd = open(filename, O_WRONLY || O_CREAT);
  int i;
  if (fd == -1)
    printf("can't open file\n");
  else if (x->w == NULL)
    printf("start audio first\n");
  else
  {
    i = write(fd, &x->n, sizeof(int));
    i = write(fd, x->w, (x->n/2 + 1)*sizeof(float));
  }
  i = close(fd);
}




More information about the Pd-list mailing list