本文整理汇总了C++中pd_error函数的典型用法代码示例。如果您正苦于以下问题:C++ pd_error函数的具体用法?C++ pd_error怎么用?C++ pd_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pd_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fwriteln_open
static void fwriteln_open (t_fwriteln *x, t_symbol *s, t_symbol*type)
{
char* filename;
string_copy(s->s_name, &filename);
sys_bashfilename (filename, filename);
fwriteln_close (x);
/* if(0==type || type!=gensym("cr")) {
pd_error(x, "unknown type '%s'", (type)?type->s_name:"");
return;
}*/
if (type==gensym("cr"))
strcpy(x->linebreak_chr,"\n");
else
strcpy(x->linebreak_chr,";\n");
if (!(x->x_file=fopen(filename, "w"))) {
pd_error(x, "failed to open %128s",filename);
free(filename);
return;
}
string_copy(filename, &x->x_filename);
free(filename);
x->x_textbuf = (char *) getbytes (MAXPDSTRING + 1);
}
示例2: dict_unbind
/* adapted pd_unbind() from m_pd.c */
void dict_unbind(t_dict *x, t_pd *obj, t_symbol *s)
{
#ifdef DICT_DEBUG
post("unbind %x from \"%s\" at %x", (int)obj, s->s_name, (int)s);
#endif
if (s->s_thing == obj) s->s_thing = 0;
else if (s->s_thing && *s->s_thing == x->d_bindlist_class)
{
/* bindlists always have at least two elements... if the number
goes down to one, get rid of the bindlist and bind the symbol
straight to the remaining element. */
t_dict_bindlist *b = (t_dict_bindlist *)s->s_thing;
t_dict_bindelem *e, *e2;
if ((e = b->b_list)->e_who == obj)
{
b->b_list = e->e_next;
freebytes(e, sizeof(t_dict_bindelem));
}
else for (e = b->b_list; e2 = e->e_next; e = e2)
if (e2->e_who == obj)
{
e->e_next = e2->e_next;
freebytes(e2, sizeof(t_dict_bindelem));
break;
}
if (!b->b_list->e_next)
{
s->s_thing = b->b_list->e_who;
freebytes(b->b_list, sizeof(t_dict_bindelem));
pd_free(&b->b_pd);
}
}
else pd_error(obj, "%s: couldn't unbind", s->s_name);
}
示例3: pd_vmess
/* convenience routine giving a stdarg interface to typedmess(). Only
ten args supported; it seems unlikely anyone will need more since
longer messages are likely to be programmatically generated anyway. */
void pd_vmess(t_pd *x, t_symbol *sel, char *fmt, ...)
{
va_list ap;
t_atom arg[10], *at = arg;
int nargs = 0;
char *fp = fmt;
va_start(ap, fmt);
while (1)
{
if (nargs >= 10)
{
pd_error(x, "pd_vmess: only 10 allowed");
break;
}
switch(*fp++)
{
case 'f': SETFLOAT(at, va_arg(ap, double)); break;
case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
case 't':
SETBLOB(at, va_arg(ap, t_blob *));
/*post("pd_vmess: arg[0].a_w.w_blob = %p", arg[0].a_w.w_blob);*/
break; /* MP 20061226 blob type */
case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
case 'p': SETPOINTER(at, va_arg(ap, t_gpointer *)); break;
default: goto done;
}
at++;
nargs++;
}
done:
va_end(ap);
typedmess(x, sel, nargs, arg);
}
示例4: colorpanel_list
static void colorpanel_list(t_colorpanel *x, t_symbol *s, int argc, t_atom *argv)
{
t_symbol *tmp_symbol = s; /* <-- this gets rid of the unused variable warning */
int i;
unsigned int tmp_int;
char color_buffer[3];
char color_string[MAXPDSTRING];
strncpy(color_string,"#",MAXPDSTRING);
if(argc > 3)
logpost(x, 2, "[colorpanel] warning more than three elements in list");
for(i=0; i<3; i++)
{
tmp_symbol = atom_getsymbolarg(i, argc, argv);
if(tmp_symbol == &s_)
{
tmp_int = (unsigned int)(atom_getfloatarg(i, argc , argv) * 255);
snprintf(color_buffer, 3, "%02x", (tmp_int > 255 ? 255 : tmp_int));
strncat(color_string, color_buffer, 3);
}
else
{
pd_error(x,"[colorpanel] symbols are not allowed in the color list");
return;
}
}
memcpy(x->current_color, color_string, 7);
colorpanel_bang(x);
}
示例5: packRTCP_version
static void packRTCP_version(t_packRTCP *x, t_symbol*s, int argc, t_atom*argv) {
if(argc) {
int version = atom_getint(argv);
if(version != 2) pd_error(x, "currently only version '2' is supported!");
x->x_rtcp.common.version = 2;
} else post("%s: %d", s->s_name, x->x_rtcp.common.version);
}
示例6: packRTCP_p
static void packRTCP_p(t_packRTCP *x, t_symbol*s, int argc, t_atom*argv) {
if(argc) {
int p = atom_getint(argv);
if(p != 0) pd_error(x, "currently only padding '0' is supported!");
x->x_rtcp.common.p = 0;
} else post("'%s': %d", s->s_name, x->x_rtcp.common.p);
}
示例7: pd_unbind
void pd_unbind(t_pd *x, t_symbol *s)
{
if (s->s_thing == x) s->s_thing = 0;
else if (s->s_thing && *s->s_thing == bindlist_class)
{
/* bindlists always have at least two elements... if the number
goes down to one, get rid of the bindlist and bind the symbol
straight to the remaining element. */
t_bindlist *b = (t_bindlist *)s->s_thing;
t_bindelem *e, *e2;
if ((e = b->b_list)->e_who == x)
{
b->b_list = e->e_next;
freebytes(e, sizeof(t_bindelem));
}
else for (e = b->b_list; (e2 = e->e_next); e = e2)
if (e2->e_who == x)
{
e->e_next = e2->e_next;
freebytes(e2, sizeof(t_bindelem));
break;
}
if (!b->b_list->e_next)
{
s->s_thing = b->b_list->e_who;
freebytes(b->b_list, sizeof(t_bindelem));
pd_free(&b->b_pd);
}
}
else pd_error(x, "%s: couldn't unbind", s->s_name);
}
示例8: freadln_open
static void freadln_open (t_freadln *x, t_symbol *s, t_symbol*type)
{
char filenamebuf[MAXPDSTRING], *filenamebufptr;
char*dirname=canvas_getdir(x->x_canvas)->s_name;
int fd, len;
freadln_close(x);
/*
if(type!=gensym("cr")) {
pd_error(x, "currently only 'cr' type files are implemented!");
return;
}
*/
if (type==gensym("cr"))
strcpy(x->linebreak_chr,"\n");
else
strcpy(x->linebreak_chr,";\n");
/* directory, filename, extension, dirresult, nameresult, unsigned int size, int bin */
if ((fd=open_via_path(dirname,
s->s_name,"", filenamebuf, &filenamebufptr, MAXPDSTRING,0)) < 0 ) {
pd_error(x, "%s: failed to open %s", s->s_name, filenamebuf);
return;
}
close(fd);
len=strlen(filenamebuf);
if (!(x->x_filename=(char*)getbytes(sizeof(char)*(len+strlen(s->s_name)+2)))) {
pd_error(x, "out of memory");
freadln_close(x);
return;
}
strcpy(x->x_filename,filenamebuf);
strcpy(x->x_filename+len,"/");
strcpy(x->x_filename+len+1,s->s_name);
if (!(x->x_file=fopen(x->x_filename, "r"))) {
pd_error(x, "freadln: failed to open %128s",filenamebuf);
return;
}
if (!(x->x_textbuf = (char *) getbytes (MIN_FREADLN_LENGTH * sizeof(char)))) {
pd_error(x, "out of memory");
freadln_close(x);
return;
}
x->x_textbuf_length=MIN_FREADLN_LENGTH;
}
示例9: outlet_new
static void *specCentroid_new(t_symbol *s)
{
t_specCentroid *x = (t_specCentroid *)pd_new(specCentroid_class);
int i;
t_garray *a;
x->x_centroid = outlet_new(&x->x_obj, &s_float);
if(s)
{
x->x_arrayname = s;
if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
;
else if(!garray_getfloatwords(a, &x->x_arrayPoints, &x->x_vec))
pd_error(x, "%s: bad template for specCentroid", x->x_arrayname->s_name);
}
else
error("specCentroid: no array specified.");
x->sr = 44100.0;
x->window = 1; // should be a bogus size initially to force the proper resizes when a real _analyze request comes through
x->windowFuncSize = 1;
x->windowFunction = 4; // 4 is hann window
x->powerSpectrum = 0; // choose mag (0) or power (1) spec in the specCentroid computation
x->maxWindowSize = MAXWINDOWSIZE; // this seems to be the maximum size allowable by mayer_realfft();
x->powersOfTwo = (int *)t_getbytes(sizeof(int));
x->powersOfTwo[0] = 64; // must have at least this large of a window
i=1;
while(x->powersOfTwo[i-1] < x->maxWindowSize)
{
x->powersOfTwo = (int *)t_resizebytes(x->powersOfTwo, i*sizeof(int), (i+1)*sizeof(int));
x->powersOfTwo[i] = pow(2, i+6); // +6 because we're starting at 2**6
i++;
}
x->powTwoArrSize = i;
x->signal_R = (t_sample *)t_getbytes(x->window*sizeof(t_sample));
for(i=0; i<x->window; i++)
x->signal_R[i] = 0.0;
x->blackman = (t_float *)t_getbytes(x->windowFuncSize*sizeof(t_float));
x->cosine = (t_float *)t_getbytes(x->windowFuncSize*sizeof(t_float));
x->hamming = (t_float *)t_getbytes(x->windowFuncSize*sizeof(t_float));
x->hann = (t_float *)t_getbytes(x->windowFuncSize*sizeof(t_float));
// initialize signal windowing functions
tIDLib_blackmanWindow(x->blackman, x->windowFuncSize);
tIDLib_cosineWindow(x->cosine, x->windowFuncSize);
tIDLib_hammingWindow(x->hamming, x->windowFuncSize);
tIDLib_hannWindow(x->hann, x->windowFuncSize);
return (x);
}
示例10: pd_defaultanything
static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv)
{
#ifdef ROCKBOX
(void) argc;
(void) argv;
#endif
pd_error(x, "%s: no method for '%s'", (*x)->c_name->s_name, s->s_name);
}
示例11: muse_set
static void muse_set(t_muse *x, t_symbol *s, int ac, t_atom *av) {
if (ac==2 && av->a_type == A_FLOAT)
{ int i = muse_limtr(x, av->a_w.w_float, 1);
t_atomtype typ = (av+1)->a_type;
if (typ == A_FLOAT) x->x_scl[i] = (av+1)->a_w.w_float;
else if (typ == A_SYMBOL) muse_operate(x->x_scl+i, av+1); }
else pd_error(x, "muse_set: bad arguments");
}
示例12: ctw_output_curl_error
static void ctw_output_curl_error(struct _ctw *common, CURLMsg *msg) {
t_atom status_data[2];
SETFLOAT(&status_data[0], msg->data.result);
SETSYMBOL(&status_data[1], gensym(curl_easy_strerror(msg->data.result)));
pd_error(common, "Error while performing request: %s", curl_easy_strerror(msg->data.result));
outlet_list(common->status_out, &s_list, 2, &status_data[0]);
}
示例13: wiimote_cwiid_error
static void wiimote_cwiid_error(t_wiimote *x, struct cwiid_error_mesg *mesg) {
switch(mesg->error) {
case CWIID_ERROR_NONE:
pd_error(x, "no error");
break;
case CWIID_ERROR_DISCONNECT:
pd_error(x, "disconnect error");
wiimote_doDisconnect(x);
break;
case CWIID_ERROR_COMM:
pd_error(x, "comm error");
wiimote_doDisconnect(x);
break;
default:
pd_error(x, "unknown error %d", mesg->error);
}
}
示例14: readdir_seek
/*--------------------------------------------------------------------
* seek FLOAT
*/
static void readdir_seek(t_readdir *x, t_floatarg pos)
{
if (!x->x_dir) {
pd_error(x, "readdir: seek %g: no directory opened!", pos);
return;
}
seekdir(x->x_dir, (off_t)pos);
}
示例15: readdir_next
/*--------------------------------------------------------------------
* next : get next entry
*/
static void readdir_next(t_readdir *x)
{
t_symbol *sel = sp_unknown;
struct dirent *result = NULL;
if ( !x->x_dir || !(result = readdir(x->x_dir)) ) {
if (errno == EBADF) {
//-- real error
pd_error(x, "readdir: cannot read from %s: %s", x->x_dirname->s_name, strerror(errno));
}
else {
//-- end of directory
outlet_bang(x->x_eod_outlet);
}
return;
}
#if HAVE_STRUCT_DIRENT_D_TYPE
//-- get type (if this OS supports it, e.g. if we're not on windoof)
switch (result->d_type)
{
#if HAVE_DECL_DT_REG
case DT_REG: sel = sp_file; break;
#endif
#if HAVE_DECL_DT_DIR
case DT_DIR: sel = sp_dir; break;
#endif
#if HAVE_DECL_DT_FIFO
case DT_FIFO: sel = sp_fifo; break;
#endif
#if HAVE_DECL_DT_SOCK
case DT_SOCK: sel = sp_sock; break;
#endif
#if HAVE_DECL_DT_CHR
case DT_CHR: sel = sp_chrdev; break;
#endif
#if HAVE_DECL_DT_BLK
case DT_BLK: sel = sp_blkdev; break;
#endif
#if HAVE_DECL_DT_UNKNOWN
case DT_UNKNOWN:
#endif
default:
sel = sp_unknown;
break;
}
#else /* if !HAVE_STRUCT_DIRENT_D_TYPE */
sel = sp_unknown;
#endif /* HAVE_STRUCT_DIRENT_D_TYPE */
x->x_eatom.a_w.w_symbol = gensym(result->d_name);
outlet_anything(x->x_ent_outlet, sel, 1, &x->x_eatom);
}