• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中post函数的典型用法代码示例。如果您正苦于以下问题:C++ post函数的具体用法?C++ post怎么用?C++ post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: oggread_open

    /* open ogg/vorbis file */                 
static void oggread_open(t_oggread *x, t_symbol *filename)
{
	int i;

	x->x_stream = 0;
		/* first close previous file */
	if(x->x_fd > 0)
	{
		ov_clear(&x->x_ov);
		post("oggread~: previous file closed");
	}
		/* open file for reading */
#ifdef WIN32
	if((x->x_file = fopen(filename->s_name, "rb")) < 0)
#else
   if((x->x_file = fopen(filename->s_name, "r")) < 0)
#endif
    {
		post("oggread~: could not open file \"%s\"", filename->s_name);
		x->x_eos = 1;
		x->x_fd = -1;
    }
    else
    {
		x->x_stream = 0;
		x->x_eos = 0;
		x->x_fd = 1;
		x->x_outreadposition = 0;
		x->x_outwriteposition = 0;
		x->x_outunread = 0;
		post("oggread~: file \"%s\" opened", filename->s_name);
		outlet_float( x->x_out_position, 0);

			/* try to open as ogg vorbis file */
		if(ov_open(x->x_file, &x->x_ov, NULL, -1) < 0)
		{		/* an error occured (no ogg vorbis file ?) */
			post("oggread~: error: could not open \"%s\" as an OggVorbis file", filename->s_name);
			ov_clear(&x->x_ov);
			post("oggread~: file closed due to error");
      x->x_fd=-1;
      x->x_eos=1;
      return;
		}

			/* print details about each logical bitstream in the input */
		if(ov_seekable(&x->x_ov))
		{
			post("oggread~: input bitstream contained %ld logical bitstream section(s)", ov_streams(&x->x_ov));
			post("oggread~: total bitstream playing time: %ld seconds", (long)ov_time_total(&x->x_ov,-1));
			post("oggread~: encoded by: %s\n",ov_comment(&x->x_ov,-1)->vendor);
		}
		else
		{
			post("oggread~: file \"%s\" was not seekable\n"
			"oggread~: first logical bitstream information:", filename->s_name);
		}

		for(i = 0; i < ov_streams(&x->x_ov); i++)
		{
			x->x_vi = ov_info(&x->x_ov,i);
			post("\tlogical bitstream section %d information:",i+1);
			post("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld",
				x->x_vi->rate,x->x_vi->channels,ov_bitrate(&x->x_ov,i)/1000, ov_serialnumber(&x->x_ov,i));
			post("\t\theader length: %ld bytes",(long)
			(x->x_ov.dataoffsets[i] - x->x_ov.offsets[i]));
			post("\t\tcompressed length: %ld bytes",(long)(ov_raw_total(&x->x_ov,i)));
			post("\t\tplay time: %ld seconds\n",(long)ov_time_total(&x->x_ov,i));
		}

    } 
}
开发者ID:Angeldude,项目名称:pd,代码行数:72,代码来源:oggread~.c


示例2: featureMean_print

static void featureMean_print(t_featureMean *x)
{
    post("averaging %i vectors with %i features", x->numFrames, x->featureLength);
}
开发者ID:SMC-INESC,项目名称:drumtranscription_maxmsp,代码行数:4,代码来源:featureMean.c


示例3: zeroCrossing_tilde_overlap

static void zeroCrossing_tilde_overlap(t_zeroCrossing_tilde *x, t_floatarg f)
{
	x->overlap = (int)f;

    post("overlap: %i", x->overlap);
}
开发者ID:brunorohde,项目名称:SINCOPA,代码行数:6,代码来源:zeroCrossing~.c


示例4: ASSERT

