Esempio n. 1
0
// Process the input
bool EffectBassTreble::ProcessPass1(float *buffer, sampleCount len)
{
   for (sampleCount i = 0; i < len; i++)
      buffer[i] = (DoFilter(buffer[i]) / mPreGain);

   return true;
}
Esempio n. 2
0
/**
- FUNCTION: Filter (const version)
- FUNCTIONALITY: Get some blobs from the class based on conditions on measures
				 of the blobs.
- PARAMETERS:
	- dst: where to store the selected blobs
	- filterAction:	B_INCLUDE: include the blobs which pass the filter in the result
				    B_EXCLUDE: exclude the blobs which pass the filter in the result
	- evaluador: Object to evaluate the blob
	- Condition: How to decide if  the result returned by evaluador on each blob
				 is included or not. It can be:
				    B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL,
				    B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE
	- LowLimit:  numerical value to evaluate the Condition on evaluador(blob)
	- HighLimit: numerical value to evaluate the Condition on evaluador(blob).
				 Only useful for B_INSIDE and B_OUTSIDE
- RESULT:
	- It returns on dst the blobs that accomplish (B_INCLUDE) or discards (B_EXCLUDE)
	  the Condition on the result returned by evaluador on each blob
- RESTRICTIONS:
- AUTHOR: Ricard Borràs
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
void CBlobResult::Filter(CBlobResult &dst,
						 int filterAction,
						 funcio_calculBlob *evaluador,
						 int condition,
						 double lowLimit, double highLimit /*=0*/)

{
	int numBlobs = GetNumBlobs();

	// do the job
	DoFilter(dst, filterAction, evaluador, condition, lowLimit, highLimit );

	// inline operation: remove previous blobs
	if( &dst == this )
	{
		// esborrem els primers blobs ( que són els originals )
		// ja que els tindrem replicats al final si passen el filtre
		Blob_vector::iterator itBlobs = m_blobs.begin();
		for( int i = 0; i < numBlobs; i++ )
		{
			delete *itBlobs;
			itBlobs++;
		}
		m_blobs.erase( m_blobs.begin(), itBlobs );
	}
}
Esempio n. 3
0
size_t EffectBassTreble::InstanceProcess(EffectBassTrebleState & data,
                                              float **inBlock,
                                              float **outBlock,
                                              size_t blockLen)
{
   float *ibuf = inBlock[0];
   float *obuf = outBlock[0];

   // Set value to ensure correct rounding
   double oldBass = DB_TO_LINEAR(mBass);
   double oldTreble = DB_TO_LINEAR(mTreble);

   data.gain = DB_TO_LINEAR(mGain);

   // Compute coefficents of the low shelf biquand IIR filter
   if (data.bass != oldBass)
      Coefficents(data.hzBass, data.slope, mBass, data.samplerate, kBass,
                  data.a0Bass, data.a1Bass, data.a2Bass,
                  data.b0Bass, data.b1Bass, data.b2Bass);

   // Compute coefficents of the high shelf biquand IIR filter
   if (data.treble != oldTreble)
      Coefficents(data.hzTreble, data.slope, mTreble, data.samplerate, kTreble,
                  data.a0Treble, data.a1Treble, data.a2Treble,
                  data.b0Treble, data.b1Treble, data.b2Treble);

   for (decltype(blockLen) i = 0; i < blockLen; i++) {
      obuf[i] = DoFilter(data, ibuf[i]) * data.gain;
   }

   return blockLen;
}
Esempio n. 4
0
// Filter the decoded macroblock row (if needed)
static void FilterRow(const VP8Decoder* const dec) {
  int mb_x;
  const int mb_y = dec->thread_ctx_.mb_y_;
  assert(dec->thread_ctx_.filter_row_);
  for (mb_x = dec->tl_mb_x_; mb_x < dec->br_mb_x_; ++mb_x) {
    DoFilter(dec, mb_x, mb_y);
  }
}
Esempio n. 5
0
/**
- FUNCTION: Filter
- FUNCTIONALITY: Get some blobs from the class based on conditions on measures
				 of the blobs.
- PARAMETERS:
	- dst: where to store the selected blobs
	- filterAction:	B_INCLUDE: include the blobs which pass the filter in the result
				    B_EXCLUDE: exclude the blobs which pass the filter in the result
	- evaluador: Object to evaluate the blob
	- Condition: How to decide if  the result returned by evaluador on each blob
				 is included or not. It can be:
				    B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL,
				    B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE
	- LowLimit:  numerical value to evaluate the Condition on evaluador(blob)
	- HighLimit: numerical value to evaluate the Condition on evaluador(blob).
				 Only useful for B_INSIDE and B_OUTSIDE
- RESULT:
	- It returns on dst the blobs that accomplish (B_INCLUDE) or discards (B_EXCLUDE)
	  the Condition on the result returned by evaluador on each blob
- RESTRICTIONS:
- AUTHOR: Ricard Borràs
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
void CBlobResult::Filter(CBlobResult &dst,
						 int filterAction,
						 funcio_calculBlob *evaluador,
						 int condition,
						 double lowLimit, double highLimit /*=0*/) const

