Beispiel #1
0
Datei: clara.c Projekt: plops/mma
int
main()
{
  init_clara();
  C(PrepareAcquisition());
  
  int i;
  for(i=0;;i++){
    C(StartAcquisition());
    capture_clara();
  }
  C(AbortAcquisition());
  C(FreeInternalMemory());
  uninit_clara();
  return 0;
}
Beispiel #2
0
WBPMDetect1::~WBPMDetect1()
{
	FreeInternalMemory();
}
Beispiel #3
0
int WBPMDetect1::AllocateInternalMemory()
{

	c_Amplitudes = (BPM_DETECT1_REAL*) malloc(BPM_DETECT_FFT_POINTS1 / 2 * sizeof(BPM_DETECT1_REAL));
	c_Samples = (BPM_DETECT1_REAL*) malloc(BPM_DETECT_FFT_POINTS1 * sizeof(BPM_DETECT1_REAL));
	c_pflWindow = (BPM_DETECT1_REAL*) malloc(BPM_DETECT_FFT_POINTS1 * sizeof(BPM_DETECT1_REAL));
	c_pnIp = (int*) malloc( ( 2 + (int) sqrt((BPM_DETECT1_REAL) BPM_DETECT_FFT_POINTS1 / 2.0) ) * sizeof(int));
	c_pflw = (BPM_DETECT1_REAL*) malloc(BPM_DETECT_FFT_POINTS1 / 2 * sizeof(BPM_DETECT1_REAL));
	c_pnOffset = (unsigned int*) malloc((BPM_DETECT_MAX_BPM + BPM_DETECT_MAX_MARGIN + 2) * sizeof(unsigned int));

	if(c_Amplitudes == 0 || c_Samples == 0 || c_pflWindow == 0 || c_pnIp == 0 || c_pflw == 0 || c_pnOffset == 0)
	{
		FreeInternalMemory();
		return 0;
	}


	c_pnIp[0] = 0;

	c_pSubBand = (SUBBAND1*) malloc(BPM_NUMBER_OF_SUBBANDS * sizeof(SUBBAND1));
	if(c_pSubBand == 0)
	{
		FreeInternalMemory();
		return 0;
	}

	memset(c_pSubBand, 0, BPM_NUMBER_OF_SUBBANDS * sizeof(SUBBAND1));

	unsigned int i;



	for(i = 0; i < BPM_NUMBER_OF_SUBBANDS; i++)
	{
		c_pSubBand[i].Buffer = (BPM_DETECT1_REAL*) malloc(c_nBufferSize * sizeof(BPM_DETECT1_REAL));
		if(c_pSubBand[i].Buffer == 0)
		{
			FreeInternalMemory();
			return 0;
		}

		memset(c_pSubBand[i].Buffer, 0, c_nBufferSize * sizeof(BPM_DETECT1_REAL));


		c_pSubBand[i].BPMHistoryHit = (unsigned int*) malloc((BPM_DETECT_MAX_BPM + 2) * sizeof(unsigned int));
		if(c_pSubBand[i].BPMHistoryHit == 0)
		{
			FreeInternalMemory();
			return 0;
		}
	}

 
	// create COSINE window

	double n;
	double N = (double) BPM_DETECT_FFT_POINTS1;
	double pi = PI;
	for(i = 0; i < BPM_DETECT_FFT_POINTS1; i++)
	{
		n = (double) i;
		c_pflWindow[i] = (BPM_DETECT1_REAL) ( sin( (pi * n) / (N - 1.0)) ); 
	}


	c_fReady = 1;
	return 1;

}