/*! Get sample frames
	\param buf		pointer array to channel buffers
	\param frames	number of maximum frames to get
	\return			frames put into buffers
*/
int Stream::doGet(int ch,float *const *buf,int frames,float sr)
{
	ASSERT(ch > 0 && frames >= 0 && sr > 0);

	if(isOk() && !isInitializing()) {
		// signal thread worker
		pthread_cond_signal(&cond);

		// check/(re)allocate buffers

		int strch = getChannels();
		if(bufs && bufch < strch) { 
			delete[] decoded;
			for(int i = 0; i < bufch; ++i) src_delete(src_state[i]);
			delete[] src_state;
			delete[] bufs;	bufs = NULL; 
		}

		if(!bufs) {
			if(bufch < strch) bufch = strch;
			bufs = new float *[bufch];
			decoded = new Fifo<float>[bufch];

			src_state = new SRC_STATE *[bufch];
			for(int i = 0; i < bufch; ++i) {
				int error;
				src_state[i] = src_new(SRC_ZERO_ORDER_HOLD,1,&error);
				if(!src_state[i]) post("src init error %i",error);
			}
		}

		// get frames

		float ratio = sr/getSamplerate();
		int frneed = (int)(frames/ratio)+DECMORE;  // number of frames to read from decoder fifo

		if(decoded[0].Size() < frneed) {
			// fifos are too small -> resize them (while keeping their contents)
			for(int i = 0; i < bufch; ++i) decoded[i].Resize(frneed,true);
		}

		// how many frames do we need to get from decoder?
		int frread = frneed-decoded[0].Have();

		int ret = state == ST_WAIT?0:DataRead(frread);

		if(ret < 0) {
			if(debug) post("read error");
			// clear output
			for(int c = 0; c < ch; ++c)
				memset(buf[c],0,frames*sizeof *buf[c]);
			return 0;
		}
		else {
			// how many channels do we really need for output?
			// this should be set elsewhere, because we can't change anyway!!! 
			// (SRC_STATE for dangling channels would be incorrect)
			int cmin = strch;
			if(ch < cmin) cmin = ch;

			// write data to fifo
			for(int i = 0; i < cmin; ++i) {
				int wr = decoded[i].Write(ret,bufs[i]);
				if(wr < ret) post("fifo overflow");
			}

//			state = ST_PROCESS;

			if(ratio == 1) {
				// no resampling necessary

				// hopefully all channel fifos advance uniformly.....
				for(int i = 0; i < cmin; ++i) {

					for(int got = 0; got < frames; ) {
						int cnt = frames-got;

						if(decoded[i].Have()) {
							got += decoded[i].Read(cnt,buf[i]+got);
						}
						else {
							state = ST_WAIT;
							if(debug) post("fifo underrun");

							// Buffer underrun!! -> zero output buffer
							memset(buf[i]+got,0,cnt*sizeof(*buf[i]));
							got += cnt;
						}
					}
				}
			}
			else 
			{
				SRC_DATA src_data;
				src_data.src_ratio = ratio;
//.........这里部分代码省略.........
开发者ID:IcaroL2ORK,项目名称:pd,代码行数:101,代码来源:stream.cpp


示例5: ViewMover

 ViewMover (const GlobalRef& view_, int x_, int y_, int w_, int h_)
     : view (view_), x (x_), y (y_), w (w_), h (h_)
 {
     post();
 }
开发者ID:Theadd,项目名称:juced,代码行数:5,代码来源:juce_android_Windowing.cpp


示例6: post

 response const post (request const & request_, string_type const & body_) {
     return post(request_, "x-application/octet-stream", body_);
 }
开发者ID:LittleForker,项目名称:cpp-netlib,代码行数:3,代码来源:facade.hpp


示例7: post

HttpResponse HttpClient::post(const HttpUrl& url, const FormData& form_data){
    return post(url, form_data.get_string(), form_data.get_content_type());
}
开发者ID:SuperV1234,项目名称:InstagramCpp,代码行数:3,代码来源:HttpClient.cpp


示例8: routeOSC_verbosity

static void routeOSC_verbosity(t_routeOSC *x, t_floatarg v)
{
    x->x_verbosity = (v == 0)? 0: 1;
    if (x->x_verbosity) post("routeOSC_verbosity(%p) is %d", x, x->x_verbosity);
}
开发者ID:nebogeo,项目名称:sonic-kayaks-puredata,代码行数:5,代码来源:routeOSC.c


示例9: routeOSC_doanything

static void routeOSC_doanything(t_routeOSC *x, t_symbol *s, int argc, t_atom *argv)
{
    char    *pattern, *nextSlash;
    int     i = 0, pattern_depth = 0, matchedAnything = 0;
    int     noPath = 0; // nonzero if we are dealing with a simple list (as from a previous [routeOSC])

    pattern = s->s_name;
    if (x->x_verbosity) post("routeOSC_doanything(%p): pattern is %s", x, pattern);
    if (pattern[0] != '/')
    {
        /* output unmatched data on rightmost outlet */
        if (x->x_verbosity) post("routeOSC_doanything no OSC path(%p) , %d args", x, argc);
        outlet_anything(x->x_outlets[x->x_num], s, argc, argv);
        return;
    }
    pattern_depth = routeOSC_count_slashes(pattern);
    if (x->x_verbosity) post("routeOSC_doanything(%p): pattern_depth is %i", x, pattern_depth);
    nextSlash = NextSlashOrNull(pattern+1);
    if (*nextSlash == '\0')
    { /* pattern_depth == 1 */
        /* last level of the address, so we'll output the argument list */
    
        for (i = 0; i < x->x_num; ++i)
        {
            if
            (
                (x->x_prefix_depth[i] <= pattern_depth)
                && (MyPatternMatch(pattern+1, x->x_prefixes[i]+1))
            )
            {
                ++matchedAnything;
                if (noPath)
                { // just a list starting with a symbol
                  // The special symbol is s
                  if (x->x_verbosity) post("routeOSC_doanything _1_(%p): (%d) noPath: s is \"%s\"", x, i, s->s_name);
                  outlet_anything(x->x_outlets[i], s, argc, argv);
                }
                else // normal OSC path
                {
                    // I hate stupid Max lists with a special first element
                    if (argc == 0)
                    {
                        if (x->x_verbosity) post("routeOSC_doanything _2_(%p): (%d) no args", x, i);
                        outlet_bang(x->x_outlets[i]);
                    }
                    else if (argv[0].a_type == A_SYMBOL)
                    {
                        // Promote the symbol that was argv[0] to the special symbol
                        if (x->x_verbosity) post("routeOSC_doanything _3_(%p): (%d) symbol: is \"%s\"", x, i, argv[0].a_w.w_symbol->s_name);
                        outlet_anything(x->x_outlets[i], argv[0].a_w.w_symbol, argc-1, argv+1);
                    }
                    else if (argc > 1)
                    {
                        // Multiple arguments starting with a number, so naturally we have
                        // to use a special function to output this "list", since it's what
                        // Max originally meant by "list".
                        if (x->x_verbosity) post("routeOSC_doanything _4_(%p): (%d) list:", x, i);
                        outlet_list(x->x_outlets[i], 0L, argc, argv);
                    }
                    else
                    {
                        // There was only one argument, and it was a number, so we output it
                        // not as a list
                        if (argv[0].a_type == A_FLOAT)
                        {
                            if (x->x_verbosity) post("routeOSC_doanything _5_(%p): (%d) a single float", x, i);
                            outlet_float(x->x_outlets[i], argv[0].a_w.w_float);
                        }
                        else
                        {
                            pd_error(x, "* routeOSC: unrecognized atom type!");
                        }
                    }
                }
            }
        }
    }
    else
    {
        /* There's more address after this part, so our output list will begin with
           the next slash.  */
        t_symbol *restOfPattern = 0; /* avoid the gensym unless we have to output */
        char patternBegin[1000];

        /* Get the incoming pattern to match against all our prefixes */

        for (i = 0; i < x->x_num; ++i)
        {
            restOfPattern = 0;
            if (x->x_prefix_depth[i] <= pattern_depth)
            {
                StrCopyUntilNthSlash(patternBegin, pattern+1, x->x_prefix_depth[i]);
                if (x->x_verbosity)
                    post("routeOSC_doanything _6_(%p): (%d) patternBegin is %s", x, i, patternBegin);
                if (MyPatternMatch(patternBegin, x->x_prefixes[i]+1))
                {
                    if (x->x_verbosity)
                        post("routeOSC_doanything _7_(%p): (%d) matched %s depth %d", x, i, x->x_prefixes[i], x->x_prefix_depth[i]);
                    ++matchedAnything;
                    nextSlash = NthSlashOrNull(pattern+1, x->x_prefix_depth[i]);
//.........这里部分代码省略.........
开发者ID:nebogeo,项目名称:sonic-kayaks-puredata,代码行数:101,代码来源:routeOSC.c


示例10: IS_A_FLOAT

static void *NLMSerr_in_tilde_new(t_symbol *s, t_int argc, t_atom *argv)
{
    t_NLMSerr_in_tilde *x = (t_NLMSerr_in_tilde *)pd_new(NLMSerr_in_tilde_class);
    t_int i, n_order=39;
    t_symbol    *w_name;
    t_float beta=0.01f;
    t_float gammax=0.00001f;
    
    if((argc >= 4) &&
        IS_A_FLOAT(argv,0) &&   //IS_A_FLOAT/SYMBOL from iemlib.h
        IS_A_FLOAT(argv,1) &&
        IS_A_FLOAT(argv,2) &&
        IS_A_SYMBOL(argv,3))
    {
        n_order = (t_int)atom_getintarg(0, argc, argv);
        beta    = (t_float)atom_getfloatarg(1, argc, argv);
        gammax  = (t_float)atom_getfloatarg(2, argc, argv);
        w_name  = (t_symbol *)atom_getsymbolarg(3, argc, argv);
        
        if(beta < 0.0f)
            beta = 0.0f;
        if(beta > 2.0f)
            beta = 2.0f;
        
        if(gammax < 0.0f)
            gammax = 0.0f;
        if(gammax > 1.0f)
            gammax = 1.0f;
        
        if(n_order < 2)
            n_order = 2;
        if(n_order > 1111111)
            n_order = 1111111;
        
        inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
        inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
        outlet_new(&x->x_obj, &s_signal);
        
        x->x_flt_sig_in1 = 0;
        x->x_n_order = n_order;
        x->x_update = 0;
        x->x_beta = beta;
        x->x_gamma = gammax;
        // 2 times in and one time err_in memory allocation (history)
        x->x_ref_filt_in_hist = (t_float *)getbytes(x->x_n_order*sizeof(t_float));
        x->x_ref_adapt_in_hist = (t_float *)getbytes(x->x_n_order*sizeof(t_float));
        
        // table-symbols will be linked to their memory in future (dsp_routine)
        x->x_w_array_sym_name = gensym(w_name->s_name);
        x->x_w_array_mem_beg = (t_float *)0;
        
        x->x_rw_index = 0;
        
        return(x);
    }
    else
    {
        post("NLMSerr_in~-ERROR: need 3 float- + 1 symbol-arguments:");
        post("  order_of_filter + learnrate_beta + security_value + array_name_taps");
        return(0);
    }
}
开发者ID:Angeldude,项目名称:pd,代码行数:62,代码来源:NLMSerr_in~.c


示例11: routeOSC_paths

static void routeOSC_paths(t_routeOSC *x, t_symbol *s, int argc, t_atom *argv)
{ /* print  out the paths we are matching */
    int i;
    
    for (i = 0; i < x->x_num; ++i) post("path[%d]: %s (depth %d)", i, x->x_prefixes[i], x->x_prefix_depth[i]);
}
开发者ID:nebogeo,项目名称:sonic-kayaks-puredata,代码行数:6,代码来源:routeOSC.c


示例12: kbuffer_info

void kbuffer_info(t_kbuffer *x) {
	post("function length is %d samples",x->length);
	post("function sampling rate is %.2f",x->ksrate);
	post("function byte size is %d",x->memsize);
	post("function duration is %.2f seconds",x->duration);
}
开发者ID:ericlyon,项目名称:LyonPotpourri-MaxMSP,代码行数:6,代码来源:kbuffer~.c


示例13: buildResource

unsigned int KeenClient::addEvents(const char *events)
{
	buildResource();
	setAuthorizationHeader(write_key);
	return post(resource, events);
}
开发者ID:elof,项目名称:keen-arduino,代码行数:6,代码来源:KeenClient.cpp


示例14: ctw_cancel_request

static void ctw_cancel_request(void *args) {
	struct _ctw *common = args; 
	curl_multi_remove_handle(common->multi_handle, common->easy_handle);
	common->locked = 0;
	post("request cancelled.");
}
开发者ID:quahada,项目名称:PuRestJson,代码行数:6,代码来源:ctw.c


示例15: phone_to_elm

/// Append Holmes-elements for phones in (phonestr) to (eltq).
/// Returns ps->t.
unsigned phone_to_elm(phtoelm_state_t *ps, char *phonestr, dsqueue_t *eltq) {

#ifdef PHOLMES_DEBUG
  post("phone_to_elm(): called with phonestr='%s'", phonestr);
#endif

  ps->s = phonestr;
  while (ps->s && *ps->s) {
    pte_eltseq_str es = trie_lookup(&phtoelm, &(ps->s));
    if (es) {
     int n = *es++;
     while (n-- > 0) {
       int eid = *es++;             // -- index of sequence-element in Elements[]
       holmes_qelt_t he;            // -- encoded Holmes-triple for output-queue
       Elm_ptr ep = &Elements[eid]; // -- pointer to actual current element
       int dur;                     // -- placeholder for element duration

       //
       // This works because only vowels have ud != du,
       //  and we set stress just before a vowel
       //
       if (!(ep->feat & vwl)) ps->stress = 0;
       dur = StressDur(ep,ps->stress);
       he = hqeNew(eid,dur,ps->stress);

       // append the encoded element to the output queue
       dsqueue_append(eltq, (void *)he);

#ifdef PHOLMES_DEBUG
       post("phone_to_elm(): enqueued Holmes-triple %s,%d,%d", ep->name,dur,ps->stress);
#endif
     }
    }
    else {
     char ch = *(ps->s++);
     switch (ch) {
     case '\'':                // Primary stress
       ps->stress = 3;
       break;
     case ',':                 // Secondary stress
       ps->stress = 2;
       break;
     case '+':                 // Tertiary stress
       ps->stress = 1;
       break;
     case '-':                 // hyphen in input
       break;
     case '.':                 // literal dot indicates end-of-utterance
       dsqueue_append(eltq, (void *)hqeNew(0,0,0));
       break;
     default:
       {
	 fprintf(stderr,
		 "phone_to_elm(): ignoring unknown character '%c'\n",
		 ch);
	 break;
       }
     }
    }
  }
  return ps->t;
}
开发者ID:megrimm,项目名称:pd-chips,代码行数:64,代码来源:phtoelm.c


示例16: socket

static void *netreceive_new(t_symbol *compatflag,
    t_floatarg fportno, t_floatarg udpflag)
{
    t_netreceive *x;
    struct sockaddr_in server;
    int sockfd, portno = fportno, udp = (udpflag != 0);
    int old = !strcmp(compatflag->s_name , "old");
    int intarg;
        /* create a socket */
    sockfd = socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0);
#if 0
    fprintf(stderr, "receive socket %d\n", sockfd);
#endif
    if (sockfd < 0)
    {
        sys_sockerror("socket");
        return (0);
    }
    server.sin_family = AF_INET;
    server.sin_addr.s_addr = INADDR_ANY;

#if 1
        /* ask OS to allow another Pd to repoen this port after we close it. */
    intarg = 1;
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
        (char *)&intarg, sizeof(intarg)) < 0)
            post("setsockopt (SO_REUSEADDR) failed\n");
#endif
#if 0
    intarg = 0;
    if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,
        &intarg, sizeof(intarg)) < 0)
            post("setsockopt (SO_RCVBUF) failed\n");
#endif
    intarg = 1;
    if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, 
                  (const void *)&intarg, sizeof(intarg)) < 0)
        post("setting SO_BROADCAST");
        /* Stream (TCP) sockets are set NODELAY */
    if (!udp)
    {
        intarg = 1;
        if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
            (char *)&intarg, sizeof(intarg)) < 0)
                post("setsockopt (TCP_NODELAY) failed\n");
    }
        /* assign server port number */
    server.sin_port = htons((u_short)portno);

        /* name the socket */
    if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
    {
        sys_sockerror("bind");
        sys_closesocket(sockfd);
        return (0);
    }
    x = (t_netreceive *)pd_new(netreceive_class);
    if (old)
    {
        /* old style, nonsecure version */
        x->x_msgout = 0;
    }
    else x->x_msgout = outlet_new(&x->x_obj, &s_anything);

    if (udp)        /* datagram protocol */
    {
        t_socketreceiver *y = socketreceiver_new((void *)x, 
            (t_socketnotifier)netreceive_notify,
                (x->x_msgout ? netreceive_doit : 0), 1);
        sys_addpollfn(sockfd, (t_fdpollfn)socketreceiver_read, y);
        x->x_connectout = 0;
    }
    else        /* streaming protocol */
    {
        if (listen(sockfd, 5) < 0)
        {
            sys_sockerror("listen");
            sys_closesocket(sockfd);
            sockfd = -1;
        }
        else
        {
            sys_addpollfn(sockfd, (t_fdpollfn)netreceive_connectpoll, x);
            x->x_connectout = outlet_new(&x->x_obj, &s_float);
        }
    }
    x->x_connectsocket = sockfd;
    x->x_nconnections = 0;
    x->x_udp = udp;

    return (x);
}
开发者ID:Gaz5700,项目名称:pd-double,代码行数:92,代码来源:x_net.c


