Beispiel #1
0
void
initialize_registers (int context)
{
  reg_image_t &reg_image = reg_images[context];

  memclr (reg_image.FPR, FPR_LENGTH * sizeof (double));
  reg_image.FGR = (float *) reg_image.FPR;
  reg_image.FWR = (int *) reg_image.FPR;

  memclr (reg_image.R, R_LENGTH * sizeof (reg_word));
  reg_image.R[REG_SP] = STACK_TOP - BYTES_PER_WORD - 4096; /* Initialize $sp */
  reg_image.HI = reg_image.LO = 0;
  reg_image.PC = TEXT_BOT;

  CP0_BadVAddr(reg_image) = 0;
  CP0_Count(reg_image) = 0;
  CP0_Compare(reg_image) = 0;
  CP0_Status(reg_image) = (CP0_Status_CU & 0x30000000) | CP0_Status_IM | CP0_Status_UM;
  CP0_Cause(reg_image) = 0;
  CP0_EPC(reg_image) = 0;
#ifdef SPIM_BIGENDIAN
  CP0_Configreg_image() =  CP0_Config_BE;
#else
  CP0_Config(reg_image) = 0;
#endif

  FIR(reg_image) = FIR_W | FIR_D | FIR_S;	/* Word, double, & single implemented */
  FCSR(reg_image) = 0x0;
  FCCR(reg_image) = 0x0;
  FEXR(reg_image) = 0x0;
  FENR(reg_image) = 0x0;

  reg_image.RFE_cycle = 0;
}
Beispiel #2
0
void playback(void){
    int16 i1 = 0; 
    int16 k = 0;
    int16 D1 = 11;
    int16 B1 = 1;
    int16 temp = 0;
    int16 temp2 = 0;
    int16 temp3 = 0;
    
    while(1){
    	while((Rcv & I2S0_IR) == 0); 							// Wait for interrupt pending flag
	    //AudioInVar 	= I2S0_W0_MSW_R;  						// 16 bit left channel received audio data
	    AudioIn[i1] = I2S0_W0_MSW_R; 
	    //temp = AudioIn[i1]; 
	    i1++; if(i1 == 23) i1 = 0;
	    D1++; if(D1 == 23) D1 = 0;
	    FIR1Out[k] = FIR(AudioIn, COEFF, i1); 
	    Band1[B1] = AudioIn[D1] - FIR1Out[k];
	    temp2 = Band1[B1];
	    temp3 = FIR1Out[k];
	    temp = Band1[B1] + FIR1Out[k];   

	    while((Xmit & I2S0_IR) == 0);  						// Wait for interrupt pending flag
		k++; if(k == 45) k = 0;
		B1++; if(B1 == 23) B1 = 0;
		I2S0_W0_MSW_W = temp;  						// 16 bit left channel transmit audio data
		

    }

}
Beispiel #3
0
void FIR_Chan_FIR(void* inputFIFOs[], void* outputFIFOs[], Param inParams[], Param outParams[]){
	FIR(
		/* NbS */ (Param) inParams[0],
		/* ix  */ (char*) inputFIFOs[1],
		/* in  */ (float*) inputFIFOs[0],
		/* out */ (float*) outputFIFOs[0]
	);
}
bool SCFilter::Apply(AFSample* yt, AFSample* xt, const AFSampleCount length)
{
    if(int(length) < m_nOrder)
        return false;
        
    if(m_adbA == 0)
    {
        FIR(yt, xt, length);    
    }
    else
    {
        IIR(yt, xt, length);        
    }
  
    return true;    
}  
Beispiel #5
0
// Filter data through filter
static af_data_t* play(struct af_instance_s* af, af_data_t* data){
  af_surround_t* s   = (af_surround_t*)af->setup;
  float*	 m   = steering_matrix[0]; 
  float*     	 in  = data->audio; 	// Input audio data
  float*     	 out = NULL;		// Output audio data
  float*	 end = in + data->len / sizeof(float); // Loop end
  int 		 i   = s->i;	// Filter queue index
  int 		 ri  = s->ri;	// Read index for delay queue
  int 		 wi  = s->wi;	// Write index for delay queue

  if (AF_OK != RESIZE_LOCAL_BUFFER(af, data))
    return NULL;

  out = af->data->audio;

  while(in < end){
    /* Dominance:
       abs(in[0])  abs(in[1]);
       abs(in[0]+in[1])  abs(in[0]-in[1]);
       10 * log( abs(in[0]) / (abs(in[1])|1) );
       10 * log( abs(in[0]+in[1]) / (abs(in[0]-in[1])|1) ); */

    /* About volume balancing...
       Surround encoding does the following:
           Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S
       So S should be extracted as:
           (Lt-Rt)
       But we are splitting the S to two output channels, so we
       must take 3dB off as we split it:
           Ls=Rs=.707*(Lt-Rt)
       Trouble is, Lt could be +1, Rt -1, so possibility that S will
       overflow. So to avoid that, we cut L/R by 3dB (*.707), and S by
       6dB (/2). This keeps the overall balance, but guarantees no
       overflow. */

    // Output front left and right
    out[0] = m[0]*in[0] + m[1]*in[1];
    out[1] = m[2]*in[0] + m[3]*in[1];

    // Low-pass output @ 7kHz
    FIR((&s->lq[i]), s->w, s->dl[wi]);

    // Delay output by d ms
    out[2] = s->dl[ri];

#ifdef SPLITREAR
    // Low-pass output @ 7kHz
    FIR((&s->rq[i]), s->w, s->dr[wi]);

    // Delay output by d ms
    out[3] = s->dr[ri];
#else
    out[3] = -out[2];
#endif

    // Update delay queues indexes
    UPDATEQI(ri);
    UPDATEQI(wi);

    // Calculate and save surround in circular queue
#ifdef SPLITREAR
    ADDQUE(i, s->rq, s->lq, m[6]*in[0]+m[7]*in[1], m[8]*in[0]+m[9]*in[1]);
#else
    ADDQUE(i, s->lq, m[4]*in[0]+m[5]*in[1]);
#endif

    // Next sample...
    in = &in[data->nch];  
    out = &out[af->data->nch];
  }
  
  // Save indexes
  s->i  = i; s->ri = ri; s->wi = wi;

  // Set output data
  data->audio = af->data->audio;
  data->len   = (data->len*af->mul.n)/af->mul.d;
  data->nch   = af->data->nch;

  return data;
}
Beispiel #6
0
static int filter_frame(struct af_instance *af, struct mp_audio *data)
{
  if (!data)
    return 0;
  struct mp_audio *outframe =
    mp_audio_pool_get(af->out_pool, &af->fmt_out, data->samples);
  if (!outframe) {
    talloc_free(data);
    return -1;
  }
  mp_audio_copy_attributes(outframe, data);

  af_surround_t* s   = (af_surround_t*)af->priv;
  const float*   m   = steering_matrix[0];
  float*         in  = data->planes[0];         // Input audio data
  float*         out = outframe->planes[0];     // Output audio data
  float*         end = in + data->samples * data->nch;
  int            i   = s->i;    // Filter queue index
  int            ri  = s->ri;   // Read index for delay queue
  int            wi  = s->wi;   // Write index for delay queue

  while(in < end){
    /* Dominance:
       abs(in[0])  abs(in[1]);
       abs(in[0]+in[1])  abs(in[0]-in[1]);
       10 * log( abs(in[0]) / (abs(in[1])|1) );
       10 * log( abs(in[0]+in[1]) / (abs(in[0]-in[1])|1) ); */

    /* About volume balancing...
       Surround encoding does the following:
           Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S
       So S should be extracted as:
           (Lt-Rt)
       But we are splitting the S to two output channels, so we
       must take 3dB off as we split it:
           Ls=Rs=.707*(Lt-Rt)
       Trouble is, Lt could be +1, Rt -1, so possibility that S will
       overflow. So to avoid that, we cut L/R by 3dB (*.707), and S by
       6dB (/2). This keeps the overall balance, but guarantees no
       overflow. */

    // Output front left and right
    out[0] = m[0]*in[0] + m[1]*in[1];
    out[1] = m[2]*in[0] + m[3]*in[1];

    // Low-pass output @ 7kHz
    FIR((&s->lq[i]), s->w, s->dl[wi]);

    // Delay output by d ms
    out[2] = s->dl[ri];

#ifdef SPLITREAR
    // Low-pass output @ 7kHz
    FIR((&s->rq[i]), s->w, s->dr[wi]);

    // Delay output by d ms
    out[3] = s->dr[ri];
#else
    out[3] = -out[2];
#endif

    // Update delay queues indexes
    UPDATEQI(ri);
    UPDATEQI(wi);

    // Calculate and save surround in circular queue
#ifdef SPLITREAR
    ADDQUE(i, s->rq, s->lq, m[6]*in[0]+m[7]*in[1], m[8]*in[0]+m[9]*in[1]);
#else
    ADDQUE(i, s->lq, m[4]*in[0]+m[5]*in[1]);
#endif

    // Next sample...
    in = &in[data->nch];
    out = &out[af->data->nch];
  }

  // Save indexes
  s->i  = i; s->ri = ri; s->wi = wi;

  talloc_free(data);
  af_add_output_frame(af, outframe);
  return 0;
}