当前位置: 首页>>代码示例>>C++>>正文


C++ LIMIT函数代码示例

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


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

示例1: Resize

void Resize(Window w, unsigned width, unsigned height)
{
    if (w != topWindow)
	return;

    /* ignore illegal resizes */
    LIMIT(width, MIN_TOP_WIDTH, MAX_TOP_WIDTH);
    LIMIT(height, MIN_TOP_HEIGHT, MAX_TOP_HEIGHT);
    top_width = width;
    top_height = height;
    if (!drawWindow)
	return;

    if (radar_score_mapped)
	draw_width = top_width - 258;
    else
	draw_width = top_width;
    draw_height = top_height;

    Check_view_dimensions();
    Net_flush();
    XResizeWindow(dpy, drawWindow, draw_width, draw_height);
    if (dbuf_state->type == PIXMAP_COPY) {
	XFreePixmap(dpy, drawPixmap);
	drawPixmap = XCreatePixmap(dpy, drawWindow, draw_width, draw_height,
				   dispDepth);
    }
    players_height = top_height - (RadarHeight + ButtonHeight + 2);
    XResizeWindow(dpy, playersWindow,
		  players_width, players_height);
    Talk_resize();
    Config_resize();
}
开发者ID:calumchisholm,项目名称:XPilotNG-web,代码行数:33,代码来源:xinit.c

示例2: run_adding_AutoPan

void 
run_adding_AutoPan(LADSPA_Handle Instance,
		   unsigned long SampleCount) {
  
	AutoPan * ptr = (AutoPan *)Instance;

	LADSPA_Data * input_L = ptr->input_L;
	LADSPA_Data * input_R = ptr->input_R;
	LADSPA_Data * output_L = ptr->output_L;
	LADSPA_Data * output_R = ptr->output_R;
	LADSPA_Data freq = LIMIT(*(ptr->freq),0.0f,20.0f);
	LADSPA_Data depth = LIMIT(*(ptr->depth),0.0f,100.0f);
	LADSPA_Data gain = db2lin(LIMIT(*(ptr->gain),-70.0f,20.0f));
	unsigned long sample_index;
	LADSPA_Data phase_L = 0;
	LADSPA_Data phase_R = 0;
	
	for (sample_index = 0; sample_index < SampleCount; sample_index++) {
		phase_L = 1024.0f * freq * sample_index / ptr->SampleRate + ptr->Phase;
		while (phase_L >= 1024.0f)
		        phase_L -= 1024.0f;  
 		phase_R = phase_L + 512.0f;
		while (phase_R >= 1024.0f)
		        phase_R -= 1024.0f;  

		*(output_L++) += *(input_L++) * gain * ptr->run_adding_gain *
			(1 - 0.5*depth/100 + 0.5 * depth/100 * cos_table[(unsigned long) phase_L]);
		*(output_R++) += *(input_R++) * gain * ptr->run_adding_gain *
			(1 - 0.5*depth/100 + 0.5 * depth/100 * cos_table[(unsigned long) phase_R]);
	}
	ptr->Phase = phase_L;
	while (ptr->Phase >= 1024.0f)
		ptr->Phase -= 1024.0f;
}
开发者ID:EQ4,项目名称:tap-plugins,代码行数:34,代码来源:tap_autopan.c

示例3: run_adding_Tremolo

void 
run_adding_Tremolo(LADSPA_Handle Instance,
		   unsigned long SampleCount) {
  
	LADSPA_Data * input;
	LADSPA_Data * output;
	LADSPA_Data freq;
	LADSPA_Data depth;
	LADSPA_Data gain;
	Tremolo * ptr;
	unsigned long sample_index;
	LADSPA_Data phase = 0.0f;
	
	ptr = (Tremolo *)Instance;
	
	input = ptr->InputBuffer_1;
	output = ptr->OutputBuffer_1;
	freq = LIMIT(*(ptr->Control_Freq),0.0f,20.0f);
	depth = LIMIT(*(ptr->Control_Depth),0.0f,100.0f);
	gain = db2lin(LIMIT(*(ptr->Control_Gain),-70.0f,20.0f));

  	for (sample_index = 0; sample_index < SampleCount; sample_index++) {
		phase = 1024.0f * freq * sample_index / ptr->SampleRate + ptr->Phase;

		while (phase >= 1024.0f)
			phase -= 1024.0f;

		*(output++) += *(input++) * ptr->run_adding_gain * gain *
			(1 - 0.5*depth/100 + 0.5 * depth/100 * cos_table[(unsigned long) phase]);
	}
	ptr->Phase = phase;
	while (ptr->Phase >= 1024.0f)
		ptr->Phase -= 1024.0f;
}
开发者ID:AHudon,项目名称:SOEN6471_LMMS,代码行数:34,代码来源:tap_tremolo.c

