music/patcher/pd/ HomePage


Writing Externals

See pure data site, which points to this github and FlextCpp

See here for where to install externals. (On Linux it's ~/.local/lib/pd/extra/).

Simplest Example

helloworld.c

#include "m_pd.h"

static t_class *helloworld_class;

typedef struct _helloworld {
  t_object x_obj;
} t_helloworld;

void helloworld_bang(t_helloworld *x)
{
  post("Hello world!!");
}

void *helloworld_new(void);
void helloworld_setup(void)
{
  helloworld_class = class_new(gensym("helloworld"),
    (t_newmethod)helloworld_new,
    0, sizeof(t_helloworld),
    CLASS_DEFAULT, 0);
  class_addbang(helloworld_class, helloworld_bang);
}

void *helloworld_new(void)
{
  t_helloworld *x = (t_helloworld *)pd_new(helloworld_class);
  return (void *)x;
}

Makefile

# Makefile for mylib

lib.name = helloworldlib

class.sources = helloworld.c

datafiles = 

include Makefile.pdlibbuilder

where Makefile.pdbuilder is here.