Exemple #1
0
interrupt void c_int11()	 // interrupt service routine
{
 	input = input_left_sample(); //read new input sample
	for(i=0; i < taps; i++) {
		rpf = rp + i*size/taps;
		if(rpf > dsize) rpf -= disze;
		rpi = (int) rpf;
		frac = rpf - rpi;
		if(rpi != dsize-1) next = delay[rpi+1];
		else next = delay[0];
		// envelop index
		ep = rpi - wp;
		if(ep < 0) ep += dsize;
		s += (delay[rpi] + frac*(next - delay[rpi]))*env[ep];
	}
	// inc reader pointer and check bounds
	rp += p;
	rp = rp < dsize ? rp : rp - dsize;
	// feed the delay line
	delay[wp] = input + s*fdb;
	// output the signal
	output = (s/taps)*gain;
 	//output = input + delayed;    //output sum of new and delayed samples
  	//delay[i] = input;           //replace delayed sample with  
  	//if(++i >= BUF_SIZE) i=0;     //new input sample then increment
  	if(++wp >= dsize) wp = 0;
  	 
  	output_left_sample(output);  //buffer index
  	output_right_sample(output);
  	return;                      //return from ISR
}
Exemple #2
0
void c_int11()         //ISR - AD535 codec interrupts at 8kHz
{  
  x[0] = (float)(input_left_sample()); //get new input into delay line
  output_left_sample((short)(yn));     //output to codec
  SWI_post(&SWI_fir_isr);
  return;
}
Exemple #3
0
interrupt void c_int11()            //ISR
{
  y[0] =(y[1]*a1)-y[2];
 y[2] = y[1];                             //update y1(n-2)
 y[1] = y[0];                             //update y1(n-1)
 output_left_sample((short)(y[0]*AMPLITUDE));             //output result
 return;					//return to main
}
Exemple #4
0
void c_int11(void)
{
	input[bufferindex] = (fixedp)input_left_sample();	
	output_left_sample((short)output[bufferindex]);
	if(++bufferindex >= N) {
		bufferindex = 0;
		bufferflag = 1;
		SWI_post(&SWI_process_isr);
	}
	return;
}
Exemple #5
0
interrupt void c_int11()    //interrupt service routine
{
  output_left_sample(sine_table[(short)loopindexlow] + sine_table[(short)loopindexhigh]);
  loopindexlow += STEP_697;
  if (loopindexlow > (float)TABLESIZE)
    loopindexlow -= (float)TABLESIZE;
  loopindexhigh += STEP_1477;
  if (loopindexhigh > (float)TABLESIZE)
    loopindexhigh -= (float)TABLESIZE;

  return;					//return from interrupt
}
Exemple #6
0
interrupt void c_int11(void)      //ISR
{
  output_left_sample((short)((output_ptr + buffercount)->real));
  outbuffer[buffercount] = -(short)((output_ptr + buffercount)->real);
  (input_ptr + buffercount)->real = (float)(input_left_sample());
  (input_ptr + buffercount++)->imag = 0.0;
  if (buffercount >= N)       //for overlap-add method iobuffer
  {                             // is half size of FFT used
    buffercount = 0;
    bufferfull = 1;
  }
}
Exemple #7
0
interrupt void c_int11()
{
  //theta_increment = 2*PI*frequency/SAMPLING_FREQ;
  //theta += theta_increment;
  //if (theta > 2*PI) theta -= 2*PI;
  //output_left_sample((short)(amplitude*sin(theta)));
  
	WaveTable_doOscillate(&t, &tval);
  output_left_sample(tval);
  if(++i >= 1024) {
	i = 0;
  }
  return;
}
Exemple #8
0
void c_int11()    //interrupt service routine
{
    int gain = (int)(*(unsigned volatile int *)GAINADRESS);

    in = (fixedp)input_left_sample();
    in = BiQuad_do(lpf, in);

    chin = qfpart(in);
    output_left_sample(chin);

    /*if(HPI_FLAG) {
    	//output_left_sample(f * 16000.0); //gain*sine_table[loopindex]);	// output look up table value
    }
    else {
    	//output_left_sample(sine_table[loopindex]);
    }*/
    if (++loopindex >= LOOPLENGTH) loopindex = 0; // check for end of look up table
    return;					//return from interrupt
}
Exemple #9
0
interrupt void c_int11()	 //interrupt service routine
{
  int section;   // index for section number
  float input;   // input to each section
  float wn,yn;   // intermediate and output values in each stage

  input = ((float)input_left_sample());
  
  for (section=0 ; section< NUM_SECTIONS ; section++)
  {
    wn = input - a[section][0]*w[section][0] - a[section][1]*w[section][1];
    yn = b[section][0]*wn + b[section][1]*w[section][0] + b[section][2]*w[section][1];
    w[section][1] = w[section][0];
    w[section][0] = wn;
    input = yn;              // output of current section will be input to next
  }

  output_left_sample((short)(yn)); // before writing to codec

  return;                       //return from ISR
}
Exemple #10
0
interrupt void c_int11()               //interrupt service routine
{                         
 int i;
 float adaptfir_out = 0.0;             //initialise adaptive filter output
 float fir_out = 0.0;
 float E;                              //error=difference of fixed/adapt out

 fir_out = (float)(input_left_sample());    //read output from external system
 dly_adapt[0]=prand();          	   //pseudo-random noise sample used as 
 output_left_sample((short)(dly_adapt[0])); //input to adaptive filter and output
                                       //to external system
 for (i = 0; i < WLENGTH; i++)
   adaptfir_out +=(w[i]*dly_adapt[i]); //compute adaptive filter output 
 
 E = fir_out - adaptfir_out;           //error signal           
 
 for (i = WLENGTH-1; i >= 0; i--)         
  {
   w[i] = w[i]+(beta*E*dly_adapt[i]);  //update weights of adaptive FIR  
   dly_adapt[i+1] = dly_adapt[i];      //update samples of adaptive FIR   
  } 
 return;
}
Exemple #11
0
interrupt void c_int11()    //interrupt service routine
{
  // THIS CODE IS FOR THE FIRST AND SECOND PARTS
  output_left_sample((sine_table[(short)loopindexlow] + sine_table[(short)loopindexhigh])/10);
  //AIC23_data.channel[LEFT] = sine_table[(short)loopindexlow];
  //AIC23_data.channel[RIGHT] = sine_table[(short)loopindexhigh];
  //output_sample(AIC23_data.uint);
  //output_left_sample(sine_table[(short)loopindexlow]);
  //output_right_sample(sine_table[(short)loopindexhigh]);
  /*loopindexlow += STEP_697;
  if (loopindexlow > (float)TABLESIZE)
    loopindexlow -= (float)TABLESIZE;
  loopindexhigh += STEP_1477;
  if (loopindexhigh > (float)TABLESIZE)
    loopindexhigh -= (float)TABLESIZE;*/

  // THIS CODE IS FOR THE THIRD PART
  //printf("Inside the interrupt\n");
  if(inLoop == 1)
  {
	  output_left_sample(sine_table[(short)loopindexlow] + sine_table[(short)loopindexhigh]);
	  if( ( dip0state == 1 ) && ( dip1state == 1 ) && ( dip2state == 1 ) && ( dip3state == 1 ) )
	  {
		  // output a 0
		  loopindexlow += STEP_941;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1336;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 1 ) && ( dip2state == 1 ) && ( dip3state == 0 ) )
	  {
		  // output a 1
		  loopindexlow += STEP_697;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1209;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 1 ) && ( dip2state == 0 ) && ( dip3state == 1 ) )
	  {
		  // output a 2
		  loopindexlow += STEP_697;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1336;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 1 ) && ( dip2state == 0 ) && ( dip3state == 0 ) )
	  {
		  // output a 3
		  loopindexlow += STEP_697;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1477;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 0 ) && ( dip2state == 1 ) && ( dip3state == 1 ) )
	  {
		  // output a 4
		  loopindexlow += STEP_770;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1209;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 0 ) && ( dip2state == 1 ) && ( dip3state == 0 ) )
	  {
		  // output a 5
		  loopindexlow += STEP_770;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1336;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 1 ) && ( dip1state == 0 ) && ( dip2state == 0 ) && ( dip3state == 1 ) )
	  {
		  // output a 6
		  loopindexlow += STEP_770;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1477;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
      }
	  else if( ( dip0state == 1 ) && ( dip1state == 0 ) && ( dip2state == 0 ) && ( dip3state == 0 ) )
	  {
		  // output a 7
		  loopindexlow += STEP_852;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1209;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 0 ) && ( dip1state == 1 ) && ( dip2state == 1 ) && ( dip3state == 1 ) )
	  {
		  // output a 8
		  loopindexlow += STEP_852;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1336;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 0 ) && ( dip1state == 1 ) && ( dip2state == 1 ) && ( dip3state == 0 ) )
	  {
		  // output a 9
		  loopindexlow += STEP_852;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1477;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 0 ) && ( dip1state == 1 ) && ( dip2state == 0 ) && ( dip3state == 1 ) )
	  {
		  // output a *
		  loopindexlow += STEP_941;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1209;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else if( ( dip0state == 0 ) && ( dip1state == 1 ) && ( dip2state == 0 ) && ( dip3state == 0 ) )
	  {
		  // output a #
		  loopindexlow += STEP_941;
		  if (loopindexlow > (float)TABLESIZE)
			  loopindexlow -= (float)TABLESIZE;
		  loopindexhigh += STEP_1477;
		  if (loopindexhigh > (float)TABLESIZE)
			  loopindexhigh -= (float)TABLESIZE;
	  }
	  else
	  {
		  // invalid input
	  }
	  toneCounter++;
	  if( toneCounter > 32000 )
	  {
		  toneCounter = 0;
		  inLoop = 0;
	  }
  }
  else
  {
	  if( ( DSK6713_DIP_get(0) == dip0state ) && ( DSK6713_DIP_get(1) == dip1state ) && ( DSK6713_DIP_get(2) == dip2state ) && ( DSK6713_DIP_get(3) == dip3state ) )
	  {
		  startCounter++;
	  }
	  else
	  {
		  startCounter = 0;
		  dip0state = DSK6713_DIP_get(0);
		  dip1state = DSK6713_DIP_get(1);
		  dip2state = DSK6713_DIP_get(2);
		  dip3state = DSK6713_DIP_get(3);
	  }

	  if( startCounter > 32000 )
	  {
		  startCounter = 0;
		  inLoop = 1;
		  loopindexlow = 0.0;
		  loopindexhigh = 0.0;
	  }
  }

  return;					//return from interrupt
}
Exemple #12
0
void c_int11(void)
{
  output_left_sample(sine_table[loopindex++]);
  if (loopindex >= LOOPLENGTH ) loopindex = 0;
  return;
}
Exemple #13
0
interrupt void interrupt4(void){
	//float left_sample = input_left_sample();

	//Frequency Response stuff

//	if(response_index < K) {
//		response[response_index] += fabsf(left_sample)/N;
//	}

//	if(buffer_index < N) {
//		buffer[buffer_index] = left_sample;
//		buffer_index++;
//	}

	phi_t += ((6000.0+symbols[curr_symbol])/(float)SAMP_FREQ)*2.0*PI;

//	if(counter == N-1) {
//		curr_symbol = (curr_symbol+1)%S;
//	}

	// PLL Implementation ------------------------------------------------
	//PLL Routine
	x[x_index] = left_sample;
	sImag = 0;

	int i;
	for(i = 0; i <= CBUFF_LEN; i+= 2) { //indexing by 2, B[odd] = 0
		sImag += x[(x_index+i)%CBUFF_LEN]*B[i]; //dot product
	}

	sReal = x[(x_index+15)%CBUFF_LEN];//*scaleFactor; //group delay of filter is 15 samples

	//scaleFactor = 1/sqrt(sReal*sReal + sImag*sImag);
	sReal *= scaleFactor; //scaling prior to loop filter
	sImag *= scaleFactor; //scaling prior to loop filter

	x_index = (x_index+1)%(CBUFF_LEN);

	//execute D-PLL (loop)
	vcoOutputReal = cosf(phi);
	vcoOutputImag = sinf(phi);

	if(buffer_index < N) buffer[buffer_index] = vcoOutputReal;
	buffer_index++;

	phaseDetectorOutputReal = sReal*vcoOutputReal+sImag*vcoOutputImag;
	phaseDetectorOutputImag = sImag*vcoOutputReal-sReal*vcoOutputImag;
	q = phaseDetectorOutputReal*phaseDetectorOutputImag;
	sigma += beta*q;
	loopFilterOutput = sigma+alpha*q;
	phi+=2.0*pi*Fmsg/(float)SAMP_FREQ + loopFilterOutput;

	output_freq = Fmsg + SAMP_FREQ*loopFilterOutput/(2.0*pi);

	if(phi > 2*pi) phi -= 2*pi; //modulo 2*pi
	//if(phi < 0) phi += 2*pi;



	counter++;
	counter = counter%N;

	left_sample = amplitude*sin(phi_t);
	output_left_sample(left_sample);
}