示例4: run_Tremolo

void
run_Tremolo(LV2_Handle Instance,
	    uint32_t SampleCount) {

	float * input;
	float * output;
	float freq;
	float depth;
	float gain;
	Tremolo * ptr;
	double sample_index;
	float phase = 0.0f;

	ptr = (Tremolo *)Instance;

	input = ptr->InputBuffer_1;
	output = ptr->OutputBuffer_1;
	freq = LIMIT(*(ptr->Control_Freq),0.0f,20.0f);
	depth = LIMIT(*(ptr->Control_Depth),0.0f,100.0f);
	gain = db2lin(LIMIT(*(ptr->Control_Gain),-70.0f,20.0f));

  	for (sample_index = 0; sample_index < SampleCount; sample_index++) {
		phase = 1024.0f * freq * sample_index / ptr->SampleRate + ptr->Phase;

		while (phase >= 1024.0f)
			phase -= 1024.0f;

		*(output++) = *(input++) * gain *
			(1 - 0.5*depth/100 + 0.5 * depth/100 * cos_table[(unsigned long) phase]);
	}
	ptr->Phase = phase;
	while (ptr->Phase >= 1024.0f)
		ptr->Phase -= 1024.0f;
}
开发者ID:pjotrompet,项目名称:tap-lv2,代码行数:34,代码来源:tap_tremolo.c

示例5: run_adding_Vibrato

void 
run_adding_Vibrato(LADSPA_Handle Instance,
		   unsigned long SampleCount) {
  
	Vibrato * ptr = (Vibrato *)Instance;

	LADSPA_Data freq = LIMIT(*(ptr->freq),0.0f,PM_FREQ);
	LADSPA_Data depth = 
		LIMIT(LIMIT(*(ptr->depth),0.0f,20.0f) * ptr->sample_rate / 200.0f / M_PI / freq,
		      0, ptr->buflen / 2);
	LADSPA_Data drylevel = db2lin(LIMIT(*(ptr->drylevel),-90.0f,20.0f));
	LADSPA_Data wetlevel = db2lin(LIMIT(*(ptr->wetlevel),-90.0f,20.0f));
	LADSPA_Data * input = ptr->input;
	LADSPA_Data * output = ptr->output;

	unsigned long sample_index;
	unsigned long sample_count = SampleCount;

	LADSPA_Data in = 0.0f;
	LADSPA_Data phase = 0.0f;
	LADSPA_Data fpos = 0.0f;
	LADSPA_Data n = 0.0f;
	LADSPA_Data rem = 0.0f;
	LADSPA_Data s_a, s_b;


	if (freq == 0.0f)
		depth = 0.0f;

	for (sample_index = 0; sample_index < sample_count; sample_index++) {

		in = *(input++);

		phase = COS_TABLE_SIZE * freq * sample_index / ptr->sample_rate + ptr->phase;
		while (phase >= COS_TABLE_SIZE)
		        phase -= COS_TABLE_SIZE;

		push_buffer(in, ptr->ringbuffer, ptr->buflen, &(ptr->pos));

		fpos = depth * (1.0f - cos_table[(unsigned long) phase]);
		n = floorf(fpos);
		rem = fpos - n;

		s_a = read_buffer(ptr->ringbuffer, ptr->buflen, ptr->pos, (unsigned long) n);
		s_b = read_buffer(ptr->ringbuffer, ptr->buflen, ptr->pos, (unsigned long) n + 1);

		*(output++) += ptr->run_adding_gain * wetlevel * ((1 - rem) * s_a + rem * s_b) +
			drylevel * read_buffer(ptr->ringbuffer, ptr->buflen,
					       ptr->pos, ptr->buflen / 2);

	}

	ptr->phase += COS_TABLE_SIZE * freq * sample_index / ptr->sample_rate;
	while (ptr->phase >= COS_TABLE_SIZE)
		ptr->phase -= COS_TABLE_SIZE;

	*(ptr->latency) = ptr->buflen / 2;
}
开发者ID:AHudon,项目名称:SOEN6471_LMMS,代码行数:58,代码来源:tap_vibrato.c