{
	// do the job
	DoFilter(dst, filterAction, evaluador, condition, lowLimit, highLimit );
}
Esempio n. 6
0
void CLogViewDlg::OnBnClickedBtnDoFilter()
{
    CString strTextFilter;
    GetDlgItemText(IDC_EDIT_TEXT_FILTER, strTextFilter);

    m_vctTextFilter.clear();

    BOOL bEnableRegex = CConfig::GetConfig().IsRegexEnabled();
    // BOOL bEnableWildcard = CConfig::GetConfig().IsWildcardEnabled();
    // if(bEnableRegex || bEnableWildcard)
    if(bEnableRegex)
    {

        try
        {
            boost::wregex expression(strTextFilter);
        }
        catch(...)
        {
            m_bEditTextFilterUnApplied = TRUE;
            GetDlgItem(IDC_EDIT_TEXT_FILTER)->Invalidate(TRUE);
            AfxMessageBox(_T("Invalid Regex Expression!"), MB_OK | MB_ICONWARNING);
            return;
        }

        if(!strTextFilter.IsEmpty())
            m_vctTextFilter.push_back((LPCTSTR)strTextFilter);
    }
    else
    {
        CString strToken;
        int curPos = 0;
        strToken = strTextFilter.Tokenize(_T(";"),curPos);
        while (strToken != _T(""))
        {
            m_vctTextFilter.push_back((LPCTSTR)strToken);
            strToken = strTextFilter.Tokenize(_T(";"), curPos);
        };
    }

    DoFilter();
    m_bEditTextFilterUnApplied = FALSE;
    GetDlgItem(IDC_EDIT_TEXT_FILTER)->Invalidate(TRUE);
}
Esempio n. 7
0
//-------------------------------------------------------------------------------
//
// DoStart
//
// The main filtering routine for this plug in. See if we have any registry
// parameters from the last time we ran. Determine if the UI needs to be
// displayed by reading the script parameters. Save the last dialog parameters
// in case something goes wrong or the user cancels.
//
//-------------------------------------------------------------------------------
void DoStart(void)
{
	LockHandles();

	// see if we have any information in the Photoshop registry
	ReadRegistryParameters();

	// save parameters
	int16 lastDisposition = gParams->disposition;
	int16 lastPercent = gParams->percent;
	Boolean lastIgnoreSelection = gParams->ignoreSelection;

	// does the user want a dialog
	Boolean isOK = true;
	Boolean displayDialog;
	OSErr err = ReadScriptParameters(&displayDialog);
	err; // turn off compiler warning for now

	// run the dialog on the specific OS
	if (!err && displayDialog)
		isOK = DoUI();

	// we know we have enough information to run without next time
	gData->queryForParameters = false;

	if (isOK)
	{
		// the main processing routine
		DoFilter();
	}
	else
	{
		// restore if the user hit cancel
		gParams->disposition = lastDisposition;
		gParams->percent = lastPercent;
		gParams->ignoreSelection = lastIgnoreSelection;
		*gResult = userCanceledErr;
	}
}
Esempio n. 8
0
struct descriptor_xd *MdsFilter(float *in_data, float *in_dim, int *size, float *cut_off, int *num_in_poles)
{ 
    static struct descriptor_xd out_xd = {0, DTYPE_DSC, CLASS_XD, 0, 0};

