Example #1
0
// This kicks everything off
int cpu_sucker( int on_time, int off_time ) 
{
  int pid, child_pid;

  pid = getpid();
  modPid = getpid();

  if (child_pid = fork()) {
    int RC;
    RC = set_schedule( modPid, 2 );
    if (RC != 0) {
      kill( child_pid, SIGKILL );
      return RC;
    }

    childPid = child_pid;
    RC = set_schedule( childPid, 1);
    if (RC != 0) {
      kill( childPid, SIGKILL );
      return RC;
    }

    modulate( childPid, on_time, off_time );
    return 0;
  } else {
    suck_cpu();
    return 0;
  }
}
Example #2
0
TEST(RealVectorMethods, Modulate) {
    double inputData[] = {1, 0, -1, -2, -3, -4, -5, -6, -7};
    double expectedData[] = {0.86602540,0.00000000,0.95931397,-1.27484798,-1.37129378,3.99025620,-1.64433323,-4.43073204,6.37478563};
    unsigned numElements = sizeof(expectedData)/sizeof(expectedData[0]);
	NimbleDSP::RealVector<double> buf(inputData, numElements);
    
    modulate(buf, 283.0, 900.0, M_PI/3);
    EXPECT_EQ(numElements, buf.size());
    for (unsigned i=0; i<buf.size(); i++) {
        EXPECT_TRUE(FloatsEqual(expectedData[i], buf[i]));
    }
}
Example #3
0
 void processAudio(AudioBuffer &buffer){
   int size = buffer.getSize();
   unsigned int delaySamples;
     
   rate     = getParameterValue(PARAMETER_A) * 0.000005f; // flanger needs slow rate
   depth    = getParameterValue(PARAMETER_B);
   feedback = getParameterValue(PARAMETER_C)* 0.707; // so we keep a -3dB summation of the delayed signal
     
   for (int ch = 0; ch<buffer.getChannels(); ++ch) {
       for (int i = 0 ; i < size; i++) {
           float* buf = buffer.getSamples(ch);
           delaySamples = (depth * modulate(rate)) * (delayBuffer.getSize()-1); // compute delay according to rate and depth
           buf[i] += feedback * delayBuffer.read(delaySamples); // add scaled delayed signal to dry signal
           delayBuffer.write(buf[i]); // update delay buffer
       }
   }
 }