示例6: revers_filter

unsigned int	revers_filter(unsigned int color, UNUSED t_opt *opt)
{
  unsigned char	comp[3];

  decomp_color(color, comp);
  comp[0] = LIMIT(2.0 * (128 - comp[0]) + comp[0], 0, 255);
  comp[1] = LIMIT(2.0 * (128 - comp[1]) + comp[1], 0, 255);
  comp[2] = LIMIT(2.0 * (128 - comp[2]) + comp[2], 0, 255);
  return (recomp_color(comp));
}
开发者ID:Tastyep,项目名称:rt,代码行数:10,代码来源:other_filter.c

示例7: i80286_data_descriptor_full

static void i80286_data_descriptor_full(i80286_state *cpustate, int reg, UINT16 selector, int cpl, UINT32 trap, UINT16 offset, int size)
{
	if (PM) {
		UINT16 desc[3];
		UINT8 r;
		UINT32 addr;
		/* selector format
           15..3 number/address in descriptor table
           2: 0 global, 1 local descriptor table
           1,0: requested privileg level
           must be higher or same as current privileg level in code selector */
		if ((reg != SS) && !IDXTBL(selector)) {
			cpustate->sregs[reg]=0;
			cpustate->limit[reg]=0;
			cpustate->base[reg]=0;
			cpustate->rights[reg]=0;
			cpustate->valid[reg]=0;
			return;
		}

		if ((addr = i80286_selector_address(cpustate,selector)) == -1) throw trap;

		desc[0] = ReadWord(addr);
		desc[1] = ReadWord(addr+2);
		desc[2] = ReadWord(addr+4);
		r = RIGHTS(desc);
		if (!SEGDESC(r)) throw trap;
		if (reg == SS) {
			if (!IDXTBL(selector)) throw trap;
			if (DPL(r)!=cpl) throw trap;
			if (RPL(selector)!=cpl) throw trap;
			if (!RW(r) || CODE(r)) throw trap;
			if (!PRES(r)) throw TRAP(STACK_FAULT,(IDXTBL(selector)+(trap&1)));
		} else {
			if ((DPL(r) < PMAX(cpl,RPL(selector))) && (!CODE(r) || (CODE(r) && !CONF(r)))) throw trap;
			if (CODE(r) && !READ(r)) throw trap;
			if (!PRES(r)) throw TRAP(SEG_NOT_PRESENT,(IDXTBL(selector)+(trap&1)));
		}
		if (offset+size) {
			if ((CODE(r) || !EXPDOWN(r)) && ((offset+size-1) > LIMIT(desc))) throw (reg==SS)?TRAP(STACK_FAULT,(trap&1)):trap;
			if (!CODE(r) && EXPDOWN(r) && ((offset <= LIMIT(desc)) || ((offset+size-1) > 0xffff))) throw (reg==SS)?TRAP(STACK_FAULT,(trap&1)):trap;
		}

		SET_ACC(desc);
		WriteWord(addr+4, desc[2]);
		cpustate->sregs[reg]=selector;
		cpustate->limit[reg]=LIMIT(desc);
		cpustate->base[reg]=BASE(desc);
		cpustate->rights[reg]=RIGHTS(desc);
	} else {
		cpustate->sregs[reg]=selector;
		cpustate->base[reg]=selector<<4;
	}
	cpustate->valid[reg]=1;
}
开发者ID:NastyNoah,项目名称:groovyarcade.groovymame,代码行数:55,代码来源:instr286.c