示例17: netsend_connect

static void netsend_connect(t_netsend *x, t_symbol *hostname,
    t_floatarg fportno)
{
    struct sockaddr_in server;
    struct hostent *hp;
    int sockfd;
    int portno = fportno;
    int intarg;
    if (x->x_fd >= 0)
    {
        error("netsend_connect: already connected");
        return;
    }

        /* create a socket */
    sockfd = socket(AF_INET, x->x_protocol, 0);
#if 0
    fprintf(stderr, "send socket %d\n", sockfd);
#endif
    if (sockfd < 0)
    {
        sys_sockerror("socket");
        return;
    }
    /* connect socket using hostname provided in command line */
    server.sin_family = AF_INET;
    hp = gethostbyname(hostname->s_name);
    if (hp == 0)
    {
        post("bad host?\n");
        return;
    }
#if 0
    intarg = 0;
    if (setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF,
        &intarg, sizeof(intarg)) < 0)
            post("setsockopt (SO_RCVBUF) failed\n");
#endif
    intarg = 1;
    if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, 
                  (const void *)&intarg, sizeof(intarg)) < 0)
        post("setting SO_BROADCAST");
        /* for stream (TCP) sockets, specify "nodelay" */
    if (x->x_protocol == SOCK_STREAM)
    {
        intarg = 1;
        if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
            (char *)&intarg, sizeof(intarg)) < 0)
                post("setsockopt (TCP_NODELAY) failed\n");
    }
    memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);

    /* assign client port number */
    server.sin_port = htons((u_short)portno);

    post("connecting to port %d", portno);
        /* try to connect.  LATER make a separate thread to do this
        because it might block */
    if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
    {
        sys_sockerror("connecting stream socket");
        sys_closesocket(sockfd);
        return;
    }
    x->x_fd = sockfd;
    outlet_float(x->x_obj.ob_outlet, 1);
}
开发者ID:Gaz5700,项目名称:pd-double,代码行数:67,代码来源:x_net.c