    DESCRIPTOR_A(data_d, sizeof(float), DTYPE_FLOAT, 0, 0);
    DESCRIPTOR_SIGNAL(signal_d, 1, 0, 0);
    DESCRIPTOR_DIMENSION(dimension_d, 0, 0);
    DESCRIPTOR_WINDOW(window_d, 0, 0, 0);
    DESCRIPTOR_RANGE(range_d, 0, 0, 0);

    struct descriptor
	start_d = {sizeof(float), DTYPE_FLOAT, CLASS_S, 0},
	end_d = {sizeof(float), DTYPE_FLOAT, CLASS_S, 0},
	delta_d = {sizeof(float), DTYPE_FLOAT, CLASS_S, 0},
	start_idx_d = {sizeof(int), DTYPE_L, CLASS_S, 0},
	end_idx_d = {sizeof(int), DTYPE_L, CLASS_S, 0},
	time_at_0_d = {sizeof(float), DTYPE_FLOAT, CLASS_S, 0};

	
    int num_samples, num_poles, start_idx, end_idx, i;
    float fc, delta, dummy, *filtered_data, start, end, time_at_0;
    float phs_steep, delay;
    float *mod, *phs;
    static Filter *filter;

    if(*num_in_poles > 0)
    	num_poles = *num_in_poles;
    else
    	num_poles = 10;

    signal_d.data = (struct descriptor *)&data_d;
    signal_d.dimensions[0] = (struct descriptor *)&dimension_d;
    dimension_d.window = (struct descriptor *)&window_d;
    dimension_d.axis = (struct descriptor *)&range_d;
    window_d.startidx = (struct descriptor *)&start_idx_d;
    window_d.endingidx = (struct descriptor *)&end_idx_d;
    window_d.value_at_idx0 = (struct descriptor *)&time_at_0_d;
    start_idx_d.pointer = (char*)&start_idx;
    end_idx_d.pointer = (char *)&end_idx;
    time_at_0_d.pointer = (char *)&time_at_0;
    range_d.begin = (struct descriptor *)&start_d;
    range_d.ending = (struct descriptor *)&end_d;
    range_d.deltaval = (struct descriptor *)&delta_d;
    start_d.pointer = (char *)&start;
    end_d.pointer = (char *)&end;
    delta_d.pointer = (char *)&delta;
    

    num_samples = *size;

    fc = 1/ (in_dim[1] - in_dim[0]);
    filter = ButtwInvar(cut_off, &dummy, &dummy, &dummy, &fc, &num_poles);
    
    filtered_data = (float *)malloc(num_samples * sizeof(float));
    mod = (float *)malloc(sizeof(float) * 1000);
    phs = (float *)malloc(sizeof(float) * 1000);
    TestFilter(filter, fc, 1000, mod, phs);

    for(i = 1; i < 1000 - 1  && !isnan(phs[i]) && !isnan(phs[i+1]) && phs[i] > phs[i+1]; i++);


    if(i > 1 && i < 1000)
    {
    	phs_steep = (phs[1] - phs[i])/((i/1000.) * fc/2.);
       	delay = phs_steep/(2*PI);
	
    }


    free((char *)mod);
    free((char *)phs);
    
    
    DoFilter(filter, in_data, filtered_data, &num_samples);
    FreeFilter(filter);
    data_d.pointer = (char *)filtered_data;
    data_d.arsize = num_samples * sizeof(float);
    start = in_dim[0]-delay;
    end = in_dim[num_samples - 1]-delay;
    delta = in_dim[1] - in_dim[0];
    start_idx = 0;
    end_idx = num_samples - 1;
    time_at_0 = in_dim[0] - delay;

    MdsCopyDxXd((struct descriptor *)&signal_d, &out_xd);
    free((char *)filtered_data);
    
    
    
    
    return &out_xd;
}
Esempio n. 9
0
		void Filter::DoWrite(const std::string &s)
		{
			auto f = DoFilter(s);
			if (!f.empty())
				BranchableStream::DoWrite(f);
		}
Esempio n. 10
0
LRESULT CLogViewDlg::OnProcPanelMsg(WPARAM wParam, LPARAM lParam)
{
    DoFilter();
    SetActiveWindow();
    return 0;
}
Esempio n. 11
0
static Int IsRecObject(Obj obj)
{
    return (DoFilter( IsRecFilt, obj ) == True);
}