示例8: fandFilter

/**
 * @brief AND each 
 *
 * @param dataOut
 * @param dataIn
 * @param row
 * @param col
 * @param step
 * @param KernelArray
 * @param m
 * @param n
 */
void fandFilter (char *dataOut, char *dataIn, int row,int col,int step,int* KernelArray,int m,int n )
{
    unsigned char bits[9] ;
    int flag[3];
    if(KernelArray == 0) return ;
    for(int rgb =0;rgb < 3;rgb++){
    bits[0] = LIMIT(dataIn P(row-1,col-1,step,rgb));
    bits[1] = LIMIT(dataIn P(row-1,col,  step,rgb));
    bits[2] = LIMIT(dataIn P(row-1,col+1,step,rgb));
    bits[3] = LIMIT(dataIn P(row  ,col-1,step,rgb));
    bits[4] = LIMIT(dataIn P(row  ,col  ,step,rgb));
    bits[5] = LIMIT(dataIn P(row  ,col+1,step,rgb));
    bits[6] = LIMIT(dataIn P(row+1,col-1,step,rgb));
    bits[7] = LIMIT(dataIn P(row+1,col  ,step,rgb));
    bits[8] = LIMIT(dataIn P(row+1,col+1,step,rgb));
    
    flag[rgb] = (bits[4] * KA[4] ) ^ ( ( bits[1] * KA[1] ) |
                                  ( bits[3] * KA[3] ) |
                                  ( bits[5] * KA[5] ) |
                                  ( bits[7] * KA[7] ) );
    //if(flag) 
    //    dataOutP(row,col,step,rgb) = 255;
    //else
    //    dataOutP(row,col,step,rgb) = 0;
    }
    if(flag[0] | flag[1] | flag[2]){
            dataOutP(row,col,step,0) = 0;
            dataOutP(row,col,step,1) = 0;
            dataOutP(row,col,step,2) = 0;
    }else{
            dataOutP(row,col,step,0) =  dataInP(row,col,step,0);
            dataOutP(row,col,step,1) =dataInP(row,col,step,1);
            dataOutP(row,col,step,2) =dataInP(row,col,step,2);
    }
}
开发者ID:maverick0122,项目名称:vas,代码行数:47,代码来源:filterKernel.cpp

示例9: gamma_filter

unsigned int	gamma_filter(unsigned int color, double gamma)
{
  unsigned char	comp[3];

  gamma = 1.0 / gamma;
  decomp_color(color, comp);
  comp[0] = LIMIT(encode_srgb(comp[0], gamma), 0, 255);
  comp[1] = LIMIT(encode_srgb(comp[1], gamma), 0, 255);
  comp[2] = LIMIT(encode_srgb(comp[2], gamma), 0, 255);
  return (recomp_color(comp));
}
开发者ID:Tastyep,项目名称:rt,代码行数:11,代码来源:filter.c

示例10: SetPwm_5

void SetPwm_5(int16_t pwm_3,int16_t pwm_4,s16 min,s16 max)
{
	s16 pwm_tem_3,pwm_tem_4;
	
	pwm_tem_3 = pwm_3 ;
	pwm_tem_3 = LIMIT(pwm_tem_3,min,max);
	pwm_tem_4 = pwm_4 ;
	pwm_tem_4 = LIMIT(pwm_tem_4,min,max);
	
 	TIM5->CCR4 = pwm_tem_4 + INIT_DUTY;				//4	
 	TIM5->CCR3 = pwm_tem_3 + INIT_DUTY;				//3	
}
开发者ID:DoctorKey,项目名称:camera,代码行数:12,代码来源:pwm_out.c

示例11: audio_callback