示例18: object_alloc

// function to create new instance and initialise its parameters
void *drag_new(t_symbol *s, short argc, t_atom *argv)
{
    t_double bound_lo = -1.0, bound_hi = 1.0;
    t_int i = 0, dir = -1;
    t_drag *x = object_alloc(drag_class); // set aside memory for the struct for the object

    x->mode = 0;
    x->drag = DRAG_DEFAULT;
    x->dragCurve = DRAGCURVE;
    x->maxcrash = log(CRASHMAX);
    x->fmax = FMAX * 0.5;
    x->bound_lo = bound_lo;
    x->bound_hi = bound_hi;
    atom_arg_getlong(&(x->voice_count), 0, argc, argv);
    atom_arg_getdouble(&(x->bound_lo), 1, argc, argv);
    atom_arg_getdouble(&(x->bound_hi), 2, argc, argv);
    x->mode = atom_getintarg(3,argc,argv);
    if(x->mode < 0) x->mode = 0;
    else if (x->mode > 4) x->mode = 4;
    atom_arg_getdouble(&(x->drag), 4, argc, argv);

    //protect against invalid parameters
    if(x->voice_count > MAX_VOICES) {
        x->voice_count = MAX_VOICES;
    } else if (x->voice_count < 1) {
        x->voice_count = 1;
    }
    if (x->bound_lo < BOUND_L_MIN) x->bound_lo = BOUND_L_MIN;
    if (x->bound_hi > BOUND_H_MAX) x->bound_lo = BOUND_H_MAX;
    if(x->bound_lo >= x->bound_hi) {
        x->bound_lo = BOUND_L_MIN;
        x->bound_hi = BOUND_H_MAX;
        post("invalid args for bounds, set to %f, %f", BOUND_L_MIN, BOUND_H_MAX);
    }
    x->drag = DRAG_DEFAULT;

    // add to dsp chain, set up inlets
    dsp_setup((t_pxobject *)x, 2*x->voice_count + 2); // upper and lower bounds, plus hz and symm per voice
    x->obj.z_misc |= Z_NO_INPLACE; // force independent signal vectors

    // allocate memory for variable arrays
    x->hz = (t_double **) t_getbytes(x->voice_count * sizeof(t_double *));
    x->symm = (t_double **) t_getbytes(x->voice_count * sizeof(t_double *));
    x->out = (t_double **) t_getbytes(x->voice_count * sizeof(t_double *));
    x->hzFloat = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->hzActual = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->grad = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->ball_loc = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->crash = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->lastcrash = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->direction = (t_int *) t_getbytes(x->voice_count * sizeof(t_int));
    x->hz_conn = (t_int *) t_getbytes(x->voice_count * sizeof(t_int));
    x->symm_conn = (t_int *) t_getbytes(x->voice_count * sizeof(t_int));
    x->dcblock_on = (t_bool *) t_getbytes(x->voice_count * sizeof(t_bool));
    x->dc_prev_in = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->dc_prev_out = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->shape = (t_double *) t_getbytes(x->voice_count * sizeof(t_double));
    x->sin = (t_double *)  t_getbytes(LKTBL_LNGTH * sizeof(t_double));
    x->sinh = (t_double *)  t_getbytes(LKTBL_LNGTH * sizeof(t_double));
    x->isfree = (t_bool *) t_getbytes(x->voice_count * sizeof(t_bool));

    setup_lktables(x,0); // build lookup tables for waveshaper

    //set up outlets & and get rate for each voice from args
    x->ball_loc[0] = bound_lo + THINNESTPIPE;
    x->direction[0] = 1;
    for(i=0; i < x->voice_count; i++) {
        outlet_new((t_object *)x, "signal");

        x->shape[i] = 0.1f;
        x->grad[i] = 2;
        x->hzActual[i] = x->hzFloat[i] = 100;
        x->ball_loc[i] =  (x->ball_loc[i-1] + THINNESTPIPE); // begin near bottom of current bound
        dir *= -1,  x->direction[i] = dir;	// alternate up and down
        x->dcblock_on[i] = 0;
        x->dc_prev_in[i] = x->dc_prev_out[i] = 0.f;

    }

    // initialize remaining parameters
    x->srate = (t_double)sys_getsr();

#if DEBUG_ON == 1|| DEBUG_ON == 2
    x->poll_count = POLL_NO_SAMPLES-1;
    x->stopdebug = x->debug_count = 0;
#endif

    return x;
}
开发者ID:EQ4,项目名称:db.drag,代码行数:90,代码来源:db.drag~.c