Example #4
0
int work(void **inp, void **out) {
	int i, out_len;
	input_t *input;
	output_t *output;

	param_get_int(modulation_id,&modulation);

	for (i=0;i<NOF_INPUT_ITF;i++) {
		input = inp[i];
		output = out[i];

		if (get_input_samples(i)) {
			out_len = modulate(input,output,get_input_samples(i));
			if (out_len == -1) {
				return -1;
			}
			set_output_samples(i,out_len);
		}
	}
	return 0;
}
Example #5
0
void Image_controls::set_thumbnail(const Image_buffer<rendering::Color4>& source, uint32_t channel, bool inverted, float modulate_factor)
{
	Image_buffer<rendering::Color4>& scratch_buffer = thumbnail_provider_->scratch_buffer();

	Channel_to_grayscale<rendering::Color4> to_grayscale(channel);
	to_grayscale.filter(scratch_buffer, source);

	if (inverted)
	{
		Invert<rendering::Color4> invert;
		invert.filter(scratch_buffer, scratch_buffer);
	}

	if (1.f != modulate_factor)
	{
		Modulate modulate(modulate_factor);
		modulate.filter(scratch_buffer, scratch_buffer);
	}

	const uint2& source_dimensions = source.dimensions();
	const uint2& thumbnail_dimensions = thumbnail_.dimensions();

	if (source_dimensions.x < thumbnail_dimensions.x || source_dimensions.y < thumbnail_dimensions.y)
	{
		Copy<rendering::Color4c> copy;
		copy.filter(thumbnail_, thumbnail_provider_->checkerboard());
	}

	// No need to swap channels for Qt here, as it is grayscale
	To_BGRA filter(false);
	filter.filter(thumbnail_, scratch_buffer, source.dimensions());

	QImage qimage(reinterpret_cast<const uchar*>(thumbnail_.data()),
				  thumbnail_dimensions.x, thumbnail_dimensions.y, QImage::Format_RGB32);

	QPixmap pixmap = QPixmap::fromImage(qimage);

	ui->image_label_->setPixmap(pixmap);
}
Example #6
0
cvec qam_mod::process(bvec ce, ivec x)
{
 cvec y;	
 int N;
 ivec iv;
 cvec cv;

	#if (DEBUG_LEVEL==3)
	cout << "***** qam_mod::process *****" << endl;	
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	sleep(1000);
	#endif

	iv.set_length(1);
	cv.set_length(1);
	N=ce.length();
	y.set_length(N);
	if (x.length()!=N) {
		throw sci_exception("qam_mod::process - ce.size <> x.size", x.length() );
	}	
	for (int i=0; i<N; i++) {
		if ( bool(ce[i])) {
			iv[0]  = x[i];
			cv = modulate(iv);
			y0 = scale * cv[0];
		}
		y[i]=y0;
	}

	#if (DEBUG_LEVEL==3)
	cout << "y=" << y << endl;
	cout << "+++++ qam_mod::process +++++" << endl;	
	sleep(1000);
	#endif

	return (y);
}
Example #7
0
void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {

	Item *ci = p_canvas_item;

	if (!ci->visible)
		return;

	Rect2 rect = ci->get_rect();
	Transform2D xform = p_transform * ci->xform;
	Rect2 global_rect = xform.xform(rect);
	global_rect.pos += p_clip_rect.pos;

	if (ci->use_parent_material && p_material_owner)
		ci->material_owner = p_material_owner;
	else {
		p_material_owner = ci;
		ci->material_owner = NULL;
	}

	Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a);

	if (modulate.a < 0.007)
		return;

	int child_item_count = ci->child_items.size();
	Item **child_items = (Item **)alloca(child_item_count * sizeof(Item *));
	copymem(child_items, ci->child_items.ptr(), child_item_count * sizeof(Item *));

	if (ci->clip) {
		if (p_canvas_clip != NULL) {
			ci->final_clip_rect = p_canvas_clip->final_clip_rect.clip(global_rect);
		} else {
			ci->final_clip_rect = global_rect;
		}
		ci->final_clip_owner = ci;

	} else {
		ci->final_clip_owner = p_canvas_clip;
	}

	if (ci->sort_y) {

		SortArray<Item *, ItemPtrSort> sorter;
		sorter.sort(child_items, child_item_count);
	}

	if (ci->z_relative)
		p_z = CLAMP(p_z + ci->z, VS::CANVAS_ITEM_Z_MIN, VS::CANVAS_ITEM_Z_MAX);
	else
		p_z = ci->z;

	for (int i = 0; i < child_item_count; i++) {

		if (!child_items[i]->behind)
			continue;
		_render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
	}

	if (ci->copy_back_buffer) {

		ci->copy_back_buffer->screen_rect = xform.xform(ci->copy_back_buffer->rect).clip(p_clip_rect);
	}

	if ((!ci->commands.empty() && p_clip_rect.intersects(global_rect)) || ci->vp_render || ci->copy_back_buffer) {
		//something to draw?
		ci->final_transform = xform;
		ci->final_modulate = Color(modulate.r * ci->self_modulate.r, modulate.g * ci->self_modulate.g, modulate.b * ci->self_modulate.b, modulate.a * ci->self_modulate.a);
		ci->global_rect_cache = global_rect;
		ci->global_rect_cache.pos -= p_clip_rect.pos;
		ci->light_masked = false;

		int zidx = p_z - VS::CANVAS_ITEM_Z_MIN;

		if (z_last_list[zidx]) {
			z_last_list[zidx]->next = ci;
			z_last_list[zidx] = ci;

		} else {
			z_list[zidx] = ci;
			z_last_list[zidx] = ci;
		}

		ci->next = NULL;
	}

	for (int i = 0; i < child_item_count; i++) {

		if (child_items[i]->behind)
			continue;
		_render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
	}
}
Example #8
0
int main()
{
	srand (time(NULL));
	int i,j;
	double sigma;


	unsigned int *X = random_X (NUM_BLOCKS*NUM_CARRIERS);

	complex_table *IP_SIG = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (IP_SIG,NUM_CARRIERS,NUM_BLOCKS,"IP_SIG");
	
    create_IP_BLOCKS (IP_SIG,X,ALPHA,PI);
	
	

	complex_table *CARRIERS = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (CARRIERS,NUM_BLOCKS,NUM_CARRIERS,"CARRIERS");

	create_CARRIERS (CARRIERS);
	print_table (CARRIERS);
	


	complex_table *CARRIERST = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (CARRIERST,NUM_CARRIERS,NUM_BLOCKS,"CARRIERST");

	TRANSPOSE (CARRIERS,CARRIERST);
	//print_table (CARRIERST);
	
	
	//printf("\nrows : %d\tcolumns : %d",CARRIERST->rows,CARRIERST->columns);
	
	
	complex_table *CORRELATION = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (CORRELATION,CARRIERST->columns,CARRIERST->columns,"CORRELATION");

	CORRELATET (CARRIERST,CORRELATION);
	//print_table (CORRELATION);
	

	complex_table *MODI = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (MODI,NUM_BLOCKS,NUM_BLOCKS,"MODI");

	modulate (MODI,CARRIERS,IP_SIG);
	sigma = complex_sigma (MODI); 

	complex_table *AWGN = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (AWGN,NUM_BLOCKS*OVERSAMPLING,NUM_BLOCKS,"AWGN");
	create_noise (AWGN,Eb,sigma,OVERSAMPLING);
	
	complex_table *NOISY = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (NOISY,NUM_BLOCKS,NUM_BLOCKS*OVERSAMPLING,"NOISY");

	//	printf("\nhere\n");
	//	create_noisy (NOISY,AWGN,MODI);

	complex_addition (NOISY,AWGN,MODI);


	complex_table *INVERSE = (complex_table *) malloc (sizeof(complex_table));
	complex_table_init (INVERSE,CORRELATION->rows,CORRELATION->columns,"INVERSE");

	complex_idenity_init (INVERSE);
	
	
	complex_inverse (CORRELATION,INVERSE);
	
	//print_table (CORRELATION);

	

	
	
	/*for (i=0;i<NUM_BLOCKS;i++) {
		o = column_from_table (IP_SIG,i);
		complex_Ax (CARRIERS,SYMBOL,IP_BLOCK);
		list_to_table (MODI,SYMBOL,i);	
	}*/
	

	//inverse (CORRELATION,INVERSE);
		
	
	// send result to table :end of loop calculate sigma
	
	
	/*complex_list *IP_BLOCK = (complex_list *) malloc (sizeof(complex_list));
	complex_list_init (IP_BLOCK);*/
		
	
	//	printf("\t%d\t%d\t:\t%.5lf\t%.5lf\t\n",mynode->col,mynode->row,mynode->real,mynode->imag);

	//complex_table *SYMBOL_MODI = create_SYMBOL_MODI (CARRIERS,IP_BLOCK);

	//complex_list *SEFDM_SYMBOL = (complex_list *) malloc (sizeof(complex_list));
	//A_complex_x (CARRIERS,SEFDM_SYMBOL,IP_BLOCK);

	//double SEFDM_SQUARED = complex


	
	printf("\n\n");
	printf("NUM_CARRIERS :\t\t%d \n",NUM_CARRIERS);
	printf("MODULATION_LEVEL :\t%d \n",MODULATION_LEVEL);
	printf("NUM_BLOCKS :\t\t%d \n",NUM_BLOCKS);
	printf("ALPHA :\t\t\t%d \n",ALPHA);
	printf("OVERSAMPLING :\t\t%d \n",OVERSAMPLING);
	printf("Eb :\t\t\t%d \n",Eb);
	
	//print_table (CARRIERS);
	//print_table (CORRELATION);
	
	/*
	print_table (IP_SIG);
	print_table (CARRIERS);
	print_table (CORRELATION);
	print_table (MODI);
	print_table (AWGN);
	print_table (NOISY);
	print_table (INVERSE);
	*/
	
	return 0;
}
// virtual
Signal
BluetoothTransmitter::transmit(const Bits& input,
                               double df) {
    return modulate(input, df);
}
Example #10
0
void
Vibe::out (float *smpsl, float *smpsr)
{

    int i,j;
    float lfol, lfor, xl, xr;
    float  fxl=0.0f;
    float  fxr=0.0f;
    //float vbe,vin;
    float cvolt, ocvolt, evolt, input;
    float emitterfb = 0.0f;
    float outl, outr;

    input = cvolt = ocvolt = evolt = 0.0f;

    lfo.effectlfoout (&lfol, &lfor);

    lfol = fdepth + lfol*fwidth;
    if (lfol > 1.0f)
        lfol = 1.0f;
    else if (lfol < 0.0f)
        lfol = 0.0f;
    lfol = 2.0f - 2.0f/(lfol + 1.0f); //emulate lamp turn on/off characteristic by typical curves

    if(Pstereo) {
        lfor = fdepth + lfor*fwidth;
        if (lfor > 1.0f) lfor = 1.0f;
        else if (lfor < 0.0f) lfor = 0.0f;
        lfor = 2.0f - 2.0f/(lfor + 1.0f);   //
    }

    for (i = 0; i < param->PERIOD; i++) {
        //Left Lamp
        gl = lfol*lampTC + oldgl*ilampTC;
        oldgl = gl;

        //Left Cds
        stepl = gl*alphal + dalphal*oldstepl;
        oldstepl = stepl;
        dRCl = dTC*f_exp(stepl*minTC);
        alphal = cSAMPLE_RATE/(dRCl + cSAMPLE_RATE);
        dalphal = 1.0f - cSAMPLE_RATE/(0.5f*dRCl + cSAMPLE_RATE);     //different attack & release character
        xl = CNST_E + stepl*b;
        fxl = f_exp(Ra/logf(xl));

        //Right Lamp
        if(Pstereo) {
            gr = lfor*lampTC + oldgr*ilampTC;
            oldgr = gr;

            //Right Cds
            stepr = gr*alphar + dalphar*oldstepr;
            oldstepr = stepr;
            dRCr = dTC*f_exp(stepr*minTC);
            alphar = cSAMPLE_RATE/(dRCr + cSAMPLE_RATE);
            dalphar = 1.0f - cSAMPLE_RATE/(0.5f*dRCr + cSAMPLE_RATE);      //different attack & release character
            xr = CNST_E + stepr*b;
            fxr = f_exp(Ra/logf(xr));
        }

        if(i%16 == 0)  modulate(fxl, fxr);

        //Left Channel
        input = bjt_shape(fbl + smpsl[i]);


        /*
        //Inline BJT Shaper bleow
            vin = 7.5f*(1.0f + fbl+smpsl[i]);
            if(vin<0.0f) vin = 0.0f;
            if(vin>15.0f) vin = 15.0f;
            vbe = 0.8f - 0.8f/(vin + 1.0f);  //really rough, simplistic bjt turn-on emulator
            input = vin - vbe;
            input = input*0.1333333333f -0.90588f;  //some magic numbers to return gain to unity & zero the DC

        */

        emitterfb = 25.0f/fxl;
        for(j=0; j<4; j++) { //4 stages phasing
            /*
            //Inline filter implementation below
                float y0 = 0.0f;
                y0 = input*ecvc[j].n0 + ecvc[j].x1*ecvc[j].n1 - ecvc[j].y1*ecvc[j].d1;
                ecvc[j].y1 = y0 + DENORMAL_GUARD;
                ecvc[j].x1 = input;


                float x0 = 0.0f;
                float data = input + emitterfb*oldcvolt[j];
                x0 = data*vc[j].n0 + vc[j].x1*vc[j].n1 - vc[j].y1*vc[j].d1;
                vc[j].y1 = x0 + DENORMAL_GUARD;
                vc[j].x1 = data;

                cvolt=y0+x0;


                ocvolt= cvolt*vcvo[j].n0 + vcvo[j].x1*vcvo[j].n1 - vcvo[j].y1*vcvo[j].d1;
                vcvo[j].y1 = ocvolt + DENORMAL_GUARD;
                vcvo[j].x1 = cvolt;

                oldcvolt[j] = ocvolt;

                evolt = input*vevo[j].n0 + vevo[j].x1*vevo[j].n1 - vevo[j].y1*vevo[j].d1;
                vevo[j].y1 = evolt + DENORMAL_GUARD;
                vevo[j].x1 = input;

                vin = 7.5f*(1.0f + ocvolt+evolt);
                if(vin<0.0f) vin = 0.0f;
                if(vin>15.0f) vin = 15.0f;
                vbe = 0.8f - 0.8f/(vin + 1.0f);  //really rough, simplistic bjt turn-on emulator
                input = vin - vbe;
                input = input*0.1333333333f -0.90588f;  //some magic numbers to return gain to unity & zero the DC
            */

// Orig code, Comment below if instead using inline
            cvolt = vibefilter(input,ecvc,j) + vibefilter(input + emitterfb*oldcvolt[j],vc,j);
            ocvolt = vibefilter(cvolt,vcvo,j);
            oldcvolt[j] = ocvolt;
            evolt = vibefilter(input, vevo,j);

            input = bjt_shape(ocvolt + evolt);
            //Close comment here if using inline

        }
        fbl = fb*ocvolt;
        outl = lpanning*input;

        //Right channel

        if(Pstereo) {
            /*
            //Inline BJT shaper
             vin = 7.5f*(1.0f + fbr+smpsr[i]);
             if(vin<0.0f) vin = 0.0f;
             if(vin>15.0f) vin = 15.0f;
             vbe = 0.8f - 0.8f/(vin + 1.0f);  //really rough, simplistic bjt turn-on emulator
             input = vin - vbe;
             input = input*0.1333333333f -0.90588f;  //some magic numbers to return gain to unity & zero the DC
             */


//Orig code
            input = bjt_shape(fbr + smpsr[i]);
            //Close Comment here if using Inline instead

            emitterfb = 25.0f/fxr;
            for(j=4; j<8; j++) { //4 stages phasing

                /*
                //This is the inline version

                    float y0 = 0.0f;
                    y0 = input*ecvc[j].n0 + ecvc[j].x1*ecvc[j].n1 - ecvc[j].y1*ecvc[j].d1;
                    ecvc[j].y1 = y0 + DENORMAL_GUARD;
                    ecvc[j].x1 = input;


                    float x0 = 0.0f;
                    float data = input + emitterfb*oldcvolt[j];
                    x0 = data*vc[j].n0 + vc[j].x1*vc[j].n1 - vc[j].y1*vc[j].d1;
                    vc[j].y1 = x0 + DENORMAL_GUARD;
                    vc[j].x1 = data;

                    cvolt=y0+x0;


                    ocvolt= cvolt*vcvo[j].n0 + vcvo[j].x1*vcvo[j].n1 - vcvo[j].y1*vcvo[j].d1;
                    vcvo[j].y1 = ocvolt + DENORMAL_GUARD;
                    vcvo[j].x1 = cvolt;

                    oldcvolt[j] = ocvolt;

                    evolt = input*vevo[j].n0 + vevo[j].x1*vevo[j].n1 - vevo[j].y1*vevo[j].d1;
                    vevo[j].y1 = evolt + DENORMAL_GUARD;
                    vevo[j].x1 = input;


                    vin = 7.5f*(1.0f + ocvolt+evolt);
                    if(vin<0.0f) vin = 0.0f;
                    if(vin>15.0f) vin = 15.0f;
                    vbe = 0.8f - 0.8f/(vin + 1.0f);  //really rough, simplistic bjt turn-on emulator
                    input = vin - vbe;
                    input = input*0.1333333333f -0.90588f;  //some magic numbers to return gain to unity & zero the DC

                */

//  Comment block below if using inline code instead
                cvolt = vibefilter(input,ecvc,j) + vibefilter(input + emitterfb*oldcvolt[j],vc,j);
                ocvolt = vibefilter(cvolt,vcvo,j);
                oldcvolt[j] = ocvolt;
                evolt = vibefilter(input, vevo,j);

                input = bjt_shape(ocvolt + evolt);
// Close comment here if inlining
            }

            fbr = fb*ocvolt;
            outr = rpanning*input;

            efxoutl[i] = outl*fcross + outr*flrcross;
            efxoutr[i] = outr*fcross + outl*flrcross;
        }  else {  //if(Pstereo)
            efxoutl[i] = outl;
            efxoutr[i] = outl;
        }

    };

};