void audio_callback(void* data, Uint8* stream, int length)
{
    int j;
    SDL_AudioSpec spec = *((SDL_AudioSpec*)data);
    float factor = 126.f;
    if(stuff[i]) {
        int totl = spec.freq / (stuff[i]/2);
        switch(method) {
        case SQUARE:
            for(j = 0; j < length; ++j) {
                // half the period output MAX
                if(k < totl/2) {
                    stream[j] = factor;
                // half output 0
                } else {
                    stream[j] = 0;
                }
                k = (k + 1) % totl;
            }
            break;
        case TRIANGLE:
            for(j = 0; j < length; ++j) {
                // first quarter-period, increasing linear function [0..MAX]
                if(k < totl/4) {
                    stream[j] = (Uint8)LIMIT(factor * ((float)k / (totl/4.f)));
                // second and third quarters, decreasing linear function [MAX..-MAX]
                } else if(k < 3*totl/4) {
                    stream[j] = (Uint8)LIMIT(factor * (
                                ((float)totl/2.f - (float)k)/(totl/4.f)));
                // fourth quarter, increasing linear function [-MAX..0]
                } else {
                    stream[j] = (Uint8)LIMIT(factor * (
                                (float)(k - totl) / (totl/4.)));
                }
                k = (k + 1) % totl;
            }
            break;
        case SINE:
            for(j = 0; j < length; ++j) {
                // I don't understand what the deal with the frequency is
                //     that I DON'T have to multiply by 2 here...
                // Anyway, compared with a reference sound and indeed this
                //     is the correct frequency (somehow)
                stream[j] = (Uint8)(factor * sin(k * stuff[i] * M_PI / (float)spec.freq));
                k = (k + 1) % totl;
            }
            break;
        }
    } else {
        // if we aren't supposed to output any sound, set the buffer to 0
        memset(stream, 0, length);
    }
}
开发者ID:alzwded,项目名称:etc,代码行数:53,代码来源:sound1.c

示例12: question

void question(int x) {
  MIN(x++, 12);
  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: side effects in the 1st macro argument 'A'
  MIN(34, x++);
  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: side effects in the 2nd macro argument 'B'
  LIMIT(x++, 0, 100);
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: side effects in the 1st macro argument 'X'
  LIMIT(20, x++, 100);
  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: side effects in the 2nd macro argument 'A'
  LIMIT(20, 0, x++);
  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: side effects in the 3rd macro argument 'B'
}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:12,代码来源:misc-repeated-side-effects-in-macro.c

示例13: saturation

unsigned int	saturation(unsigned int color, double val)
{
  double	pert;
  unsigned char	comp[3];

  decomp_color(color, comp);
  pert = sqrt(comp[0] * comp[0] * 0.299 + comp[1] * comp[1] * 0.587
	      + comp[2] * comp[2] * 0.114);
  comp[0] = LIMIT(pert + (comp[0] - pert) * val, 0 , 255);
  comp[1] = LIMIT(pert + (comp[1] - pert) * val, 0 , 255);
  comp[2] = LIMIT(pert + (comp[2] - pert) * val, 0 , 255);
  return (recomp_color(comp));
}
开发者ID:Tastyep,项目名称:rt,代码行数:13,代码来源:other_filter.c

示例14: apply_contrast

unsigned int	apply_contrast(unsigned int color, t_opt *opt)
{
  unsigned char	comp[3];

  decomp_color(color, comp);
  comp[0] = LIMIT((((double)comp[0] / 255 - 0.5) * opt->contrast + 0.5)
                  * 255, 0, 255);
  comp[1] = LIMIT((((double)comp[1] / 255 - 0.5) * opt->contrast + 0.5)
                  * 255, 0, 255);
  comp[2] = LIMIT((((double)comp[2] / 255 - 0.5) * opt->contrast + 0.5)
                  * 255, 0, 255);
  return (recomp_color(comp));
}
开发者ID:Tastyep,项目名称:rt,代码行数:13,代码来源:other_filter.c

示例15: LIMIT

	void SimpleVolumeMeter::setValue( float peak, float hold )
	{
		LIMIT( peak, 0.f, 1.f );
		LIMIT( hold, 0.f, 1.f );
	
		if( m_bStereo || m_peak[0] != peak || m_hold[0] != hold )
		{
			m_bStereo = false;
			m_peak[0] = peak;
			m_hold[0] = hold;
			_requestRender();
		}
	}
开发者ID:tempbottle,项目名称:WonderGUI,代码行数:13,代码来源:wg_simplevolumemeter.cpp


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