示例19: render

/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
void vertex_combine :: render(GemState *state)
{
  int size,srcL,srcS,count,sizeR,ratio,remainder;
  GLfloat *VertexArray;
  float blendL, blendR, ratiof;

  VertexArray =state->VertexArray;
  if (state->VertexArray == NULL || state->VertexArraySize <= 0) {
    post("no vertex array!");
    return;
  }

  if (state->ColorArray == NULL ) {
    post("no color array!");
    return;
  }

  size = state->VertexArraySize;
  sizeR = m_vertCountR;

  //dumb and dirty x-fade
  blendR = m_blend;
  blendL = fabs(1.f - m_blend);

  if (size > sizeR) {
    //left is larger
    ratiof = static_cast<float>(size)/sizeR;
    ratio = size / sizeR;
    remainder = size % sizeR;
    // post("float ratio %f:1 int ratio %d:1 remainder %d",ratiof,ratio,remainder);
    int i = 0;
    srcL = 0;
    srcS = 0;
    while (i < sizeR) {
      count = 0;
      while (count < ratio) {
        VertexArray[srcL] = (VertexArray[srcL] * blendL) +
                            (m_rightVertexArray[srcS] * blendR);
        VertexArray[srcL+1] = (VertexArray[srcL+1] * blendL) +
                              (m_rightVertexArray[srcS+1] * blendR);
        VertexArray[srcL+2] = (VertexArray[srcL+2] * blendL) +
                              (m_rightVertexArray[srcS+2] * blendR);
        VertexArray[srcL+3] = (VertexArray[srcL+3] * blendL )+
                              (m_rightVertexArray[srcS+3] * blendR);
        srcL+=4;
        count++;
      }
      i++;
      srcS+=4;
    }
    state->VertexArraySize = size;
  } else {
    ratiof = static_cast<float>(sizeR)/size;
    ratio = sizeR / size;
    remainder = sizeR % size;
    post("float ratio %f:1 int ratio %d:1 remainder %d",ratiof,ratio,
         remainder);
  }

  /* -- this almost works - good for fast and dirty integer ratios
  if (size > sizeR){
      //left is larger
      ratiof = static_cast<float>(size)/sizeR;
      ratio = size / sizeR;
      remainder = size % sizeR;
     // post("float ratio %f:1 int ratio %d:1 remainder %d",ratiof,ratio,remainder);
      i = 0;
      srcL = 0;
      srcS = 0;
      while (i < sizeR) {
          count = 0;
          while (count < ratio){
              VertexArray[srcL] = (VertexArray[srcL] * blendL) + (m_rightVertexArray[srcS] * blendR);
              VertexArray[srcL+1] = (VertexArray[srcL+1] * blendL) + (m_rightVertexArray[srcS+1] * blendR);
              VertexArray[srcL+2] = (VertexArray[srcL+2] * blendL) + (m_rightVertexArray[srcS+2] * blendR);
              VertexArray[srcL+3] = (VertexArray[srcL+3] * blendL )+ (m_rightVertexArray[srcS+3] * blendR);
              srcL+=4;
              count++;
          }
          i++;
          srcS+=4;
      }
      state->VertexArraySize = size;
  }else{
      ratiof = static_cast<float>(sizeR)/size;
      ratio = sizeR / size;
      remainder = sizeR % size;
      post("float ratio %f:1 int ratio %d:1 remainder %d",ratiof,ratio,remainder);
  }
  */

}
开发者ID:umlaeute,项目名称:Gem,代码行数:96,代码来源:vertex_combine.cpp


示例20: post

static t_symbol *iem_image_calc_size(t_iem_image *x)
{
    char dirbuf[MAXPDSTRING], *namebufptr;
    char namebuf[MAXPDSTRING];
    unsigned char buf[222];
    unsigned int i;
    char *c;
    int fd;
    FILE *fh;
    size_t items;

    if(!x->x_gifsym || !x->x_gifsym->s_name)
    {
        post("iem_image-ERROR: no gifname");
        x->x_gifsym = (t_symbol *)0;
        return((t_symbol *)0);
    }
    fd = open_via_path(canvas_getdir(glist_getcanvas(x->x_gui.x_glist))->s_name, x->x_gifsym->s_name,
                       "", dirbuf, &namebufptr, MAXPDSTRING, 1);
    if (fd < 0)
    {
        post("iem_image-ERROR: cannot open %s first time", x->x_gifsym->s_name);
        x->x_gifsym = (t_symbol *)0;
        return((t_symbol *)0);
    }
    else
    {
        if(fd >= 0)
            close(fd);
        strcpy(namebuf, dirbuf);
        strcat(namebuf, "/");
        strcat(namebuf, namebufptr);
        fh = fopen(namebuf, "r");
        if(fh == NULL)
        {
            post("iem_image-ERROR: cannot open %s second time", namebuf);
            x->x_gifsym = (t_symbol *)0;
            return((t_symbol *)0);
        }
        else
        {
            items=fread(buf, 22, sizeof(unsigned char), fh);
            if((items < 1)||(strlen((char*)buf)<7)) {
                post("iem_image-ERROR: can not read header in %s, only %d items read: %s.", namebuf, strlen((char*)buf), (char*) buf);
                x->x_gifsym = (t_symbol *)0;
                return((t_symbol *)0);
            };
            fclose(fh);
            c = (char *)buf;
            if((c[0] != 'G')||(c[1] != 'I')||(c[2] != 'F'))
            {
                post("iem_image-ERROR: %s is not a GIF-file", namebuf);
                x->x_gifsym = (t_symbol *)0;
                return((t_symbol *)0);
            }
            i = 256*(unsigned int)buf[7];
            i += (unsigned int)buf[6];
            x->x_gui.x_w = (int)i;
            i = 256*(unsigned int)buf[9];
            i += (unsigned int)buf[8];
            x->x_gui.x_h = (int)i;
            SETFLOAT(x->x_at_out, (t_float)x->x_gui.x_w);
            SETFLOAT(x->x_at_out+1, (t_float)x->x_gui.x_h);
            outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at_out);
            if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
                pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at_out);
            return(gensym(namebuf));
        }
    }
}
开发者ID:Tzero2,项目名称:pd,代码行数:70,代码来源:iem_image.c



注:本文中的post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ postEvent函数代码示例发布时间:2022-05-30
下一篇:
C++ possiblyHasMarkers函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap